remove boolWithToken type

This commit is contained in:
z7zmey 2018-05-11 23:23:57 +03:00
parent e93874f644
commit cf4fb26764
4 changed files with 824 additions and 847 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ import (
%union{ %union{
node node.Node node node.Node
token *scanner.Token token *scanner.Token
boolWithToken boolWithToken
list []node.Node list []node.Node
foreachVariable foreachVariable foreachVariable foreachVariable
simpleIndirectReference simpleIndirectReference simpleIndirectReference simpleIndirectReference
@ -261,7 +260,7 @@ import (
%type <simpleIndirectReference> simple_indirect_reference %type <simpleIndirectReference> simple_indirect_reference
%type <foreachVariable> foreach_variable foreach_optional_arg %type <foreachVariable> foreach_variable foreach_optional_arg
%type <boolWithToken> is_reference is_variadic %type <token> is_reference is_variadic
%% %%
@ -952,11 +951,11 @@ additional_catch:
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$"))
yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments(identifier, $4.Comments()) yylex.(*Parser).comments.AddComments(identifier, $4.Comments())
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments(variable, $4.Comments()) yylex.(*Parser).comments.AddComments(variable, $4.Comments())
$$ = stmt.NewCatch([]node.Node{$3}, variable, $7) $$ = stmt.NewCatch([]node.Node{$3}, variable, $7)
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8))
yylex.(*Parser).comments.AddComments($$, $1.Comments()) yylex.(*Parser).comments.AddComments($$, $1.Comments())
@ -987,16 +986,16 @@ class_declaration_statement:
is_reference: is_reference:
/* empty */ /* empty */
{ $$ = boolWithToken{false, nil} } { $$ = nil }
| '&' | '&'
{ $$ = boolWithToken{true, $1} } { $$ = $1 }
; ;
is_variadic: is_variadic:
/* empty */ /* empty */
{ $$ = boolWithToken{false, nil} } { $$ = nil }
| T_ELLIPSIS | T_ELLIPSIS
{ $$ = boolWithToken{true, $1} } { $$ = $1 }
; ;
unticked_function_declaration_statement: unticked_function_declaration_statement:
@ -1006,7 +1005,7 @@ unticked_function_declaration_statement:
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3))
yylex.(*Parser).comments.AddComments(name, $3.Comments()) yylex.(*Parser).comments.AddComments(name, $3.Comments())
$$ = stmt.NewFunction(name, $2.value, $5, nil, $8, "") $$ = stmt.NewFunction(name, $2 != nil, $5, nil, $8, "")
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9))
yylex.(*Parser).comments.AddComments($$, $1.Comments()) yylex.(*Parser).comments.AddComments($$, $1.Comments())
} }
@ -1039,7 +1038,7 @@ unticked_class_declaration_statement:
name := node.NewIdentifier($2.Value) name := node.NewIdentifier($2.Value)
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2))
yylex.(*Parser).comments.AddComments(name, $2.Comments()) yylex.(*Parser).comments.AddComments(name, $2.Comments())
$$ = stmt.NewInterface(name, $3, $5, "") $$ = stmt.NewInterface(name, $3, $5, "")
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6))
yylex.(*Parser).comments.AddComments($$, $1.Comments()) yylex.(*Parser).comments.AddComments($$, $1.Comments())
@ -1374,17 +1373,17 @@ parameter:
yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments($$, $4.Comments()) yylex.(*Parser).comments.AddComments($$, $4.Comments())
$$ = node.NewParameter($1, variable, nil, $2.value, $3.value) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
if $1 != nil { if $1 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} else if $2.value == true { } else if $2 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2.token, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4))
yylex.(*Parser).comments.AddComments($$, $2.token.Comments()) yylex.(*Parser).comments.AddComments($$, $2.Comments())
} else if $3.value == true { } else if $3 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3.token, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4))
yylex.(*Parser).comments.AddComments($$, $3.token.Comments()) yylex.(*Parser).comments.AddComments($$, $3.Comments())
} else { } else {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments($$, $4.Comments()) yylex.(*Parser).comments.AddComments($$, $4.Comments())
@ -1400,17 +1399,17 @@ parameter:
yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments(variable, $4.Comments()) yylex.(*Parser).comments.AddComments(variable, $4.Comments())
$$ = node.NewParameter($1, variable, $6, $2.value, $3.value) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
if $1 != nil { if $1 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} else if $2.value == true { } else if $2 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2.token, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6))
yylex.(*Parser).comments.AddComments($$, $2.token.Comments()) yylex.(*Parser).comments.AddComments($$, $2.Comments())
} else if $3.value == true { } else if $3 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3.token, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6))
yylex.(*Parser).comments.AddComments($$, $3.token.Comments()) yylex.(*Parser).comments.AddComments($$, $3.Comments())
} else { } else {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6))
yylex.(*Parser).comments.AddComments($$, $4.Comments()) yylex.(*Parser).comments.AddComments($$, $4.Comments())
@ -1632,7 +1631,7 @@ class_statement:
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
yylex.(*Parser).comments.AddComments(name, $4.Comments()) yylex.(*Parser).comments.AddComments(name, $4.Comments())
$$ = stmt.NewClassMethod(name, $1, $3.value, $6, nil, $8, "") $$ = stmt.NewClassMethod(name, $1, $3 != nil, $6, nil, $8, "")
if $1 == nil { if $1 == nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $8)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $8))
@ -1778,13 +1777,13 @@ method_body:
';' /* abstract method */ ';' /* abstract method */
{ {
$$ = stmt.NewNop() $$ = stmt.NewNop()
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1))
} }
| '{' inner_statement_list '}' | '{' inner_statement_list '}'
{ {
$$ = stmt.NewStmtList($2) $$ = stmt.NewStmtList($2)
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
} }
; ;
@ -2482,14 +2481,14 @@ expr_without_variable:
} }
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' | function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
{ {
$$ = expr.NewClosure($4, $6, nil, $8, false, $2.value, "") $$ = expr.NewClosure($4, $6, nil, $8, false, $2 != nil, "")
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9))
yylex.(*Parser).comments.AddComments($$, $1.Comments()) yylex.(*Parser).comments.AddComments($$, $1.Comments())
} }
| T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' | T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
{ {
$$ = expr.NewClosure($5, $7, nil, $9, true, $3.value, "") $$ = expr.NewClosure($5, $7, nil, $9, true, $3 != nil, "")
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $10)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $10))
yylex.(*Parser).comments.AddComments($$, $1.Comments()) yylex.(*Parser).comments.AddComments($$, $1.Comments())
@ -3998,11 +3997,6 @@ type foreachVariable struct {
byRef bool byRef bool
} }
type boolWithToken struct {
value bool
token *scanner.Token
}
type simpleIndirectReference struct { type simpleIndirectReference struct {
all []*expr.Variable all []*expr.Variable
last *expr.Variable last *expr.Variable

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,6 @@ import (
%union{ %union{
node node.Node node node.Node
token *scanner.Token token *scanner.Token
boolWithToken boolWithToken
list []node.Node list []node.Node
foreachVariable foreachVariable foreachVariable foreachVariable
str string str string
@ -228,7 +227,7 @@ import (
%left T_ENDIF %left T_ENDIF
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC %right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
%type <boolWithToken> is_reference is_variadic returns_ref %type <token> is_reference is_variadic returns_ref
%type <token> reserved_non_modifiers %type <token> reserved_non_modifiers
%type <token> semi_reserved %type <token> semi_reserved
@ -1153,16 +1152,17 @@ function_declaration_statement:
T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}' T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}'
{ {
name := node.NewIdentifier($3.Value) name := node.NewIdentifier($3.Value)
$$ = stmt.NewFunction(name, $2.value, $6, $8, $10, $4) $$ = stmt.NewFunction(name, $2 != nil, $6, $8, $10, $4)
// save position // save position
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11))
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken)
if $2.token != nil { if $2 != nil {
yylex.(*Parser).comments.AddFromToken($$, $2.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken)
} }
yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken)
yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken)
@ -1174,16 +1174,16 @@ function_declaration_statement:
is_reference: is_reference:
/* empty */ /* empty */
{ $$ = boolWithToken{false, nil} } { $$ = nil }
| '&' | '&'
{ $$ = boolWithToken{true, $1} } { $$ = $1 }
; ;
is_variadic: is_variadic:
/* empty */ /* empty */
{ $$ = boolWithToken{false, nil} } { $$ = nil }
| T_ELLIPSIS | T_ELLIPSIS
{ $$ = boolWithToken{true, $1} } { $$ = $1 }
; ;
class_declaration_statement: class_declaration_statement:
@ -1698,13 +1698,13 @@ parameter:
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
if $1 != nil { if $1 != nil {
$$ = node.NewParameter($1, variable, nil, $2.value, $3.value) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
} else if $2.value { } else if $2 != nil {
$$ = node.NewParameter($1, variable, nil, $2.value, $3.value) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
} else if $3.value { } else if $3 != nil {
$$ = node.NewParameter($1, variable, nil, $2.value, $3.value) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
} else { } else {
$$ = node.NewParameter($1, variable, nil, $2.value, $3.value) $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil)
} }
// save position // save position
@ -1712,20 +1712,20 @@ parameter:
yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
if $1 != nil { if $1 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4))
} else if $2.value { } else if $2 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2.token, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4))
} else if $3.value { } else if $3 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3.token, $4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4))
} else { } else {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
} }
// save comments // save comments
if $2.value { if $2 != nil {
yylex.(*Parser).comments.AddFromToken($$, $2.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken)
} }
if $3.value { if $3 != nil {
yylex.(*Parser).comments.AddFromToken($$, $3.token, comment.EllipsisToken) yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken)
} }
yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken)
} }
@ -1734,13 +1734,13 @@ parameter:
identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$"))
variable := expr.NewVariable(identifier) variable := expr.NewVariable(identifier)
if $1 != nil { if $1 != nil {
$$ = node.NewParameter($1, variable, $6, $2.value, $3.value) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
} else if $2.value == true { } else if $2 != nil {
$$ = node.NewParameter($1, variable, $6, $2.value, $3.value) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
} else if $3.value == true { } else if $3 != nil {
$$ = node.NewParameter($1, variable, $6, $2.value, $3.value) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
} else { } else {
$$ = node.NewParameter($1, variable, $6, $2.value, $3.value) $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil)
} }
// save position // save position
@ -1748,20 +1748,20 @@ parameter:
yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
if $1 != nil { if $1 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6))
} else if $2.value == true { } else if $2 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2.token, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6))
} else if $3.value == true { } else if $3 != nil {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3.token, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6))
} else { } else {
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6))
} }
// save comments // save comments
if $2.value { if $2 != nil {
yylex.(*Parser).comments.AddFromToken($$, $2.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken)
} }
if $3.value { if $3 != nil {
yylex.(*Parser).comments.AddFromToken($$, $3.token, comment.EllipsisToken) yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken)
} }
yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken)
yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken) yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken)
@ -1989,7 +1989,7 @@ class_statement:
| method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body | method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body
{ {
name := node.NewIdentifier($4.Value) name := node.NewIdentifier($4.Value)
$$ = stmt.NewClassMethod(name, $1, $3.value, $7, $9, $10, $5) $$ = stmt.NewClassMethod(name, $1, $3 != nil, $7, $9, $10, $5)
// save position // save position
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
@ -2001,8 +2001,8 @@ class_statement:
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken)
if $3.value { if $3 != nil {
yylex.(*Parser).comments.AddFromToken($$, $3.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken)
} }
yylex.(*Parser).comments.AddFromToken(name, $4, comment.IdentifierToken) yylex.(*Parser).comments.AddFromToken(name, $4, comment.IdentifierToken)
yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenParenthesisToken)
@ -3204,15 +3204,15 @@ expr_without_variable:
} }
| T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}' | T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}'
{ {
$$ = expr.NewClosure($5, $7, $8, $10, false, $2.value, $3) $$ = expr.NewClosure($5, $7, $8, $10, false, $2 != nil, $3)
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11))
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken)
if $2.value { if $2 != nil {
yylex.(*Parser).comments.AddFromToken($$, $2.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken)
} }
yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken)
yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken)
@ -3221,7 +3221,7 @@ expr_without_variable:
} }
| T_STATIC T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}' | T_STATIC T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}'
{ {
$$ = expr.NewClosure($6, $8, $9, $11, true, $3.value, $4) $$ = expr.NewClosure($6, $8, $9, $11, true, $3 != nil, $4)
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $12)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $12))
@ -3229,8 +3229,8 @@ expr_without_variable:
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken)
yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken)
if $3.value { if $3 != nil {
yylex.(*Parser).comments.AddFromToken($$, $3.token, comment.AmpersandToken) yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken)
} }
yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken)
yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken)
@ -3249,9 +3249,9 @@ backup_doc_comment:
returns_ref: returns_ref:
/* empty */ /* empty */
{ $$ = boolWithToken{false, nil} } { $$ = nil }
| '&' | '&'
{ $$ = boolWithToken{true, $1} } { $$ = $1 }
; ;
lexical_vars: lexical_vars:
@ -4289,8 +4289,3 @@ type foreachVariable struct {
node node.Node node node.Node
byRef bool byRef bool
} }
type boolWithToken struct {
value bool
token *scanner.Token
}