1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2026-04-20 18:16:59 +00:00

Add some tests, fix some bugs, show that one bug remains.

This commit is contained in:
Chris Pressey
2018-02-06 10:05:56 +00:00
parent c12a76e106
commit 612ae588f7
2 changed files with 83 additions and 4 deletions
+4 -3
View File
@@ -51,6 +51,7 @@ class Parser(object):
if self.scanner.consume('define'):
name = self.scanner.token
self.scanner.scan()
routine = self.routine(name)
else:
routine = self.legacy_routine()
name = routine.name
@@ -61,6 +62,8 @@ class Parser(object):
self.scanner.check_type('EOF')
# now backpatch the executable types.
#for type_name, type_ in self.typedefs.iteritems():
# type_.backpatch_constraint_labels(lambda w: self.lookup(w))
for defn in defns:
defn.location.type.backpatch_constraint_labels(lambda w: self.lookup(w))
for routine in routines:
@@ -192,9 +195,7 @@ class Parser(object):
location=location
)
def routine(self):
name = self.scanner.token
self.scanner.scan()
def routine(self, name):
type_ = self.defn_type()
# TODO assert that it's a routine
if self.scanner.consume('@'):
+79 -1
View File
@@ -1941,7 +1941,7 @@ vector says it does.
| }
= ok
### Vector tables ###
### vector tables ###
A vector can be copied into a vector table.
@@ -2037,3 +2037,81 @@ A vector in a vector table cannot be directly called.
| call many + x
| }
? ValueError
### typedef ###
A typedef is a more-readable alias for a type. "Alias" means
that types have structural equivalence, not name equivalence.
| typedef routine
| inputs x
| outputs x
| trashes z, n
| routine_type
|
| vector routine_type vec
|
| routine foo
| inputs x
| outputs x
| trashes z, n
| {
| inc x
| }
|
| routine main
| outputs vec
| trashes a, z, n
| {
| copy foo, vec
| }
= 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
| inputs x
| outputs x
| trashes z, n
| routine_type
|
| vector routine_type vec
|
| define foo routine_type
| {
| inc x
| }
|
| routine main
| outputs vec
| trashes a, z, n
| {
| copy foo, vec
| }
= ok