mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Check for table size (in parser, thus tests are for syntax.)
This commit is contained in:
parent
aa5b06980c
commit
93e2dada16
@ -146,6 +146,8 @@ 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):
|
||||
raise SyntaxError("Table size must be a power of two, 0 < size <= 256")
|
||||
type_ = TableType(type_, size)
|
||||
|
||||
return type_
|
||||
|
@ -533,34 +533,6 @@ You can also copy a literal word to a word table.
|
||||
|
||||
#### tables: range checking ####
|
||||
|
||||
A table may not have more than 256 entries.
|
||||
|
||||
| word table[512] many
|
||||
|
|
||||
| routine main
|
||||
| inputs many
|
||||
| outputs many
|
||||
| trashes a, x, n, z
|
||||
| {
|
||||
| ld x, 0
|
||||
| copy 9999, many + x
|
||||
| }
|
||||
? zzzzz
|
||||
|
||||
The number of entries in a table must be a power of two.
|
||||
|
||||
| word table[48] many
|
||||
|
|
||||
| routine main
|
||||
| inputs many
|
||||
| outputs many
|
||||
| trashes a, x, n, z
|
||||
| {
|
||||
| ld x, 0
|
||||
| copy 9999, many + x
|
||||
| }
|
||||
? zzzz
|
||||
|
||||
If a table has fewer than 256 entries, it cannot be read or written
|
||||
beyond the maximum number of entries it has.
|
||||
|
||||
|
@ -153,6 +153,45 @@ 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.
|
||||
|
||||
| word table[512] many
|
||||
|
|
||||
| routine main
|
||||
| inputs many
|
||||
| outputs many
|
||||
| trashes a, x, n, z
|
||||
| {
|
||||
| ld x, 0
|
||||
| copy 9999, many + x
|
||||
| }
|
||||
? 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
|
||||
| inputs many
|
||||
| outputs many
|
||||
| trashes a, x, n, z
|
||||
| {
|
||||
| ld x, 0
|
||||
| copy 9999, many + x
|
||||
| }
|
||||
? SyntaxError
|
||||
|
||||
Typedefs of different types.
|
||||
|
||||
| typedef byte octet
|
||||
|
Loading…
x
Reference in New Issue
Block a user