Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added test for a simple arithmetic parser. This test is not fully functional, because the generated parser is not tested. |
---|---|
Timelines: | family | ancestors | trunk |
Files: | files | file ages | folders |
SHA1: |
a13decd30ff28da79b4319a6ee05fcec |
User & Date: | wolf 2009-09-18 08:02:55.000 |
Context
2009-09-18
| ||
08:02 | Added test for a simple arithmetic parser. This test is not fully functional, because the generated parser is not tested. Leaf check-in: a13decd30f user: wolf tags: trunk | |
2009-09-05
| ||
20:06 | Added tests for ifdef / ifndef special directive and forgot to commit test description for fallback special directive. check-in: 6ba26bfaf5 user: wolf tags: trunk | |
Changes
Added test/simple_arithmetic.py.
> > > | 1 2 3 | output="" return_code=0 grammar='simple_arithmetic.y' |
Added test_grammar/simple_arithmetic.y.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | // Set the token type to be of type int %token_type int /* This is expression which we are trying to evaluate. * Nonterminals start with a lowercase letter and are * written conventionaly all lowercase. * Each production stops with a dot. * After each production there may be an embedded block * of C Code, which will be executed once the expression * was red. */ start::= expr(EXP_VALUE). { printf("result=%i\n",EXP_VALUE); } // Note how we can assign letters like A,B and C // for the values of expressions and use them in C code. expr(A) ::= expr(B) PLUS expr(C). { A=B+C;} expr(A) ::= expr(B) TIMES expr(C). { A=B*C;} expr(A)::= expr(B) MINUS expr(C). { A=B-C;} expr(A)::= expr(B) DIVIDE expr(C). { A=B/C;} // Terminals all start with an uppercase first letter and usually // are written all upercase. expr(A) ::= LPAREN expr(B) RPAREN. { A=B;} expr(A) ::= NUMBER(NUM_VALUE). { A=NUM_VALUE;} // This makes the operators left associative. %left PLUS MINUS. // The order is important: TIMES and DIVIDE get higher precedence than PLUS MINUS, // because they are below. %left TIMES DIVIDE. |