`goto` may only occur at the end of a block.
Chris Pressey
6 years ago
379 | 379 | self.scanner.expect('{') |
380 | 380 | while not self.scanner.on('}'): |
381 | 381 | instrs.append(self.instr()) |
382 | if isinstance(instrs[-1], SingleOp) and instrs[-1].opcode == 'goto': | |
383 | break | |
382 | 384 | self.scanner.expect('}') |
383 | 385 | return Block(self.scanner.line_number, instrs=instrs) |
384 | 386 |
2989 | 2989 | | } |
2990 | 2990 | | |
2991 | 2991 | | define main routine trashes x, z, n { |
2992 | | goto bar | |
2992 | | ld x, 0 | |
2993 | | if z { | |
2994 | | ld x, 1 | |
2995 | | goto bar | |
2996 | | } | |
2993 | 2997 | | ld x, 0 |
2994 | 2998 | | } |
2995 | 2999 | ? IllegalJumpError |
570 | 570 | | } |
571 | 571 | ? SyntaxError |
572 | 572 | |
573 | `goto` may only be the final instruction in a block. | |
574 | ||
575 | | define bar routine trashes x, z, n { | |
576 | | ld x, 200 | |
577 | | } | |
578 | | | |
579 | | define main routine trashes x, z, n { | |
580 | | goto bar | |
581 | | ld x, 0 | |
582 | | } | |
583 | ? Expected '}', but found 'ld' | |
584 | ||
573 | 585 | Buffers and pointers. |
574 | 586 | |
575 | 587 | | buffer[2048] buf |