1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-02 03:41:28 +00:00

Move test, add test, add assertion.

This commit is contained in:
Chris Pressey 2018-02-06 11:52:50 +00:00
parent 783d8764ca
commit 9778e083c1
3 changed files with 41 additions and 29 deletions

View File

@ -207,7 +207,8 @@ class Parser(object):
def routine(self, name):
type_ = self.defn_type()
# TODO assert that it's a routine
if not isinstance(type_, RoutineType):
raise SyntaxError("Can only define a routine, not %r" % type_)
if self.scanner.consume('@'):
self.scanner.check_type('integer literal')
block = None

View File

@ -402,7 +402,7 @@ Copying to and from a word table.
= ok
| word one
| byte table[256] many
| word table[256] many
|
| routine main
| inputs one, many
@ -415,7 +415,7 @@ Copying to and from a word table.
? TypeMismatchError
| word one
| byte table[256] many
| word table[256] many
|
| routine main
| inputs one, many
@ -2067,32 +2067,6 @@ that types have structural equivalence, not name equivalence.
| }
= ok
Routines can be defined in a new style.
| typedef routine
| inputs x
| outputs x
| trashes z, n
| routine_type
|
| vector routine_type vec
|
| define foo routine
| inputs x
| outputs x
| trashes z, n
| {
| inc x
| }
|
| routine main
| outputs vec
| trashes a, z, n
| {
| copy foo, vec
| }
= ok
The new style routine definitions support typedefs.
| typedef routine

View File

@ -492,3 +492,40 @@ Buffers and pointers.
| copy [ptr] + y, foo
| }
= ok
Routines can be defined in a new style.
| typedef routine
| inputs x
| outputs x
| trashes z, n
| routine_type
|
| vector routine_type vec
|
| define foo routine
| inputs x
| outputs x
| trashes z, n
| {
| inc x
| }
|
| routine main
| outputs vec
| trashes a, z, n
| {
| copy foo, vec
| }
= ok
Only routines can be defined in the new style.
| define foo byte table[256]
|
| routine main
| trashes a, z, n
| {
| ld a, 0
| }
? SyntaxError