diff --git a/doc/SixtyPical.md b/doc/SixtyPical.md index 3d9570e..7e29545 100644 --- a/doc/SixtyPical.md +++ b/doc/SixtyPical.md @@ -25,7 +25,7 @@ There are five *primitive types* in SixtyPical: There are also three *type constructors*: -* T table[N] (N is a power of 2, 1 ≤ N ≤ 256; each entry holds a value +* T table[N] (N entries, 1 ≤ N ≤ 256; each entry holds a value of type T, where T is `byte`, `word`, or `vector`) * buffer[N] (N entries; each entry is a byte; 1 ≤ N ≤ 65536) * vector T (address of a value of type T; T must be a routine type) diff --git a/src/sixtypical/parser.py b/src/sixtypical/parser.py index cf3b5a6..320e53c 100644 --- a/src/sixtypical/parser.py +++ b/src/sixtypical/parser.py @@ -146,7 +146,7 @@ class Parser(object): if self.scanner.consume('table'): size = self.defn_size() - if size not in (1, 2, 4, 8, 16, 32, 64, 129, 256): + if size <= 0 or size > 256: raise SyntaxError("Table size must be a power of two, 0 < size <= 256") type_ = TableType(type_, size) diff --git a/tests/SixtyPical Syntax.md b/tests/SixtyPical Syntax.md index e9862ec..a434345 100644 --- a/tests/SixtyPical Syntax.md +++ b/tests/SixtyPical Syntax.md @@ -153,8 +153,8 @@ Tables of different types. | } = ok -The number of entries in a table must be a power of two -which is greater than 0 and less than or equal to 256. +The number of entries in a table must be +greater than 0 and less than or equal to 256. | word table[512] many | @@ -168,18 +168,6 @@ which is greater than 0 and less than or equal to 256. | } ? SyntaxError - | word table[48] many - | - | routine main - | inputs many - | outputs many - | trashes a, x, n, z - | { - | ld x, 0 - | copy 9999, many + x - | } - ? SyntaxError - | word table[0] many | | routine main @@ -192,6 +180,18 @@ which is greater than 0 and less than or equal to 256. | } ? SyntaxError + | word table[48] many + | + | routine main + | inputs many + | outputs many + | trashes a, x, n, z + | { + | ld x, 0 + | copy 9999, many + x + | } + = ok + Typedefs of different types. | typedef byte octet