aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_yaccer.y
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-05 04:47:56 +1000
committerDavid Walter Seikel2012-01-05 04:47:56 +1000
commitd4b977d0904a1dea37922dac60d3bb37f9769230 (patch)
treee5f23ddd6a6dd880f770c897fa9c11e67c4c79cf /LuaSL/src/LuaSL_yaccer.y
parentAdd a compiler stub. (diff)
downloadSledjHamr-d4b977d0904a1dea37922dac60d3bb37f9769230.zip
SledjHamr-d4b977d0904a1dea37922dac60d3bb37f9769230.tar.gz
SledjHamr-d4b977d0904a1dea37922dac60d3bb37f9769230.tar.bz2
SledjHamr-d4b977d0904a1dea37922dac60d3bb37f9769230.tar.xz
Add a simple flex + btyacc stub.
Will be fleshed out soon with LSL grammer.
Diffstat (limited to 'LuaSL/src/LuaSL_yaccer.y')
-rw-r--r--LuaSL/src/LuaSL_yaccer.y36
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
24input:
25 expr { ((SParserParam*)data)->expression = $1; }
26 ;
27
28expr:
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