diff options
Diffstat (limited to '')
-rw-r--r-- | bnftest | 18 | ||||
-rw-r--r-- | bnftest.2 | 24 |
2 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,18 @@ | |||
1 | tokens = tokPlus tokMinus tokMult tokDivide tokOpenParen tokCloseParen | ||
2 | tokEquals tokNumber; | ||
3 | |||
4 | input: input line | ||
5 | | | ||
6 | ; | ||
7 | |||
8 | line: expr tokEquals {print} | ||
9 | ; | ||
10 | |||
11 | expr: expr tokPlus expr {add} | ||
12 | | expr tokMinus expr {subtract} | ||
13 | | expr tokMult expr {multiply} | ||
14 | | expr tokDivide expr {divide} | ||
15 | | tokOpenParen expr tokCloseParen | ||
16 | | [tokNumber] | ||
17 | ; | ||
18 | |||
diff --git a/bnftest.2 b/bnftest.2 new file mode 100644 index 0000000..229943b --- /dev/null +++ b/bnftest.2 | |||
@@ -0,0 +1,24 @@ | |||
1 | tokens = tokPlus tokMinus tokMult tokDivide tokOpenParen tokCloseParen | ||
2 | tokEquals tokNumber; | ||
3 | |||
4 | input: line input# | ||
5 | | | ||
6 | ; | ||
7 | |||
8 | input#: line input# | ||
9 | | | ||
10 | ; | ||
11 | |||
12 | line: expr tokEquals {print} | ||
13 | ; | ||
14 | |||
15 | expr: tokOpenParen expr tokCloseParen expr# | ||
16 | | [tokNumber] expr# | ||
17 | ; | ||
18 | |||
19 | expr#: tokPlus expr {add} expr# | ||
20 | | tokMinus expr {subtract} expr# | ||
21 | | tokMult expr {multiply} expr# | ||
22 | | tokDivide expr {divide} expr# | ||
23 | | | ||
24 | ; | ||