git @ Cat's Eye Technologies SixtyPical / 9778e08
Move test, add test, add assertion. Chris Pressey 3 years ago
3 changed file(s) with 43 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
206206
207207 def routine(self, name):
208208 type_ = self.defn_type()
209 # TODO assert that it's a routine
209 if not isinstance(type_, RoutineType):
210 raise SyntaxError("Can only define a routine, not %r" % type_)
210211 if self.scanner.consume('@'):
211212 self.scanner.check_type('integer literal')
212213 block = None
401401 = ok
402402
403403 | word one
404 | byte table[256] many
404 | word table[256] many
405405 |
406406 | routine main
407407 | inputs one, many
414414 ? TypeMismatchError
415415
416416 | word one
417 | byte table[256] many
417 | word table[256] many
418418 |
419419 | routine main
420420 | inputs one, many
20662066 | }
20672067 = ok
20682068
2069 Routines can be defined in a new style.
2069 The new style routine definitions support typedefs.
20702070
20712071 | typedef routine
20722072 | inputs x
20762076 |
20772077 | vector routine_type vec
20782078 |
2079 | define foo routine
2080 | inputs x
2081 | outputs x
2082 | trashes z, n
2079 | define foo routine_type
20832080 | {
20842081 | inc x
20852082 | }
20912088 | copy foo, vec
20922089 | }
20932090 = ok
2094
2095 The new style routine definitions support typedefs.
2096
2097 | typedef routine
2098 | inputs x
2099 | outputs x
2100 | trashes z, n
2101 | routine_type
2102 |
2103 | vector routine_type vec
2104 |
2105 | define foo routine_type
2106 | {
2107 | inc x
2108 | }
2109 |
2110 | routine main
2111 | outputs vec
2112 | trashes a, z, n
2113 | {
2114 | copy foo, vec
2115 | }
2116 = ok
491491 | copy [ptr] + y, foo
492492 | }
493493 = ok
494
495 Routines can be defined in a new style.
496
497 | typedef routine
498 | inputs x
499 | outputs x
500 | trashes z, n
501 | routine_type
502 |
503 | vector routine_type vec
504 |
505 | define foo routine
506 | inputs x
507 | outputs x
508 | trashes z, n
509 | {
510 | inc x
511 | }
512 |
513 | routine main
514 | outputs vec
515 | trashes a, z, n
516 | {
517 | copy foo, vec
518 | }
519 = ok
520
521 Only routines can be defined in the new style.
522
523 | define foo byte table[256]
524 |
525 | routine main
526 | trashes a, z, n
527 | {
528 | ld a, 0
529 | }
530 ? SyntaxError