diff options
Diffstat (limited to 'LuaSL/src/LuaSL_yaccer.y')
-rw-r--r-- | LuaSL/src/LuaSL_yaccer.y | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_yaccer.y b/LuaSL/src/LuaSL_yaccer.y new file mode 100644 index 0000000..07f1fd7 --- /dev/null +++ b/LuaSL/src/LuaSL_yaccer.y | |||
@@ -0,0 +1,36 @@ | |||
1 | %{ | ||
2 | |||
3 | #include "LuaSL_parser_param.h" | ||
4 | #include "LuaSL_yaccer.tab.h" | ||
5 | |||
6 | %} | ||
7 | |||
8 | %define api.pure | ||
9 | |||
10 | %left '+' TOKEN_PLUS | ||
11 | %left '*' TOKEN_MULTIPLY | ||
12 | |||
13 | %token TOKEN_LPAREN | ||
14 | %token TOKEN_RPAREN | ||
15 | %token TOKEN_PLUS | ||
16 | %token TOKEN_MULTIPLY | ||
17 | |||
18 | %token <value> TOKEN_NUMBER | ||
19 | |||
20 | %type <expression> expr | ||
21 | |||
22 | %% | ||
23 | |||
24 | input: | ||
25 | expr { ((SParserParam*)data)->expression = $1; } | ||
26 | ; | ||
27 | |||
28 | expr: | ||
29 | expr TOKEN_PLUS expr { $$ = createOperation( ePLUS, $1, $3 ); } | ||
30 | | expr TOKEN_MULTIPLY expr { $$ = createOperation( eMULTIPLY, $1, $3 ); } | ||
31 | | TOKEN_LPAREN expr TOKEN_RPAREN { $$ = $2; } | ||
32 | | TOKEN_NUMBER { $$ = createNumber($1); } | ||
33 | ; | ||
34 | |||
35 | %% | ||
36 | |||