From d4b977d0904a1dea37922dac60d3bb37f9769230 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 5 Jan 2012 04:47:56 +1000 Subject: Add a simple flex + btyacc stub. Will be fleshed out soon with LSL grammer. --- LuaSL/src/LuaSL_yaccer.y | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 LuaSL/src/LuaSL_yaccer.y (limited to 'LuaSL/src/LuaSL_yaccer.y') 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 @@ +%{ + +#include "LuaSL_parser_param.h" +#include "LuaSL_yaccer.tab.h" + +%} + +%define api.pure + +%left '+' TOKEN_PLUS +%left '*' TOKEN_MULTIPLY + +%token TOKEN_LPAREN +%token TOKEN_RPAREN +%token TOKEN_PLUS +%token TOKEN_MULTIPLY + +%token TOKEN_NUMBER + +%type expr + +%% + +input: + expr { ((SParserParam*)data)->expression = $1; } + ; + +expr: + expr TOKEN_PLUS expr { $$ = createOperation( ePLUS, $1, $3 ); } + | expr TOKEN_MULTIPLY expr { $$ = createOperation( eMULTIPLY, $1, $3 ); } + | TOKEN_LPAREN expr TOKEN_RPAREN { $$ = $2; } + | TOKEN_NUMBER { $$ = createNumber($1); } +; + +%% + -- cgit v1.1