diff --git a/HISTORY.markdown b/HISTORY.markdown index b0c0a31..7539862 100644 --- a/HISTORY.markdown +++ b/HISTORY.markdown @@ -1,6 +1,11 @@ History of SixtyPical ===================== +0.6-PRE +------- + +* Added `routine` and `vector` types, and `copy` instruction. + 0.5 --- diff --git a/README.markdown b/README.markdown index 667beb2..93e15b5 100644 --- a/README.markdown +++ b/README.markdown @@ -34,15 +34,16 @@ TODO For 0.6: * `interrupt` routines. -* `vector` type. -* `with sei` blocks. -* `copy` instruction. +* `goto` (tail call). +* `vector` type... with declared `inputs` `outputs` `trashes`? +* `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. For 0.7: * `word` type. * `trash` instruction. +* zero-page memory locations. * indirect addressing. At some point... diff --git a/src/sixtypical/parser.py b/src/sixtypical/parser.py index 90c28e6..8b41679 100644 --- a/src/sixtypical/parser.py +++ b/src/sixtypical/parser.py @@ -248,7 +248,10 @@ class Parser(object): self.scanner.scan() name = self.scanner.token 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) elif self.scanner.token in ("copy",): opcode = self.scanner.token diff --git a/tests/SixtyPical Syntax.md b/tests/SixtyPical Syntax.md index 7fb614d..e5d36a5 100644 --- a/tests/SixtyPical Syntax.md +++ b/tests/SixtyPical Syntax.md @@ -163,15 +163,33 @@ Can't shadow the name of a register or a flag. | } ? SyntaxError -> Can't call routine that hasn;t been defined. -> -> | routine main { -> | ld x, 0 -> | ld y, 1 -> | call up -> | call up -> | } -> ? SyntaxError +Can't call routine that hasn't been defined. + + | routine main { + | ld x, 0 + | ld y, 1 + | call up + | call up + | } + ? 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.