Lemon

Check-in [fe6ff36567]
Login

Check-in [fe6ff36567]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added test for embedded actions.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fe6ff365670e32702e007798053d596e76eae87e
User & Date: wolf 2009-09-04 17:28:19.000
Context
2009-09-04
17:30
removed include special directive from embedded actions test. It is to be tested on its own. check-in: 55c69f7ffb user: wolf tags: trunk
17:28
Added test for embedded actions. check-in: fe6ff36567 user: wolf tags: trunk
2009-09-03
16:30
improved error diagnostics message check-in: c058314432 user: wolf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Added test/embedded_actions.py.












































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
output=""
return_code=0
grammar='embedded_actions.y'
lookuptable=[
('n','NUMBER'),
('l','LPAREN'),
('r','RPAREN'),
('p','PLUS'),
('t','TIMES'),
('m','MINUS'),
('d','DIVIDE'),
]
testdrives=[
('',False),
('n',True,"number expression"),
('npn',True,"number number plus expression"),
('ntn',True,"number number times expression"),
('ndn',True,"number number divide expression"),
('nmn',True,"number number minus expression"),
('lnmnr',True,"number number minus parens expression"),
('lnpnrtn',True,"number number plus parens number times expression"),
]
Added test_grammar/embedded_actions.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
// Set the token type to be of 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.
 */
%include {void append_string(const char*);}
start::= expr. {append_string( "expression "); }

// Note how we can assign letters like A,B and C
// for the values of expressions and use them in C code.
expr ::= expr PLUS expr. { append_string( "plus "); }
expr ::= expr TIMES expr.{ append_string( "times "); }
expr::= expr MINUS expr.{ append_string( "minus "); }
expr::= expr DIVIDE expr.{ append_string( "divide "); }
// Terminals all start with an uppercase first letter and usually
// are written all upercase.
expr ::= LPAREN expr RPAREN.{ append_string( "parens "); }
expr ::= NUMBER.{append_string( "number "); }

// 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.