Skip to content

Commit 7c57a7f

Browse files
Check in standards documents
1 parent 0178add commit 7c57a7f

File tree

3 files changed

+2749
-0
lines changed

3 files changed

+2749
-0
lines changed

doc/grammar.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Formal grammar from the ICWS '94 annotated draft 3.3, section 2.3, line 0199
2+
http://corewar.co.uk/standards/icws94.txt
3+
4+
assembly_file:
5+
line+ EOF
6+
line:
7+
comment | instruction
8+
comment:
9+
; v* newline | newline
10+
instruction:
11+
label_list operation mode expr comment |
12+
label_list operation mode expr , mode expr comment
13+
label_list:
14+
label newline* label_list | e
15+
label:
16+
alpha alphanumeral*
17+
operation:
18+
opcode | opcode.modifier
19+
opcode:
20+
DAT | MOV | ADD | SUB | MUL | DIV | MOD |
21+
JMP | JMZ | JMN | DJN | CMP | SEQ | SNE |
22+
SLT | SPL | NOP | ORG | EQU | END
23+
modifier:
24+
A | B | AB | BA | F | X | I
25+
mode:
26+
# | $ | * | @ | { | < | } | > | e
27+
expr:
28+
term |
29+
term + expr | term - expr |
30+
term * expr | term / expr |
31+
term % expr
32+
term:
33+
label | number | ( expression )
34+
number:
35+
whole_number | signed_integer
36+
signed_integer:
37+
+whole_number | -whole_number
38+
whole_number:
39+
numeral+
40+
alpha:
41+
A-Z | a-z | _
42+
numeral:
43+
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
44+
alphanumeral:
45+
alpha | numeral
46+
v:
47+
^newline
48+
newline:
49+
LF | CR | LF CR | CR LF
50+
e:

0 commit comments

Comments
 (0)