git @ Cat's Eye Technologies SixtyPical / 08ec0e4
Remove the need for parens in `vector (routine ...) table` type. Chris Pressey 3 years ago
6 changed file(s) with 20 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
99 * Implements the "union rule for trashes" when analyzing `if` blocks.
1010 * Even if we `goto` another routine, we can't trash an output.
1111 * `static` storage locations local to routines can now be defined within routines.
12 * Small grammar change that obviates the need for parentheses in the type expression
13 `vector (routine ...) table`.
1214 * Fixed bug where `trash` was not marking the location as being virtually altered.
1315
1416 0.11
6666 ### And at some point...
6767
6868 * `const`s that can be used in defining the size of tables, etc.
69 * Remove the need for `forward` and `vector () table` (make grammar changes)
69 * Remove the need for `forward` (lots of backpatching)
7070 * Tests, and implementation, ensuring a routine can be assigned to a vector of "wider" type
7171 * Check that the buffer being read or written to through pointer, appears in approporiate inputs or outputs set.
7272 (Associate each pointer with the buffer it points into.)
7373 * `static` pointers -- currently not possible because pointers must be zero-page, thus `@`, thus uninitialized.
74 * Question the value of the "consistent initialization" principle for `if` statement analysis.
7475 * `interrupt` routines -- to indicate that "the supervisor" has stored values on the stack, so we can trash them.
7576 * Error messages that include the line number of the source code.
7677 * Add absolute addressing in shl/shr, absolute-indexed for add, sub, etc.
536536 Program ::= {TypeDefn} {Defn} {Routine}.
537537 TypeDefn::= "typedef" Type Ident<new>.
538538 Defn ::= Type Ident<new> [Constraints] (":" Literal | "@" LitWord).
539 Type ::= "(" Type ")" | TypeExpr ["table" TypeSize].
539 Type ::= TypeTerm ["table" TypeSize].
540540 TypeExpr::= "byte"
541541 | "word"
542542 | "buffer" TypeSize
543543 | "pointer"
544 | "vector" Type
544 | "vector" TypeTerm
545545 | "routine" Constraints
546 | "(" Type ")"
546547 .
547548 TypeSize::= "[" LitWord "]".
548549 Constrnt::= ["inputs" LocExprs] ["outputs" LocExprs] ["trashes" LocExprs].
8686 word table[256] actor_delta
8787 word delta
8888
89 vector (logic_routine) table[256] actor_logic
89 vector logic_routine table[256] actor_logic
9090 vector logic_routine dispatch_logic
9191
9292 byte table[32] press_fire_msg: "PRESS`FIRE`TO`PLAY"
135135 return size
136136
137137 def defn_type(self):
138 type_ = self.defn_type_term()
139
140 if self.scanner.consume('table'):
141 size = self.defn_size()
142 type_ = TableType(type_, size)
143
144 return type_
145
146 def defn_type_term(self):
138147 type_ = None
139148
140149 if self.scanner.consume('('):
147156 elif self.scanner.consume('word'):
148157 type_ = TYPE_WORD
149158 elif self.scanner.consume('vector'):
150 type_ = self.defn_type()
159 type_ = self.defn_type_term()
151160 if not isinstance(type_, RoutineType):
152161 raise SyntaxError("Vectors can only be of a routine, not %r" % type_)
153162 type_ = VectorType(type_)
165174 if type_name not in self.typedefs:
166175 raise SyntaxError("Undefined type '%s'" % type_name)
167176 type_ = self.typedefs[type_name]
168
169 if self.scanner.consume('table'):
170 size = self.defn_size()
171 type_ = TableType(type_, size)
172177
173178 return type_
174179
633633 | outputs x
634634 | trashes a, z, n
635635 | one
636 | vector (routine
636 | vector routine
637637 | outputs x
638 | trashes a, z, n)
638 | trashes a, z, n
639639 | table[256] many
640640 |
641641 | routine bar outputs x trashes a, z, n {