I can no longer see a reason to require that it is a power of two.
Chris Pressey
4 years ago

24 | 24 | |

25 | 25 | There are also three *type constructors*: |

26 | 26 | |

27 | * T table[N] (N is a power of 2, 1 ≤ N ≤ 256; each entry holds a value | |

27 | * T table[N] (N entries, 1 ≤ N ≤ 256; each entry holds a value | |

28 | 28 | of type T, where T is `byte`, `word`, or `vector`) |

29 | 29 | * buffer[N] (N entries; each entry is a byte; 1 ≤ N ≤ 65536) |

30 | 30 | * vector T (address of a value of type T; T must be a routine type) |

145 | 145 | |

146 | 146 | if self.scanner.consume('table'): |

147 | 147 | size = self.defn_size() |

148 | if size not in (1, 2, 4, 8, 16, 32, 64, 129, 256): | |

148 | if size <= 0 or size > 256: | |

149 | 149 | raise SyntaxError("Table size must be a power of two, 0 < size <= 256") |

150 | 150 | type_ = TableType(type_, size) |

151 | 151 |

152 | 152 | | } |

153 | 153 | = ok |

154 | 154 | |

155 | The number of entries in a table must be a power of two | |

156 | which is greater than 0 and less than or equal to 256. | |

155 | The number of entries in a table must be | |

156 | greater than 0 and less than or equal to 256. | |

157 | 157 | |

158 | 158 | | word table[512] many |

159 | 159 | | |

167 | 167 | | } |

168 | 168 | ? SyntaxError |

169 | 169 | |

170 | | word table[48] many | |

170 | | word table[0] many | |

171 | 171 | | |

172 | 172 | | routine main |

173 | 173 | | inputs many |

179 | 179 | | } |

180 | 180 | ? SyntaxError |

181 | 181 | |

182 | | word table[0] many | |

182 | | word table[48] many | |

183 | 183 | | |

184 | 184 | | routine main |

185 | 185 | | inputs many |

189 | 189 | | ld x, 0 |

190 | 190 | | copy 9999, many + x |

191 | 191 | | } |

192 | ? SyntaxError | |

192 | = ok | |

193 | 193 | |

194 | 194 | Typedefs of different types. |

195 | 195 |