-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar
34 lines (24 loc) · 1.24 KB
/
grammar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
program = "-- HUMAN RESOURCE MACHINE PROGRAM --\n",
{(label | op_and_operand), "\n" };
label = {alphabetic_character}, ':' ;
op_and_operand = (op_taking_label, label)
| (op_taking_address, address)
| op_without_operand ;
op_taking_label = "JUMP" | "JUMPZ" | "JUMPN" ;
op_taking_address = "COPYFROM" | "COPYTO" | "BUMPUP" | "BUMPDN" | "SUB" | "ADD" ;
address = natural_number | ("[", natural_number, "]")
op_without_operand = "INBOX" | "OUTBOX" ;
op_define = "DEFINE", ("COMMENT" | "LABEL"), integer ;
op_comment = "COMMENT", natural_number
alphabetic_character = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z"
| "a" | "b" | "c" | "d" | "e" | "f" | "g"
| "h" | "i" | "j" | "k" | "l" | "m" | "n"
| "o" | "p" | "q" | "r" | "s" | "t" | "u"
| "v" | "w" | "x" | "y" | "z" ;
nonzero_digit = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
digit = "0" | nonzero_digit ;
natural_number = nonzero_digit, { digit } ;
integer = "0" | [ "-" ], natural_number ;