#26 replace TrimLeft by TrimLeftFunc

This commit is contained in:
z7zmey 2018-06-10 14:53:10 +03:00
parent 339c7e5296
commit 43451a070f
6 changed files with 80 additions and 72 deletions

View File

@ -113,3 +113,7 @@ func lastNode(nn []node.Node) node.Node {
func firstNode(nn []node.Node) node.Node { func firstNode(nn []node.Node) node.Node {
return nn[0] return nn[0]
} }
func isDollar(r rune) bool {
return r == '$'
}

View File

@ -3320,7 +3320,7 @@ yydefault:
yyDollar = yyS[yypt-9 : yypt+1] yyDollar = yyS[yypt-9 : yypt+1]
//line php5/php5.y:1143 //line php5/php5.y:1143
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
catch := stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) catch := stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list)
yyVAL.list = append([]node.Node{catch}, yyDollar[9].list...) yyVAL.list = append([]node.Node{catch}, yyDollar[9].list...)
@ -3386,7 +3386,7 @@ yydefault:
yyDollar = yyS[yypt-8 : yypt+1] yyDollar = yyS[yypt-8 : yypt+1]
//line php5/php5.y:1196 //line php5/php5.y:1196
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) yyVAL.node = stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list)
@ -4052,7 +4052,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php5/php5.y:1792 //line php5/php5.y:1792
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil)
@ -4082,7 +4082,7 @@ yydefault:
yyDollar = yyS[yypt-6 : yypt+1] yyDollar = yyS[yypt-6 : yypt+1]
//line php5/php5.y:1820 //line php5/php5.y:1820
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil)
@ -4262,7 +4262,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:1982 //line php5/php5.y:1982
{ {
name := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(name) yyVAL.node = expr.NewVariable(name)
// save position // save position
@ -4302,7 +4302,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:2020 //line php5/php5.y:2020
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[3].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, nil) staticVar := stmt.NewStaticVar(variable, nil)
yyVAL.list = append(yyDollar[1].list, staticVar) yyVAL.list = append(yyDollar[1].list, staticVar)
@ -4320,7 +4320,7 @@ yydefault:
yyDollar = yyS[yypt-5 : yypt+1] yyDollar = yyS[yypt-5 : yypt+1]
//line php5/php5.y:2036 //line php5/php5.y:2036
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[3].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, yyDollar[5].node) staticVar := stmt.NewStaticVar(variable, yyDollar[5].node)
yyVAL.list = append(yyDollar[1].list, staticVar) yyVAL.list = append(yyDollar[1].list, staticVar)
@ -4339,7 +4339,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:2053 //line php5/php5.y:2053
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, nil) staticVar := stmt.NewStaticVar(variable, nil)
yyVAL.list = []node.Node{staticVar} yyVAL.list = []node.Node{staticVar}
@ -4356,7 +4356,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:2068 //line php5/php5.y:2068
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, yyDollar[3].node) staticVar := stmt.NewStaticVar(variable, yyDollar[3].node)
yyVAL.list = []node.Node{staticVar} yyVAL.list = []node.Node{staticVar}
@ -4781,7 +4781,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:2439 //line php5/php5.y:2439
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[3].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, nil, "") property := stmt.NewProperty(variable, nil, "")
yyVAL.list = append(yyDollar[1].list, property) yyVAL.list = append(yyDollar[1].list, property)
@ -4799,7 +4799,7 @@ yydefault:
yyDollar = yyS[yypt-5 : yypt+1] yyDollar = yyS[yypt-5 : yypt+1]
//line php5/php5.y:2455 //line php5/php5.y:2455
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[3].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, yyDollar[5].node, "") property := stmt.NewProperty(variable, yyDollar[5].node, "")
yyVAL.list = append(yyDollar[1].list, property) yyVAL.list = append(yyDollar[1].list, property)
@ -4818,7 +4818,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:2472 //line php5/php5.y:2472
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, nil, "") property := stmt.NewProperty(variable, nil, "")
yyVAL.list = []node.Node{property} yyVAL.list = []node.Node{property}
@ -4835,7 +4835,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:2487 //line php5/php5.y:2487
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, yyDollar[3].node, "") property := stmt.NewProperty(variable, yyDollar[3].node, "")
yyVAL.list = []node.Node{property} yyVAL.list = []node.Node{property}
@ -6095,7 +6095,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:3546 //line php5/php5.y:3546
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[3].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.list = append(yyDollar[1].list, variable) yyVAL.list = append(yyDollar[1].list, variable)
@ -6111,7 +6111,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php5/php5.y:3560 //line php5/php5.y:3560
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
reference := expr.NewReference(variable) reference := expr.NewReference(variable)
yyVAL.list = append(yyDollar[1].list, reference) yyVAL.list = append(yyDollar[1].list, reference)
@ -6129,7 +6129,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:3576 //line php5/php5.y:3576
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.list = []node.Node{variable} yyVAL.list = []node.Node{variable}
@ -6144,7 +6144,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:3589 //line php5/php5.y:3589
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[2].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
reference := expr.NewReference(variable) reference := expr.NewReference(variable)
yyVAL.list = []node.Node{reference} yyVAL.list = []node.Node{reference}
@ -7660,7 +7660,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:4857 //line php5/php5.y:4857
{ {
name := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(name) yyVAL.node = expr.NewVariable(name)
// save position // save position
@ -8028,7 +8028,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:5183 //line php5/php5.y:5183
{ {
name := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(name) yyVAL.node = expr.NewVariable(name)
// save position // save position
@ -8042,7 +8042,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php5/php5.y:5195 //line php5/php5.y:5195
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node)
@ -8060,7 +8060,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php5/php5.y:5211 //line php5/php5.y:5211
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
fetch := node.NewIdentifier(yyDollar[3].token.Value) fetch := node.NewIdentifier(yyDollar[3].token.Value)
yyVAL.node = expr.NewPropertyFetch(variable, fetch) yyVAL.node = expr.NewPropertyFetch(variable, fetch)
@ -8164,7 +8164,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php5/php5.y:5304 //line php5/php5.y:5304
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(identifier) yyVAL.node = expr.NewVariable(identifier)
// save position // save position

View File

@ -1141,7 +1141,7 @@ catch_statement:
{ $$ = []node.Node{} } { $$ = []node.Node{} }
| T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' additional_catches | T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' additional_catches
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
catch := stmt.NewCatch([]node.Node{$3}, variable, $7) catch := stmt.NewCatch([]node.Node{$3}, variable, $7)
$$ = append([]node.Node{catch}, $9...) $$ = append([]node.Node{catch}, $9...)
@ -1194,7 +1194,7 @@ non_empty_additional_catches:
additional_catch: additional_catch:
T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}'
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = stmt.NewCatch([]node.Node{$3}, variable, $7) $$ = stmt.NewCatch([]node.Node{$3}, variable, $7)
@ -1790,7 +1790,7 @@ non_empty_parameter_list:
parameter: parameter:
optional_class_type is_reference is_variadic T_VARIABLE optional_class_type is_reference is_variadic T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
@ -1818,7 +1818,7 @@ parameter:
} }
| optional_class_type is_reference is_variadic T_VARIABLE '=' static_scalar | optional_class_type is_reference is_variadic T_VARIABLE '=' static_scalar
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
@ -1980,7 +1980,7 @@ global_var_list:
global_var: global_var:
T_VARIABLE T_VARIABLE
{ {
name := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(name) $$ = expr.NewVariable(name)
// save position // save position
@ -2018,7 +2018,7 @@ global_var:
static_var_list: static_var_list:
static_var_list ',' T_VARIABLE static_var_list ',' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($3.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, nil) staticVar := stmt.NewStaticVar(variable, nil)
$$ = append($1, staticVar) $$ = append($1, staticVar)
@ -2034,7 +2034,7 @@ static_var_list:
} }
| static_var_list ',' T_VARIABLE '=' static_scalar | static_var_list ',' T_VARIABLE '=' static_scalar
{ {
identifier := node.NewIdentifier(strings.TrimLeft($3.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, $5) staticVar := stmt.NewStaticVar(variable, $5)
$$ = append($1, staticVar) $$ = append($1, staticVar)
@ -2051,7 +2051,7 @@ static_var_list:
} }
| T_VARIABLE | T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, nil) staticVar := stmt.NewStaticVar(variable, nil)
$$ = []node.Node{staticVar} $$ = []node.Node{staticVar}
@ -2066,7 +2066,7 @@ static_var_list:
} }
| T_VARIABLE '=' static_scalar | T_VARIABLE '=' static_scalar
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
staticVar := stmt.NewStaticVar(variable, $3) staticVar := stmt.NewStaticVar(variable, $3)
$$ = []node.Node{staticVar} $$ = []node.Node{staticVar}
@ -2437,7 +2437,7 @@ member_modifier:
class_variable_declaration: class_variable_declaration:
class_variable_declaration ',' T_VARIABLE class_variable_declaration ',' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($3.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, nil, "") property := stmt.NewProperty(variable, nil, "")
$$ = append($1, property) $$ = append($1, property)
@ -2453,7 +2453,7 @@ class_variable_declaration:
} }
| class_variable_declaration ',' T_VARIABLE '=' static_scalar | class_variable_declaration ',' T_VARIABLE '=' static_scalar
{ {
identifier := node.NewIdentifier(strings.TrimLeft($3.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, $5, "") property := stmt.NewProperty(variable, $5, "")
$$ = append($1, property) $$ = append($1, property)
@ -2470,7 +2470,7 @@ class_variable_declaration:
} }
| T_VARIABLE | T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, nil, "") property := stmt.NewProperty(variable, nil, "")
$$ = []node.Node{property} $$ = []node.Node{property}
@ -2485,7 +2485,7 @@ class_variable_declaration:
} }
| T_VARIABLE '=' static_scalar | T_VARIABLE '=' static_scalar
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
property := stmt.NewProperty(variable, $3, "") property := stmt.NewProperty(variable, $3, "")
$$ = []node.Node{property} $$ = []node.Node{property}
@ -3544,7 +3544,7 @@ lexical_vars:
lexical_var_list: lexical_var_list:
lexical_var_list ',' T_VARIABLE lexical_var_list ',' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($3.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = append($1, variable) $$ = append($1, variable)
@ -3558,7 +3558,7 @@ lexical_var_list:
} }
| lexical_var_list ',' '&' T_VARIABLE | lexical_var_list ',' '&' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
reference := expr.NewReference(variable) reference := expr.NewReference(variable)
$$ = append($1, reference) $$ = append($1, reference)
@ -3574,7 +3574,7 @@ lexical_var_list:
} }
| T_VARIABLE | T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = []node.Node{variable} $$ = []node.Node{variable}
@ -3587,7 +3587,7 @@ lexical_var_list:
} }
| '&' T_VARIABLE | '&' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($2.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($2.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
reference := expr.NewReference(variable) reference := expr.NewReference(variable)
$$ = []node.Node{reference} $$ = []node.Node{reference}
@ -4855,7 +4855,7 @@ reference_variable:
compound_variable: compound_variable:
T_VARIABLE T_VARIABLE
{ {
name := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(name) $$ = expr.NewVariable(name)
// save position // save position
@ -5181,7 +5181,7 @@ encaps_list:
encaps_var: encaps_var:
T_VARIABLE T_VARIABLE
{ {
name := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(name) $$ = expr.NewVariable(name)
// save position // save position
@ -5193,7 +5193,7 @@ encaps_var:
} }
| T_VARIABLE '[' encaps_var_offset ']' | T_VARIABLE '[' encaps_var_offset ']'
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = expr.NewArrayDimFetch(variable, $3) $$ = expr.NewArrayDimFetch(variable, $3)
@ -5209,7 +5209,7 @@ encaps_var:
} }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING | T_VARIABLE T_OBJECT_OPERATOR T_STRING
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
fetch := node.NewIdentifier($3.Value) fetch := node.NewIdentifier($3.Value)
$$ = expr.NewPropertyFetch(variable, fetch) $$ = expr.NewPropertyFetch(variable, fetch)
@ -5302,7 +5302,7 @@ encaps_var_offset:
} }
| T_VARIABLE | T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(identifier) $$ = expr.NewVariable(identifier)
// save position // save position

