From 9edffc663e0766f8ae0e4f4a7dc7834f10827e4b Mon Sep 17 00:00:00 2001 From: vadim Date: Thu, 30 Nov 2017 20:45:54 +0200 Subject: [PATCH] parse isset --- parser.go | 3381 +++++++++++++++++++++++++++-------------------------- parser.y | 32 +- 2 files changed, 1732 insertions(+), 1681 deletions(-) diff --git a/parser.go b/parser.go index 79305f9..be2c2f2 100644 --- a/parser.go +++ b/parser.go @@ -367,10 +367,9 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line parser.y:1203 +//line parser.y:1220 const src = ` ctor_arguments %type class_name_reference %type new_variable +%type internal_functions_in_yacc +%type isset_variables +%type isset_variable %% @@ -1010,12 +1013,7 @@ expr_without_variable: | expr '?' expr ':' expr { $$ = Node("Ternary").append($1).append($3).append($5); } | expr '?' ':' expr { $$ = Node("Ternary").append($1).append($4); } | expr T_COALESCE expr { $$ = Node("Coalesce").append($1).append($3); } - | T_EMPTY '(' expr ')' { $$ = Node("Empty").append($3); } - | T_INCLUDE expr { $$ = Node("Include").append($2); } - | T_INCLUDE_ONCE expr { $$ = Node("IncludeOnce").append($2); } - | T_EVAL '(' expr ')' { $$ = Node("Eval").append($3); } - | T_REQUIRE expr { $$ = Node("Require").append($2); } - | T_REQUIRE_ONCE expr { $$ = Node("RequireOnce").append($2); } + | internal_functions_in_yacc { $$ = $1} | T_INT_CAST expr { $$ = Node("CastInt").append($2); } | T_DOUBLE_CAST expr { $$ = Node("CastDouble").append($2); } | T_STRING_CAST expr { $$ = Node("CastString").append($2); } @@ -1076,6 +1074,25 @@ encaps_var_offset: | T_VARIABLE { $$ = Node("OffsetVariable").attribute("value", $1) } ; +internal_functions_in_yacc: + T_ISSET '(' isset_variables possible_comma ')' { $$ = $3; } + | T_EMPTY '(' expr ')' { $$ = Node("Empty").append($3); } + | T_INCLUDE expr { $$ = Node("Include").append($2); } + | T_INCLUDE_ONCE expr { $$ = Node("IncludeOnce").append($2); } + | T_EVAL '(' expr ')' { $$ = Node("Eval").append($3); } + | T_REQUIRE expr { $$ = Node("Require").append($2); } + | T_REQUIRE_ONCE expr { $$ = Node("RequireOnce").append($2); } +; + +isset_variables: + isset_variable { $$ = $1; } + | isset_variables ',' isset_variable { $$ = Node("AndIsset").append($1).append($3); } +; + +isset_variable: + expr { $$ = Node("Isset").append($1) } +; + constant: name { $$ = Node("Const").append($1) } | class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = Node("Const").append($1).append($3) } @@ -1203,8 +1220,7 @@ new_variable: %% const src = `