1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-14 08:29:33 +00:00

goto may only occur at the end of a block.

This commit is contained in:
Chris Pressey 2018-11-27 13:43:36 +00:00
parent 3cd28bdb3e
commit 9e9284bee5
3 changed files with 19 additions and 1 deletions

View File

@ -380,6 +380,8 @@ class Parser(object):
self.scanner.expect('{')
while not self.scanner.on('}'):
instrs.append(self.instr())
if isinstance(instrs[-1], SingleOp) and instrs[-1].opcode == 'goto':
break
self.scanner.expect('}')
return Block(self.scanner.line_number, instrs=instrs)

View File

@ -2990,7 +2990,11 @@ Calling the vector does indeed trash the things the vector says it does.
| }
|
| define main routine trashes x, z, n {
| goto bar
| ld x, 0
| if z {
| ld x, 1
| goto bar
| }
| ld x, 0
| }
? IllegalJumpError

View File

@ -571,6 +571,18 @@ goto.
| }
? SyntaxError
`goto` may only be the final instruction in a block.
| define bar routine trashes x, z, n {
| ld x, 200
| }
|
| define main routine trashes x, z, n {
| goto bar
| ld x, 0
| }
? Expected '}', but found 'ld'
Buffers and pointers.
| buffer[2048] buf