From bae6192c54533e8da95d8ae1ed4d4eccee28c39a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 29 Dec 2011 10:27:38 -0700 Subject: Getting close to realy running. --- src/parser.y | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index 90c771d..e6210d1 100644 --- a/src/parser.y +++ b/src/parser.y @@ -96,7 +96,8 @@ gameDecls: ; globalDecl: - | tokGlobal '{' globalExprList '}' + | tokGlobal '{' { bld.beginGlobal(); } globalExprList '}' + { bld.closeGlobal(); } ; globalExprList: @@ -134,11 +135,11 @@ function: tokFunction tokIdent { bld.beginFunction( *($2) ); } '(' funcParamList ; funcParamList: - | tokIdent { bld.addParam( *($1) ); } funcParamListEx + | tokIdent { bld.addFunctionParam( *($1) ); } funcParamListEx ; funcParamListEx: - | funcParamListEx ',' tokIdent { bld.addParam( *($3) ); } + | funcParamListEx ',' tokIdent { bld.addFunctionParam( *($3) ); } ; cmpltExprList: @@ -156,7 +157,8 @@ cmpltExpr: expr ';' bld.closeNode(); bld.addNode( AstNode::tScope ); } tokDo '{' cmpltExprList '}' { - bld.closeNode(); bld.closeNode(); + bld.closeNode(); + bld.closeNode(); } ; @@ -198,7 +200,7 @@ literal: tokInt { bld.addLiteral( Variable( $1 ) ); } ; expr: literal - | tokIdent '(' listValues ')' + | tokIdent '(' funcCallParams ')' { bld.addFuncCall( *($1) ); } | varRef | varRef '=' expr { bld.addNode( AstNode::tStore ); } | varRef tokPlusAssign expr { bld.addNode( AstNode::tPlusStore ); } @@ -227,6 +229,14 @@ expr: literal | '-' expr %prec NEG { bld.addNode( AstNode::tNegate ); } ; +funcCallParams: + | expr funcCallParamsEx + ; + +funcCallParamsEx: + | funcCallParamsEx ',' expr + ; + listValues: expr | listValues ',' expr ; @@ -235,12 +245,13 @@ dictValues: expr ':' expr | dictValues ',' expr ':' expr ; -commandDecl: tokCommand ':' tokString commandParamList '{' cmpltExprList '}' +commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); } + commandParamList '{' cmpltExprList '}' { bld.closeCommand(); } ; commandParamList: - | commandParamList tokString - | commandParamList tokIdent + | commandParamList tokString { bld.addCommandLiteral( *$2 ); } + | commandParamList tokIdent { bld.addCommandParam( *$2 ); } ; %% /* -- cgit v1.2.3