-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
26 lines (23 loc) · 1.06 KB
/
grammar.txt
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
<expr> ::= <mlt_div_expr> <plus_minus> <expr> | <mlt_div_expr>
<mlt_div_expr> ::= <atom> <mlt_div> <mlt_div_expr> | <atom>
<atom> ::= <roman_numeral> | <minus_atom> | <brackets_atom>
<minus_atom> ::= "-" <atom>
<brackets_atom> ::= "(" <atom> ")"
<plus_minus> ::= "+" | "-"
<mlt_div> ::= "*" | "/"
// Numerals Part
// Any number of "M" is allowed
<roman_numeral> ::= "Z" | <1000>
<1000> ::= "M" <1000> | <900> | "M"
<900> ::= "CM" <500> | <500> | "CM"
<500> ::= "D" <400> | <400> | "D"
<400> ::= "CD" <100> | <100> | "CD"
<100> ::= "CCC" <90> | "CC" <90> | "C" <90> | <90> | "CCC" | "CC" | "C"
<90> ::= "XC" <50> | <50> | "XC"
<50> ::= "L" <40> | <40> | "L"
<40> ::= "XL" <10> | <10> | "XL"
<10> ::= "XXX" <9> | "XX" <9> | "X" <9> | <9> | "XXX" | "XX" | "X"
<9> ::= "IX" <5> | <5> | "IX"
<5> ::= "V" <4> | <4> | "V"
<4> ::= "IV" <1> | <1> | "IV"
<1> ::= "I" | "II" | "III"