#70: [php7] inherit meta.Data at stmt.Use, stmt.GroupUse, stmt.UseList, name.Name
This commit is contained in:
parent
11d621cb90
commit
86afa319f3
841
php7/php7.go
841
php7/php7.go
File diff suppressed because it is too large
Load Diff
25
php7/php7.y
25
php7/php7.y
@ -395,6 +395,9 @@ name:
|
||||
// save position
|
||||
$$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
||||
|
||||
// save comments
|
||||
$1[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_NAMESPACE T_NS_SEPARATOR namespace_name
|
||||
@ -644,6 +647,8 @@ group_use_declaration:
|
||||
}
|
||||
$6.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
|
||||
|
||||
$1[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
||||
@ -666,6 +671,8 @@ group_use_declaration:
|
||||
}
|
||||
$7.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
|
||||
|
||||
$2[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
;
|
||||
@ -689,6 +696,8 @@ mixed_group_use_declaration:
|
||||
}
|
||||
$6.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
|
||||
|
||||
$1[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
||||
@ -711,6 +720,8 @@ mixed_group_use_declaration:
|
||||
}
|
||||
$7.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
|
||||
|
||||
$2[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
;
|
||||
@ -785,12 +796,16 @@ inline_use_declaration:
|
||||
{
|
||||
$$ = $1
|
||||
|
||||
$1.(*stmt.Use).Use.GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| use_type unprefixed_use_declaration
|
||||
{
|
||||
$$ = $2.(*stmt.Use).SetUseType($1)
|
||||
|
||||
$1.GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
;
|
||||
@ -805,6 +820,8 @@ unprefixed_use_declaration:
|
||||
name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
||||
$$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
||||
|
||||
$1[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| namespace_name T_AS T_STRING
|
||||
@ -822,6 +839,8 @@ unprefixed_use_declaration:
|
||||
$2.Meta.SetTokenName(meta.AsToken).AppendTo($$.GetMeta())
|
||||
$3.Meta.SetTokenName(meta.NodeStart).AppendTo(alias.GetMeta())
|
||||
|
||||
$1[0].GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo(name.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
;
|
||||
@ -831,6 +850,8 @@ use_declaration:
|
||||
{
|
||||
$$ = $1
|
||||
|
||||
$1.(*stmt.Use).Use.GetMeta().Cut(meta.TokenNameFilter(meta.NodeStart)).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_NS_SEPARATOR unprefixed_use_declaration
|
||||
@ -838,8 +859,8 @@ use_declaration:
|
||||
$$ = $2;
|
||||
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.UseLeadingNsSeparatorToken).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $1, meta.UseLeadingNsSeparatorToken)
|
||||
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $1, meta.NodeStart)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
|
@ -122,11 +122,11 @@ func ExampleDumper() {
|
||||
// | [*name.Name]
|
||||
// | "Position": Pos{Line: 5-5 Pos: 86-89}
|
||||
// | "NamespacedName": "null"
|
||||
// | "Meta":
|
||||
// | " " before "NodeStart"
|
||||
// | "Parts":
|
||||
// | [*name.NamePart]
|
||||
// | "Position": Pos{Line: 5-5 Pos: 86-89}
|
||||
// | "Meta":
|
||||
// | " " before "NodeStart"
|
||||
// | "Value": "null"
|
||||
// | "Stmt":
|
||||
// | [*stmt.StmtList]
|
||||
|
@ -355,14 +355,6 @@ func ExampleGoDumper() {
|
||||
// StartPos: 86,
|
||||
// EndPos: 89,
|
||||
// },
|
||||
// Parts: []node.Node{
|
||||
// &name.NamePart{
|
||||
// Position: &position.Position{
|
||||
// StartLine: 5,
|
||||
// EndLine: 5,
|
||||
// StartPos: 86,
|
||||
// EndPos: 89,
|
||||
// },
|
||||
// Meta: meta.Collection{
|
||||
// &meta.Data{
|
||||
// Type: meta.WhiteSpaceType,
|
||||
@ -376,6 +368,14 @@ func ExampleGoDumper() {
|
||||
// TokenName: meta.NodeStart,
|
||||
// },
|
||||
// },
|
||||
// Parts: []node.Node{
|
||||
// &name.NamePart{
|
||||
// Position: &position.Position{
|
||||
// StartLine: 5,
|
||||
// EndLine: 5,
|
||||
// StartPos: 86,
|
||||
// EndPos: 89,
|
||||
// },
|
||||
// Value: "null",
|
||||
// },
|
||||
// },
|
||||
|
@ -37,5 +37,5 @@ func ExampleJsonDumper() {
|
||||
nodes.Walk(dumper)
|
||||
|
||||
// Output:
|
||||
// {"type":"*node.Root","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"Stmts":[{"type":"*stmt.Namespace","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"meta":[{"type":"*meta.TokenType","value":"<?php","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\n\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t","tokenName":"CloseCurlyBracesToken"}],"NamespaceName":{"type":"*name.Name","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"Parts":[{"type":"*name.NamePart","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Foo"}]},"Stmts":[{"type":"*stmt.Class","position":{"startPos":29,"endPos":162,"startLine":4,"endLine":11},"namespacedName":"Foo\\Bar","meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"ClassToken"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"CloseCurlyBracesToken"}],"PhpDocComment":"","ClassName":{"type":"*node.Identifier","position":{"startPos":35,"endPos":37,"startLine":4,"endLine":4},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Bar"},"Stmts":[{"type":"*stmt.ClassMethod","position":{"startPos":45,"endPos":157,"startLine":5,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"FunctionToken"}],"PhpDocComment":"","ReturnsRef":false,"MethodName":{"type":"*node.Identifier","position":{"startPos":61,"endPos":72,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"FunctionName"},"Modifiers":[{"type":"*node.Identifier","position":{"startPos":45,"endPos":50,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"}],"Value":"public"}],"Params":[{"type":"*node.Parameter","position":{"startPos":74,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"EqualToken"}],"ByRef":false,"Variadic":false,"VariableType":{"type":"*name.Name","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"namespacedName":"Foo\\Type","Parts":[{"type":"*name.NamePart","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"Value":"Type"}]},"Variable":{"type":"*expr.Variable","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"Value":"var"}},"DefaultValue":{"type":"*expr.ConstFetch","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"Constant":{"type":"*name.Name","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"namespacedName":"null","Parts":[{"type":"*name.NamePart","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"null"}]}}}],"Stmt":{"type":"*stmt.StmtList","position":{"startPos":96,"endPos":157,"startLine":6,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"CloseCurlyBracesToken"}],"Stmts":[{"type":"*stmt.Expression","position":{"startPos":147,"endPos":151,"startLine":9,"endLine":9},"meta":[{"type":"*meta.TokenType","value":";","tokenName":"SemiColonToken"}],"Expr":{"type":"*expr.Variable","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// some comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// second comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"Value":"var"}}}]}}]}]}]}
|
||||
// {"type":"*node.Root","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"Stmts":[{"type":"*stmt.Namespace","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"meta":[{"type":"*meta.TokenType","value":"<?php","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\n\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t","tokenName":"CloseCurlyBracesToken"}],"NamespaceName":{"type":"*name.Name","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"Parts":[{"type":"*name.NamePart","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Foo"}]},"Stmts":[{"type":"*stmt.Class","position":{"startPos":29,"endPos":162,"startLine":4,"endLine":11},"namespacedName":"Foo\\Bar","meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"ClassToken"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"CloseCurlyBracesToken"}],"PhpDocComment":"","ClassName":{"type":"*node.Identifier","position":{"startPos":35,"endPos":37,"startLine":4,"endLine":4},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Bar"},"Stmts":[{"type":"*stmt.ClassMethod","position":{"startPos":45,"endPos":157,"startLine":5,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"FunctionToken"}],"PhpDocComment":"","ReturnsRef":false,"MethodName":{"type":"*node.Identifier","position":{"startPos":61,"endPos":72,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"FunctionName"},"Modifiers":[{"type":"*node.Identifier","position":{"startPos":45,"endPos":50,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"}],"Value":"public"}],"Params":[{"type":"*node.Parameter","position":{"startPos":74,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"EqualToken"}],"ByRef":false,"Variadic":false,"VariableType":{"type":"*name.Name","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"namespacedName":"Foo\\Type","Parts":[{"type":"*name.NamePart","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"Value":"Type"}]},"Variable":{"type":"*expr.Variable","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"Value":"var"}},"DefaultValue":{"type":"*expr.ConstFetch","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"Constant":{"type":"*name.Name","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"namespacedName":"null","meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Parts":[{"type":"*name.NamePart","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"Value":"null"}]}}}],"Stmt":{"type":"*stmt.StmtList","position":{"startPos":96,"endPos":157,"startLine":6,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"CloseCurlyBracesToken"}],"Stmts":[{"type":"*stmt.Expression","position":{"startPos":147,"endPos":151,"startLine":9,"endLine":9},"meta":[{"type":"*meta.TokenType","value":";","tokenName":"SemiColonToken"}],"Expr":{"type":"*expr.Variable","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// some comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// second comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"Value":"var"}}}]}}]}]}]}
|
||||
}
|
||||
|
@ -300,6 +300,13 @@ func ExamplePrettyJsonDumper() {
|
||||
// "endLine": 5
|
||||
// },
|
||||
// "namespacedName": "null",
|
||||
// "meta": [
|
||||
// {
|
||||
// "type": "*meta.WhiteSpaceType",
|
||||
// "value": " ",
|
||||
// "tokenName": "NodeStart"
|
||||
// }
|
||||
// ],
|
||||
// "Parts": [
|
||||
// {
|
||||
// "type": "*name.NamePart",
|
||||
@ -309,13 +316,6 @@ func ExamplePrettyJsonDumper() {
|
||||
// "startLine": 5,
|
||||
// "endLine": 5
|
||||
// },
|
||||
// "meta": [
|
||||
// {
|
||||
// "type": "*meta.WhiteSpaceType",
|
||||
// "value": " ",
|
||||
// "tokenName": "NodeStart"
|
||||
// }
|
||||
// ],
|
||||
// "Value": "null"
|
||||
// }
|
||||
// ]
|
||||
|
Loading…
Reference in New Issue
Block a user