-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrammar
68 lines (48 loc) · 1.09 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
AssemblyUnit:
Instruction*
Instruction:
Ident ':' Ident (Expr ',')* (Expr ','?)? '\n'
Expr:
Ident | Literal | Bracket | '(' Expr ')'
Operation:
Expr '+' Expr |
Expr '-' Expr |
Expr '*' Expr |
Expr '/' Expr |
Expr '%' Expr |
Expr '&' Expr |
Expr '|' Expr |
Expr '^' Expr
Bracket:
'[' Instruction ']'
Ident:
Alphabetic (Alphabetic | DecDigit)*
Alphabetic:
'a' .. 'z' | 'A' .. 'Z' | '_' | '<' | '>' | '$'
Literal:
String | Char | Number
String:
'"' <what you expect> '"'
Char:
"'" <what you expect> "'"
Number:
FloatNumber | DecNumber | BinNumber | OctNumber | HexNumber
FloatNumber:
DecNumber '.' ( DecNumber (('E' | 'e') DecNumber)?)? |
'.' DecNumber (('E' | 'e') DecNumber)?
DecNumber:
DecDigit (DecDigit | '_')*
DecDigit:
'0' .. '9'
BinNumber:
('0b' | '0B') BinDigit (BinDigit | '_')*
BinDigit:
'0' | '1'
OctNumber:
('0x' | '0O') OctDigit (OctDigit | '_')*
OctDigit:
'0' .. '7'
HexNumber:
('0x' | '0X') HexNumber (HexNumber | '_')*
HexNumber:
'0' .. '9' | 'a' .. 'f' | 'A' .. 'F'