aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_yaccer.y
blob: 414b5e911e33cfea6af5cbf93c89f8d73a44fcd5 (plain)
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
30
31
32
33
34
35
36
37
38
%{

#include "LuaSL_LSL_tree.h"

//extern char *yytext;
//#define YYDEBUG_LEXER_TEXT yytext

%}

%define api.pure

%left '+' LSL_ADD
%left '*' LSL_MULTIPLY

%token LSL_PARENTHESIS_OPEN
%token LSL_PARENTHESIS_CLOSE
%token LSL_ADD
%token LSL_MULTIPLY

%token <integerValue> LSL_INTEGER

%type <expressionValue> expr

%%

input: 
        expr { ((LuaSL_yyparseParam*)data)->expression = $1; }
        ;

expr:
     LSL_PARENTHESIS_OPEN expr LSL_PARENTHESIS_CLOSE { $$ = $2; }
    | expr LSL_MULTIPLY expr { $$ = addOperation( LSL_MULTIPLY, $1, $3 ); }
    | expr LSL_ADD expr { $$ = addOperation( LSL_ADD, $1, $3 ); }
    | LSL_INTEGER { $$ = addInteger($1); }
;

%%