mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-22 01:32:13 +00:00
Syntax for goto
.
This commit is contained in:
parent
16649042cb
commit
be76b9a00d
@ -33,7 +33,7 @@ TODO
|
||||
|
||||
For 0.6:
|
||||
|
||||
* `call` vector (generates an indirect JMP.)
|
||||
* `call` vector (generates an JSR to a trampoline that does indirect JMP.)
|
||||
* `goto` (tail call) a routine or a vector.
|
||||
* A more involved demo for the C64 — one that sets up an interrupt?
|
||||
|
||||
|
@ -363,16 +363,20 @@ copy more general types of data (for example, vectors,) and it trashes the
|
||||
After execution, dest is considered initialized, and `z` and `n`, and
|
||||
`a` are considered uninitialized.
|
||||
|
||||
### goto ###
|
||||
|
||||
TBW
|
||||
|
||||
Grammar
|
||||
-------
|
||||
|
||||
Program ::= {Defn} {Routine}.
|
||||
Defn ::= Type NewIdent [Constraints] ["@" WordConst].
|
||||
Defn ::= Type Ident<new> [Constraints] ["@" WordConst].
|
||||
Type ::= "byte" ["table"] | "vector"
|
||||
Constrnt::= ["inputs" LocExprs] ["outputs" LocExprs] ["trashes" LocExprs].
|
||||
Routine ::= "routine" NewIdent Constraints (Block | "@" WordConst).
|
||||
Routine ::= "routine" Ident<new> Constraints (Block | "@" WordConst).
|
||||
LocExprs::= LocExpr {"," LocExpr}.
|
||||
LocExpr ::= Register | Flag | LitByte | DefnIdent.
|
||||
LocExpr ::= Register | Flag | LitByte | Ident.
|
||||
Register::= "a" | "x" | "y".
|
||||
Flag ::= "c" | "z" | "n" | "v".
|
||||
LitByte ::= "0" ... "255".
|
||||
@ -390,7 +394,8 @@ Grammar
|
||||
| "shr" LocExpr
|
||||
| "inc" LocExpr
|
||||
| "dec" LocExpr
|
||||
| "call" RoutineIdent
|
||||
| "call" Ident<routine>
|
||||
| "goto" Ident<executable>
|
||||
| "if" ["not"] LocExpr Block ["else" Block]
|
||||
| "repeat" Block ("until" ["not"] LocExpr | "forever")
|
||||
| "copy" LocExpr "," LocExpr ["+" LocExpr]
|
||||
|
@ -260,7 +260,7 @@ class Parser(object):
|
||||
self.scanner.scan()
|
||||
dest = self.locexpr()
|
||||
return Instr(opcode=opcode, dest=dest, src=None)
|
||||
elif self.scanner.token in ("call",):
|
||||
elif self.scanner.token in ("call", "goto"):
|
||||
opcode = self.scanner.token
|
||||
self.scanner.scan()
|
||||
name = self.scanner.token
|
||||
|
@ -248,3 +248,32 @@ Only vectors can be decorated with constraints like that.
|
||||
| routine main {
|
||||
| }
|
||||
? SyntaxError
|
||||
|
||||
goto.
|
||||
|
||||
| routine foo {
|
||||
| ld a, 0
|
||||
| }
|
||||
| routine main {
|
||||
| goto foo
|
||||
| }
|
||||
= ok
|
||||
|
||||
| vector foo
|
||||
|
|
||||
| routine main {
|
||||
| goto foo
|
||||
| }
|
||||
= ok
|
||||
|
||||
| routine main {
|
||||
| goto foo
|
||||
| }
|
||||
? SyntaxError
|
||||
|
||||
| byte foo
|
||||
|
|
||||
| routine main {
|
||||
| goto foo
|
||||
| }
|
||||
? SyntaxError
|
||||
|
Loading…
Reference in New Issue
Block a user