View File

@ -102,3 +102,7 @@ func lastNode(nn []node.Node) node.Node {
func firstNode(nn []node.Node) node.Node { func firstNode(nn []node.Node) node.Node {
return nn[0] return nn[0]
} }
func isDollar(r rune) bool {
return r == '$'
}

View File

@ -3489,7 +3489,7 @@ yydefault:
yyDollar = yyS[yypt-9 : yypt+1] yyDollar = yyS[yypt-9 : yypt+1]
//line php7/php7.y:1089 //line php7/php7.y:1089
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[5].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[5].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
catch := stmt.NewCatch(yyDollar[4].list, variable, yyDollar[8].list) catch := stmt.NewCatch(yyDollar[4].list, variable, yyDollar[8].list)
yyVAL.list = append(yyDollar[1].list, catch) yyVAL.list = append(yyDollar[1].list, catch)
@ -4166,7 +4166,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php7/php7.y:1694 //line php7/php7.y:1694
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil)
@ -4196,7 +4196,7 @@ yydefault:
yyDollar = yyS[yypt-6 : yypt+1] yyDollar = yyS[yypt-6 : yypt+1]
//line php7/php7.y:1722 //line php7/php7.y:1722
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[4].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil)
@ -4403,7 +4403,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php7/php7.y:1902 //line php7/php7.y:1902
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = stmt.NewStaticVar(variable, nil) yyVAL.node = stmt.NewStaticVar(variable, nil)
@ -4419,7 +4419,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php7/php7.y:1916 //line php7/php7.y:1916
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = stmt.NewStaticVar(variable, yyDollar[3].node) yyVAL.node = stmt.NewStaticVar(variable, yyDollar[3].node)
@ -4859,7 +4859,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:2303 //line php7/php7.y:2303
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = stmt.NewProperty(variable, nil, yyDollar[2].str) yyVAL.node = stmt.NewProperty(variable, nil, yyDollar[2].str)
@ -4875,7 +4875,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php7/php7.y:2317 //line php7/php7.y:2317
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = stmt.NewProperty(variable, yyDollar[3].node, yyDollar[4].str) yyVAL.node = stmt.NewProperty(variable, yyDollar[3].node, yyDollar[4].str)
@ -6023,7 +6023,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php7/php7.y:3288 //line php7/php7.y:3288
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(identifier) yyVAL.node = expr.NewVariable(identifier)
// save position // save position
@ -6037,7 +6037,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:3300 //line php7/php7.y:3300
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[2].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = expr.NewReference(variable) yyVAL.node = expr.NewReference(variable)
@ -6596,7 +6596,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php7/php7.y:3746 //line php7/php7.y:3746
{ {
name := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(name) yyVAL.node = expr.NewVariable(name)
// save position // save position
@ -6942,7 +6942,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php7/php7.y:4042 //line php7/php7.y:4042
{ {
name := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(name) yyVAL.node = expr.NewVariable(name)
// save position // save position
@ -6956,7 +6956,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1] yyDollar = yyS[yypt-4 : yypt+1]
//line php7/php7.y:4054 //line php7/php7.y:4054
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node)
@ -6974,7 +6974,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line php7/php7.y:4070 //line php7/php7.y:4070
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
fetch := node.NewIdentifier(yyDollar[3].token.Value) fetch := node.NewIdentifier(yyDollar[3].token.Value)
yyVAL.node = expr.NewPropertyFetch(variable, fetch) yyVAL.node = expr.NewPropertyFetch(variable, fetch)
@ -7109,7 +7109,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line php7/php7.y:4192 //line php7/php7.y:4192
{ {
identifier := node.NewIdentifier(strings.TrimLeft(yyDollar[1].token.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
yyVAL.node = expr.NewVariable(identifier) yyVAL.node = expr.NewVariable(identifier)
// save position // save position

View File

@ -1087,7 +1087,7 @@ catch_list:
{ $$ = []node.Node{} } { $$ = []node.Node{} }
| catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}' | catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}'
{ {
identifier := node.NewIdentifier(strings.TrimLeft($5.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($5.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
catch := stmt.NewCatch($4, variable, $8) catch := stmt.NewCatch($4, variable, $8)
$$ = append($1, catch) $$ = append($1, catch)
@ -1692,7 +1692,7 @@ non_empty_parameter_list:
parameter: parameter:
optional_type is_reference is_variadic T_VARIABLE optional_type is_reference is_variadic T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
@ -1720,7 +1720,7 @@ parameter:
} }
| optional_type is_reference is_variadic T_VARIABLE '=' expr | optional_type is_reference is_variadic T_VARIABLE '=' expr
{ {
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
@ -1900,7 +1900,7 @@ static_var_list:
static_var: static_var:
T_VARIABLE T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = stmt.NewStaticVar(variable, nil) $$ = stmt.NewStaticVar(variable, nil)
@ -1914,7 +1914,7 @@ static_var:
} }
| T_VARIABLE '=' expr | T_VARIABLE '=' expr
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = stmt.NewStaticVar(variable, $3) $$ = stmt.NewStaticVar(variable, $3)
@ -2301,7 +2301,7 @@ property_list:
property: property:
T_VARIABLE backup_doc_comment T_VARIABLE backup_doc_comment
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = stmt.NewProperty(variable, nil, $2) $$ = stmt.NewProperty(variable, nil, $2)
@ -2315,7 +2315,7 @@ property:
} }
| T_VARIABLE '=' expr backup_doc_comment | T_VARIABLE '=' expr backup_doc_comment
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = stmt.NewProperty(variable, $3, $4) $$ = stmt.NewProperty(variable, $3, $4)
@ -3286,7 +3286,7 @@ lexical_var_list:
lexical_var: lexical_var:
T_VARIABLE T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(identifier) $$ = expr.NewVariable(identifier)
// save position // save position
@ -3298,7 +3298,7 @@ lexical_var:
} }
| '&' T_VARIABLE | '&' T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($2.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($2.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = expr.NewReference(variable) $$ = expr.NewReference(variable)
@ -3744,7 +3744,7 @@ variable:
simple_variable: simple_variable:
T_VARIABLE T_VARIABLE
{ {
name := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(name) $$ = expr.NewVariable(name)
// save position // save position
@ -4040,7 +4040,7 @@ encaps_list:
encaps_var: encaps_var:
T_VARIABLE T_VARIABLE
{ {
name := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(name) $$ = expr.NewVariable(name)
// save position // save position
@ -4052,7 +4052,7 @@ encaps_var:
} }
| T_VARIABLE '[' encaps_var_offset ']' | T_VARIABLE '[' encaps_var_offset ']'
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
$$ = expr.NewArrayDimFetch(variable, $3) $$ = expr.NewArrayDimFetch(variable, $3)
@ -4068,7 +4068,7 @@ encaps_var:
} }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING | T_VARIABLE T_OBJECT_OPERATOR T_STRING
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
fetch := node.NewIdentifier($3.Value) fetch := node.NewIdentifier($3.Value)
$$ = expr.NewPropertyFetch(variable, fetch) $$ = expr.NewPropertyFetch(variable, fetch)
@ -4190,7 +4190,7 @@ encaps_var_offset:
} }
| T_VARIABLE | T_VARIABLE
{ {
identifier := node.NewIdentifier(strings.TrimLeft($1.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar))
$$ = expr.NewVariable(identifier) $$ = expr.NewVariable(identifier)
// save position // save position