1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 23:49:17 +00:00

Re-enable disabled test and fix it and add a few related tests.

This commit is contained in:
Chris Pressey 2015-10-19 12:22:44 +01:00
parent 04de73d04d
commit a12a44eadb
4 changed files with 40 additions and 13 deletions

View File

@ -1,6 +1,11 @@
History of SixtyPical History of SixtyPical
===================== =====================
0.6-PRE
-------
* Added `routine` and `vector` types, and `copy` instruction.
0.5 0.5
--- ---

View File

@ -34,15 +34,16 @@ TODO
For 0.6: For 0.6:
* `interrupt` routines. * `interrupt` routines.
* `vector` type. * `goto` (tail call).
* `with sei` blocks. * `vector` type... with declared `inputs` `outputs` `trashes`?
* `copy` instruction. * `copy` instruction... that can copy a constant to a user-def mem loc.
* A more involved demo for the C64 — one that sets up an interrupt. * A more involved demo for the C64 — one that sets up an interrupt.
For 0.7: For 0.7:
* `word` type. * `word` type.
* `trash` instruction. * `trash` instruction.
* zero-page memory locations.
* indirect addressing. * indirect addressing.
At some point... At some point...

View File

@ -248,7 +248,10 @@ class Parser(object):
self.scanner.scan() self.scanner.scan()
name = self.scanner.token name = self.scanner.token
self.scanner.scan() self.scanner.scan()
# TODO: check that is has been defined if name not in self.symbols:
raise SyntaxError('Undefined routine "%s"' % name)
if self.symbols[name].model.type != TYPE_ROUTINE:
raise SyntaxError('Illegal call of non-routine "%s"' % name)
return Instr(opcode=opcode, name=name, dest=None, src=None) return Instr(opcode=opcode, name=name, dest=None, src=None)
elif self.scanner.token in ("copy",): elif self.scanner.token in ("copy",):
opcode = self.scanner.token opcode = self.scanner.token

View File

@ -163,15 +163,33 @@ Can't shadow the name of a register or a flag.
| } | }
? SyntaxError ? SyntaxError
> Can't call routine that hasn;t been defined. Can't call routine that hasn't been defined.
>
> | routine main { | routine main {
> | ld x, 0 | ld x, 0
> | ld y, 1 | ld y, 1
> | call up | call up
> | call up | call up
> | } | }
> ? SyntaxError ? SyntaxError
And you can't call a non-routine.
| byte up
|
| routine main {
| ld x, 0
| ld y, 1
| call up
| }
? SyntaxError
| routine main {
| ld x, 0
| ld y, 1
| call x
| }
? SyntaxError
Can't define two routines with the same name. Can't define two routines with the same name.