parse Unset stmt

This commit is contained in:
vadim 2017-11-29 11:37:16 +02:00
parent aa1c9b9257
commit 7863670c5c
4 changed files with 1011 additions and 963 deletions

View File

@ -7669,6 +7669,7 @@ yyrule2: // .
tb := []byte{} tb := []byte{}
for { for {
if c == -1 { if c == -1 {
tb = l.TokenBytes(nil)
break break
} }
if '?' == rune(c) { if '?' == rune(c) {

View File

@ -158,6 +158,7 @@ NEW_LINE (\r|\n|\r\n)
for { for {
if c == -1 { if c == -1 {
tb = l.TokenBytes(nil);
break; break;
} }

1944
parser.go

File diff suppressed because it is too large Load Diff

View File

@ -215,6 +215,8 @@ func (n node) attribute(key string, value string) node {
%type <node> static_var %type <node> static_var
%type <node> echo_expr_list %type <node> echo_expr_list
%type <node> echo_expr %type <node> echo_expr
%type <node> unset_variables
%type <node> unset_variable
%% %%
@ -305,6 +307,11 @@ statement:
| T_ECHO echo_expr_list ';' { $$ = $2; } | T_ECHO echo_expr_list ';' { $$ = $2; }
| T_INLINE_HTML { $$ = Node("Echo").append(Node("InlineHtml").attribute("value", $1)) } | T_INLINE_HTML { $$ = Node("Echo").append(Node("InlineHtml").attribute("value", $1)) }
| expr ';' { $$ = $1; } | expr ';' { $$ = $1; }
| T_UNSET '(' unset_variables possible_comma ')' ';'
{
$$ = Node("Unset").append($3);
}
if_stmt_without_else: if_stmt_without_else:
T_IF '(' expr ')' statement T_IF '(' expr ')' statement
@ -415,6 +422,20 @@ echo_expr:
expr { $$ = Node("Echo").append($1) } expr { $$ = Node("Echo").append($1) }
; ;
unset_variables:
unset_variable { $$ = Node("UnsetVariablesList").append($1) }
| unset_variables ',' unset_variable { $$ = $1.append($3) }
;
unset_variable:
variable { $$ = $1 }
;
possible_comma:
/* empty */
| ','
;
class_declaration_statement: class_declaration_statement:
class_modifiers T_CLASS T_STRING '{' '}' { $$ = $1.attribute("name", $3) } class_modifiers T_CLASS T_STRING '{' '}' { $$ = $1.attribute("name", $3) }
| T_CLASS T_STRING '{' '}' { $$ = Node("Class").attribute("name", $2) } | T_CLASS T_STRING '{' '}' { $$ = Node("Class").attribute("name", $2) }
@ -613,12 +634,9 @@ simple_variable:
const src = `a<? const src = `a<?
static $a, $b = $c; unset($a, $b, );
?> test<?php
echo $a, $b = $c;
?> test
` `
func main() { func main() {