diff --git a/.gitignore b/.gitignore index 66451b4..9e6bbd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ .vscode php-parser +**/*.test + *example.php -cpu.prof -mem.prof -php7.test -php5.test +cpu.pprof +mem.pprof +trace.out \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 01803e1..4abba27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ branches: only: - master before_script: + - go get -u gotest.tools/assert - go get -u golang.org/x/tools/cmd/goyacc - - go get -u github.com/kylelemons/godebug/pretty + - go get -u github.com/pkg/profile - go get -u github.com/cznic/golex/lex - go get -u github.com/yookoala/realpath - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter diff --git a/Makefile b/Makefile index 4f0a311..460cda5 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,11 @@ fmt: find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' + build: + go generate ./... go build run: - ./php-parser $(PHPFILE) + ./php-parser -d go $(PHPFILE) test: go test ./... @@ -21,7 +22,7 @@ bench: go test -benchmem -bench=. ./php5 go test -benchmem -bench=. ./php7 -compile: ./php5/php5.go ./php7/php7.go ./scanner/scanner.go +compile: ./php5/php5.go ./php7/php7.go ./scanner/scanner.go fmt sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./php7/php7.go sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./php5/php5.go rm -f y.output @@ -36,17 +37,17 @@ compile: ./php5/php5.go ./php7/php7.go ./scanner/scanner.go goyacc -o $@ $< cpu_pprof: - GOGC=off go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php7 - go tool pprof ./php7.test cpu.prof + go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./php7 + go tool pprof ./php7.test cpu.pprof mem_pprof: - GOGC=off go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php7 - go tool pprof -alloc_objects ./php7.test mem.prof + go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./php7 + go tool pprof -alloc_objects ./php7.test mem.pprof cpu_pprof_php5: - GOGC=off go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php5 + go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php5 go tool pprof ./php5.test cpu.prof mem_pprof_php5: - GOGC=off go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php5 + go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php5 go tool pprof -alloc_objects ./php5.test mem.prof diff --git a/README.md b/README.md index 0be3ab4..c932164 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,3 @@ - - PHP Parser written in Go ======================== @@ -26,13 +19,13 @@ Features: - Fully support PHP 5 and PHP 7 syntax - Abstract syntax tree (AST) representation - Traversing AST -- Namespace resolver -- Able to parse syntax-invalid PHP files +- Resolving namespaced names +- Parsing syntax-invalid PHP files +- Saving and printing free-floating comments and whitespaces Roadmap ------- -- Pretty printer - Control Flow Graph (CFG) - PhpDocComment parser - Stabilize api @@ -48,9 +41,17 @@ CLI --- ``` -php-parser [-php5 -noDump] ... +php-parser [flags] ... ``` +| flag | type | description | +|-------|------|----------------------------------------------| +| -d |string| dump format: [custom, go, json, pretty-json] | +| -r | bool | resolve names | +| -ff | bool | parse and show free floating strings | +| -prof |string| start profiler: [cpu, mem, trace] | +| -php5 | bool | parse as PHP5 | + Dump AST to stdout. Example @@ -97,79 +98,3 @@ Namespace resolver is a visitor that resolves nodes fully qualified name and sav - For `Class`, `Interface`, `Trait`, `Function`, `Constant` nodes it saves name with current namespace. - For `Name`, `Relative`, `FullyQualified` nodes it resolves `use` aliases and saves a fully qualified name. - -Parsing syntax-invalid PHP files --------------------------------- - -If we try to parse `$a$b;` then the parser triggers error 'syntax error: unexpected T_VARIABLE'. Token `$b` is unexpected, but parser recovers parsing process and returns `$b;` statement to AST, because it is syntactically correct. - -Pretty printer [work in progress] ---------------------------------- - -```Golang -nodes := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - &stmt.Class{ - Modifiers: []node.Node{ - &node.Identifier{Value: "abstract"}, - }, - ClassName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, - }, - }, - Extends: &stmt.ClassExtends{ - ClassName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{ - Value: "Baz" - }, - }, - }, - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - }, - MethodName: &node.Identifier{Value: "greet"}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Echo{ - Exprs: []node.Node{ - &scalar.String{Value: "'Hello world'"}, - }, - }, - }, - }, - }, - }, - }, - }, -} - -file := os.Stdout -p := printer.NewPrinter(file, " ") -p.Print(nodes) -``` - -It prints to stdout: - -```PHP -' - DotToken // '.' -) - -var TokenNames = map[TokenName]string{ - UnknownToken: "UnknownToken", - IncludeToken: "IncludeToken", - IncludeOnceToken: "IncludeOnceToken", - ExitToken: "ExitToken", - IfToken: "IfToken", - LnumberToken: "LnumberToken", - DnumberToken: "DnumberToken", - StringToken: "StringToken", - StringVarnameToken: "StringVarnameToken", - VariableToken: "VariableToken", - NumStringToken: "NumStringToken", - InlineHTMLToken: "InlineHTMLToken", - EncapsedAndWhitespaceToken: "EncapsedAndWhitespaceToken", - ConstantEncapsedStringToken: "ConstantEncapsedStringToken", - EchoToken: "EchoToken", - DoToken: "DoToken", - WhileToken: "WhileToken", - EndwhileToken: "EndwhileToken", - ForInitSemicolonToken: "ForInitSemicolonToken", - ForCondSemicolonToken: "ForCondSemicolonToken", - ForToken: "ForToken", - EndforToken: "EndforToken", - ForeachToken: "ForeachToken", - EndforeachToken: "EndforeachToken", - DeclareToken: "DeclareToken", - EnddeclareToken: "EnddeclareToken", - AsToken: "AsToken", - SwitchToken: "SwitchToken", - EndswitchToken: "EndswitchToken", - CaseToken: "CaseToken", - DefaultToken: "DefaultToken", - BreakToken: "BreakToken", - ContinueToken: "ContinueToken", - GotoToken: "GotoToken", - FunctionToken: "FunctionToken", - ConstToken: "ConstToken", - ReturnToken: "ReturnToken", - TryToken: "TryToken", - CatchToken: "CatchToken", - FinallyToken: "FinallyToken", - ThrowToken: "ThrowToken", - UseToken: "UseToken", - InsteadofToken: "InsteadofToken", - GlobalToken: "GlobalToken", - VarToken: "VarToken", - UnsetToken: "UnsetToken", - IssetToken: "IssetToken", - EmptyToken: "EmptyToken", - ClassToken: "ClassToken", - TraitToken: "TraitToken", - InterfaceToken: "InterfaceToken", - ExtendsToken: "ExtendsToken", - ImplementsToken: "ImplementsToken", - DoubleArrowToken: "DoubleArrowToken", - ListToken: "ListToken", - ArrayToken: "ArrayToken", - CallableToken: "CallableToken", - ClassCToken: "ClassCToken", - TraitCToken: "TraitCToken", - MethodCToken: "MethodCToken", - FuncCToken: "FuncCToken", - LineToken: "LineToken", - FileToken: "FileToken", - StartHeredocToken: "StartHeredocToken", - DollarOpenCurlyBracesToken: "DollarOpenCurlyBracesToken", - CurlyOpenToken: "CurlyOpenToken", - PaamayimNekudotayimToken: "PaamayimNekudotayimToken", - NamespaceToken: "NamespaceToken", - NsCToken: "NsCToken", - DirToken: "DirToken", - NsSeparatorToken: "NsSeparatorToken", - EllipsisToken: "EllipsisToken", - EvalToken: "EvalToken", - RequireToken: "RequireToken", - RequireOnceToken: "RequireOnceToken", - LogicalOrToken: "LogicalOrToken", - LogicalXorToken: "LogicalXorToken", - LogicalAndToken: "LogicalAndToken", - InstanceofToken: "InstanceofToken", - NewToken: "NewToken", - CloneToken: "CloneToken", - ElseifToken: "ElseifToken", - ElseToken: "ElseToken", - EndifToken: "EndifToken", - PrintToken: "PrintToken", - YieldToken: "YieldToken", - StaticToken: "StaticToken", - AbstractToken: "AbstractToken", - FinalToken: "FinalToken", - PrivateToken: "PrivateToken", - ProtectedToken: "ProtectedToken", - PublicToken: "PublicToken", - IncToken: "IncToken", - DecToken: "DecToken", - YieldFromToken: "YieldFromToken", - ObjectOperatorToken: "ObjectOperatorToken", - IntCastToken: "IntCastToken", - DoubleCastToken: "DoubleCastToken", - StringCastToken: "StringCastToken", - ArrayCastToken: "ArrayCastToken", - ObjectCastToken: "ObjectCastToken", - BoolCastToken: "BoolCastToken", - UnsetCastToken: "UnsetCastToken", - CoalesceToken: "CoalesceToken", - SpaceshipToken: "SpaceshipToken", - PlusEqualToken: "PlusEqualToken", - MinusEqualToken: "MinusEqualToken", - MulEqualToken: "MulEqualToken", - PowEqualToken: "PowEqualToken", - DivEqualToken: "DivEqualToken", - ConcatEqualToken: "ConcatEqualToken", - ModEqualToken: "ModEqualToken", - AndEqualToken: "AndEqualToken", - OrEqualToken: "OrEqualToken", - XorEqualToken: "XorEqualToken", - SlEqualToken: "SlEqualToken", - SrEqualToken: "SrEqualToken", - BooleanOrToken: "BooleanOrToken", - BooleanAndToken: "BooleanAndToken", - PowToken: "PowToken", - SlToken: "SlToken", - SrToken: "SrToken", - IsIdenticalToken: "IsIdenticalToken", - IsNotIdenticalToken: "IsNotIdenticalToken", - IsEqualToken: "IsEqualToken", - IsNotEqualToken: "IsNotEqualToken", - IsSmallerOrEqualToken: "IsSmallerOrEqualToken", - IsGreaterOrEqualToken: "IsGreaterOrEqualToken", - HaltCompilerToken: "HaltCompilerToken", - IdentifierToken: "IdentifierToken", - CaseSeparatorToken: "CaseSeparatorToken", - DoubleQuoteToken: "DoubleQuoteToken", - BackquoteToken: "BackquoteToken", - OpenCurlyBracesToken: "OpenCurlyBracesToken", - CloseCurlyBracesToken: "CloseCurlyBracesToken", - SemiColonToken: "SemiColonToken", - ColonToken: "ColonToken", - OpenParenthesisToken: "OpenParenthesisToken", - CloseParenthesisToken: "CloseParenthesisToken", - OpenSquareBracket: "OpenSquareBracket", - CloseSquareBracket: "CloseSquareBracket", - QuestionMarkToken: "QuestionMarkToken", - AmpersandToken: "AmpersandToken", - MinusToken: "MinusToken", - PlusToken: "PlusToken", - ExclamationMarkToken: "ExclamationMarkToken", - TildeToken: "TildeToken", - AtToken: "AtToken", - DollarToken: "DollarToken", - CommaToken: "CommaToken", - VerticalBarToken: "VerticalBarToken", - EqualToken: "EqualToken", - CaretToken: "CaretToken", - AsteriskToken: "AsteriskToken", - SlashToken: "SlashToken", - PercentToken: "PercentToken", - LessToken: "LessToken", - GreaterToken: "GreaterToken", - DotToken: "DotToken", -} diff --git a/errors/error_test.go b/errors/error_test.go index 8d563ea..439157e 100644 --- a/errors/error_test.go +++ b/errors/error_test.go @@ -1,29 +1,14 @@ package errors_test import ( - "reflect" "testing" - "github.com/z7zmey/php-parser/position" + "gotest.tools/assert" "github.com/z7zmey/php-parser/errors" - - "github.com/kylelemons/godebug/pretty" + "github.com/z7zmey/php-parser/position" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - - } -} - func TestConstructor(t *testing.T) { pos := position.NewPosition(1, 2, 3, 4) @@ -34,7 +19,7 @@ func TestConstructor(t *testing.T) { Pos: pos, } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPrint(t *testing.T) { @@ -46,7 +31,7 @@ func TestPrint(t *testing.T) { expected := "message at line 1" - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPrintWithotPos(t *testing.T) { @@ -56,5 +41,5 @@ func TestPrintWithotPos(t *testing.T) { expected := "message" - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/freefloating/position_string.go b/freefloating/position_string.go new file mode 100644 index 0000000..d10a397 --- /dev/null +++ b/freefloating/position_string.go @@ -0,0 +1,16 @@ +// Code generated by "stringer -type=Position -output ./position_string.go"; DO NOT EDIT. + +package freefloating + +import "strconv" + +const _Position_name = "StartEndSlashColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" + +var _Position_index = [...]uint16{0, 5, 8, 13, 18, 27, 33, 39, 48, 52, 58, 61, 64, 71, 81, 93, 106, 117, 123, 126, 130, 134, 142, 150, 157, 161, 165, 178, 187, 193, 198, 201, 206, 209, 215, 220, 227, 234, 239, 246, 250, 257, 259, 265, 269, 277, 285, 290, 292, 297, 301, 306, 311, 316, 320, 324, 327, 332, 337, 342, 349, 358, 366, 375, 387, 400, 413, 424, 436, 448, 461, 475, 489, 507, 527, 548} + +func (i Position) String() string { + if i < 0 || i >= Position(len(_Position_index)-1) { + return "Position(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Position_name[_Position_index[i]:_Position_index[i+1]] +} diff --git a/freefloating/string.go b/freefloating/string.go new file mode 100644 index 0000000..be5507f --- /dev/null +++ b/freefloating/string.go @@ -0,0 +1,112 @@ +package freefloating + +import "github.com/z7zmey/php-parser/position" + +type StringType int + +const ( + WhiteSpaceType StringType = iota + CommentType + TokenType +) + +type Position int + +//go:generate stringer -type=Position -output ./position_string.go +const ( + Start Position = iota + End + Slash + Colon + SemiColon + AltEnd + Dollar + Ampersand + Name + Prefix + Key + Var + UseType + ReturnType + OptionalType + CaseSeparator + LexicalVars + Params + Ref + Cast + Expr + InitExpr + CondExpr + IncExpr + True + Cond + + HaltCompiller + Namespace + Static + Class + Use + While + For + Switch + Break + Foreach + Declare + Label + Finally + List + Default + If + ElseIf + Else + Variadic + Function + Alias + As + Equal + Exit + Array + Isset + Empty + Eval + Echo + Try + Catch + Unset + + Stmts + VarList + ConstList + NameList + ParamList + ModifierList + ArrayPairList + CaseListStart + CaseListEnd + ArgumentList + PropertyList + ParameterList + AdaptationList + LexicalVarList + UseDeclarationList + + OpenParenthesisToken + CloseParenthesisToken +) + +type String struct { + StringType StringType + Value string + Position *position.Position +} + +type Collection map[Position][]String + +func (c Collection) IsEmpty() bool { + for _, v := range c { + if len(v) > 0 { + return false + } + } + return true +} diff --git a/main.go b/main.go index 53f9901..a0a2dc1 100644 --- a/main.go +++ b/main.go @@ -1,50 +1,81 @@ package main import ( + "bufio" + "bytes" "flag" "fmt" + "io/ioutil" "log" "os" "path/filepath" + "runtime" "sync" + "github.com/pkg/profile" "github.com/yookoala/realpath" "github.com/z7zmey/php-parser/parser" "github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/printer" "github.com/z7zmey/php-parser/visitor" ) var wg sync.WaitGroup var usePhp5 *bool -var noDump *bool +var dumpType string +var profiler string +var withFreeFloating *bool +var showResolvedNs *bool +var printBack *bool + +type file struct { + path string + content []byte +} func main() { - usePhp5 = flag.Bool("php5", false, "use PHP5 parserWorker") - noDump = flag.Bool("noDump", false, "disable dumping to stdout") + usePhp5 = flag.Bool("php5", false, "parse as PHP5") + withFreeFloating = flag.Bool("ff", false, "parse and show free floating strings") + showResolvedNs = flag.Bool("r", false, "resolve names") + printBack = flag.Bool("pb", false, "print AST back into the parsed file") + flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]") + flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]") + flag.Parse() - pathCh := make(chan string) - resultCh := make(chan parser.Parser) + switch profiler { + case "cpu": + defer profile.Start(profile.ProfilePath("."), profile.NoShutdownHook).Stop() + case "mem": + defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + case "trace": + defer profile.Start(profile.TraceProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + } + + numCpu := runtime.NumCPU() + + fileCh := make(chan *file, numCpu) + resultCh := make(chan parser.Parser, numCpu) // run 4 concurrent parserWorkers - for i := 0; i < 4; i++ { - go parserWorker(pathCh, resultCh) + for i := 0; i < numCpu; i++ { + go parserWorker(fileCh, resultCh) } // run printer goroutine - go printer(resultCh) + go printerWorker(resultCh) // process files - processPath(flag.Args(), pathCh) + processPath(flag.Args(), fileCh) // wait the all files done wg.Wait() - close(pathCh) + close(fileCh) close(resultCh) } -func processPath(pathList []string, pathCh chan<- string) { +func processPath(pathList []string, fileCh chan<- *file) { for _, path := range pathList { real, err := realpath.Realpath(path) checkErr(err) @@ -52,7 +83,9 @@ func processPath(pathList []string, pathCh chan<- string) { err = filepath.Walk(real, func(path string, f os.FileInfo, err error) error { if !f.IsDir() && filepath.Ext(path) == ".php" { wg.Add(1) - pathCh <- path + content, err := ioutil.ReadFile(path) + checkErr(err) + fileCh <- &file{path, content} } return nil }) @@ -60,54 +93,93 @@ func processPath(pathList []string, pathCh chan<- string) { } } -func parserWorker(pathCh <-chan string, result chan<- parser.Parser) { +func parserWorker(fileCh <-chan *file, result chan<- parser.Parser) { var parserWorker parser.Parser for { - path, ok := <-pathCh + f, ok := <-fileCh if !ok { return } - src, _ := os.Open(path) + src := bytes.NewReader(f.content) if *usePhp5 { - parserWorker = php5.NewParser(src, path) + parserWorker = php5.NewParser(src, f.path) } else { - parserWorker = php7.NewParser(src, path) + parserWorker = php7.NewParser(src, f.path) + } + + if *withFreeFloating { + parserWorker.WithFreeFloating() } parserWorker.Parse() + result <- parserWorker } } -func printer(result <-chan parser.Parser) { +func printerWorker(result <-chan parser.Parser) { + var counter int + + w := bufio.NewWriter(os.Stdout) + for { parserWorker, ok := <-result if !ok { + w.Flush() return } - fmt.Printf("==> %s\n", parserWorker.GetPath()) + counter++ + + fmt.Fprintf(w, "==> [%d] %s\n", counter, parserWorker.GetPath()) for _, e := range parserWorker.GetErrors() { - fmt.Println(e) + fmt.Fprintln(w, e) } - if !*noDump { - nsResolver := visitor.NewNamespaceResolver() - parserWorker.GetRootNode().Walk(nsResolver) + if *printBack { + o := bytes.NewBuffer([]byte{}) + p := printer.NewPrinter(o) + p.Print(parserWorker.GetRootNode()) - dumper := visitor.Dumper{ + err := ioutil.WriteFile(parserWorker.GetPath(), o.Bytes(), 0644) + checkErr(err) + } + + var nsResolver *visitor.NamespaceResolver + if *showResolvedNs { + nsResolver = visitor.NewNamespaceResolver() + parserWorker.GetRootNode().Walk(nsResolver) + } + + switch dumpType { + case "custom": + dumper := &visitor.Dumper{ Writer: os.Stdout, - Indent: " | ", - Comments: parserWorker.GetComments(), - Positions: parserWorker.GetPositions(), + Indent: "| ", NsResolver: nsResolver, } parserWorker.GetRootNode().Walk(dumper) + case "json": + dumper := &visitor.JsonDumper{ + Writer: os.Stdout, + NsResolver: nsResolver, + } + parserWorker.GetRootNode().Walk(dumper) + case "pretty_json": + dumper := &visitor.PrettyJsonDumper{ + Writer: os.Stdout, + NsResolver: nsResolver, + } + parserWorker.GetRootNode().Walk(dumper) + case "go": + dumper := &visitor.GoDumper{Writer: os.Stdout} + parserWorker.GetRootNode().Walk(dumper) } + wg.Done() } } diff --git a/node/expr/assign/n_assign.go b/node/expr/assign/n_assign.go index d94df64..dd55306 100644 --- a/node/expr/assign/n_assign.go +++ b/node/expr/assign/n_assign.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Assign node type Assign struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewAssign node constructor func NewAssign(Variable node.Node, Expression node.Node) *Assign { return &Assign{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Assign) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Assign) GetPosition() *position.Position { + return n.Position +} + +func (n *Assign) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Assign) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Assign) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_assign_ref.go b/node/expr/assign/n_assign_ref.go index 8cbd264..fbf95ae 100644 --- a/node/expr/assign/n_assign_ref.go +++ b/node/expr/assign/n_assign_ref.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Reference node type Reference struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewReference node constructor func NewReference(Variable node.Node, Expression node.Node) *Reference { return &Reference{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Reference) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Reference) GetPosition() *position.Position { + return n.Position +} + +func (n *Reference) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Reference) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Reference) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_bitwise_and.go b/node/expr/assign/n_bitwise_and.go index bc112e6..1ba0a97 100644 --- a/node/expr/assign/n_bitwise_and.go +++ b/node/expr/assign/n_bitwise_and.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseAnd node type BitwiseAnd struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewBitwiseAnd node constructor func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd { return &BitwiseAnd{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *BitwiseAnd) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseAnd) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseAnd) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseAnd) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_bitwise_or.go b/node/expr/assign/n_bitwise_or.go index b8ae059..46f9ee4 100644 --- a/node/expr/assign/n_bitwise_or.go +++ b/node/expr/assign/n_bitwise_or.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseOr node type BitwiseOr struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewBitwiseOr node constructor func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr { return &BitwiseOr{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *BitwiseOr) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseOr) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseOr) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseOr) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_bitwise_xor.go b/node/expr/assign/n_bitwise_xor.go index 905158b..7f8050f 100644 --- a/node/expr/assign/n_bitwise_xor.go +++ b/node/expr/assign/n_bitwise_xor.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseXor node type BitwiseXor struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewBitwiseXor node constructor func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor { return &BitwiseXor{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *BitwiseXor) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseXor) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseXor) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseXor) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_concat.go b/node/expr/assign/n_concat.go index a43e3a1..63c7e9d 100644 --- a/node/expr/assign/n_concat.go +++ b/node/expr/assign/n_concat.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Concat node type Concat struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewConcat node constructor func NewConcat(Variable node.Node, Expression node.Node) *Concat { return &Concat{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Concat) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Concat) GetPosition() *position.Position { + return n.Position +} + +func (n *Concat) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Concat) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Concat) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_div.go b/node/expr/assign/n_div.go index 05bc2ed..2073b15 100644 --- a/node/expr/assign/n_div.go +++ b/node/expr/assign/n_div.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Div node type Div struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewDiv node constructor func NewDiv(Variable node.Node, Expression node.Node) *Div { return &Div{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Div) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Div) GetPosition() *position.Position { + return n.Position +} + +func (n *Div) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Div) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Div) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_minus.go b/node/expr/assign/n_minus.go index c66b1d2..efc147c 100644 --- a/node/expr/assign/n_minus.go +++ b/node/expr/assign/n_minus.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Minus node type Minus struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewMinus node constructor func NewMinus(Variable node.Node, Expression node.Node) *Minus { return &Minus{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Minus) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Minus) GetPosition() *position.Position { + return n.Position +} + +func (n *Minus) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Minus) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Minus) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_mod.go b/node/expr/assign/n_mod.go index 6e394c5..8fab46a 100644 --- a/node/expr/assign/n_mod.go +++ b/node/expr/assign/n_mod.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Mod node type Mod struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewMod node constructor func NewMod(Variable node.Node, Expression node.Node) *Mod { return &Mod{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Mod) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Mod) GetPosition() *position.Position { + return n.Position +} + +func (n *Mod) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Mod) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Mod) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_mul.go b/node/expr/assign/n_mul.go index 3dc8090..3076b05 100644 --- a/node/expr/assign/n_mul.go +++ b/node/expr/assign/n_mul.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Mul node type Mul struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewMul node constructor func NewMul(Variable node.Node, Expression node.Node) *Mul { return &Mul{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Mul) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Mul) GetPosition() *position.Position { + return n.Position +} + +func (n *Mul) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Mul) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Mul) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_plus.go b/node/expr/assign/n_plus.go index d5cc425..f2c3753 100644 --- a/node/expr/assign/n_plus.go +++ b/node/expr/assign/n_plus.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Plus node type Plus struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewPlus node constructor func NewPlus(Variable node.Node, Expression node.Node) *Plus { return &Plus{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Plus) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Plus) GetPosition() *position.Position { + return n.Position +} + +func (n *Plus) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Plus) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Plus) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_pow.go b/node/expr/assign/n_pow.go index a81cb0c..6bd48e7 100644 --- a/node/expr/assign/n_pow.go +++ b/node/expr/assign/n_pow.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Pow node type Pow struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewPow node constructor func NewPow(Variable node.Node, Expression node.Node) *Pow { return &Pow{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *Pow) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Pow) GetPosition() *position.Position { + return n.Position +} + +func (n *Pow) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Pow) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Pow) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_shift_left.go b/node/expr/assign/n_shift_left.go index 6b52663..0c541ba 100644 --- a/node/expr/assign/n_shift_left.go +++ b/node/expr/assign/n_shift_left.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // ShiftLeft node type ShiftLeft struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewShiftLeft node constructor func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft { return &ShiftLeft{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *ShiftLeft) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *ShiftLeft) GetPosition() *position.Position { + return n.Position +} + +func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *ShiftLeft) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *ShiftLeft) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/n_shift_right.go b/node/expr/assign/n_shift_right.go index 126b801..c496e7e 100644 --- a/node/expr/assign/n_shift_right.go +++ b/node/expr/assign/n_shift_right.go @@ -1,24 +1,43 @@ package assign import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // ShiftRight node type ShiftRight struct { - Variable node.Node - Expression node.Node + FreeFloating freefloating.Collection + Position *position.Position + Variable node.Node + Expression node.Node } // NewShiftRight node constructor func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight { return &ShiftRight{ - Variable, - Expression, + FreeFloating: nil, + Variable: Variable, + Expression: Expression, } } +// SetPosition sets node position +func (n *ShiftRight) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *ShiftRight) GetPosition() *position.Position { + return n.Position +} + +func (n *ShiftRight) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *ShiftRight) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *ShiftRight) Walk(v walker.Visitor) { } if n.Variable != nil { - vv := v.GetChildrenVisitor("Variable") - n.Variable.Walk(vv) + v.EnterChildNode("Variable", n) + n.Variable.Walk(v) + v.LeaveChildNode("Variable", n) } if n.Expression != nil { - vv := v.GetChildrenVisitor("Expression") - n.Expression.Walk(vv) + v.EnterChildNode("Expression", n) + n.Expression.Walk(v) + v.LeaveChildNode("Expression", n) } v.LeaveNode(n) diff --git a/node/expr/assign/t_assign_op_test.go b/node/expr/assign/t_assign_op_test.go index 207e891..19b0ca7 100644 --- a/node/expr/assign/t_assign_op_test.go +++ b/node/expr/assign/t_assign_op_test.go @@ -2,12 +2,12 @@ package assign_test import ( "bytes" - "reflect" "testing" - "github.com/z7zmey/php-parser/node/expr/assign" + "gotest.tools/assert" - "github.com/kylelemons/godebug/pretty" + "github.com/z7zmey/php-parser/node/expr/assign" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" @@ -17,56 +17,63 @@ import ( "github.com/z7zmey/php-parser/php7" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - } -} - func TestReference(t *testing.T) { src := `>= $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Expr: &assign.ShiftRight{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + Value: "b", + }, + }, }, }, }, @@ -442,10 +1266,10 @@ func TestShiftRight(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/assign/t_freefloating_test.go b/node/expr/assign/t_freefloating_test.go new file mode 100644 index 0000000..151ac20 --- /dev/null +++ b/node/expr/assign/t_freefloating_test.go @@ -0,0 +1,81 @@ +package assign_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/freefloating" + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/expr/assign" +) + +var expected freefloating.Collection = freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.WhiteSpaceType, + Value: " ", + Position: nil, + }, + { + StringType: freefloating.CommentType, + Value: "//comment\n", + Position: nil, + }, + }, +} + +var nodes = []node.Node{ + &assign.Reference{ + FreeFloating: expected, + }, + &assign.Assign{ + FreeFloating: expected, + }, + &assign.BitwiseAnd{ + FreeFloating: expected, + }, + &assign.BitwiseOr{ + FreeFloating: expected, + }, + &assign.BitwiseXor{ + FreeFloating: expected, + }, + &assign.Concat{ + FreeFloating: expected, + }, + &assign.Div{ + FreeFloating: expected, + }, + &assign.Minus{ + FreeFloating: expected, + }, + &assign.Mod{ + FreeFloating: expected, + }, + &assign.Mul{ + FreeFloating: expected, + }, + &assign.Plus{ + FreeFloating: expected, + }, + &assign.Pow{ + FreeFloating: expected, + }, + &assign.ShiftLeft{ + FreeFloating: expected, + }, + &assign.ShiftRight{ + FreeFloating: expected, + }, + &assign.ShiftRight{ + FreeFloating: expected, + }, +} + +func TestMeta(t *testing.T) { + for _, n := range nodes { + actual := *n.GetFreeFloating() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/expr/assign/t_position_test.go b/node/expr/assign/t_position_test.go new file mode 100644 index 0000000..8963458 --- /dev/null +++ b/node/expr/assign/t_position_test.go @@ -0,0 +1,18 @@ +package assign_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/position" +) + +func TestPosition(t *testing.T) { + expected := position.NewPosition(1, 1, 1, 1) + for _, n := range nodes { + n.SetPosition(expected) + actual := n.GetPosition() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/expr/assign/t_visitor_test.go b/node/expr/assign/t_visitor_test.go index 643d158..6694b5b 100644 --- a/node/expr/assign/t_visitor_test.go +++ b/node/expr/assign/t_visitor_test.go @@ -1,15 +1,13 @@ package assign_test import ( - "reflect" "testing" - "github.com/z7zmey/php-parser/node/expr/assign" - - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/node/expr/assign" "github.com/z7zmey/php-parser/walker" ) @@ -20,115 +18,115 @@ var nodesToTest = []struct { }{ { &assign.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Assign{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.BitwiseAnd{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.BitwiseOr{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.BitwiseXor{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Concat{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Div{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Minus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Mod{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Mul{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Plus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.Pow{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.ShiftLeft{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, { &assign.ShiftRight{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{}, + Expression: &expr.Variable{}, }, []string{"Variable", "Expression"}, - map[string]interface{}{}, + nil, }, } @@ -138,39 +136,37 @@ type visitorMock struct { } func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } -func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { +func (v *visitorMock) LeaveNode(n walker.Walkable) {} +func (v *visitorMock) EnterChildNode(key string, w walker.Walkable) { v.visitedKeys = append(v.visitedKeys, key) - return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walkable) {} +func (v *visitorMock) LeaveChildNode(key string, w walker.Walkable) {} +func (v *visitorMock) EnterChildList(key string, w walker.Walkable) { + v.visitedKeys = append(v.visitedKeys, key) +} +func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { - v := &visitorMock{false, nil} + v := &visitorMock{false, []string{}} tt.node.Walk(v) expected := []string{} actual := v.visitedKeys - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } func TestVisitor(t *testing.T) { for _, tt := range nodesToTest { - v := &visitorMock{true, nil} + v := &visitorMock{true, []string{}} tt.node.Walk(v) expected := tt.expectedVisitedKeys actual := v.visitedKeys - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } @@ -181,9 +177,6 @@ func TestNameAttributes(t *testing.T) { expected := tt.expectedAttributes actual := tt.node.Attributes() - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } diff --git a/node/expr/binary/n_bitwise_and.go b/node/expr/binary/n_bitwise_and.go index 842398d..76eb9ed 100644 --- a/node/expr/binary/n_bitwise_and.go +++ b/node/expr/binary/n_bitwise_and.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseAnd node type BitwiseAnd struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewBitwiseAnd node constructor func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd { return &BitwiseAnd{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *BitwiseAnd) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseAnd) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseAnd) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseAnd) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_bitwise_or.go b/node/expr/binary/n_bitwise_or.go index 2d257b5..6f3ea41 100644 --- a/node/expr/binary/n_bitwise_or.go +++ b/node/expr/binary/n_bitwise_or.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseOr node type BitwiseOr struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewBitwiseOr node constructor func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr { return &BitwiseOr{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *BitwiseOr) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseOr) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseOr) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseOr) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_bitwise_xor.go b/node/expr/binary/n_bitwise_xor.go index c67fe00..57ae9fa 100644 --- a/node/expr/binary/n_bitwise_xor.go +++ b/node/expr/binary/n_bitwise_xor.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BitwiseXor node type BitwiseXor struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewBitwiseXor node constructor func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor { return &BitwiseXor{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *BitwiseXor) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BitwiseXor) GetPosition() *position.Position { + return n.Position +} + +func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BitwiseXor) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BitwiseXor) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_boolean_and.go b/node/expr/binary/n_boolean_and.go index e7ca96b..d81371f 100644 --- a/node/expr/binary/n_boolean_and.go +++ b/node/expr/binary/n_boolean_and.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BooleanAnd node type BooleanAnd struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewBooleanAnd node constructor func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd { return &BooleanAnd{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *BooleanAnd) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BooleanAnd) GetPosition() *position.Position { + return n.Position +} + +func (n *BooleanAnd) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BooleanAnd) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BooleanAnd) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_boolean_or.go b/node/expr/binary/n_boolean_or.go index bb92e0a..20837d4 100644 --- a/node/expr/binary/n_boolean_or.go +++ b/node/expr/binary/n_boolean_or.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // BooleanOr node type BooleanOr struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewBooleanOr node constructor func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr { return &BooleanOr{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *BooleanOr) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *BooleanOr) GetPosition() *position.Position { + return n.Position +} + +func (n *BooleanOr) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *BooleanOr) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *BooleanOr) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_coalesce.go b/node/expr/binary/n_coalesce.go index b0eb6f5..f938099 100644 --- a/node/expr/binary/n_coalesce.go +++ b/node/expr/binary/n_coalesce.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Coalesce node type Coalesce struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewCoalesce node constructor func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce { return &Coalesce{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Coalesce) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Coalesce) GetPosition() *position.Position { + return n.Position +} + +func (n *Coalesce) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Coalesce) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Coalesce) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_concat.go b/node/expr/binary/n_concat.go index 3a74a4d..c356e6f 100644 --- a/node/expr/binary/n_concat.go +++ b/node/expr/binary/n_concat.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Concat node type Concat struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewConcat node constructor func NewConcat(Variable node.Node, Expression node.Node) *Concat { return &Concat{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Concat) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Concat) GetPosition() *position.Position { + return n.Position +} + +func (n *Concat) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Concat) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Concat) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_div.go b/node/expr/binary/n_div.go index aa68b9a..978e446 100644 --- a/node/expr/binary/n_div.go +++ b/node/expr/binary/n_div.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Div node type Div struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewDiv node constructor func NewDiv(Variable node.Node, Expression node.Node) *Div { return &Div{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Div) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Div) GetPosition() *position.Position { + return n.Position +} + +func (n *Div) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Div) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Div) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_equal.go b/node/expr/binary/n_equal.go index c02b1ec..e8debbb 100644 --- a/node/expr/binary/n_equal.go +++ b/node/expr/binary/n_equal.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Equal node type Equal struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewEqual node constructor func NewEqual(Variable node.Node, Expression node.Node) *Equal { return &Equal{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Equal) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Equal) GetPosition() *position.Position { + return n.Position +} + +func (n *Equal) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Equal) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Equal) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_greater.go b/node/expr/binary/n_greater.go index daab173..0915acc 100644 --- a/node/expr/binary/n_greater.go +++ b/node/expr/binary/n_greater.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Greater node type Greater struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewGreater node constructor func NewGreater(Variable node.Node, Expression node.Node) *Greater { return &Greater{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Greater) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Greater) GetPosition() *position.Position { + return n.Position +} + +func (n *Greater) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Greater) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Greater) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_greater_or_equal.go b/node/expr/binary/n_greater_or_equal.go index 47f1df2..3f1a4e7 100644 --- a/node/expr/binary/n_greater_or_equal.go +++ b/node/expr/binary/n_greater_or_equal.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // GreaterOrEqual node type GreaterOrEqual struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewGreaterOrEqual node constructor func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual { return &GreaterOrEqual{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *GreaterOrEqual) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *GreaterOrEqual) GetPosition() *position.Position { + return n.Position +} + +func (n *GreaterOrEqual) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *GreaterOrEqual) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *GreaterOrEqual) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_identical.go b/node/expr/binary/n_identical.go index 6a782e0..51e3f9d 100644 --- a/node/expr/binary/n_identical.go +++ b/node/expr/binary/n_identical.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Identical node type Identical struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewIdentical node constructor func NewIdentical(Variable node.Node, Expression node.Node) *Identical { return &Identical{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Identical) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Identical) GetPosition() *position.Position { + return n.Position +} + +func (n *Identical) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Identical) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Identical) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_logical_and.go b/node/expr/binary/n_logical_and.go index b2d35b6..8bacaac 100644 --- a/node/expr/binary/n_logical_and.go +++ b/node/expr/binary/n_logical_and.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // LogicalAnd node type LogicalAnd struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewLogicalAnd node constructor func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd { return &LogicalAnd{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *LogicalAnd) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *LogicalAnd) GetPosition() *position.Position { + return n.Position +} + +func (n *LogicalAnd) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *LogicalAnd) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *LogicalAnd) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_logical_or.go b/node/expr/binary/n_logical_or.go index 5e7d88e..85de6ef 100644 --- a/node/expr/binary/n_logical_or.go +++ b/node/expr/binary/n_logical_or.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // LogicalOr node type LogicalOr struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewLogicalOr node constructor func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr { return &LogicalOr{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *LogicalOr) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *LogicalOr) GetPosition() *position.Position { + return n.Position +} + +func (n *LogicalOr) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *LogicalOr) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *LogicalOr) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_logical_xor.go b/node/expr/binary/n_logical_xor.go index 043e0a3..9764d23 100644 --- a/node/expr/binary/n_logical_xor.go +++ b/node/expr/binary/n_logical_xor.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // LogicalXor node type LogicalXor struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewLogicalXor node constructor func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor { return &LogicalXor{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *LogicalXor) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *LogicalXor) GetPosition() *position.Position { + return n.Position +} + +func (n *LogicalXor) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *LogicalXor) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *LogicalXor) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_minus.go b/node/expr/binary/n_minus.go index 397fa68..e9b3d2e 100644 --- a/node/expr/binary/n_minus.go +++ b/node/expr/binary/n_minus.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Minus node type Minus struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewMinus node constructor func NewMinus(Variable node.Node, Expression node.Node) *Minus { return &Minus{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Minus) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Minus) GetPosition() *position.Position { + return n.Position +} + +func (n *Minus) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Minus) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Minus) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_mod.go b/node/expr/binary/n_mod.go index 30809e3..11a2845 100644 --- a/node/expr/binary/n_mod.go +++ b/node/expr/binary/n_mod.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Mod node type Mod struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewMod node constructor func NewMod(Variable node.Node, Expression node.Node) *Mod { return &Mod{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Mod) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Mod) GetPosition() *position.Position { + return n.Position +} + +func (n *Mod) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Mod) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Mod) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_mul.go b/node/expr/binary/n_mul.go index c601bfd..994b762 100644 --- a/node/expr/binary/n_mul.go +++ b/node/expr/binary/n_mul.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Mul node type Mul struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewMul node constructor func NewMul(Variable node.Node, Expression node.Node) *Mul { return &Mul{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Mul) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Mul) GetPosition() *position.Position { + return n.Position +} + +func (n *Mul) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Mul) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Mul) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_not_equal.go b/node/expr/binary/n_not_equal.go index e63cfcd..747917f 100644 --- a/node/expr/binary/n_not_equal.go +++ b/node/expr/binary/n_not_equal.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // NotEqual node type NotEqual struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewNotEqual node constructor func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual { return &NotEqual{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *NotEqual) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *NotEqual) GetPosition() *position.Position { + return n.Position +} + +func (n *NotEqual) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *NotEqual) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *NotEqual) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_not_identical.go b/node/expr/binary/n_not_identical.go index 4f8f13e..c9d9951 100644 --- a/node/expr/binary/n_not_identical.go +++ b/node/expr/binary/n_not_identical.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // NotIdentical node type NotIdentical struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewNotIdentical node constructor func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical { return &NotIdentical{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *NotIdentical) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *NotIdentical) GetPosition() *position.Position { + return n.Position +} + +func (n *NotIdentical) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *NotIdentical) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *NotIdentical) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_plus.go b/node/expr/binary/n_plus.go index 5d68c46..d6007d0 100644 --- a/node/expr/binary/n_plus.go +++ b/node/expr/binary/n_plus.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Plus node type Plus struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewPlus node constructor func NewPlus(Variable node.Node, Expression node.Node) *Plus { return &Plus{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Plus) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Plus) GetPosition() *position.Position { + return n.Position +} + +func (n *Plus) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Plus) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Plus) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_pow.go b/node/expr/binary/n_pow.go index a21e115..9f3bebb 100644 --- a/node/expr/binary/n_pow.go +++ b/node/expr/binary/n_pow.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Pow node type Pow struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewPow node constructor func NewPow(Variable node.Node, Expression node.Node) *Pow { return &Pow{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Pow) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Pow) GetPosition() *position.Position { + return n.Position +} + +func (n *Pow) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Pow) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Pow) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_shift_left.go b/node/expr/binary/n_shift_left.go index 2b1dec0..2ab0efd 100644 --- a/node/expr/binary/n_shift_left.go +++ b/node/expr/binary/n_shift_left.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // ShiftLeft node type ShiftLeft struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewShiftLeft node constructor func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft { return &ShiftLeft{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *ShiftLeft) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *ShiftLeft) GetPosition() *position.Position { + return n.Position +} + +func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *ShiftLeft) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *ShiftLeft) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_shift_right.go b/node/expr/binary/n_shift_right.go index 44911cb..5716b56 100644 --- a/node/expr/binary/n_shift_right.go +++ b/node/expr/binary/n_shift_right.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // ShiftRight node type ShiftRight struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewShiftRight node constructor func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight { return &ShiftRight{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *ShiftRight) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *ShiftRight) GetPosition() *position.Position { + return n.Position +} + +func (n *ShiftRight) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *ShiftRight) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *ShiftRight) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_smaller.go b/node/expr/binary/n_smaller.go index 1622871..cccc320 100644 --- a/node/expr/binary/n_smaller.go +++ b/node/expr/binary/n_smaller.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Smaller node type Smaller struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewSmaller node constructor func NewSmaller(Variable node.Node, Expression node.Node) *Smaller { return &Smaller{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Smaller) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Smaller) GetPosition() *position.Position { + return n.Position +} + +func (n *Smaller) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Smaller) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Smaller) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_smaller_or_equal.go b/node/expr/binary/n_smaller_or_equal.go index 9a839d8..5d9c1df 100644 --- a/node/expr/binary/n_smaller_or_equal.go +++ b/node/expr/binary/n_smaller_or_equal.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // SmallerOrEqual node type SmallerOrEqual struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewSmallerOrEqual node constructor func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual { return &SmallerOrEqual{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *SmallerOrEqual) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *SmallerOrEqual) GetPosition() *position.Position { + return n.Position +} + +func (n *SmallerOrEqual) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *SmallerOrEqual) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *SmallerOrEqual) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/n_spaceship.go b/node/expr/binary/n_spaceship.go index ea05c77..e3ca60e 100644 --- a/node/expr/binary/n_spaceship.go +++ b/node/expr/binary/n_spaceship.go @@ -1,24 +1,43 @@ package binary import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Spaceship node type Spaceship struct { - Left node.Node - Right node.Node + FreeFloating freefloating.Collection + Position *position.Position + Left node.Node + Right node.Node } // NewSpaceship node constructor func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship { return &Spaceship{ - Variable, - Expression, + FreeFloating: nil, + Left: Variable, + Right: Expression, } } +// SetPosition sets node position +func (n *Spaceship) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Spaceship) GetPosition() *position.Position { + return n.Position +} + +func (n *Spaceship) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Spaceship) Attributes() map[string]interface{} { return nil @@ -32,13 +51,15 @@ func (n *Spaceship) Walk(v walker.Visitor) { } if n.Left != nil { - vv := v.GetChildrenVisitor("Left") - n.Left.Walk(vv) + v.EnterChildNode("Left", n) + n.Left.Walk(v) + v.LeaveChildNode("Left", n) } if n.Right != nil { - vv := v.GetChildrenVisitor("Right") - n.Right.Walk(vv) + v.EnterChildNode("Right", n) + n.Right.Walk(v) + v.LeaveChildNode("Right", n) } v.LeaveNode(n) diff --git a/node/expr/binary/t_binary_op_test.go b/node/expr/binary/t_binary_op_test.go index 3f316d0..5ad987f 100644 --- a/node/expr/binary/t_binary_op_test.go +++ b/node/expr/binary/t_binary_op_test.go @@ -2,10 +2,9 @@ package binary_test import ( "bytes" - "reflect" "testing" - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" @@ -13,29 +12,68 @@ import ( "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/position" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - } -} - func TestBitwiseAnd(t *testing.T) { src := `= $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, Expr: &binary.GreaterOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + Value: "b", + }, + }, }, }, }, @@ -264,23 +752,73 @@ func TestGreaterOrEqual(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestGreater(t *testing.T) { src := ` $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, Expr: &binary.Greater{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 10, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 9, + EndPos: 10, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 9, + EndPos: 10, + }, + Value: "b", + }, + }, }, }, }, @@ -289,23 +827,73 @@ func TestGreater(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestIdentical(t *testing.T) { src := `> $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, Expr: &binary.ShiftRight{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + Value: "b", + }, + }, }, }, }, @@ -614,23 +1802,73 @@ func TestShiftRight(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestSmallerOrEqual(t *testing.T) { src := ` $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Expr: &binary.Spaceship{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + Value: "b", + }, + }, }, }, }, @@ -689,5 +2027,5 @@ func TestSpaceship(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/binary/t_freefloating_test.go b/node/expr/binary/t_freefloating_test.go new file mode 100644 index 0000000..7db5cf4 --- /dev/null +++ b/node/expr/binary/t_freefloating_test.go @@ -0,0 +1,117 @@ +package binary_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/freefloating" + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/expr/binary" +) + +var expected freefloating.Collection = freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.WhiteSpaceType, + Value: " ", + Position: nil, + }, + { + StringType: freefloating.CommentType, + Value: "//comment\n", + Position: nil, + }, + }, +} + +var nodes = []node.Node{ + &binary.BitwiseAnd{ + FreeFloating: expected, + }, + &binary.BitwiseOr{ + FreeFloating: expected, + }, + &binary.BitwiseXor{ + FreeFloating: expected, + }, + &binary.BooleanAnd{ + FreeFloating: expected, + }, + &binary.BooleanOr{ + FreeFloating: expected, + }, + &binary.Coalesce{ + FreeFloating: expected, + }, + &binary.Concat{ + FreeFloating: expected, + }, + &binary.Div{ + FreeFloating: expected, + }, + &binary.Equal{ + FreeFloating: expected, + }, + &binary.GreaterOrEqual{ + FreeFloating: expected, + }, + &binary.Greater{ + FreeFloating: expected, + }, + &binary.Identical{ + FreeFloating: expected, + }, + &binary.LogicalAnd{ + FreeFloating: expected, + }, + &binary.LogicalOr{ + FreeFloating: expected, + }, + &binary.LogicalXor{ + FreeFloating: expected, + }, + &binary.Minus{ + FreeFloating: expected, + }, + &binary.Mod{ + FreeFloating: expected, + }, + &binary.Mul{ + FreeFloating: expected, + }, + &binary.NotEqual{ + FreeFloating: expected, + }, + &binary.NotIdentical{ + FreeFloating: expected, + }, + &binary.Plus{ + FreeFloating: expected, + }, + &binary.Pow{ + FreeFloating: expected, + }, + &binary.ShiftLeft{ + FreeFloating: expected, + }, + &binary.ShiftRight{ + FreeFloating: expected, + }, + &binary.SmallerOrEqual{ + FreeFloating: expected, + }, + &binary.Smaller{ + FreeFloating: expected, + }, + &binary.Spaceship{ + FreeFloating: expected, + }, +} + +func TestMeta(t *testing.T) { + for _, n := range nodes { + actual := *n.GetFreeFloating() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/expr/binary/t_position_test.go b/node/expr/binary/t_position_test.go new file mode 100644 index 0000000..079e380 --- /dev/null +++ b/node/expr/binary/t_position_test.go @@ -0,0 +1,18 @@ +package binary_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/position" +) + +func TestPosition(t *testing.T) { + expected := position.NewPosition(1, 1, 1, 1) + for _, n := range nodes { + n.SetPosition(expected) + actual := n.GetPosition() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/expr/binary/t_visitor_test.go b/node/expr/binary/t_visitor_test.go index 868bddf..7962e23 100644 --- a/node/expr/binary/t_visitor_test.go +++ b/node/expr/binary/t_visitor_test.go @@ -1,15 +1,13 @@ package binary_test import ( - "reflect" "testing" - "github.com/kylelemons/godebug/pretty" - "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/binary" "github.com/z7zmey/php-parser/walker" + "gotest.tools/assert" ) var nodesToTest = []struct { @@ -19,219 +17,219 @@ var nodesToTest = []struct { }{ { &binary.BitwiseAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.BitwiseOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.BitwiseXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.BooleanAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.BooleanOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Coalesce{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Concat{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Div{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Equal{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.GreaterOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Greater{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Identical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.LogicalAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.LogicalOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.LogicalXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Minus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Mod{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Mul{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.NotEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.NotIdentical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Plus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Pow{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.ShiftLeft{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.ShiftRight{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.SmallerOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Smaller{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, { &binary.Spaceship{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{}, + Right: &expr.Variable{}, }, []string{"Left", "Right"}, - map[string]interface{}{}, + nil, }, } @@ -241,39 +239,37 @@ type visitorMock struct { } func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } -func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { +func (v *visitorMock) LeaveNode(n walker.Walkable) {} +func (v *visitorMock) EnterChildNode(key string, w walker.Walkable) { v.visitedKeys = append(v.visitedKeys, key) - return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walkable) {} +func (v *visitorMock) LeaveChildNode(key string, w walker.Walkable) {} +func (v *visitorMock) EnterChildList(key string, w walker.Walkable) { + v.visitedKeys = append(v.visitedKeys, key) +} +func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { - v := &visitorMock{false, nil} + v := &visitorMock{false, []string{}} tt.node.Walk(v) expected := []string{} actual := v.visitedKeys - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } func TestVisitor(t *testing.T) { for _, tt := range nodesToTest { - v := &visitorMock{true, nil} + v := &visitorMock{true, []string{}} tt.node.Walk(v) expected := tt.expectedVisitedKeys actual := v.visitedKeys - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } @@ -284,9 +280,6 @@ func TestNameAttributes(t *testing.T) { expected := tt.expectedAttributes actual := tt.node.Attributes() - diff := pretty.Compare(expected, actual) - if diff != "" { - t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff) - } + assert.DeepEqual(t, expected, actual) } } diff --git a/node/expr/cast/n_cast_array.go b/node/expr/cast/n_cast_array.go index 56537a8..f12458b 100644 --- a/node/expr/cast/n_cast_array.go +++ b/node/expr/cast/n_cast_array.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Array node type Array struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewArray node constructor func NewArray(Expr node.Node) *Array { return &Array{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Array) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Array) GetPosition() *position.Position { + return n.Position +} + +func (n *Array) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Array) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Array) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_bool.go b/node/expr/cast/n_cast_bool.go index f4c5988..a794df8 100644 --- a/node/expr/cast/n_cast_bool.go +++ b/node/expr/cast/n_cast_bool.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Bool node type Bool struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewBool node constructor func NewBool(Expr node.Node) *Bool { return &Bool{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Bool) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Bool) GetPosition() *position.Position { + return n.Position +} + +func (n *Bool) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Bool) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Bool) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_double.go b/node/expr/cast/n_cast_double.go index addbbc7..61dcc43 100644 --- a/node/expr/cast/n_cast_double.go +++ b/node/expr/cast/n_cast_double.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Double node type Double struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewDouble node constructor func NewDouble(Expr node.Node) *Double { return &Double{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Double) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Double) GetPosition() *position.Position { + return n.Position +} + +func (n *Double) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Double) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Double) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_int.go b/node/expr/cast/n_cast_int.go index 2d70e16..fc3f98d 100644 --- a/node/expr/cast/n_cast_int.go +++ b/node/expr/cast/n_cast_int.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Int node type Int struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewInt node constructor func NewInt(Expr node.Node) *Int { return &Int{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Int) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Int) GetPosition() *position.Position { + return n.Position +} + +func (n *Int) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Int) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Int) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_object.go b/node/expr/cast/n_cast_object.go index b25b919..ea67ce2 100644 --- a/node/expr/cast/n_cast_object.go +++ b/node/expr/cast/n_cast_object.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Object node type Object struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewObject node constructor func NewObject(Expr node.Node) *Object { return &Object{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Object) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Object) GetPosition() *position.Position { + return n.Position +} + +func (n *Object) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Object) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Object) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_string.go b/node/expr/cast/n_cast_string.go index 3fcd0d2..68a09e2 100644 --- a/node/expr/cast/n_cast_string.go +++ b/node/expr/cast/n_cast_string.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // String node type String struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewString node constructor func NewString(Expr node.Node) *String { return &String{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *String) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *String) GetPosition() *position.Position { + return n.Position +} + +func (n *String) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *String) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *String) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/n_cast_unset.go b/node/expr/cast/n_cast_unset.go index a3dc011..a792daa 100644 --- a/node/expr/cast/n_cast_unset.go +++ b/node/expr/cast/n_cast_unset.go @@ -1,22 +1,41 @@ package cast import ( + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // Unset node type Unset struct { - Expr node.Node + FreeFloating freefloating.Collection + Position *position.Position + Expr node.Node } // NewUnset node constructor func NewUnset(Expr node.Node) *Unset { return &Unset{ - Expr, + FreeFloating: nil, + Expr: Expr, } } +// SetPosition sets node position +func (n *Unset) SetPosition(p *position.Position) { + n.Position = p +} + +// GetPosition returns node positions +func (n *Unset) GetPosition() *position.Position { + return n.Position +} + +func (n *Unset) GetFreeFloating() *freefloating.Collection { + return &n.FreeFloating +} + // Attributes returns node attributes as map func (n *Unset) Attributes() map[string]interface{} { return nil @@ -30,8 +49,9 @@ func (n *Unset) Walk(v walker.Visitor) { } if n.Expr != nil { - vv := v.GetChildrenVisitor("Expr") - n.Expr.Walk(vv) + v.EnterChildNode("Expr", n) + n.Expr.Walk(v) + v.LeaveChildNode("Expr", n) } v.LeaveNode(n) diff --git a/node/expr/cast/t_cast_test.go b/node/expr/cast/t_cast_test.go index 4058f6c..578266b 100644 --- a/node/expr/cast/t_cast_test.go +++ b/node/expr/cast/t_cast_test.go @@ -2,10 +2,9 @@ package cast_test import ( "bytes" - "reflect" "testing" - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" @@ -13,28 +12,51 @@ import ( "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/position" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - } -} - func TestArray(t *testing.T) { src := `1, &$b,);` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 21, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 21, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 20, + }, Items: []node.Node{ &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 13, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 10, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 13, + }, + Value: "1", + }, }, &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 18, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 18, + }, + Value: "b", + }, + }, + }, }, - nil, + &expr.ArrayItem{}, }, }, }, @@ -91,10 +212,10 @@ func TestArrayItems(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/t_bitwise_not_test.go b/node/expr/t_bitwise_not_test.go index a4c6456..56968f7 100644 --- a/node/expr/t_bitwise_not_test.go +++ b/node/expr/t_bitwise_not_test.go @@ -4,7 +4,10 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/stmt" @@ -16,10 +19,44 @@ func TestBitwiseNot(t *testing.T) { src := `foo();` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 13, + }, Expr: &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Method: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 12, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 10, + }, + Value: "foo", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, }, }, }, @@ -30,10 +82,10 @@ func TestMethodCall(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/t_new_test.go b/node/expr/t_new_test.go index cba3c88..3b2f0ab 100644 --- a/node/expr/t_new_test.go +++ b/node/expr/t_new_test.go @@ -4,7 +4,10 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/name" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node/expr" @@ -18,12 +21,44 @@ func TestNew(t *testing.T) { src := `foo;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 11, + }, Expr: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 10, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 10, + }, + Value: "foo", + }, }, }, }, @@ -29,10 +74,10 @@ func TestPropertyFetch(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/t_reference_test.go b/node/expr/t_reference_test.go index 9f83687..93be36e 100644 --- a/node/expr/t_reference_test.go +++ b/node/expr/t_reference_test.go @@ -4,7 +4,10 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/stmt" @@ -17,12 +20,86 @@ func TestForeachWithRef(t *testing.T) { src := ` &$v) {}` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 31, + }, Stmts: []node.Node{ &stmt.Foreach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 31, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + Value: "a", + }, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "k", + }, + }, + Variable: &expr.Reference{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + Value: "v", + }, + }, + }, Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, Stmts: []node.Node{}, }, }, @@ -32,10 +109,10 @@ func TestForeachWithRef(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/t_shell_exec_test.go b/node/expr/t_shell_exec_test.go index 19f4ee9..1a31728 100644 --- a/node/expr/t_shell_exec_test.go +++ b/node/expr/t_shell_exec_test.go @@ -4,7 +4,10 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/scalar" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node/expr" @@ -18,12 +21,54 @@ func TestShellExec(t *testing.T) { src := "1, &$b,];` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 16, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 16, + }, Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 15, + }, Items: []node.Node{ &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 8, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 5, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 8, + }, + Value: "1", + }, }, &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + Value: "b", + }, + }, + }, }, - nil, + &expr.ArrayItem{}, }, }, }, @@ -91,10 +212,10 @@ func TestShortArrayItems(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/expr/t_short_list_test.go b/node/expr/t_short_list_test.go index 9492ef9..4a83933 100644 --- a/node/expr/t_short_list_test.go +++ b/node/expr/t_short_list_test.go @@ -4,30 +4,93 @@ import ( "bytes" "testing" - "github.com/z7zmey/php-parser/node/expr/assign" - - "github.com/z7zmey/php-parser/node/expr" + "gotest.tools/assert" "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/node/expr/assign" "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/position" ) func TestShortList(t *testing.T) { src := ` $b;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 18, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 18, + }, Expr: &expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Value: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 17, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + Value: "a", + }, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 17, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 17, + }, + Value: "b", + }, + }, }, }, }, @@ -76,22 +182,48 @@ func TestYieldKeyVal(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestYieldExpr(t *testing.T) { src := ` 1;` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 17, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 17, + }, Expr: &expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Value: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 16, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + Value: "a", + }, + }, + Value: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 16, + }, + Value: "1", + }, }, }, }, @@ -125,22 +299,56 @@ func TestYieldKeyExpr(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestYieldFrom(t *testing.T) { src := `bar()";` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 22, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 22, + }, Expr: &scalar.Encapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 21, + }, Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "test "}, - &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Property: &node.Identifier{Value: "bar"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 9, + }, + Value: "test ", + }, + &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 18, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 13, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 13, + }, + Value: "foo", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + Value: "bar", + }, + }, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "()", }, - &scalar.EncapsedStringPart{Value: "()"}, }, }, }, @@ -146,24 +405,66 @@ func TestSimpleVarPropertyFetch(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestDollarOpenCurlyBraces(t *testing.T) { src := `bar()}";` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 24, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 24, + }, Expr: &scalar.Encapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 23, + }, Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "test "}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 9, + }, + Value: "test ", + }, &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Method: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 21, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 14, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 14, + }, + Value: "foo", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 19, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, }, }, }, @@ -234,10 +654,10 @@ func TestCurlyOpenMethodCall(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/scalar/t_freefloating_test.go b/node/scalar/t_freefloating_test.go new file mode 100644 index 0000000..c30e2ff --- /dev/null +++ b/node/scalar/t_freefloating_test.go @@ -0,0 +1,57 @@ +package scalar_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/freefloating" + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/scalar" +) + +var expected freefloating.Collection = freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.WhiteSpaceType, + Value: " ", + Position: nil, + }, + { + StringType: freefloating.CommentType, + Value: "//comment\n", + Position: nil, + }, + }, +} + +var nodes = []node.Node{ + &scalar.Dnumber{ + FreeFloating: expected, + }, + &scalar.EncapsedStringPart{ + FreeFloating: expected, + }, + &scalar.Encapsed{ + FreeFloating: expected, + }, + &scalar.Heredoc{ + FreeFloating: expected, + }, + &scalar.Lnumber{ + FreeFloating: expected, + }, + &scalar.MagicConstant{ + FreeFloating: expected, + }, + &scalar.String{ + FreeFloating: expected, + }, +} + +func TestMeta(t *testing.T) { + for _, n := range nodes { + actual := *n.GetFreeFloating() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/scalar/t_heredoc_test.go b/node/scalar/t_heredoc_test.go index 10ffb61..45acd48 100644 --- a/node/scalar/t_heredoc_test.go +++ b/node/scalar/t_heredoc_test.go @@ -4,7 +4,10 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/scalar" @@ -20,14 +23,55 @@ LBL; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 24, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 24, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 23, + }, Label: "LBL", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "test "}, - &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - &scalar.EncapsedStringPart{Value: "\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 11, + EndPos: 15, + }, + Value: "test ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 16, + EndPos: 19, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 16, + EndPos: 19, + }, + Value: "var", + }, + }, }, }, }, @@ -37,12 +81,12 @@ LBL; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestSimpleHeredocLabel(t *testing.T) { @@ -52,14 +96,55 @@ LBL; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 26, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 26, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 25, + }, Label: "\"LBL\"", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "test "}, - &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - &scalar.EncapsedStringPart{Value: "\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 13, + EndPos: 17, + }, + Value: "test ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 18, + EndPos: 21, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 18, + EndPos: 21, + }, + Value: "var", + }, + }, }, }, }, @@ -69,12 +154,12 @@ LBL; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestSimpleNowdocLabel(t *testing.T) { @@ -84,12 +169,38 @@ LBL; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 26, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 26, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 25, + }, Label: "'LBL'", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "test $var\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 13, + EndPos: 21, + }, + Value: "test $var", + }, }, }, }, @@ -99,12 +210,12 @@ LBL; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestEmptyHeredoc(t *testing.T) { @@ -113,9 +224,27 @@ CAD; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 7, + EndPos: 14, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 7, + EndPos: 14, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 7, + EndPos: 13, + }, Label: "CAD", }, }, @@ -125,12 +254,12 @@ CAD; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestHeredocScalarString(t *testing.T) { @@ -140,12 +269,38 @@ CAD; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 21, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 21, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 1, + EndLine: 3, + StartPos: 7, + EndPos: 20, + }, Label: "CAD", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 11, + EndPos: 16, + }, + Value: "\thello", + }, }, }, }, @@ -155,10 +310,10 @@ CAD; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/scalar/t_magic_constant_test.go b/node/scalar/t_magic_constant_test.go index 0fbdfdb..4c57efc 100644 --- a/node/scalar/t_magic_constant_test.go +++ b/node/scalar/t_magic_constant_test.go @@ -4,11 +4,14 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/scalar" "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/position" ) func TestMagicConstant(t *testing.T) { @@ -16,9 +19,29 @@ func TestMagicConstant(t *testing.T) { src := ` $v) {}` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 30, + }, Stmts: []node.Node{ &stmt.Foreach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}, - Stmt: &stmt.StmtList{Stmts: []node.Node{}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 30, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + Value: "a", + }, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "k", + }, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 26, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 26, + }, + Value: "v", + }, + }, + Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + Stmts: []node.Node{}, + }, }, }, } @@ -101,24 +320,84 @@ func TestForeachWithKey(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestForeachExprWithKey(t *testing.T) { src := ` $v) {}` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 30, + }, Stmts: []node.Node{ &stmt.Foreach{ - Expr: &expr.ShortArray{Items: []node.Node{}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}, - Stmt: &stmt.StmtList{Stmts: []node.Node{}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 30, + }, + Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + Items: []node.Node{}, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "k", + }, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 26, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 26, + }, + Value: "v", + }, + }, + Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + Stmts: []node.Node{}, + }, }, }, } @@ -126,24 +405,100 @@ func TestForeachExprWithKey(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestForeachWithRef(t *testing.T) { src := ` &$v) {}` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 31, + }, Stmts: []node.Node{ &stmt.Foreach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}}, - Stmt: &stmt.StmtList{Stmts: []node.Node{}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 31, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + Value: "a", + }, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "k", + }, + }, + Variable: &expr.Reference{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + Value: "v", + }, + }, + }, + Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + Stmts: []node.Node{}, + }, }, }, } @@ -151,30 +506,110 @@ func TestForeachWithRef(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestForeachWithList(t *testing.T) { src := ` list($v)) {}` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 36, + }, Stmts: []node.Node{ &stmt.Foreach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 36, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + Value: "a", + }, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + Value: "k", + }, + }, Variable: &expr.List{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 32, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "v"}}, + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + Value: "v", + }, + }, }, }, }, - Stmt: &stmt.StmtList{Stmts: []node.Node{}}, + Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 35, + EndPos: 36, + }, + Stmts: []node.Node{}, + }, }, }, } @@ -182,10 +617,10 @@ func TestForeachWithList(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/stmt/t_freefloating_test.go b/node/stmt/t_freefloating_test.go new file mode 100644 index 0000000..182c5d9 --- /dev/null +++ b/node/stmt/t_freefloating_test.go @@ -0,0 +1,216 @@ +package stmt_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/freefloating" + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/stmt" +) + +var expected freefloating.Collection = freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.WhiteSpaceType, + Value: " ", + Position: nil, + }, + { + StringType: freefloating.CommentType, + Value: "//comment\n", + Position: nil, + }, + }, +} + +var nodes = []node.Node{ + &stmt.AltElseIf{ + FreeFloating: expected, + }, + &stmt.AltElse{ + FreeFloating: expected, + }, + &stmt.AltFor{ + FreeFloating: expected, + }, + &stmt.AltForeach{ + FreeFloating: expected, + }, + &stmt.AltIf{ + FreeFloating: expected, + }, + &stmt.AltSwitch{ + FreeFloating: expected, + }, + &stmt.AltWhile{ + FreeFloating: expected, + }, + &stmt.Break{ + FreeFloating: expected, + }, + &stmt.CaseList{ + FreeFloating: expected, + }, + &stmt.Case{ + FreeFloating: expected, + }, + &stmt.Catch{ + FreeFloating: expected, + }, + &stmt.ClassConstList{ + FreeFloating: expected, + }, + &stmt.ClassExtends{ + FreeFloating: expected, + }, + &stmt.ClassImplements{ + FreeFloating: expected, + }, + &stmt.ClassMethod{ + FreeFloating: expected, + }, + &stmt.Class{ + FreeFloating: expected, + }, + &stmt.ConstList{ + FreeFloating: expected, + }, + &stmt.Constant{ + FreeFloating: expected, + }, + &stmt.Continue{ + FreeFloating: expected, + }, + &stmt.Declare{ + FreeFloating: expected, + }, + &stmt.Default{ + FreeFloating: expected, + }, + &stmt.Do{ + FreeFloating: expected, + }, + &stmt.Echo{ + FreeFloating: expected, + }, + &stmt.ElseIf{ + FreeFloating: expected, + }, + &stmt.Else{ + FreeFloating: expected, + }, + &stmt.Expression{ + FreeFloating: expected, + }, + &stmt.Finally{ + FreeFloating: expected, + }, + &stmt.For{ + FreeFloating: expected, + }, + &stmt.Foreach{ + FreeFloating: expected, + }, + &stmt.Function{ + FreeFloating: expected, + }, + &stmt.Global{ + FreeFloating: expected, + }, + &stmt.Goto{ + FreeFloating: expected, + }, + &stmt.GroupUse{ + FreeFloating: expected, + }, + &stmt.HaltCompiler{ + FreeFloating: expected, + }, + &stmt.If{ + FreeFloating: expected, + }, + &stmt.InlineHtml{ + FreeFloating: expected, + }, + &stmt.InterfaceExtends{ + FreeFloating: expected, + }, + &stmt.Interface{ + FreeFloating: expected, + }, + &stmt.Label{ + FreeFloating: expected, + }, + &stmt.Namespace{ + FreeFloating: expected, + }, + &stmt.Nop{ + FreeFloating: expected, + }, + &stmt.PropertyList{ + FreeFloating: expected, + }, + &stmt.Property{ + FreeFloating: expected, + }, + &stmt.Return{ + FreeFloating: expected, + }, + &stmt.StaticVar{ + FreeFloating: expected, + }, + &stmt.Static{ + FreeFloating: expected, + }, + &stmt.StmtList{ + FreeFloating: expected, + }, + &stmt.Switch{ + FreeFloating: expected, + }, + &stmt.Throw{ + FreeFloating: expected, + }, + &stmt.TraitAdaptationList{ + FreeFloating: expected, + }, + &stmt.TraitMethodRef{ + FreeFloating: expected, + }, + &stmt.TraitUseAlias{ + FreeFloating: expected, + }, + &stmt.TraitUsePrecedence{ + FreeFloating: expected, + }, + &stmt.TraitUse{ + FreeFloating: expected, + }, + &stmt.Trait{ + FreeFloating: expected, + }, + &stmt.Try{ + FreeFloating: expected, + }, + &stmt.Unset{ + FreeFloating: expected, + }, + &stmt.UseList{ + FreeFloating: expected, + }, + &stmt.Use{ + FreeFloating: expected, + }, + &stmt.While{ + FreeFloating: expected, + }, +} + +func TestMeta(t *testing.T) { + for _, n := range nodes { + actual := *n.GetFreeFloating() + assert.DeepEqual(t, expected, actual) + } +} diff --git a/node/stmt/t_function_test.go b/node/stmt/t_function_test.go index fb32180..0015f46 100644 --- a/node/stmt/t_function_test.go +++ b/node/stmt/t_function_test.go @@ -4,8 +4,11 @@ import ( "bytes" "testing" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/node/name" "github.com/z7zmey/php-parser/node/scalar" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" @@ -18,12 +21,32 @@ func TestSimpleFunction(t *testing.T) { src := `
` expected := &node.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 17, + }, Stmts: []node.Node{ - &stmt.Nop{}, - &stmt.InlineHtml{Value: "
"}, + &stmt.Nop{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 4, + EndPos: 5, + }, + }, + &stmt.InlineHtml{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 17, + }, + Value: "
", + }, }, } php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual = php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/node/stmt/t_interface_test.go b/node/stmt/t_interface_test.go index 85a64d8..df770e3 100644 --- a/node/stmt/t_interface_test.go +++ b/node/stmt/t_interface_test.go @@ -2,9 +2,13 @@ package stmt_test import ( "bytes" - "github.com/z7zmey/php-parser/node/name" "testing" + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/node/name" + "github.com/z7zmey/php-parser/position" + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php5" @@ -15,11 +19,31 @@ func TestInterface(t *testing.T) { src := `\n") { + tlen = 3 + } + + phpCloseTag := []freefloating.String{} + if vlen-tlen > 1 { + phpCloseTag = append(phpCloseTag, freefloating.String{ + StringType: freefloating.WhiteSpaceType, + Value: semiColon[0].Value[1 : vlen-tlen], + Position: &position.Position{ + StartLine: p.StartLine, + EndLine: p.EndLine, + StartPos: p.StartPos + 1, + EndPos: p.EndPos - tlen, + }, + }) + } + + phpCloseTag = append(phpCloseTag, freefloating.String{ + StringType: freefloating.WhiteSpaceType, + Value: semiColon[0].Value[vlen-tlen:], + Position: &position.Position{ + StartLine: p.EndLine, + EndLine: p.EndLine, + StartPos: p.EndPos - tlen, + EndPos: p.EndPos, + }, + }) + + l.setFreeFloating(htmlNode, freefloating.Start, append(phpCloseTag, (*htmlNode.GetFreeFloating())[freefloating.Start]...)) +} + func (p *Parser) returnTokenToPool(yyDollar []yySymType, yyVAL *yySymType) { for i := 1; i < len(yyDollar); i++ { if yyDollar[i].token != nil { p.TokenPool.Put(yyDollar[i].token) - p.PositionPool.Put(yyDollar[i].token.Position) } yyDollar[i].token = nil } diff --git a/php5/php5.go b/php5/php5.go index 8216de8..e27c885 100644 --- a/php5/php5.go +++ b/php5/php5.go @@ -1,5 +1,3 @@ -// Code generated by goyacc -o php5/php5.go php5/php5.y. DO NOT EDIT. - //line php5/php5.y:2 package php5 @@ -10,7 +8,7 @@ import ( "strconv" "strings" - "github.com/z7zmey/php-parser/comment" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/assign" @@ -348,7 +346,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line php5/php5.y:6794 +//line php5/php5.y:7204 type simpleIndirectReference struct { all []*expr.Variable @@ -2331,14 +2329,23 @@ yydefault: //line php5/php5.y:281 { yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) - yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + if yylex.(*Parser).currentToken.Value == "\xff" { + yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) + } } case 2: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:291 + //line php5/php5.y:295 { + if inlineHtmlNode, ok := yyDollar[2].node.(*stmt.InlineHtml); ok && len(yyDollar[1].list) > 0 { + prevNode := lastNode(yyDollar[1].list) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if yyDollar[2].node != nil { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) } @@ -2347,7 +2354,7 @@ yydefault: } case 3: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:299 + //line php5/php5.y:308 { yyVAL.list = []node.Node{} @@ -2355,38 +2362,38 @@ yydefault: } case 4: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:308 + //line php5/php5.y:317 { namePart := name.NewNamePart(yyDollar[1].token.Value) yyVAL.list = []node.Node{namePart} // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(namePart, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 5: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:321 + //line php5/php5.y:330 { namePart := name.NewNamePart(yyDollar[3].token.Value) yyVAL.list = append(yyDollar[1].list, namePart) // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(namePart, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 6: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:338 + //line php5/php5.y:347 { // error yyVAL.node = nil @@ -2395,7 +2402,7 @@ yydefault: } case 7: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:345 + //line php5/php5.y:354 { yyVAL.node = yyDollar[1].node @@ -2403,7 +2410,7 @@ yydefault: } case 8: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:351 + //line php5/php5.y:360 { yyVAL.node = yyDollar[1].node @@ -2411,7 +2418,7 @@ yydefault: } case 9: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:357 + //line php5/php5.y:366 { yyVAL.node = yyDollar[1].node @@ -2419,18 +2426,19 @@ yydefault: } case 10: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:363 + //line php5/php5.y:372 { yyVAL.node = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.HaltCompiller, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OpenParenthesisToken, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -2438,134 +2446,141 @@ yydefault: } case 11: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:380 + //line php5/php5.y:390 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewNamespace(name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 12: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:395 + //line php5/php5.y:407 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewNamespace(name, yyDollar[4].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 13: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:411 + //line php5/php5.y:424 { yyVAL.node = stmt.NewNamespace(nil, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 14: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:425 + //line php5/php5.y:438 { yyVAL.node = stmt.NewUseList(nil, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 15: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:438 + //line php5/php5.y:452 { useType := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewUseList(useType, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(useType, yyDollar[2].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(useType, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 16: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:454 + //line php5/php5.y:469 { useType := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewUseList(useType, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(useType, yyDollar[2].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(useType, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 17: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:470 + //line php5/php5.y:486 { yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 18: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:485 + //line php5/php5.y:502 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 19: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:494 + //line php5/php5.y:511 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -2573,86 +2588,94 @@ yydefault: } case 20: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:503 + //line php5/php5.y:520 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 21: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:514 + //line php5/php5.y:534 { name := name.NewName(yyDollar[1].list) alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 22: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:531 + //line php5/php5.y:552 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 23: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:545 + //line php5/php5.y:568 { name := name.NewName(yyDollar[2].list) alias := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 24: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:566 + //line php5/php5.y:591 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 25: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:575 + //line php5/php5.y:600 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -2660,86 +2683,94 @@ yydefault: } case 26: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:584 + //line php5/php5.y:609 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 27: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:595 + //line php5/php5.y:623 { name := name.NewName(yyDollar[1].list) alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 28: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:612 + //line php5/php5.y:641 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 29: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:626 + //line php5/php5.y:657 { name := name.NewName(yyDollar[2].list) alias := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 30: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:647 + //line php5/php5.y:680 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 31: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:656 + //line php5/php5.y:689 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -2747,97 +2778,106 @@ yydefault: } case 32: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:665 + //line php5/php5.y:698 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 33: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:676 + //line php5/php5.y:712 { name := name.NewName(yyDollar[1].list) alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 34: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:693 + //line php5/php5.y:730 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 35: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:707 + //line php5/php5.y:746 { name := name.NewName(yyDollar[2].list) alias := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[2].list, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 36: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:728 + //line php5/php5.y:769 { name := node.NewIdentifier(yyDollar[3].token.Value) constant := stmt.NewConstant(name, yyDollar[5].node, "") constList := yyDollar[1].node.(*stmt.ConstList) + lastConst := lastNode(constList.Consts) constList.Consts = append(constList.Consts, constant) yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, constList.Consts)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, constList.Consts)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(constList.Consts), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastConst, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 37: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:748 + //line php5/php5.y:790 { name := node.NewIdentifier(yyDollar[2].token.Value) constant := stmt.NewConstant(name, yyDollar[4].node, "") @@ -2845,21 +2885,26 @@ yydefault: yyVAL.node = stmt.NewConstList(constList) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, constList)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, constList)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[3].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 38: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:770 + //line php5/php5.y:812 { + if inlineHtmlNode, ok := yyDollar[2].node.(*stmt.InlineHtml); ok && len(yyDollar[1].list) > 0 { + prevNode := lastNode(yyDollar[1].list) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if yyDollar[2].node != nil { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) } @@ -2868,7 +2913,7 @@ yydefault: } case 39: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:778 + //line php5/php5.y:825 { yyVAL.list = []node.Node{} @@ -2876,7 +2921,7 @@ yydefault: } case 40: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:788 + //line php5/php5.y:835 { // error yyVAL.node = nil @@ -2885,7 +2930,7 @@ yydefault: } case 41: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:795 + //line php5/php5.y:842 { yyVAL.node = yyDollar[1].node @@ -2893,7 +2938,7 @@ yydefault: } case 42: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:801 + //line php5/php5.y:848 { yyVAL.node = yyDollar[1].node @@ -2901,7 +2946,7 @@ yydefault: } case 43: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:807 + //line php5/php5.y:854 { yyVAL.node = yyDollar[1].node @@ -2909,24 +2954,27 @@ yydefault: } case 44: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:813 + //line php5/php5.y:860 { yyVAL.node = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.HaltCompiller, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OpenParenthesisToken, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + yylex.(*Parser).Begin(scanner.HALT_COMPILER) } case 45: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:832 + //line php5/php5.y:882 { yyVAL.node = yyDollar[1].node @@ -2934,78 +2982,95 @@ yydefault: } case 46: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:838 + //line php5/php5.y:888 { label := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewLabel(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(label, yyDollar[1].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Label, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 47: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:856 + //line php5/php5.y:906 { yyVAL.node = stmt.NewStmtList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 48: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:869 + //line php5/php5.y:919 { yyVAL.node = stmt.NewIf(yyDollar[2].node, yyDollar[3].node, yyDollar[4].list, yyDollar[5].node) // save position if yyDollar[5].node != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) } else if len(yyDollar[4].list) > 0 { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[4].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[4].list)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IfToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.If, (*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 49: yyDollar = yyS[yypt-8 : yypt+1] - //line php5/php5.y:887 + //line php5/php5.y:943 { stmts := stmt.NewStmtList(yyDollar[4].list) yyVAL.node = stmt.NewAltIf(yyDollar[2].node, stmts, yyDollar[5].list, yyDollar[6].node) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[4].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[4].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IfToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.If, (*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[8].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[8].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 50: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:904 + //line php5/php5.y:967 { switch n := yyDollar[3].node.(type) { case *stmt.While: @@ -3017,32 +3082,49 @@ yydefault: yyVAL.node = yyDollar[3].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.WhileToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.While, (*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 51: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:923 + //line php5/php5.y:992 { yyVAL.node = stmt.NewDo(yyDollar[2].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + if len((*yyDollar[4].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.While, (*yyDollar[4].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[4].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[4].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[4].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[4].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[4].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[4].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 52: yyDollar = yyS[yypt-9 : yypt+1] - //line php5/php5.y:937 + //line php5/php5.y:1013 { switch n := yyDollar[9].node.(type) { case *stmt.For: @@ -3058,20 +3140,20 @@ yydefault: yyVAL.node = yyDollar[9].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.ForInitSemicolonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.ForCondSemicolonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.For, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.InitExpr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CondExpr, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.IncExpr, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 53: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:964 + //line php5/php5.y:1040 { switch n := yyDollar[3].node.(type) { case *stmt.Switch: @@ -3085,225 +3167,249 @@ yydefault: yyVAL.node = yyDollar[3].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SwitchToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Switch, (*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[2].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 54: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:985 + //line php5/php5.y:1067 { yyVAL.node = stmt.NewBreak(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 55: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:998 + //line php5/php5.y:1081 { yyVAL.node = stmt.NewBreak(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 56: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1011 + //line php5/php5.y:1095 { yyVAL.node = stmt.NewContinue(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 57: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1024 + //line php5/php5.y:1109 { yyVAL.node = stmt.NewContinue(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 58: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1037 + //line php5/php5.y:1123 { yyVAL.node = stmt.NewReturn(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 59: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1050 + //line php5/php5.y:1137 { yyVAL.node = stmt.NewReturn(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 60: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1063 + //line php5/php5.y:1151 { yyVAL.node = stmt.NewReturn(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 61: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1076 + //line php5/php5.y:1165 { yyVAL.node = stmt.NewExpression(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 62: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1088 + //line php5/php5.y:1179 { yyVAL.node = stmt.NewGlobal(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.GlobalToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 63: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1101 + //line php5/php5.y:1193 { yyVAL.node = stmt.NewStatic(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 64: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1114 + //line php5/php5.y:1207 { yyVAL.node = stmt.NewEcho(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EchoToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Echo, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 65: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1127 + //line php5/php5.y:1222 { yyVAL.node = stmt.NewInlineHtml(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.InlineHTMLToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 66: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1139 + //line php5/php5.y:1234 { yyVAL.node = stmt.NewExpression(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 67: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:1151 + //line php5/php5.y:1248 { yyVAL.node = stmt.NewUnset(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UnsetToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Unset, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 68: yyDollar = yyS[yypt-8 : yypt+1] - //line php5/php5.y:1166 + //line php5/php5.y:1264 { if yyDollar[6].node == nil { switch n := yyDollar[8].node.(type) { @@ -3330,19 +3436,23 @@ yydefault: yyVAL.node = yyDollar[8].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Foreach, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) + if yyDollar[6].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Key, (*yyDollar[6].node.GetFreeFloating())[freefloating.Key]) + delete((*yyDollar[6].node.GetFreeFloating()), freefloating.Key) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[7].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 69: yyDollar = yyS[yypt-8 : yypt+1] - //line php5/php5.y:1203 + //line php5/php5.y:1304 { if yyDollar[6].node == nil { switch n := yyDollar[8].node.(type) { @@ -3369,102 +3479,110 @@ yydefault: // save position yyVAL.node = yyDollar[8].node - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Foreach, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) + if yyDollar[6].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Key, (*yyDollar[6].node.GetFreeFloating())[freefloating.Key]) + delete((*yyDollar[6].node.GetFreeFloating()), freefloating.Key) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[7].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 70: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:1240 + //line php5/php5.y:1344 { - yyVAL.node = stmt.NewDeclare(yyDollar[3].list, yyDollar[5].node) + yyVAL.node = yyDollar[5].node + yyVAL.node.(*stmt.Declare).Consts = yyDollar[3].list // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DeclareToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Declare, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ConstList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 71: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1254 + //line php5/php5.y:1359 { yyVAL.node = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 72: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:1266 + //line php5/php5.y:1372 { yyVAL.node = stmt.NewTry(yyDollar[3].list, yyDollar[5].list, yyDollar[6].node) // save position if yyDollar[6].node == nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[5].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[5].list)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TryToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Try, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 73: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1284 + //line php5/php5.y:1390 { yyVAL.node = stmt.NewThrow(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ThrowToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 74: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1297 + //line php5/php5.y:1404 { label := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewGoto(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.GotoToken) - yylex.(*Parser).comments.AddFromToken(label, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(label, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Label, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 75: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1316 + //line php5/php5.y:1424 { yyVAL.list = []node.Node{} @@ -3472,31 +3590,32 @@ yydefault: } case 76: yyDollar = yyS[yypt-9 : yypt+1] - //line php5/php5.y:1322 + //line php5/php5.y:1430 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) - catch := stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) - yyVAL.list = append([]node.Node{catch}, yyDollar[9].list...) + catchNode := stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) + yyVAL.list = append([]node.Node{catchNode}, yyDollar[9].list...) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(catch, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + catchNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) // save comments - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[1].token, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[5].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[6].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[8].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Catch, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Var, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Cond, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Stmts, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 77: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1347 + //line php5/php5.y:1456 { yyVAL.node = nil @@ -3504,23 +3623,23 @@ yydefault: } case 78: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1353 + //line php5/php5.y:1462 { yyVAL.node = stmt.NewFinally(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FinallyToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Finally, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 79: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1370 + //line php5/php5.y:1479 { yyVAL.list = yyDollar[1].list @@ -3528,7 +3647,7 @@ yydefault: } case 80: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1376 + //line php5/php5.y:1485 { yyVAL.list = []node.Node{} @@ -3536,7 +3655,7 @@ yydefault: } case 81: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1385 + //line php5/php5.y:1494 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3544,7 +3663,7 @@ yydefault: } case 82: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1391 + //line php5/php5.y:1500 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -3552,30 +3671,31 @@ yydefault: } case 83: yyDollar = yyS[yypt-8 : yypt+1] - //line php5/php5.y:1400 + //line php5/php5.y:1509 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Catch, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 84: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1424 + //line php5/php5.y:1534 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3583,18 +3703,18 @@ yydefault: } case 85: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1430 + //line php5/php5.y:1540 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 86: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1442 + //line php5/php5.y:1552 { yyVAL.node = yyDollar[1].node @@ -3602,7 +3722,7 @@ yydefault: } case 87: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1451 + //line php5/php5.y:1561 { yyVAL.node = yyDollar[1].node @@ -3610,7 +3730,7 @@ yydefault: } case 88: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1460 + //line php5/php5.y:1570 { yyVAL.node = yyDollar[1].node @@ -3618,55 +3738,57 @@ yydefault: } case 89: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1469 + //line php5/php5.y:1579 { yyVAL.token = nil } case 90: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1473 + //line php5/php5.y:1583 { yyVAL.token = yyDollar[1].token } case 91: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1480 + //line php5/php5.y:1590 { yyVAL.token = nil } case 92: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1484 + //line php5/php5.y:1594 { yyVAL.token = yyDollar[1].token } case 93: yyDollar = yyS[yypt-9 : yypt+1] - //line php5/php5.y:1491 + //line php5/php5.y:1601 { name := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewFunction(name, yyDollar[2].token != nil, yyDollar[5].list, nil, yyDollar[8].list, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[9].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[9].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FunctionToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[3].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[3].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[9].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParamList, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[9].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 94: yyDollar = yyS[yypt-7 : yypt+1] - //line php5/php5.y:1516 + //line php5/php5.y:1628 { name := node.NewIdentifier(yyDollar[2].token.Value) switch n := yyDollar[1].node.(type) { @@ -3684,99 +3806,100 @@ yydefault: yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[7].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[7].token)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[7].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 95: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:1544 + //line php5/php5.y:1656 { name := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewInterface(name, yyDollar[3].InterfaceExtends, yyDollar[5].list, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[6].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 96: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1564 + //line php5/php5.y:1677 { yyVAL.node = stmt.NewClass(nil, nil, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 97: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1576 + //line php5/php5.y:1689 { classModifier := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(classModifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(classModifier, yyDollar[1].token, comment.AbstractToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ClassToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 98: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1591 + //line php5/php5.y:1704 { yyVAL.node = stmt.NewTrait(nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TraitToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 99: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1603 + //line php5/php5.y:1716 { classModifier := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(classModifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(classModifier, yyDollar[1].token, comment.FinalToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ClassToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 100: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1621 + //line php5/php5.y:1734 { yyVAL.ClassExtends = nil @@ -3784,27 +3907,27 @@ yydefault: } case 101: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1627 + //line php5/php5.y:1740 { yyVAL.ClassExtends = stmt.NewClassExtends(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.ClassExtends, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.ClassExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.ClassExtends, yyDollar[1].token, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating(yyVAL.ClassExtends, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 102: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1642 + //line php5/php5.y:1755 { yyVAL.token = yyDollar[1].token } case 103: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1649 + //line php5/php5.y:1762 { yyVAL.InterfaceExtends = nil @@ -3812,21 +3935,21 @@ yydefault: } case 104: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1655 + //line php5/php5.y:1768 { yyVAL.InterfaceExtends = stmt.NewInterfaceExtends(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.InterfaceExtends, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.InterfaceExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.InterfaceExtends, yyDollar[1].token, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating(yyVAL.InterfaceExtends, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 105: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1670 + //line php5/php5.y:1783 { yyVAL.ClassImplements = nil @@ -3834,21 +3957,21 @@ yydefault: } case 106: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1676 + //line php5/php5.y:1789 { yyVAL.ClassImplements = stmt.NewClassImplements(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.ClassImplements, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.ClassImplements.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.ClassImplements, yyDollar[1].token, comment.ImplementsToken) + yylex.(*Parser).setFreeFloating(yyVAL.ClassImplements, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 107: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1691 + //line php5/php5.y:1804 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3856,18 +3979,18 @@ yydefault: } case 108: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1697 + //line php5/php5.y:1810 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 109: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1709 + //line php5/php5.y:1822 { yyVAL.node = nil @@ -3875,18 +3998,18 @@ yydefault: } case 110: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1715 + //line php5/php5.y:1828 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Key, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 111: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1727 + //line php5/php5.y:1840 { yyVAL.node = yyDollar[1].node @@ -3894,229 +4017,239 @@ yydefault: } case 112: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:1733 + //line php5/php5.y:1846 { yyVAL.node = expr.NewReference(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyDollar[2].node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 113: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1745 + //line php5/php5.y:1858 { yyVAL.node = expr.NewList(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 114: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1762 + //line php5/php5.y:1875 { yyVAL.node = stmt.NewFor(nil, nil, nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 115: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1771 + //line php5/php5.y:1884 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltFor(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndforToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 116: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1790 + //line php5/php5.y:1904 { yyVAL.node = stmt.NewForeach(nil, nil, nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 117: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1799 + //line php5/php5.y:1913 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltForeach(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndforeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 118: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1819 + //line php5/php5.y:1934 { - yyVAL.node = yyDollar[1].node + yyVAL.node = stmt.NewDeclare(nil, yyDollar[1].node, false) + + // save position + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 119: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1825 + //line php5/php5.y:1943 { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) + stmtList := stmt.NewStmtList(yyDollar[2].list) + yyVAL.node = stmt.NewDeclare(nil, stmtList, true) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EnddeclareToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 120: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1843 + //line php5/php5.y:1964 { name := node.NewIdentifier(yyDollar[1].token.Value) constant := stmt.NewConstant(name, yyDollar[3].node, "") yyVAL.list = []node.Node{constant} // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 121: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:1859 + //line php5/php5.y:1980 { name := node.NewIdentifier(yyDollar[3].token.Value) constant := stmt.NewConstant(name, yyDollar[5].node, "") yyVAL.list = append(yyDollar[1].list, constant) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 122: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:1880 + //line php5/php5.y:2001 { caseList := stmt.NewCaseList(yyDollar[2].list) yyVAL.node = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 123: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1895 + //line php5/php5.y:2016 { caseList := stmt.NewCaseList(yyDollar[3].list) yyVAL.node = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[2].token, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 124: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1911 + //line php5/php5.y:2032 { caseList := stmt.NewCaseList(yyDollar[2].list) yyVAL.node = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[3].token, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 125: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:1927 + //line php5/php5.y:2049 { caseList := stmt.NewCaseList(yyDollar[3].list) yyVAL.node = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[2].token, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[4].token, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 126: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:1949 + //line php5/php5.y:2072 { yyVAL.list = []node.Node{} @@ -4124,80 +4257,83 @@ yydefault: } case 127: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:1955 + //line php5/php5.y:2078 { _case := stmt.NewCase(yyDollar[3].node, yyDollar[5].list) yyVAL.list = append(yyDollar[1].list, _case) // save position - yylex.(*Parser).positions.AddPosition(_case, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) + _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_case, yyDollar[2].token, comment.CaseToken) - yylex.(*Parser).comments.AddFromToken(_case, yyDollar[4].token, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_case, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.Expr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 128: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:1969 + //line php5/php5.y:2093 { _default := stmt.NewDefault(yyDollar[4].list) yyVAL.list = append(yyDollar[1].list, _default) // save position - yylex.(*Parser).positions.AddPosition(_default, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) + _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_default, yyDollar[2].token, comment.DefaultToken) - yylex.(*Parser).comments.AddFromToken(_default, yyDollar[3].token, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_default, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.Default, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 129: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1987 + //line php5/php5.y:2112 { yyVAL.token = yyDollar[1].token } case 130: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1991 + //line php5/php5.y:2116 { yyVAL.token = yyDollar[1].token } case 131: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:1999 + //line php5/php5.y:2124 { yyVAL.node = stmt.NewWhile(nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 132: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:2008 + //line php5/php5.y:2133 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltWhile(nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndwhileToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 133: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2029 + //line php5/php5.y:2155 { yyVAL.list = nil @@ -4205,22 +4341,30 @@ yydefault: } case 134: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:2035 + //line php5/php5.y:2161 { _elseIf := stmt.NewElseIf(yyDollar[3].node, yyDollar[4].node) yyVAL.list = append(yyDollar[1].list, _elseIf) // save position - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[2].token, comment.ElseifToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, yyDollar[2].token.FreeFloating) + if len((*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, (*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[3].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, (*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[3].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 135: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2052 + //line php5/php5.y:2184 { yyVAL.list = nil @@ -4228,25 +4372,33 @@ yydefault: } case 136: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:2058 + //line php5/php5.y:2190 { stmts := stmt.NewStmtList(yyDollar[5].list) _elseIf := stmt.NewAltElseIf(yyDollar[3].node, stmts) yyVAL.list = append(yyDollar[1].list, _elseIf) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[5].list)) - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[5].list)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[2].token, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[4].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, yyDollar[2].token.FreeFloating) + if len((*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, (*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*yyDollar[3].node.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]) + delete((*yyDollar[3].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, (*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*yyDollar[3].node.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]) + delete((*yyDollar[3].node.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Cond, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 137: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2078 + //line php5/php5.y:2216 { yyVAL.node = nil @@ -4254,21 +4406,21 @@ yydefault: } case 138: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2084 + //line php5/php5.y:2222 { yyVAL.node = stmt.NewElse(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ElseToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 139: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2100 + //line php5/php5.y:2238 { yyVAL.node = nil @@ -4276,24 +4428,24 @@ yydefault: } case 140: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2106 + //line php5/php5.y:2244 { stmts := stmt.NewStmtList(yyDollar[3].list) yyVAL.node = stmt.NewAltElse(stmts) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ElseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Else, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 141: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2125 + //line php5/php5.y:2263 { yyVAL.list = yyDollar[1].list @@ -4301,7 +4453,7 @@ yydefault: } case 142: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2131 + //line php5/php5.y:2269 { yyVAL.list = nil @@ -4309,7 +4461,7 @@ yydefault: } case 143: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2140 + //line php5/php5.y:2278 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4317,83 +4469,119 @@ yydefault: } case 144: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2146 + //line php5/php5.y:2284 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 145: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:2158 + //line php5/php5.y:2296 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].node != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) } else if yyDollar[2].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) } else if yyDollar[3].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) } // save comments + if yyDollar[1].node != nil { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + } if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) } if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Variadic, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + + // normalize + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, (*yyVAL.node.GetFreeFloating())[freefloating.Variadic]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Variadic) + } + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, (*yyVAL.node.GetFreeFloating())[freefloating.Ampersand]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Ampersand) + } + if yyDollar[1].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, (*yyVAL.node.GetFreeFloating())[freefloating.OptionalType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.VariableToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 146: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:2188 + //line php5/php5.y:2341 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].node != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) } else if yyDollar[2].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) } else if yyDollar[3].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) } // save comments + if yyDollar[1].node != nil { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + } if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) } if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Variadic, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[5].token.FreeFloating) + + // normalize + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, (*yyVAL.node.GetFreeFloating())[freefloating.Variadic]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Variadic) + } + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, (*yyVAL.node.GetFreeFloating())[freefloating.Ampersand]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Ampersand) + } + if yyDollar[1].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, (*yyVAL.node.GetFreeFloating())[freefloating.OptionalType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.EqualToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 147: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2223 + //line php5/php5.y:2391 { yyVAL.node = nil @@ -4401,35 +4589,35 @@ yydefault: } case 148: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2229 + //line php5/php5.y:2397 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 149: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2241 + //line php5/php5.y:2409 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.CallableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 150: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2253 + //line php5/php5.y:2421 { yyVAL.node = yyDollar[1].node @@ -4437,54 +4625,54 @@ yydefault: } case 151: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2263 + //line php5/php5.y:2431 { yyVAL.node = node.NewArgumentList(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 152: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2276 + //line php5/php5.y:2444 { yyVAL.node = node.NewArgumentList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 153: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2289 + //line php5/php5.y:2457 { arg := node.NewArgument(yyDollar[2].node, false, false) yyVAL.node = node.NewArgumentList([]node.Node{arg}) // save position - yylex.(*Parser).positions.AddPosition(arg, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + arg.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 154: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2308 + //line php5/php5.y:2476 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4492,79 +4680,85 @@ yydefault: } case 155: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2314 + //line php5/php5.y:2482 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 156: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2326 + //line php5/php5.y:2494 { yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 157: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2335 + //line php5/php5.y:2506 { yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 158: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2344 + //line php5/php5.y:2518 { yyVAL.node = node.NewArgument(yyDollar[2].node, false, true) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 159: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2356 + //line php5/php5.y:2530 { yyVAL.node = node.NewArgument(yyDollar[2].node, true, false) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 160: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2371 + //line php5/php5.y:2545 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 161: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2380 + //line php5/php5.y:2554 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4572,53 +4766,56 @@ yydefault: } case 162: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2390 + //line php5/php5.y:2564 { name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 163: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2404 + //line php5/php5.y:2579 { yyVAL.node = expr.NewVariable(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 164: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:2416 + //line php5/php5.y:2592 { yyVAL.node = expr.NewVariable(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.Start, append(yyDollar[2].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token), (*yyDollar[3].node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.End, append((*yyDollar[3].node.GetFreeFloating())[freefloating.End], append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 165: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2434 + //line php5/php5.y:2611 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -4626,19 +4823,20 @@ yydefault: yyVAL.list = append(yyDollar[1].list, staticVar) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[3].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 166: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:2452 + //line php5/php5.y:2630 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -4646,20 +4844,21 @@ yydefault: yyVAL.list = append(yyDollar[1].list, staticVar) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[3].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(staticVar, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Var, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 167: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2471 + //line php5/php5.y:2650 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -4667,18 +4866,19 @@ yydefault: yyVAL.list = []node.Node{staticVar} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 168: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2488 + //line php5/php5.y:2668 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -4686,19 +4886,20 @@ yydefault: yyVAL.list = []node.Node{staticVar} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(staticVar, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 169: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2510 + //line php5/php5.y:2691 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -4706,7 +4907,7 @@ yydefault: } case 170: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2516 + //line php5/php5.y:2697 { yyVAL.list = []node.Node{} @@ -4714,35 +4915,38 @@ yydefault: } case 171: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2526 + //line php5/php5.y:2707 { yyVAL.node = stmt.NewPropertyList(yyDollar[1].list, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.PropertyList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 172: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2538 + //line php5/php5.y:2721 { yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ConstList, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 173: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2550 + //line php5/php5.y:2734 { yyVAL.node = yyDollar[1].node @@ -4750,54 +4954,54 @@ yydefault: } case 174: yyDollar = yyS[yypt-8 : yypt+1] - //line php5/php5.y:2556 + //line php5/php5.y:2740 { name := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewClassMethod(name, yyDollar[1].list, yyDollar[3].token != nil, yyDollar[6].list, nil, yyDollar[8].node, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].list == nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[8].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[8].node)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[8].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[8].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.FunctionToken) - if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + if len(yyDollar[1].list) > 0 { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[2].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(name, yyDollar[4].token, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseParenthesisToken) + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[4].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[4].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[7].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 175: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2583 + //line php5/php5.y:2774 { - var adaptationList *stmt.TraitAdaptationList - switch n := yyDollar[3].node.(type) { - case *stmt.TraitAdaptationList: - adaptationList = n - default: - adaptationList = nil - } - yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, adaptationList) + yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 176: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2605 + //line php5/php5.y:2789 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4805,45 +5009,46 @@ yydefault: } case 177: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2611 + //line php5/php5.y:2795 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 178: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2623 + //line php5/php5.y:2807 { yyVAL.node = stmt.NewNop() - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 179: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2635 + //line php5/php5.y:2819 { yyVAL.node = stmt.NewTraitAdaptationList(yyDollar[2].list) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AdaptationList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 180: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2650 + //line php5/php5.y:2834 { yyVAL.list = nil @@ -4851,7 +5056,7 @@ yydefault: } case 181: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2656 + //line php5/php5.y:2840 { yyVAL.list = yyDollar[1].list @@ -4859,7 +5064,7 @@ yydefault: } case 182: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2665 + //line php5/php5.y:2849 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4867,7 +5072,7 @@ yydefault: } case 183: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2671 + //line php5/php5.y:2855 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -4875,43 +5080,46 @@ yydefault: } case 184: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2680 + //line php5/php5.y:2864 { yyVAL.node = yyDollar[1].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.NameList, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 185: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2689 + //line php5/php5.y:2874 { yyVAL.node = yyDollar[1].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Alias, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 186: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2701 + //line php5/php5.y:2887 { yyVAL.node = stmt.NewTraitUsePrecedence(yyDollar[1].node, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.InsteadofToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 187: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2716 + //line php5/php5.y:2903 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4919,34 +5127,34 @@ yydefault: } case 188: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2722 + //line php5/php5.y:2909 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 189: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2734 + //line php5/php5.y:2921 { name := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewTraitMethodRef(nil, name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 190: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2748 + //line php5/php5.y:2935 { yyVAL.node = yyDollar[1].node @@ -4954,55 +5162,58 @@ yydefault: } case 191: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2757 + //line php5/php5.y:2944 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewTraitMethodRef(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, yyDollar[3].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 192: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:2775 + //line php5/php5.y:2963 { alias := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[4].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 193: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2790 + //line php5/php5.y:2979 { yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 194: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2805 + //line php5/php5.y:2995 { yyVAL.node = nil @@ -5010,7 +5221,7 @@ yydefault: } case 195: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2811 + //line php5/php5.y:3001 { yyVAL.node = yyDollar[1].node @@ -5018,36 +5229,37 @@ yydefault: } case 196: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2820 + //line php5/php5.y:3010 { yyVAL.node = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 197: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2832 + //line php5/php5.y:3023 { yyVAL.node = stmt.NewStmtList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 198: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2848 + //line php5/php5.y:3039 { yyVAL.list = yyDollar[1].list @@ -5055,22 +5267,22 @@ yydefault: } case 199: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2854 + //line php5/php5.y:3045 { modifier := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.list = []node.Node{modifier} // save position - yylex.(*Parser).positions.AddPosition(modifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(modifier, yyDollar[1].token, comment.VarToken) + yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 200: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:2870 + //line php5/php5.y:3061 { yyVAL.list = nil @@ -5078,7 +5290,7 @@ yydefault: } case 201: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2876 + //line php5/php5.y:3067 { yyVAL.list = yyDollar[1].list @@ -5086,7 +5298,7 @@ yydefault: } case 202: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2885 + //line php5/php5.y:3076 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5094,7 +5306,7 @@ yydefault: } case 203: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:2891 + //line php5/php5.y:3082 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -5102,91 +5314,91 @@ yydefault: } case 204: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2900 + //line php5/php5.y:3091 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PublicToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 205: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2912 + //line php5/php5.y:3103 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ProtectedToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 206: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2924 + //line php5/php5.y:3115 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PrivateToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 207: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2936 + //line php5/php5.y:3127 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 208: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2948 + //line php5/php5.y:3139 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AbstractToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 209: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:2960 + //line php5/php5.y:3151 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FinalToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 210: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:2975 + //line php5/php5.y:3166 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -5194,19 +5406,20 @@ yydefault: yyVAL.list = append(yyDollar[1].list, property) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[3].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 211: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:2993 + //line php5/php5.y:3185 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -5214,20 +5427,21 @@ yydefault: yyVAL.list = append(yyDollar[1].list, property) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[3].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(property, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(property, freefloating.Var, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 212: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3012 + //line php5/php5.y:3205 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -5235,18 +5449,19 @@ yydefault: yyVAL.list = []node.Node{property} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 213: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3029 + //line php5/php5.y:3223 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -5254,72 +5469,74 @@ yydefault: yyVAL.list = []node.Node{property} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(property, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(property, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 214: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:3050 + //line php5/php5.y:3245 { name := node.NewIdentifier(yyDollar[3].token.Value) constant := stmt.NewConstant(name, yyDollar[5].node, "") constList := yyDollar[1].node.(*stmt.ClassConstList) + lastConst := lastNode(constList.Consts) constList.Consts = append(constList.Consts, constant) yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) - yylex.(*Parser).positions.AddPosition(yyDollar[1].node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[5].node)) + yyDollar[1].node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(constList.Consts), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastConst, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 215: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:3070 + //line php5/php5.y:3266 { name := node.NewIdentifier(yyDollar[2].token.Value) constant := stmt.NewConstant(name, yyDollar[4].node, "") yyVAL.node = stmt.NewClassConstList(nil, []node.Node{constant}) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(constant, yyDollar[3].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 216: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3091 + //line php5/php5.y:3287 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 217: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3100 + //line php5/php5.y:3296 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5327,7 +5544,7 @@ yydefault: } case 218: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:3110 + //line php5/php5.y:3306 { yyVAL.list = nil @@ -5335,7 +5552,7 @@ yydefault: } case 219: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3116 + //line php5/php5.y:3312 { yyVAL.list = yyDollar[1].list @@ -5343,18 +5560,18 @@ yydefault: } case 220: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3125 + //line php5/php5.y:3321 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 221: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3134 + //line php5/php5.y:3330 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5362,7 +5579,7 @@ yydefault: } case 222: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3143 + //line php5/php5.y:3339 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) @@ -5370,7 +5587,7 @@ yydefault: } case 223: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3149 + //line php5/php5.y:3345 { yyVAL.list = yyDollar[1].list @@ -5378,39 +5595,39 @@ yydefault: } case 224: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:3158 + //line php5/php5.y:3354 { fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 225: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3172 + //line php5/php5.y:3368 { fetch := expr.NewArrayDimFetch(nil, yyDollar[2].node) yyVAL.list = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[3].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 226: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3189 + //line php5/php5.y:3385 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) @@ -5418,7 +5635,7 @@ yydefault: } case 227: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3195 + //line php5/php5.y:3391 { yyVAL.list = yyDollar[1].list @@ -5426,7 +5643,7 @@ yydefault: } case 228: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3201 + //line php5/php5.y:3397 { yyVAL.list = yyDollar[1].list @@ -5434,7 +5651,7 @@ yydefault: } case 229: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:3210 + //line php5/php5.y:3406 { yyVAL.list = nil @@ -5442,7 +5659,7 @@ yydefault: } case 230: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3216 + //line php5/php5.y:3412 { yyVAL.list = yyDollar[1].list @@ -5450,73 +5667,75 @@ yydefault: } case 231: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3225 + //line php5/php5.y:3421 { if yyDollar[3].node != nil { yyVAL.node = expr.NewNew(yyDollar[2].node, yyDollar[3].node.(*node.ArgumentList)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) } else { yyVAL.node = expr.NewNew(yyDollar[2].node, nil) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NewToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 232: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:3244 + //line php5/php5.y:3440 { - list := expr.NewList(yyDollar[3].list) - yyVAL.node = assign.NewAssign(list, yyDollar[6].node) + listNode := expr.NewList(yyDollar[3].list) + yyVAL.node = assign.NewAssign(listNode, yyDollar[6].node) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) // save comments - yylex.(*Parser).comments.AddFromToken(list, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[4].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 233: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3261 + //line php5/php5.y:3457 { yyVAL.node = assign.NewAssign(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 234: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:3273 + //line php5/php5.y:3470 { yyVAL.node = assign.NewReference(yyDollar[1].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 235: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:3286 + //line php5/php5.y:3484 { var _new *expr.New @@ -5529,688 +5748,734 @@ yydefault: // save position if yyDollar[6].node != nil { - yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) + _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) } else { - yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[5].node)) + _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[5].node)) } - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, _new)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, _new)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) - yylex.(*Parser).comments.AddFromToken(_new, yyDollar[4].token, comment.NewToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_new, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 236: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3312 + //line php5/php5.y:3511 { yyVAL.node = expr.NewClone(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.CloneToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 237: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3324 + //line php5/php5.y:3523 { yyVAL.node = assign.NewPlus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PlusEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 238: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3336 + //line php5/php5.y:3535 { yyVAL.node = assign.NewMinus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MinusEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 239: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3348 + //line php5/php5.y:3548 { yyVAL.node = assign.NewMul(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MulEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 240: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3360 + //line php5/php5.y:3561 { yyVAL.node = assign.NewPow(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PowEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 241: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3372 + //line php5/php5.y:3574 { yyVAL.node = assign.NewDiv(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DivEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 242: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3384 + //line php5/php5.y:3587 { yyVAL.node = assign.NewConcat(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ConcatEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 243: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3396 + //line php5/php5.y:3600 { yyVAL.node = assign.NewMod(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ModEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 244: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3408 + //line php5/php5.y:3613 { yyVAL.node = assign.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AndEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 245: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3420 + //line php5/php5.y:3626 { yyVAL.node = assign.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 246: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3432 + //line php5/php5.y:3639 { yyVAL.node = assign.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.XorEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 247: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3444 + //line php5/php5.y:3652 { yyVAL.node = assign.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 248: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3456 + //line php5/php5.y:3665 { yyVAL.node = assign.NewShiftRight(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 249: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3468 + //line php5/php5.y:3678 { yyVAL.node = expr.NewPostInc(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IncToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 250: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3480 + //line php5/php5.y:3691 { yyVAL.node = expr.NewPreInc(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 251: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3492 + //line php5/php5.y:3703 { yyVAL.node = expr.NewPostDec(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DecToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 252: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3504 + //line php5/php5.y:3716 { yyVAL.node = expr.NewPreDec(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DecToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 253: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3516 + //line php5/php5.y:3728 { yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 254: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3528 + //line php5/php5.y:3741 { yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 255: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3540 + //line php5/php5.y:3754 { yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 256: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3552 + //line php5/php5.y:3767 { yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 257: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3564 + //line php5/php5.y:3780 { yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 258: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3576 + //line php5/php5.y:3793 { yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 259: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3588 + //line php5/php5.y:3806 { yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 260: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3600 + //line php5/php5.y:3819 { yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 261: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3612 + //line php5/php5.y:3832 { yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DotToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 262: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3624 + //line php5/php5.y:3845 { yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 263: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3636 + //line php5/php5.y:3858 { yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 264: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3648 + //line php5/php5.y:3871 { yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 265: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3660 + //line php5/php5.y:3884 { yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 266: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3672 + //line php5/php5.y:3897 { yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 267: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3684 + //line php5/php5.y:3910 { yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 268: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3696 + //line php5/php5.y:3923 { yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 269: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3708 + //line php5/php5.y:3936 { yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 270: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3720 + //line php5/php5.y:3949 { yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PlusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 271: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3732 + //line php5/php5.y:3961 { yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MinusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 272: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3744 + //line php5/php5.y:3973 { yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 273: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3756 + //line php5/php5.y:3985 { yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TildeToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 274: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3768 + //line php5/php5.y:3997 { yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 275: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3780 + //line php5/php5.y:4010 { yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 276: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3792 + //line php5/php5.y:4023 { yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 277: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3804 + //line php5/php5.y:4036 { yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 278: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3816 + //line php5/php5.y:4050 { yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LessToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 279: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3828 + //line php5/php5.y:4063 { yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 280: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3840 + //line php5/php5.y:4076 { yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 281: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3852 + //line php5/php5.y:4089 { yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 282: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:3864 + //line php5/php5.y:4102 { yyVAL.node = expr.NewInstanceOf(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.InstanceofToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 283: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3876 + //line php5/php5.y:4115 { yyVAL.node = yyDollar[1].node yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + yylex.(*Parser).setFreeFloating(yyDollar[1].node, freefloating.Start, append((*yyDollar[1].node.GetFreeFloating())[freefloating.OpenParenthesisToken], (*yyDollar[1].node.GetFreeFloating())[freefloating.Start]...)) + delete((*yyDollar[1].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating(yyDollar[1].node, freefloating.End, append((*yyDollar[1].node.GetFreeFloating())[freefloating.End], (*yyDollar[1].node.GetFreeFloating())[freefloating.CloseParenthesisToken]...)) + delete((*yyDollar[1].node.GetFreeFloating()), freefloating.CloseParenthesisToken) } case 284: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3882 + //line php5/php5.y:4124 { yyVAL.node = yyDollar[1].node @@ -6218,68 +6483,73 @@ yydefault: } case 285: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:3888 + //line php5/php5.y:4130 { yyVAL.node = yyDollar[2].node + // save comments + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) + for _, n := range yyDollar[4].list { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = yyVAL.node yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.PropertyFetch: nn.Variable = yyVAL.node yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.MethodCall: nn.Variable = yyVAL.node yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) } // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, n)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, n)) } - // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 286: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:3917 + //line php5/php5.y:4162 { yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 287: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:3930 + //line php5/php5.y:4176 { yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 288: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:3943 + //line php5/php5.y:4190 { yyVAL.node = yyDollar[1].node @@ -6287,151 +6557,149 @@ yydefault: } case 289: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3949 + //line php5/php5.y:4196 { yyVAL.node = cast.NewInt(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IntCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 290: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3961 + //line php5/php5.y:4209 { yyVAL.node = cast.NewDouble(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoubleCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 291: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3973 + //line php5/php5.y:4222 { yyVAL.node = cast.NewString(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 292: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3985 + //line php5/php5.y:4235 { yyVAL.node = cast.NewArray(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 293: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:3997 + //line php5/php5.y:4248 { yyVAL.node = cast.NewObject(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ObjectCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 294: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4009 + //line php5/php5.y:4261 { yyVAL.node = cast.NewBool(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BoolCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 295: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4021 + //line php5/php5.y:4274 { yyVAL.node = cast.NewUnset(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UnsetCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 296: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4033 + //line php5/php5.y:4287 { + e := yyDollar[2].node.(*expr.Exit) + yyVAL.node = yyDollar[2].node + if strings.EqualFold(yyDollar[1].token.Value, "die") { - yyVAL.node = expr.NewDie(nil) - if yyDollar[2].node != nil { - yyVAL.node.(*expr.Die).Expr = yyDollar[2].node.(*expr.Exit).Expr - } - } else { - yyVAL.node = expr.NewExit(nil) - if yyDollar[2].node != nil { - yyVAL.node.(*expr.Exit).Expr = yyDollar[2].node.(*expr.Exit).Expr - } + e.Die = true } // save position - if yyDollar[2].node == nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + if yyDollar[2].node.GetPosition() == nil { + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ExitToken) - - if yyDollar[2].node != nil { - yylex.(*Parser).comments.AddFromChildNode(yyVAL.node, yyDollar[2].node) - } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 297: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4063 + //line php5/php5.y:4308 { yyVAL.node = expr.NewErrorSuppress(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AtToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 298: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4075 + //line php5/php5.y:4320 { yyVAL.node = yyDollar[1].node @@ -6439,7 +6707,7 @@ yydefault: } case 299: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4081 + //line php5/php5.y:4326 { yyVAL.node = yyDollar[1].node @@ -6447,7 +6715,7 @@ yydefault: } case 300: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4087 + //line php5/php5.y:4332 { yyVAL.node = yyDollar[1].node @@ -6455,250 +6723,269 @@ yydefault: } case 301: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4093 + //line php5/php5.y:4338 { yyVAL.node = expr.NewShellExec(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BackquoteToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.BackquoteToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 302: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4106 + //line php5/php5.y:4350 { yyVAL.node = expr.NewPrint(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PrintToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 303: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4118 + //line php5/php5.y:4362 { yyVAL.node = expr.NewYield(nil, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 304: yyDollar = yyS[yypt-9 : yypt+1] - //line php5/php5.y:4130 + //line php5/php5.y:4374 { yyVAL.node = expr.NewClosure(yyDollar[4].list, yyDollar[6].ClosureUse, nil, yyDollar[8].list, false, yyDollar[2].token != nil, "") // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[9].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[9].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FunctionToken) - if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[3].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[9].token.FreeFloating) + + // normalize + if yyDollar[6].ClosureUse == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.LexicalVars]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.LexicalVars) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[9].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 305: yyDollar = yyS[yypt-10 : yypt+1] - //line php5/php5.y:4149 + //line php5/php5.y:4400 { yyVAL.node = expr.NewClosure(yyDollar[5].list, yyDollar[7].ClosureUse, nil, yyDollar[9].list, true, yyDollar[3].token != nil, "") // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[10].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[10].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.FunctionToken) - if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Static, yyDollar[2].token.FreeFloating) + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[4].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[4].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, yyDollar[8].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[10].token.FreeFloating) + + // normalize + if yyDollar[7].ClosureUse == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.LexicalVars]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.LexicalVars) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[10].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 306: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4172 + //line php5/php5.y:4430 { yyVAL.node = expr.NewYield(nil, yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 307: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4184 + //line php5/php5.y:4442 { yyVAL.node = expr.NewYield(nil, yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 308: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4196 + //line php5/php5.y:4454 { yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 309: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4209 + //line php5/php5.y:4467 { yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 310: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4225 + //line php5/php5.y:4483 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 311: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4238 + //line php5/php5.y:4497 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 312: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4251 + //line php5/php5.y:4511 { str := scalar.NewString(yyDollar[1].token.Value) yyVAL.node = expr.NewArrayDimFetch(str, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(str, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, yyDollar[4].token)) + str.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 313: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4266 + //line php5/php5.y:4527 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 314: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4282 + //line php5/php5.y:4544 { yyVAL.node = expr.NewArray(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Array, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 315: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4296 + //line php5/php5.y:4558 { yyVAL.node = expr.NewShortArray(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 316: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4312 + //line php5/php5.y:4574 { yyVAL.token = yyDollar[1].token } case 317: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:4319 + //line php5/php5.y:4581 { yyVAL.ClosureUse = nil @@ -6706,35 +6993,42 @@ yydefault: } case 318: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4325 + //line php5/php5.y:4587 { yyVAL.ClosureUse = expr.NewClosureUse(yyDollar[3].list) - yylex.(*Parser).positions.AddPosition(yyVAL.ClosureUse, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + // save position + yyVAL.ClosureUse.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + + // save comments + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.Use, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.LexicalVarList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 319: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4336 + //line php5/php5.y:4604 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.list = append(yyDollar[1].list, variable) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[3].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 320: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4352 + //line php5/php5.y:4621 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -6742,36 +7036,39 @@ yydefault: yyVAL.list = append(yyDollar[1].list, reference) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[3].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 321: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4370 + //line php5/php5.y:4641 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.list = []node.Node{variable} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 322: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4385 + //line php5/php5.y:4657 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -6779,226 +7076,243 @@ yydefault: yyVAL.list = []node.Node{reference} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[2].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 323: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4406 + //line php5/php5.y:4679 { name := name.NewName(yyDollar[1].list) yyVAL.node = expr.NewFunctionCall(name, yyDollar[2].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(name, yyDollar[2].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(name, yyDollar[2].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 324: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4417 + //line php5/php5.y:4693 { funcName := name.NewRelative(yyDollar[3].list) yyVAL.node = expr.NewFunctionCall(funcName, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, yyDollar[4].node)) + funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(funcName, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(funcName, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(funcName, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 325: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4432 + //line php5/php5.y:4708 { funcName := name.NewFullyQualified(yyDollar[2].list) yyVAL.node = expr.NewFunctionCall(funcName, yyDollar[3].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, yyDollar[3].node)) + funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(funcName, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 326: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4446 + //line php5/php5.y:4722 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 327: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4458 + //line php5/php5.y:4735 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 328: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4470 + //line php5/php5.y:4748 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 329: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4482 + //line php5/php5.y:4761 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 330: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4494 + //line php5/php5.y:4774 { yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 331: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4506 + //line php5/php5.y:4789 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 332: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4518 + //line php5/php5.y:4801 { yyVAL.node = name.NewName(yyDollar[1].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 333: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4527 + //line php5/php5.y:4813 { yyVAL.node = name.NewRelative(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 334: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4540 + //line php5/php5.y:4826 { yyVAL.node = name.NewFullyQualified(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 335: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4555 + //line php5/php5.y:4841 { yyVAL.node = name.NewName(yyDollar[1].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 336: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4564 + //line php5/php5.y:4853 { yyVAL.node = name.NewRelative(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 337: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4577 + //line php5/php5.y:4866 { yyVAL.node = name.NewFullyQualified(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 338: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4592 + //line php5/php5.y:4881 { yyVAL.node = yyDollar[1].node @@ -7006,7 +7320,7 @@ yydefault: } case 339: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4598 + //line php5/php5.y:4887 { yyVAL.node = yyDollar[1].node @@ -7014,24 +7328,26 @@ yydefault: } case 340: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4607 + //line php5/php5.y:4896 { yyVAL.node = yyDollar[1].node // save comments - yylex.(*Parser).comments.AddFromToken(yyDollar[3].list[0], yyDollar[2].token, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating(yyDollar[3].list[0], freefloating.Var, yyDollar[2].token.FreeFloating) for _, n := range yyDollar[3].list { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.PropertyFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) } } @@ -7039,13 +7355,15 @@ yydefault: switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.PropertyFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) } } @@ -7053,7 +7371,7 @@ yydefault: } case 341: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4644 + //line php5/php5.y:4937 { yyVAL.node = yyDollar[1].node @@ -7061,7 +7379,7 @@ yydefault: } case 342: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4654 + //line php5/php5.y:4947 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) @@ -7069,7 +7387,7 @@ yydefault: } case 343: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:4660 + //line php5/php5.y:4953 { yyVAL.list = []node.Node{} @@ -7077,52 +7395,62 @@ yydefault: } case 344: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4670 + //line php5/php5.y:4963 { yyVAL.list = yyDollar[2].list // save comments - yylex.(*Parser).comments.AddFromToken(yyDollar[2].list[0], yyDollar[1].token, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating(yyDollar[2].list[0], freefloating.Var, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 345: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:4682 + //line php5/php5.y:4975 { - yyVAL.node = nil + yyVAL.node = expr.NewExit(nil) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 346: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4688 + //line php5/php5.y:4981 { yyVAL.node = expr.NewExit(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Exit, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 347: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4701 + //line php5/php5.y:4994 { yyVAL.node = expr.NewExit(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + if yylex.(*Parser).currentToken.Value == ")" { + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yylex.(*Parser).currentToken)) + } else { + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + // save comments + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Exit, (*yyDollar[1].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) + delete((*yyDollar[1].node.GetFreeFloating()), freefloating.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, (*yyDollar[1].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) + delete((*yyDollar[1].node.GetFreeFloating()), freefloating.CloseParenthesisToken) } case 348: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:4713 + //line php5/php5.y:5014 { yyVAL.list = []node.Node{} @@ -7130,15 +7458,19 @@ yydefault: } case 349: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4719 + //line php5/php5.y:5020 { - yyVAL.list = []node.Node{scalar.NewEncapsedStringPart(yyDollar[1].token.Value)} + part := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) + yyVAL.list = []node.Node{part} + + // save position + part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 350: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4725 + //line php5/php5.y:5030 { yyVAL.list = yyDollar[1].list @@ -7146,7 +7478,7 @@ yydefault: } case 351: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:4734 + //line php5/php5.y:5039 { yyVAL.node = nil @@ -7154,7 +7486,7 @@ yydefault: } case 352: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4740 + //line php5/php5.y:5045 { yyVAL.node = yyDollar[1].node @@ -7162,194 +7494,195 @@ yydefault: } case 353: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4749 + //line php5/php5.y:5054 { yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.LnumberToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 354: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4761 + //line php5/php5.y:5066 { yyVAL.node = scalar.NewDnumber(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DnumberToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 355: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4773 + //line php5/php5.y:5078 { yyVAL.node = scalar.NewString(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstantEncapsedStringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 356: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4785 + //line php5/php5.y:5090 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.LineToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 357: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4797 + //line php5/php5.y:5102 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FileToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 358: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4809 + //line php5/php5.y:5114 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DirToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 359: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4821 + //line php5/php5.y:5126 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TraitCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 360: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4833 + //line php5/php5.y:5138 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MethodCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 361: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4845 + //line php5/php5.y:5150 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FuncCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 362: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4857 + //line php5/php5.y:5162 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 363: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4869 + //line php5/php5.y:5174 { encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, []node.Node{encapsed}) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 364: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4883 + //line php5/php5.y:5188 { yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 365: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4898 + //line php5/php5.y:5203 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, yyDollar[3].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 366: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4916 + //line php5/php5.y:5222 { yyVAL.node = yyDollar[1].node @@ -7357,7 +7690,7 @@ yydefault: } case 367: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4925 + //line php5/php5.y:5231 { yyVAL.node = yyDollar[1].node @@ -7365,7 +7698,7 @@ yydefault: } case 368: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4931 + //line php5/php5.y:5237 { yyVAL.node = yyDollar[1].node @@ -7373,84 +7706,87 @@ yydefault: } case 369: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:4937 + //line php5/php5.y:5243 { name := name.NewName(yyDollar[1].list) yyVAL.node = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 370: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4948 + //line php5/php5.y:5257 { name := name.NewRelative(yyDollar[3].list) yyVAL.node = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 371: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:4963 + //line php5/php5.y:5272 { name := name.NewFullyQualified(yyDollar[2].list) yyVAL.node = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 372: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:4977 + //line php5/php5.y:5286 { yyVAL.node = expr.NewArray(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Array, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 373: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:4991 + //line php5/php5.y:5300 { yyVAL.node = expr.NewShortArray(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 374: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5004 + //line php5/php5.y:5313 { yyVAL.node = yyDollar[1].node @@ -7458,21 +7794,21 @@ yydefault: } case 375: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5010 + //line php5/php5.y:5319 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 376: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5022 + //line php5/php5.y:5331 { yyVAL.node = yyDollar[1].node @@ -7480,470 +7816,499 @@ yydefault: } case 377: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5031 + //line php5/php5.y:5340 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 378: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5044 + //line php5/php5.y:5354 { yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 379: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5056 + //line php5/php5.y:5367 { yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 380: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5068 + //line php5/php5.y:5380 { yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 381: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5080 + //line php5/php5.y:5393 { yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 382: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5092 + //line php5/php5.y:5406 { yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 383: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5104 + //line php5/php5.y:5419 { yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 384: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5116 + //line php5/php5.y:5432 { yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 385: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5128 + //line php5/php5.y:5444 { yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TildeToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 386: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5140 + //line php5/php5.y:5456 { yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 387: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5152 + //line php5/php5.y:5469 { yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 388: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5164 + //line php5/php5.y:5482 { yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 389: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5176 + //line php5/php5.y:5495 { yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 390: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5188 + //line php5/php5.y:5508 { yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 391: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5200 + //line php5/php5.y:5521 { yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DotToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 392: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5212 + //line php5/php5.y:5534 { yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 393: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5224 + //line php5/php5.y:5547 { yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 394: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5236 + //line php5/php5.y:5560 { yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 395: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5248 + //line php5/php5.y:5573 { yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 396: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5260 + //line php5/php5.y:5586 { yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 397: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5272 + //line php5/php5.y:5599 { yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 398: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5284 + //line php5/php5.y:5612 { yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 399: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5296 + //line php5/php5.y:5625 { yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 400: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5308 + //line php5/php5.y:5638 { yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 401: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5320 + //line php5/php5.y:5652 { yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LessToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 402: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5332 + //line php5/php5.y:5665 { yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 403: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5344 + //line php5/php5.y:5678 { yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 404: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5356 + //line php5/php5.y:5691 { yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 405: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5368 + //line php5/php5.y:5704 { yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 406: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:5381 + //line php5/php5.y:5718 { yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 407: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5394 + //line php5/php5.y:5732 { yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PlusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 408: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5406 + //line php5/php5.y:5744 { yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MinusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 409: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5418 + //line php5/php5.y:5756 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 410: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5431 + //line php5/php5.y:5769 { yyVAL.node = yyDollar[1].node @@ -7951,67 +8316,72 @@ yydefault: } case 411: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5437 + //line php5/php5.y:5775 { name := name.NewName(yyDollar[1].list) yyVAL.node = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 412: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5448 + //line php5/php5.y:5789 { name := name.NewRelative(yyDollar[3].list) yyVAL.node = expr.NewConstFetch(name) - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save position + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 413: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5461 + //line php5/php5.y:5804 { name := name.NewFullyQualified(yyDollar[2].list) yyVAL.node = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 414: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5478 + //line php5/php5.y:5821 { name := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.StringVarnameToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 415: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5492 + //line php5/php5.y:5835 { yyVAL.node = yyDollar[1].node @@ -8019,7 +8389,7 @@ yydefault: } case 416: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5498 + //line php5/php5.y:5841 { yyVAL.node = yyDollar[1].node @@ -8027,7 +8397,7 @@ yydefault: } case 417: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5504 + //line php5/php5.y:5847 { yyVAL.node = yyDollar[1].node @@ -8035,49 +8405,49 @@ yydefault: } case 418: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5510 + //line php5/php5.y:5853 { yyVAL.node = scalar.NewEncapsed(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoubleQuoteToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 419: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5522 + //line php5/php5.y:5865 { yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 420: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5534 + //line php5/php5.y:5877 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 421: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:5549 + //line php5/php5.y:5892 { yyVAL.list = nil @@ -8085,90 +8455,96 @@ yydefault: } case 422: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5555 + //line php5/php5.y:5898 { yyVAL.list = yyDollar[1].list // save comments if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 423: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:5569 + //line php5/php5.y:5912 { yyVAL.token = nil } case 424: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5573 + //line php5/php5.y:5916 { yyVAL.token = yyDollar[1].token } case 425: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:5580 + //line php5/php5.y:5923 { arrayItem := expr.NewArrayItem(yyDollar[3].node, yyDollar[5].node) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[4].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[3].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 426: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5594 + //line php5/php5.y:5938 { arrayItem := expr.NewArrayItem(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[3].node, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 427: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5607 + //line php5/php5.y:5952 { arrayItem := expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[2].token, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 428: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5620 + //line php5/php5.y:5966 { arrayItem := expr.NewArrayItem(nil, yyDollar[1].node) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 429: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5633 + //line php5/php5.y:5982 { yyVAL.node = yyDollar[1].node @@ -8176,7 +8552,7 @@ yydefault: } case 430: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5639 + //line php5/php5.y:5988 { yyVAL.node = yyDollar[1].node @@ -8184,23 +8560,43 @@ yydefault: } case 431: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5648 + //line php5/php5.y:5997 { yyVAL.node = yyDollar[2].node + // save comments + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.Start, append((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken], (*yyDollar[2].node.GetFreeFloating())[freefloating.Start]...)) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.End, append((*yyDollar[2].node.GetFreeFloating())[freefloating.End], (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]...)) + } + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.OpenParenthesisToken, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.CloseParenthesisToken, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 432: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5654 + //line php5/php5.y:6013 { yyVAL.node = yyDollar[2].node + // save comments + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.Start, append((*yyDollar[2].node.GetFreeFloating())[freefloating.OpenParenthesisToken], (*yyDollar[2].node.GetFreeFloating())[freefloating.Start]...)) + } + if len((*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.End, append((*yyDollar[2].node.GetFreeFloating())[freefloating.End], (*yyDollar[2].node.GetFreeFloating())[freefloating.CloseParenthesisToken]...)) + } + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.OpenParenthesisToken, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).setFreeFloating(yyDollar[2].node, freefloating.CloseParenthesisToken, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 433: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5664 + //line php5/php5.y:6033 { yyVAL.node = yyDollar[1].node @@ -8208,7 +8604,7 @@ yydefault: } case 434: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5674 + //line php5/php5.y:6043 { yyVAL.node = yyDollar[1].node @@ -8216,7 +8612,7 @@ yydefault: } case 435: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5683 + //line php5/php5.y:6052 { yyVAL.node = yyDollar[1].node @@ -8224,7 +8620,7 @@ yydefault: } case 436: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:5692 + //line php5/php5.y:6061 { yyVAL.node = yyDollar[1].node @@ -8234,24 +8630,27 @@ yydefault: } // save comments - yylex.(*Parser).comments.AddFromToken(yyDollar[3].list[0], yyDollar[2].token, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating(yyDollar[3].list[0], freefloating.Var, yyDollar[2].token.FreeFloating) for _, n := range yyDollar[3].list { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.PropertyFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.MethodCall: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) } } @@ -8259,18 +8658,21 @@ yydefault: switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.PropertyFetch: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) case *expr.MethodCall: nn.Variable = yyVAL.node - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) yyVAL.node = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) } } @@ -8278,7 +8680,7 @@ yydefault: } case 437: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5744 + //line php5/php5.y:6119 { yyVAL.node = yyDollar[1].node @@ -8286,7 +8688,7 @@ yydefault: } case 438: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5753 + //line php5/php5.y:6128 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) @@ -8294,7 +8696,7 @@ yydefault: } case 439: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:5759 + //line php5/php5.y:6134 { yyVAL.list = []node.Node{} @@ -8302,7 +8704,7 @@ yydefault: } case 440: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5769 + //line php5/php5.y:6144 { if yyDollar[3].list != nil { yyDollar[3].list[0].(*expr.MethodCall).Method = yyDollar[2].list[len(yyDollar[2].list)-1].(*expr.PropertyFetch).Property @@ -8312,56 +8714,56 @@ yydefault: yyVAL.list = yyDollar[2].list // save comments - yylex.(*Parser).comments.AddFromToken(yyDollar[2].list[0], yyDollar[1].token, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating(yyDollar[2].list[0], freefloating.Var, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 441: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5786 + //line php5/php5.y:6161 { fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 442: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5800 + //line php5/php5.y:6175 { fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) yyVAL.list = []node.Node{yyDollar[1].node, fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 443: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5817 + //line php5/php5.y:6192 { yyVAL.node = expr.NewMethodCall(nil, nil, yyDollar[1].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 444: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5829 + //line php5/php5.y:6204 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -8369,7 +8771,7 @@ yydefault: } case 445: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5835 + //line php5/php5.y:6210 { yyVAL.list = yyDollar[1].list @@ -8377,7 +8779,7 @@ yydefault: } case 446: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:5841 + //line php5/php5.y:6216 { yyVAL.list = nil @@ -8385,7 +8787,7 @@ yydefault: } case 447: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5850 + //line php5/php5.y:6225 { yyVAL.node = yyDollar[1].node @@ -8393,12 +8795,12 @@ yydefault: } case 448: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5856 + //line php5/php5.y:6231 { yyDollar[1].simpleIndirectReference.last.SetVarName(yyDollar[2].node) for _, n := range yyDollar[1].simpleIndirectReference.all { - yylex.(*Parser).positions[n] = yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node) + n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node)) } yyVAL.node = yyDollar[1].simpleIndirectReference.all[0] @@ -8407,35 +8809,37 @@ yydefault: } case 449: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5871 + //line php5/php5.y:6246 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 450: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:5883 + //line php5/php5.y:6259 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 451: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5898 + //line php5/php5.y:6275 { yyVAL.node = yyDollar[1].node @@ -8443,37 +8847,39 @@ yydefault: } case 452: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5907 + //line php5/php5.y:6284 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 453: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5920 + //line php5/php5.y:6298 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 454: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5936 + //line php5/php5.y:6315 { yyVAL.node = yyDollar[1].node @@ -8481,7 +8887,7 @@ yydefault: } case 455: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5942 + //line php5/php5.y:6321 { yyVAL.node = yyDollar[1].node @@ -8489,7 +8895,7 @@ yydefault: } case 456: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5948 + //line php5/php5.y:6327 { yyVAL.node = yyDollar[1].node @@ -8497,7 +8903,7 @@ yydefault: } case 457: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5958 + //line php5/php5.y:6337 { yyVAL.node = yyDollar[1].node @@ -8505,12 +8911,12 @@ yydefault: } case 458: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:5964 + //line php5/php5.y:6343 { yyDollar[1].simpleIndirectReference.last.SetVarName(yyDollar[2].node) for _, n := range yyDollar[1].simpleIndirectReference.all { - yylex.(*Parser).positions[n] = yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node) + n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node)) } yyVAL.node = yyDollar[1].simpleIndirectReference.all[0] @@ -8519,7 +8925,7 @@ yydefault: } case 459: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:5976 + //line php5/php5.y:6355 { yyVAL.node = yyDollar[1].node @@ -8527,37 +8933,39 @@ yydefault: } case 460: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5985 + //line php5/php5.y:6364 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 461: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:5998 + //line php5/php5.y:6378 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 462: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6011 + //line php5/php5.y:6392 { yyVAL.node = yyDollar[1].node @@ -8565,39 +8973,41 @@ yydefault: } case 463: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6021 + //line php5/php5.y:6402 { name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 464: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6035 + //line php5/php5.y:6417 { yyVAL.node = expr.NewVariable(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.Start, append(yyDollar[2].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token), (*yyDollar[3].node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.End, append((*yyDollar[3].node.GetFreeFloating())[freefloating.End], append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 465: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:6052 + //line php5/php5.y:6435 { yyVAL.node = nil @@ -8605,7 +9015,7 @@ yydefault: } case 466: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6058 + //line php5/php5.y:6441 { yyVAL.node = yyDollar[1].node @@ -8613,7 +9023,7 @@ yydefault: } case 467: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6068 + //line php5/php5.y:6451 { yyVAL.list = yyDollar[1].list @@ -8621,107 +9031,108 @@ yydefault: } case 468: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6074 + //line php5/php5.y:6457 { fetch := expr.NewPropertyFetch(nil, yyDollar[1].node) yyVAL.list = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 469: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6087 + //line php5/php5.y:6470 { fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 470: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6101 + //line php5/php5.y:6484 { fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 471: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6115 + //line php5/php5.y:6498 { fetch := expr.NewPropertyFetch(nil, yyDollar[1].node) yyVAL.list = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 472: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6128 + //line php5/php5.y:6511 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 473: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6140 + //line php5/php5.y:6523 { yyVAL.node = yyDollar[2].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 474: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6156 + //line php5/php5.y:6539 { n := expr.NewVariable(nil) yyVAL.simpleIndirectReference = simpleIndirectReference{[]*expr.Variable{n}, n} // save position - yylex.(*Parser).positions.AddPosition(n, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(n, yyDollar[1].token, comment.DollarToken) + yylex.(*Parser).setFreeFloating(n, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 475: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6169 + //line php5/php5.y:6553 { n := expr.NewVariable(nil) @@ -8731,35 +9142,34 @@ yydefault: yyVAL.simpleIndirectReference = yyDollar[1].simpleIndirectReference // save position - yylex.(*Parser).positions.AddPosition(n, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(n, yyDollar[2].token, comment.DollarToken) + yylex.(*Parser).setFreeFloating(n, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 476: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6189 + //line php5/php5.y:6574 { if len(yyDollar[1].list) == 0 { - yyDollar[1].list = []node.Node{nil} + yyDollar[1].list = []node.Node{expr.NewArrayItem(nil, nil)} } yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - if lastNode(yyDollar[1].list) != nil { - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - } + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 477: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6204 + //line php5/php5.y:6587 { - if yyDollar[1].node == nil { + if yyDollar[1].node.(*expr.ArrayItem).Key == nil && yyDollar[1].node.(*expr.ArrayItem).Val == nil { yyVAL.list = []node.Node{} } else { yyVAL.list = []node.Node{yyDollar[1].node} @@ -8769,44 +9179,47 @@ yydefault: } case 478: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6218 + //line php5/php5.y:6601 { yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 479: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6227 + //line php5/php5.y:6613 { - item := expr.NewList(yyDollar[3].list) - yyVAL.node = expr.NewArrayItem(nil, item) + listNode := expr.NewList(yyDollar[3].list) + yyVAL.node = expr.NewArrayItem(nil, listNode) // save position - yylex.(*Parser).positions.AddPosition(item, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(item)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(listNode)) // save comments - yylex.(*Parser).comments.AddFromToken(item, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(item, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(item, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 480: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:6243 + //line php5/php5.y:6629 { - yyVAL.node = nil + yyVAL.node = expr.NewArrayItem(nil, nil) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 481: yyDollar = yyS[yypt-0 : yypt+1] - //line php5/php5.y:6253 + //line php5/php5.y:6639 { yyVAL.list = []node.Node{} @@ -8814,154 +9227,162 @@ yydefault: } case 482: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6259 + //line php5/php5.y:6645 { yyVAL.list = yyDollar[1].list if yyDollar[2].token != nil { - yyVAL.list = append(yyDollar[1].list, nil) + yyVAL.list = append(yyDollar[1].list, expr.NewArrayItem(nil, nil)) } // save comments if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 483: yyDollar = yyS[yypt-5 : yypt+1] - //line php5/php5.y:6277 + //line php5/php5.y:6663 { arrayItem := expr.NewArrayItem(yyDollar[3].node, yyDollar[5].node) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[4].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[3].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 484: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6291 + //line php5/php5.y:6678 { arrayItem := expr.NewArrayItem(nil, yyDollar[3].node) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[3].node, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 485: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6304 + //line php5/php5.y:6692 { arrayItem := expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[2].token, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 486: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6317 + //line php5/php5.y:6706 { arrayItem := expr.NewArrayItem(nil, yyDollar[1].node) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 487: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:6327 + //line php5/php5.y:6719 { reference := expr.NewReference(yyDollar[6].node) arrayItem := expr.NewArrayItem(yyDollar[3].node, reference) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[5].token, yyDollar[6].node)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[6].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[5].token, yyDollar[6].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[6].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[4].token, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[5].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[3].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 488: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6344 + //line php5/php5.y:6737 { reference := expr.NewReference(yyDollar[4].node) arrayItem := expr.NewArrayItem(nil, reference) yyVAL.list = append(yyDollar[1].list, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 489: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6360 + //line php5/php5.y:6753 { reference := expr.NewReference(yyDollar[4].node) arrayItem := expr.NewArrayItem(yyDollar[1].node, reference) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, yyDollar[2].token, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 490: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6376 + //line php5/php5.y:6770 { reference := expr.NewReference(yyDollar[2].node) arrayItem := expr.NewArrayItem(nil, reference) yyVAL.list = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[1].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 491: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6394 + //line php5/php5.y:6788 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -8969,22 +9390,22 @@ yydefault: } case 492: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6400 + //line php5/php5.y:6794 { encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) yyVAL.list = append(yyDollar[1].list, encapsed) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, yyDollar[2].token, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 493: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6413 + //line php5/php5.y:6807 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -8992,58 +9413,59 @@ yydefault: } case 494: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6419 + //line php5/php5.y:6813 { encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) yyVAL.list = []node.Node{encapsed, yyDollar[2].node} // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, yyDollar[1].token, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 495: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6435 + //line php5/php5.y:6829 { name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 496: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6449 + //line php5/php5.y:6844 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 497: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6467 + //line php5/php5.y:6862 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -9051,98 +9473,104 @@ yydefault: yyVAL.node = expr.NewPropertyFetch(variable, fetch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ObjectOperatorToken) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 498: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6487 + //line php5/php5.y:6882 { - yyVAL.node = expr.NewVariable(yyDollar[2].node) + variable := expr.NewVariable(yyDollar[2].node) + + yyVAL.node = variable // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 499: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6500 + //line php5/php5.y:6897 { name := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = expr.NewVariable(name) + variable := expr.NewVariable(name) + + yyVAL.node = variable // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 500: yyDollar = yyS[yypt-6 : yypt+1] - //line php5/php5.y:6516 + //line php5/php5.y:6914 { identifier := node.NewIdentifier(yyDollar[2].token.Value) variable := expr.NewVariable(identifier) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[2].token, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[5].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[6].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 501: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6536 + //line php5/php5.y:6933 { yyVAL.node = yyDollar[2].node + // save comments + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 502: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6545 + //line php5/php5.y:6946 { yyVAL.node = scalar.NewString(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 503: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6557 + //line php5/php5.y:6958 { // TODO: add option to handle 64 bit integer if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil { @@ -9152,152 +9580,153 @@ yydefault: } // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NumStringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 504: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6574 + //line php5/php5.y:6975 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 505: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6591 + //line php5/php5.y:6993 { yyVAL.node = expr.NewIsset(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IssetToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Isset, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 506: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6605 + //line php5/php5.y:7007 { yyVAL.node = expr.NewEmpty(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Empty, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 507: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6619 + //line php5/php5.y:7021 { yyVAL.node = expr.NewEmpty(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Empty, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 508: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6633 + //line php5/php5.y:7035 { yyVAL.node = expr.NewInclude(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncludeToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 509: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6645 + //line php5/php5.y:7047 { yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncludeOnceToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 510: yyDollar = yyS[yypt-4 : yypt+1] - //line php5/php5.y:6657 + //line php5/php5.y:7059 { yyVAL.node = expr.NewEval(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EvalToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Eval, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 511: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6671 + //line php5/php5.y:7073 { yyVAL.node = expr.NewRequire(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.RequireToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 512: yyDollar = yyS[yypt-2 : yypt+1] - //line php5/php5.y:6683 + //line php5/php5.y:7085 { yyVAL.node = expr.NewRequireOnce(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.RequireOnceToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 513: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6698 + //line php5/php5.y:7100 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -9305,18 +9734,18 @@ yydefault: } case 514: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6704 + //line php5/php5.y:7106 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 515: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6716 + //line php5/php5.y:7118 { yyVAL.node = yyDollar[1].node @@ -9324,7 +9753,7 @@ yydefault: } case 516: yyDollar = yyS[yypt-1 : yypt+1] - //line php5/php5.y:6722 + //line php5/php5.y:7124 { yyVAL.node = yyDollar[1].node @@ -9332,65 +9761,73 @@ yydefault: } case 517: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6731 + //line php5/php5.y:7133 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 518: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6745 + //line php5/php5.y:7149 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 519: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6762 + //line php5/php5.y:7168 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 520: yyDollar = yyS[yypt-3 : yypt+1] - //line php5/php5.y:6779 + //line php5/php5.y:7187 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } diff --git a/php5/php5.y b/php5/php5.y index fab903c..57a8ba7 100644 --- a/php5/php5.y +++ b/php5/php5.y @@ -5,7 +5,7 @@ import ( "strings" "strconv" - "github.com/z7zmey/php-parser/comment" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/scanner" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/scalar" @@ -280,15 +280,24 @@ start: top_statement_list { yylex.(*Parser).rootNode = node.NewRoot($1) - yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + if yylex.(*Parser).currentToken.Value == "\xff" { + yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) + } } ; top_statement_list: top_statement_list top_statement { + if inlineHtmlNode, ok := $2.(*stmt.InlineHtml); ok && len($1) > 0 { + prevNode := lastNode($1) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if $2 != nil { $$ = append($1, $2) } @@ -310,10 +319,10 @@ namespace_name: $$ = []node.Node{namePart} // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(namePart, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -323,11 +332,11 @@ namespace_name: $$ = append($1, namePart) // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(namePart, $3, comment.StringToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -364,13 +373,14 @@ top_statement: $$ = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.HaltCompiller, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.OpenParenthesisToken, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -382,12 +392,14 @@ top_statement: $$ = stmt.NewNamespace(name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -397,13 +409,14 @@ top_statement: $$ = stmt.NewNamespace(name, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -412,12 +425,12 @@ top_statement: $$ = stmt.NewNamespace(nil, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -426,11 +439,12 @@ top_statement: $$ = stmt.NewUseList(nil, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -440,13 +454,14 @@ top_statement: $$ = stmt.NewUseList(useType, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(useType, $2, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(useType, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -456,13 +471,14 @@ top_statement: $$ = stmt.NewUseList(useType, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(useType, $2, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(useType, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -471,10 +487,11 @@ top_statement: $$ = $1 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -486,7 +503,7 @@ use_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -505,8 +522,11 @@ use_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -517,13 +537,14 @@ use_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -533,11 +554,13 @@ use_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -548,14 +571,16 @@ use_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -567,7 +592,7 @@ use_function_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -586,8 +611,11 @@ use_function_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -598,13 +626,14 @@ use_function_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -614,11 +643,13 @@ use_function_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -629,14 +660,16 @@ use_function_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -648,7 +681,7 @@ use_const_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -667,8 +700,11 @@ use_const_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -679,13 +715,14 @@ use_const_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -695,11 +732,13 @@ use_const_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -710,14 +749,16 @@ use_const_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -729,18 +770,19 @@ constant_declaration: name := node.NewIdentifier($3.Value) constant := stmt.NewConstant(name, $5, "") constList := $1.(*stmt.ConstList) + lastConst := lastNode(constList.Consts) constList.Consts = append(constList.Consts, constant) $$ = $1 // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, constList.Consts)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, constList.Consts)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(constList.Consts), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastConst, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -752,14 +794,14 @@ constant_declaration: $$ = stmt.NewConstList(constList) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, constList)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, constList)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, $3, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -768,6 +810,11 @@ constant_declaration: inner_statement_list: inner_statement_list inner_statement { + if inlineHtmlNode, ok := $2.(*stmt.InlineHtml); ok && len($1) > 0 { + prevNode := lastNode($1) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if $2 != nil { $$ = append($1, $2) } @@ -814,15 +861,18 @@ inner_statement: $$ = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.HaltCompiller, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.OpenParenthesisToken, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + yylex.(*Parser).Begin(scanner.HALT_COMPILER) } ; @@ -840,12 +890,12 @@ statement: $$ = stmt.NewLabel(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(label, $1, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Label, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -857,11 +907,11 @@ unticked_statement: $$ = stmt.NewStmtList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -871,15 +921,21 @@ unticked_statement: // save position if $5 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) } else if len($4) > 0 { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $4)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IfToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.If, (*$2.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -889,14 +945,21 @@ unticked_statement: $$ = stmt.NewAltIf($2, stmts, $5, $6) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IfToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.If, (*$2.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $8.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($8)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -912,10 +975,16 @@ unticked_statement: $$ = $3 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.WhileToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.While, (*$2.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -924,12 +993,19 @@ unticked_statement: $$ = stmt.NewDo($2, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + if len((*$4.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.While, (*$4.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$4.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$4.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$4.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$4.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$4.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$4.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($5)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -949,14 +1025,14 @@ unticked_statement: $$ = $9 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.ForInitSemicolonToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.ForCondSemicolonToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.For, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.InitExpr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CondExpr, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.IncExpr, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -974,10 +1050,16 @@ unticked_statement: $$ = $3 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SwitchToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Switch, (*$2.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$2.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -986,11 +1068,12 @@ unticked_statement: $$ = stmt.NewBreak(nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -999,11 +1082,12 @@ unticked_statement: $$ = stmt.NewBreak($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1012,11 +1096,12 @@ unticked_statement: $$ = stmt.NewContinue(nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1025,11 +1110,12 @@ unticked_statement: $$ = stmt.NewContinue($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1038,11 +1124,12 @@ unticked_statement: $$ = stmt.NewReturn(nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1051,11 +1138,12 @@ unticked_statement: $$ = stmt.NewReturn($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1064,11 +1152,12 @@ unticked_statement: $$ = stmt.NewReturn($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1077,10 +1166,12 @@ unticked_statement: $$ = stmt.NewExpression($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1089,11 +1180,12 @@ unticked_statement: $$ = stmt.NewGlobal($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.GlobalToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1102,11 +1194,12 @@ unticked_statement: $$ = stmt.NewStatic($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1115,11 +1208,13 @@ unticked_statement: $$ = stmt.NewEcho($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EchoToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Echo, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1128,10 +1223,10 @@ unticked_statement: $$ = stmt.NewInlineHtml($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.InlineHTMLToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1140,10 +1235,12 @@ unticked_statement: $$ = stmt.NewExpression($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1152,13 +1249,14 @@ unticked_statement: $$ = stmt.NewUnset($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UnsetToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Unset, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($5)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1189,13 +1287,16 @@ unticked_statement: $$ = $8 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Foreach, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) + if $6 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Key, (*$6.GetFreeFloating())[freefloating.Key]); delete((*$6.GetFreeFloating()), freefloating.Key) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $7.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1226,27 +1327,31 @@ unticked_statement: // save position $$ = $8 - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Foreach, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) + if $6 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Key, (*$6.GetFreeFloating())[freefloating.Key]); delete((*$6.GetFreeFloating()), freefloating.Key) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $7.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DECLARE '(' declare_list ')' declare_statement { - $$ = stmt.NewDeclare($3, $5) + $$ = $5 + $$.(*stmt.Declare).Consts = $3 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DeclareToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Declare, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ConstList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1255,10 +1360,11 @@ unticked_statement: $$ = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1268,15 +1374,15 @@ unticked_statement: // save position if $6 == nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TryToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Try, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1285,11 +1391,12 @@ unticked_statement: $$ = stmt.NewThrow($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ThrowToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1299,13 +1406,14 @@ unticked_statement: $$ = stmt.NewGoto(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.GotoToken) - yylex.(*Parser).comments.AddFromToken(label, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(label, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Label, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1322,21 +1430,22 @@ catch_statement: { identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) variable := expr.NewVariable(identifier) - catch := stmt.NewCatch([]node.Node{$3}, variable, $7) - $$ = append([]node.Node{catch}, $9...) + catchNode := stmt.NewCatch([]node.Node{$3}, variable, $7) + $$ = append([]node.Node{catchNode}, $9...) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(catch, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + catchNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken(catch, $1, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken(catch, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(catch, $5, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(catch, $6, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(catch, $8, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Catch, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Var, $5.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Cond, $6.FreeFloating) + yylex.(*Parser).setFreeFloating(catchNode, freefloating.Stmts, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1354,12 +1463,12 @@ finally_statement: $$ = stmt.NewFinally($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FinallyToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Finally, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1403,17 +1512,18 @@ additional_catch: $$ = stmt.NewCatch([]node.Node{$3}, variable, $7) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Catch, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1431,7 +1541,7 @@ unset_variables: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1493,19 +1603,21 @@ unticked_function_declaration_statement: $$ = stmt.NewFunction(name, $2 != nil, $5, nil, $8, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $3.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $3.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $9, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ParamList, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Params, $7.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $9.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1530,13 +1642,13 @@ unticked_class_declaration_statement: $$ = $1 // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $7)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1546,13 +1658,14 @@ unticked_class_declaration_statement: $$ = stmt.NewInterface(name, $3, $5, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1565,10 +1678,10 @@ class_entry_type: $$ = stmt.NewClass(nil, nil, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1578,12 +1691,12 @@ class_entry_type: $$ = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(classModifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(classModifier, $1, comment.AbstractToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ClassToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1592,10 +1705,10 @@ class_entry_type: $$ = stmt.NewTrait(nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TraitToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1605,12 +1718,12 @@ class_entry_type: $$ = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") // save position - yylex.(*Parser).positions.AddPosition(classModifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(classModifier, $1, comment.FinalToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ClassToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1628,10 +1741,10 @@ extends_from: $$ = stmt.NewClassExtends($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1656,10 +1769,10 @@ interface_extends_list: $$ = stmt.NewInterfaceExtends($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1677,10 +1790,10 @@ implements_list: $$ = stmt.NewClassImplements($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ImplementsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1698,7 +1811,7 @@ interface_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1716,7 +1829,7 @@ foreach_optional_arg: $$ = $2 // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Key, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1734,10 +1847,10 @@ foreach_variable: $$ = expr.NewReference($2) // save position - yylex.(*Parser).positions.AddPosition($2, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1746,12 +1859,12 @@ foreach_variable: $$ = expr.NewList($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1763,7 +1876,7 @@ for_statement: $$ = stmt.NewFor(nil, nil, nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1773,13 +1886,14 @@ for_statement: $$ = stmt.NewAltFor(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndforToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1791,7 +1905,7 @@ foreach_statement: $$ = stmt.NewForeach(nil, nil, nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1801,13 +1915,14 @@ foreach_statement: $$ = stmt.NewAltForeach(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndforeachToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1817,21 +1932,27 @@ foreach_statement: declare_statement: statement { - $$ = $1; + $$ = stmt.NewDeclare(nil, $1, false) + + // save position + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | ':' inner_statement_list T_ENDDECLARE ';' { - $$ = stmt.NewStmtList($2) + stmtList := stmt.NewStmtList($2) + $$ = stmt.NewDeclare(nil, stmtList, true) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EnddeclareToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1846,12 +1967,12 @@ declare_list: $$ = []node.Node{constant} // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1862,13 +1983,13 @@ declare_list: $$ = append($1, constant) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(constant, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1882,12 +2003,12 @@ switch_case_list: $$ = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1897,13 +2018,13 @@ switch_case_list: $$ = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, $2, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1913,13 +2034,14 @@ switch_case_list: $$ = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $3, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1930,14 +2052,15 @@ switch_case_list: $$ = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $2, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $4, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($5)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1957,11 +2080,12 @@ case_list: $$ = append($1, _case) // save position - yylex.(*Parser).positions.AddPosition(_case, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) + _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(_case, $2, comment.CaseToken) - yylex.(*Parser).comments.AddFromToken(_case, $4, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_case, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.Expr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1971,11 +2095,12 @@ case_list: $$ = append($1, _default) // save position - yylex.(*Parser).positions.AddPosition(_default, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) + _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(_default, $2, comment.DefaultToken) - yylex.(*Parser).comments.AddFromToken(_default, $3, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_default, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.Default, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2000,7 +2125,7 @@ while_statement: $$ = stmt.NewWhile(nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2010,13 +2135,14 @@ while_statement: $$ = stmt.NewAltWhile(nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndwhileToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2037,10 +2163,16 @@ elseif_list: $$ = append($1, _elseIf) // save position - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, $2, comment.ElseifToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, $2.FreeFloating) + if len((*$3.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, (*$3.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$3.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$3.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$3.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, (*$3.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$3.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$3.GetFreeFloating()), freefloating.CloseParenthesisToken) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2061,12 +2193,18 @@ new_elseif_list: $$ = append($1, _elseIf) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($5)) - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($5)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, $2, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $4, comment.ColonToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, $2.FreeFloating) + if len((*$3.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, (*$3.GetFreeFloating())[freefloating.OpenParenthesisToken][:len((*$3.GetFreeFloating())[freefloating.OpenParenthesisToken])-1]); delete((*$3.GetFreeFloating()), freefloating.OpenParenthesisToken) + } + if len((*$3.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, (*$3.GetFreeFloating())[freefloating.CloseParenthesisToken][:len((*$3.GetFreeFloating())[freefloating.CloseParenthesisToken])-1]); delete((*$3.GetFreeFloating()), freefloating.CloseParenthesisToken) + } + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Cond, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2085,10 +2223,10 @@ else_single: $$ = stmt.NewElse($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ElseToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2108,12 +2246,12 @@ new_else_single: $$ = stmt.NewAltElse(stmts) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ElseToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Else, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2147,7 +2285,7 @@ non_empty_parameter_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2161,26 +2299,41 @@ parameter: $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) } else if $2 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) } else if $3 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) } // save comments + if $1 != nil { + yylex.(*Parser).MoveFreeFloating($1, $$) + } if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) } if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Variadic, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + + // normalize + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, (*$$.GetFreeFloating())[freefloating.Variadic]); delete((*$$.GetFreeFloating()), freefloating.Variadic) + } + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, (*$$.GetFreeFloating())[freefloating.Ampersand]); delete((*$$.GetFreeFloating()), freefloating.Ampersand) + } + if $1 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, (*$$.GetFreeFloating())[freefloating.OptionalType]); delete((*$$.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2191,27 +2344,42 @@ parameter: $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) } else if $2 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) } else if $3 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) } // save comments + if $1 != nil { + yylex.(*Parser).MoveFreeFloating($1, $$) + } if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) } if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Variadic, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $5.FreeFloating) + + // normalize + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, (*$$.GetFreeFloating())[freefloating.Variadic]); delete((*$$.GetFreeFloating()), freefloating.Variadic) + } + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, (*$$.GetFreeFloating())[freefloating.Ampersand]); delete((*$$.GetFreeFloating()), freefloating.Ampersand) + } + if $1 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, (*$$.GetFreeFloating())[freefloating.OptionalType]); delete((*$$.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2230,10 +2398,10 @@ optional_class_type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2242,10 +2410,10 @@ optional_class_type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.CallableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2264,11 +2432,11 @@ function_call_parameter_list: $$ = node.NewArgumentList(nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2277,11 +2445,11 @@ function_call_parameter_list: $$ = node.NewArgumentList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2291,12 +2459,12 @@ function_call_parameter_list: $$ = node.NewArgumentList([]node.Node{arg}) // save position - yylex.(*Parser).positions.AddPosition(arg, yylex.(*Parser).positionBuilder.NewNodePosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + arg.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2315,7 +2483,7 @@ non_empty_function_call_parameter_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2327,7 +2495,10 @@ function_call_parameter: $$ = node.NewArgument($1, false, false) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2336,7 +2507,10 @@ function_call_parameter: $$ = node.NewArgument($1, false, false) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2345,10 +2519,10 @@ function_call_parameter: $$ = node.NewArgument($2, false, true) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2357,10 +2531,10 @@ function_call_parameter: $$ = node.NewArgument($2, true, false) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2372,7 +2546,7 @@ global_var_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2392,11 +2566,12 @@ global_var: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2405,10 +2580,11 @@ global_var: $$ = expr.NewVariable($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2417,12 +2593,13 @@ global_var: $$ = expr.NewVariable($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($3, freefloating.Start, append($2.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($2), (*$3.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($3, freefloating.End, append((*$3.GetFreeFloating())[freefloating.End], append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2438,13 +2615,14 @@ static_var_list: $$ = append($1, staticVar) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, $3, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2456,14 +2634,15 @@ static_var_list: $$ = append($1, staticVar) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, $3, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(staticVar, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Var, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2475,12 +2654,13 @@ static_var_list: $$ = []node.Node{staticVar} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2492,13 +2672,14 @@ static_var_list: $$ = []node.Node{staticVar} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(staticVar, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + staticVar.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(staticVar, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(staticVar, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2527,10 +2708,12 @@ class_statement: $$ = stmt.NewPropertyList($1, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.PropertyList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2539,10 +2722,11 @@ class_statement: $$ = $1 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.ConstList, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2558,21 +2742,28 @@ class_statement: $$ = stmt.NewClassMethod(name, $1, $3 != nil, $6, nil, $8, "") // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 == nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $8)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $8)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $8)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $8)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) - if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + if len($1) > 0 { + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $2.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(name, $4, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $4.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $4.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $7.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2581,20 +2772,13 @@ class_statement: trait_use_statement: T_USE trait_list trait_adaptations { - var adaptationList *stmt.TraitAdaptationList - switch n := $3.(type) { - case *stmt.TraitAdaptationList: - adaptationList = n - default: - adaptationList = nil - } - $$ = stmt.NewTraitUse($2, adaptationList) + $$ = stmt.NewTraitUse($2, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2612,7 +2796,7 @@ trait_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2623,11 +2807,11 @@ trait_adaptations: { $$ = stmt.NewNop() - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) - + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2635,11 +2819,11 @@ trait_adaptations: { $$ = stmt.NewTraitAdaptationList($2) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2681,7 +2865,8 @@ trait_adaptation_statement: $$ = $1; // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.NameList, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2690,7 +2875,8 @@ trait_adaptation_statement: $$ = $1; // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Alias, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2702,10 +2888,11 @@ trait_precedence: $$ = stmt.NewTraitUsePrecedence($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.InsteadofToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2723,7 +2910,7 @@ trait_reference_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2736,11 +2923,11 @@ trait_method_reference: $$ = stmt.NewTraitMethodRef(nil, name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2759,12 +2946,13 @@ trait_method_reference_fully_qualified: $$ = stmt.NewTraitMethodRef($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, $3, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2777,12 +2965,13 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, $3, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $4, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2791,10 +2980,11 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, $3, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2821,10 +3011,11 @@ method_body: $$ = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2833,11 +3024,11 @@ method_body: $$ = stmt.NewStmtList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2856,10 +3047,10 @@ variable_modifiers: $$ = []node.Node{modifier} // save position - yylex.(*Parser).positions.AddPosition(modifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(modifier, $1, comment.VarToken) + yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2901,10 +3092,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PublicToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2913,10 +3104,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ProtectedToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2925,10 +3116,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PrivateToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2937,10 +3128,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2949,10 +3140,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AbstractToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2961,10 +3152,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FinalToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2979,13 +3170,14 @@ class_variable_declaration: $$ = append($1, property) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, $3, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2997,14 +3189,15 @@ class_variable_declaration: $$ = append($1, property) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, $3, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(property, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(property, freefloating.Var, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3016,12 +3209,13 @@ class_variable_declaration: $$ = []node.Node{property} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3033,13 +3227,14 @@ class_variable_declaration: $$ = []node.Node{property} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(property, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + property.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(property, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating(property, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(property, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3051,18 +3246,19 @@ class_constant_declaration: name := node.NewIdentifier($3.Value) constant := stmt.NewConstant(name, $5, "") constList := $1.(*stmt.ClassConstList) + lastConst := lastNode(constList.Consts) constList.Consts = append(constList.Consts, constant) $$ = $1 // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) - yylex.(*Parser).positions.AddPosition($1, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) + $1.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(constList.Consts), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(name, $3, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(constant, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating(lastConst, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3073,14 +3269,14 @@ class_constant_declaration: $$ = stmt.NewClassConstList(nil, []node.Node{constant}) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(constant, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(constant, $3, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3092,7 +3288,7 @@ echo_expr_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3126,7 +3322,7 @@ non_empty_for_expr: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3160,11 +3356,11 @@ chaining_dereference: $$ = append($1, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, $4, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3174,11 +3370,11 @@ chaining_dereference: $$ = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($2)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, $3, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3226,14 +3422,14 @@ new_expr: if $3 != nil { $$ = expr.NewNew($2, $3.(*node.ArgumentList)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) } else { $$ = expr.NewNew($2, nil) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NewToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3242,18 +3438,18 @@ new_expr: expr_without_variable: T_LIST '(' assignment_list ')' '=' expr { - list := expr.NewList($3) - $$ = assign.NewAssign(list, $6) + listNode := expr.NewList($3) + $$ = assign.NewAssign(listNode, $6) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(list, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, $4, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3262,10 +3458,11 @@ expr_without_variable: $$ = assign.NewAssign($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3274,11 +3471,12 @@ expr_without_variable: $$ = assign.NewReference($1, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3295,16 +3493,17 @@ expr_without_variable: // save position if $6 != nil { - yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) + _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) } else { - yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $5)) + _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $5)) } - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, _new)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, _new)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) - yylex.(*Parser).comments.AddFromToken(_new, $4, comment.NewToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(_new, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3313,10 +3512,10 @@ expr_without_variable: $$ = expr.NewClone($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.CloneToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3325,10 +3524,10 @@ expr_without_variable: $$ = assign.NewPlus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PlusEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3337,10 +3536,11 @@ expr_without_variable: $$ = assign.NewMinus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MinusEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3349,10 +3549,11 @@ expr_without_variable: $$ = assign.NewMul($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MulEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3361,10 +3562,11 @@ expr_without_variable: $$ = assign.NewPow($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PowEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3373,10 +3575,11 @@ expr_without_variable: $$ = assign.NewDiv($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DivEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3385,10 +3588,11 @@ expr_without_variable: $$ = assign.NewConcat($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ConcatEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3397,10 +3601,11 @@ expr_without_variable: $$ = assign.NewMod($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ModEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3409,10 +3614,11 @@ expr_without_variable: $$ = assign.NewBitwiseAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AndEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3421,10 +3627,11 @@ expr_without_variable: $$ = assign.NewBitwiseOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3433,10 +3640,11 @@ expr_without_variable: $$ = assign.NewBitwiseXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.XorEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3445,10 +3653,11 @@ expr_without_variable: $$ = assign.NewShiftLeft($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3457,10 +3666,11 @@ expr_without_variable: $$ = assign.NewShiftRight($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3469,10 +3679,11 @@ expr_without_variable: $$ = expr.NewPostInc($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IncToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3481,10 +3692,10 @@ expr_without_variable: $$ = expr.NewPreInc($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3493,10 +3704,11 @@ expr_without_variable: $$ = expr.NewPostDec($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DecToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3505,10 +3717,10 @@ expr_without_variable: $$ = expr.NewPreDec($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DecToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3517,10 +3729,11 @@ expr_without_variable: $$ = binary.NewBooleanOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3529,10 +3742,11 @@ expr_without_variable: $$ = binary.NewBooleanAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3541,10 +3755,11 @@ expr_without_variable: $$ = binary.NewLogicalOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3553,10 +3768,11 @@ expr_without_variable: $$ = binary.NewLogicalAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3565,10 +3781,11 @@ expr_without_variable: $$ = binary.NewLogicalXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3577,10 +3794,11 @@ expr_without_variable: $$ = binary.NewBitwiseOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3589,10 +3807,11 @@ expr_without_variable: $$ = binary.NewBitwiseAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3601,10 +3820,11 @@ expr_without_variable: $$ = binary.NewBitwiseXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3613,10 +3833,11 @@ expr_without_variable: $$ = binary.NewConcat($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DotToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3625,10 +3846,11 @@ expr_without_variable: $$ = binary.NewPlus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3637,10 +3859,11 @@ expr_without_variable: $$ = binary.NewMinus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3649,10 +3872,11 @@ expr_without_variable: $$ = binary.NewMul($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3661,10 +3885,11 @@ expr_without_variable: $$ = binary.NewPow($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PowToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3673,10 +3898,11 @@ expr_without_variable: $$ = binary.NewDiv($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3685,10 +3911,11 @@ expr_without_variable: $$ = binary.NewMod($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3697,10 +3924,11 @@ expr_without_variable: $$ = binary.NewShiftLeft($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3709,10 +3937,11 @@ expr_without_variable: $$ = binary.NewShiftRight($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3721,10 +3950,10 @@ expr_without_variable: $$ = expr.NewUnaryPlus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PlusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3733,10 +3962,10 @@ expr_without_variable: $$ = expr.NewUnaryMinus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MinusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3745,10 +3974,10 @@ expr_without_variable: $$ = expr.NewBooleanNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3757,10 +3986,10 @@ expr_without_variable: $$ = expr.NewBitwiseNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TildeToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3769,10 +3998,11 @@ expr_without_variable: $$ = binary.NewIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3781,10 +4011,11 @@ expr_without_variable: $$ = binary.NewNotIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3793,10 +4024,11 @@ expr_without_variable: $$ = binary.NewEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3805,10 +4037,12 @@ expr_without_variable: $$ = binary.NewNotEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3817,10 +4051,11 @@ expr_without_variable: $$ = binary.NewSmaller($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LessToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3829,10 +4064,11 @@ expr_without_variable: $$ = binary.NewSmallerOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3841,10 +4077,11 @@ expr_without_variable: $$ = binary.NewGreater($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3853,10 +4090,11 @@ expr_without_variable: $$ = binary.NewGreaterOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3865,10 +4103,11 @@ expr_without_variable: $$ = expr.NewInstanceOf($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.InstanceofToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3877,6 +4116,9 @@ expr_without_variable: $$ = $1 yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + yylex.(*Parser).setFreeFloating($1, freefloating.Start, append((*$1.GetFreeFloating())[freefloating.OpenParenthesisToken], (*$1.GetFreeFloating())[freefloating.Start]...)); delete((*$1.GetFreeFloating()), freefloating.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating($1, freefloating.End, append((*$1.GetFreeFloating())[freefloating.End], (*$1.GetFreeFloating())[freefloating.CloseParenthesisToken]...)); delete((*$1.GetFreeFloating()), freefloating.CloseParenthesisToken) } | new_expr { @@ -3888,29 +4130,32 @@ expr_without_variable: { $$ = $2 + // save comments + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) + for _, n := range($4) { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = $$ $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.PropertyFetch: nn.Variable = $$ $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.MethodCall: nn.Variable = $$ $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) } // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($$, n)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, n)) } - // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | expr '?' expr ':' expr @@ -3918,11 +4163,12 @@ expr_without_variable: $$ = expr.NewTernary($1, $3, $5) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3931,11 +4177,12 @@ expr_without_variable: $$ = expr.NewTernary($1, nil, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3950,10 +4197,11 @@ expr_without_variable: $$ = cast.NewInt($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IntCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3962,10 +4210,11 @@ expr_without_variable: $$ = cast.NewDouble($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoubleCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3974,10 +4223,11 @@ expr_without_variable: $$ = cast.NewString($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3986,10 +4236,11 @@ expr_without_variable: $$ = cast.NewArray($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3998,10 +4249,11 @@ expr_without_variable: $$ = cast.NewObject($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ObjectCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4010,10 +4262,11 @@ expr_without_variable: $$ = cast.NewBool($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BoolCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4022,40 +4275,32 @@ expr_without_variable: $$ = cast.NewUnset($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UnsetCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_EXIT exit_expr { + e := $2.(*expr.Exit) + $$ = $2 + if (strings.EqualFold($1.Value, "die")) { - $$ = expr.NewDie(nil) - if $2 != nil { - $$.(*expr.Die).Expr = $2.(*expr.Exit).Expr - } - } else { - $$ = expr.NewExit(nil) - if $2 != nil { - $$.(*expr.Exit).Expr = $2.(*expr.Exit).Expr - } + e.Die = true } // save position - if $2 == nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + if $2.GetPosition() == nil { + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExitToken) - - if $2 != nil { - yylex.(*Parser).comments.AddFromChildNode($$, $2) - } + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4064,10 +4309,10 @@ expr_without_variable: $$ = expr.NewErrorSuppress($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AtToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4094,11 +4339,10 @@ expr_without_variable: $$ = expr.NewShellExec($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BackquoteToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.BackquoteToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4107,10 +4351,10 @@ expr_without_variable: $$ = expr.NewPrint($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PrintToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4119,10 +4363,10 @@ expr_without_variable: $$ = expr.NewYield(nil, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4131,17 +4375,24 @@ expr_without_variable: $$ = expr.NewClosure($4, $6, nil, $8, false, $2 != nil, "") // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) - if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $3.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, $7.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $9.FreeFloating) + + // normalize + if $6 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.LexicalVars]); delete((*$$.GetFreeFloating()), freefloating.LexicalVars) } - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $9, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4150,18 +4401,25 @@ expr_without_variable: $$ = expr.NewClosure($5, $7, nil, $9, true, $3 != nil, "") // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $10)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $10)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) - if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Static, $2.FreeFloating) + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $4.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $4.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, $8.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $10.FreeFloating) + + // normalize + if $7 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.LexicalVars]); delete((*$$.GetFreeFloating()), freefloating.LexicalVars) } - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $10, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4173,10 +4431,10 @@ yield_expr: $$ = expr.NewYield(nil, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4185,10 +4443,10 @@ yield_expr: $$ = expr.NewYield(nil, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4197,11 +4455,11 @@ yield_expr: $$ = expr.NewYield($2, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4210,11 +4468,11 @@ yield_expr: $$ = expr.NewYield($2, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4226,11 +4484,12 @@ combined_scalar_offset: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4239,11 +4498,12 @@ combined_scalar_offset: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4253,12 +4513,13 @@ combined_scalar_offset: $$ = expr.NewArrayDimFetch(str, $3) // save position - yylex.(*Parser).positions.AddPosition(str, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, $4)) + str.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4267,11 +4528,12 @@ combined_scalar_offset: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4283,12 +4545,12 @@ combined_scalar: $$ = expr.NewArray($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Array, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4297,11 +4559,11 @@ combined_scalar: $$ = expr.NewShortArray($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4325,7 +4587,13 @@ lexical_vars: { $$ = expr.NewClosureUse($3) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + // save position + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + + // save comments + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Use, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVarList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4339,12 +4607,13 @@ lexical_var_list: $$ = append($1, variable) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(variable, $3, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4356,13 +4625,15 @@ lexical_var_list: $$ = append($1, reference) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(reference, $3, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4373,11 +4644,12 @@ lexical_var_list: $$ = []node.Node{variable} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4389,13 +4661,14 @@ lexical_var_list: $$ = []node.Node{reference} // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(variable, $2, comment.VariableToken) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4408,8 +4681,11 @@ function_call: $$ = expr.NewFunctionCall(name, $2.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(name, $2)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(name, $2)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4419,12 +4695,12 @@ function_call: $$ = expr.NewFunctionCall(funcName, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $4)) + funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(funcName, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(funcName, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(funcName, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4434,11 +4710,11 @@ function_call: $$ = expr.NewFunctionCall(funcName, $3.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $3)) + funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(funcName, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4447,10 +4723,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4459,10 +4736,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4471,10 +4749,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4483,10 +4762,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4495,7 +4775,10 @@ function_call: $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4507,10 +4790,10 @@ class_name: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4519,7 +4802,10 @@ class_name: $$ = name.NewName($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4528,11 +4814,11 @@ class_name: $$ = name.NewRelative($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4541,10 +4827,10 @@ class_name: $$ = name.NewFullyQualified($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4556,7 +4842,10 @@ fully_qualified_class_name: $$ = name.NewName($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4565,11 +4854,11 @@ fully_qualified_class_name: $$ = name.NewRelative($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4578,10 +4867,10 @@ fully_qualified_class_name: $$ = name.NewFullyQualified($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4608,19 +4897,21 @@ dynamic_class_name_reference: $$ = $1 // save comments - yylex.(*Parser).comments.AddFromToken($3[0], $2, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating($3[0], freefloating.Var, $2.FreeFloating) for _, n := range($3) { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.PropertyFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) } } @@ -4628,13 +4919,15 @@ dynamic_class_name_reference: switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.PropertyFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) } } @@ -4671,7 +4964,7 @@ dynamic_class_name_variable_property: $$ = $2 // save comments - yylex.(*Parser).comments.AddFromToken($2[0], $1, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating($2[0], freefloating.Var, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4680,7 +4973,7 @@ dynamic_class_name_variable_property: exit_expr: /* empty */ { - $$ = nil + $$ = expr.NewExit(nil); yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4689,11 +4982,11 @@ exit_expr: $$ = expr.NewExit(nil); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Exit, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4702,9 +4995,17 @@ exit_expr: $$ = expr.NewExit($1); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + if yylex.(*Parser).currentToken.Value == ")" { + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yylex.(*Parser).currentToken)) + } else { + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + // save comments + yylex.(*Parser).setFreeFloating($$, freefloating.Exit, (*$1.GetFreeFloating())[freefloating.OpenParenthesisToken]); delete((*$1.GetFreeFloating()), freefloating.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, (*$1.GetFreeFloating())[freefloating.CloseParenthesisToken]); delete((*$1.GetFreeFloating()), freefloating.CloseParenthesisToken) } ; @@ -4717,7 +5018,11 @@ backticks_expr: } | T_ENCAPSED_AND_WHITESPACE { - $$ = []node.Node{scalar.NewEncapsedStringPart($1.Value)} + part := scalar.NewEncapsedStringPart($1.Value) + $$ = []node.Node{part} + + // save position + part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4750,10 +5055,10 @@ common_scalar: $$ = scalar.NewLnumber($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.LnumberToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4762,10 +5067,10 @@ common_scalar: $$ = scalar.NewDnumber($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DnumberToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4774,10 +5079,10 @@ common_scalar: $$ = scalar.NewString($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstantEncapsedStringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4786,10 +5091,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.LineToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4798,10 +5103,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FileToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4810,10 +5115,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DirToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4822,10 +5127,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TraitCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4834,10 +5139,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MethodCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4846,10 +5151,10 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FuncCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4858,24 +5163,24 @@ common_scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } - | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC + | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { encapsed := scalar.NewEncapsedStringPart($2.Value) $$ = scalar.NewHeredoc($1.Value, []node.Node{encapsed}) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4884,10 +5189,10 @@ common_scalar: $$ = scalar.NewHeredoc($1.Value, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4900,12 +5205,13 @@ static_class_constant: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, $3, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4939,8 +5245,11 @@ static_scalar_value: $$ = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4950,12 +5259,12 @@ static_scalar_value: $$ = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4965,11 +5274,11 @@ static_scalar_value: $$ = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4978,12 +5287,12 @@ static_scalar_value: $$ = expr.NewArray($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Array, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4992,11 +5301,11 @@ static_scalar_value: $$ = expr.NewShortArray($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5011,10 +5320,10 @@ static_scalar_value: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5032,11 +5341,12 @@ static_operation: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5045,10 +5355,11 @@ static_operation: $$ = binary.NewPlus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5057,10 +5368,11 @@ static_operation: $$ = binary.NewMinus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5069,10 +5381,11 @@ static_operation: $$ = binary.NewMul($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5081,10 +5394,11 @@ static_operation: $$ = binary.NewPow($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PowToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5093,10 +5407,11 @@ static_operation: $$ = binary.NewDiv($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5105,10 +5420,11 @@ static_operation: $$ = binary.NewMod($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5117,10 +5433,10 @@ static_operation: $$ = expr.NewBooleanNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5129,10 +5445,10 @@ static_operation: $$ = expr.NewBitwiseNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TildeToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5141,10 +5457,11 @@ static_operation: $$ = binary.NewBitwiseOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5153,10 +5470,11 @@ static_operation: $$ = binary.NewBitwiseAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5165,10 +5483,11 @@ static_operation: $$ = binary.NewBitwiseXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5177,10 +5496,11 @@ static_operation: $$ = binary.NewShiftLeft($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5189,10 +5509,11 @@ static_operation: $$ = binary.NewShiftRight($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5201,10 +5522,11 @@ static_operation: $$ = binary.NewConcat($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DotToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5213,10 +5535,11 @@ static_operation: $$ = binary.NewLogicalXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5225,10 +5548,11 @@ static_operation: $$ = binary.NewLogicalAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5237,10 +5561,11 @@ static_operation: $$ = binary.NewLogicalOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5249,10 +5574,11 @@ static_operation: $$ = binary.NewBooleanAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5261,10 +5587,11 @@ static_operation: $$ = binary.NewBooleanOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5273,10 +5600,11 @@ static_operation: $$ = binary.NewIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5285,10 +5613,11 @@ static_operation: $$ = binary.NewNotIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5297,10 +5626,11 @@ static_operation: $$ = binary.NewEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5309,10 +5639,12 @@ static_operation: $$ = binary.NewNotEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5321,10 +5653,11 @@ static_operation: $$ = binary.NewSmaller($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LessToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5333,10 +5666,11 @@ static_operation: $$ = binary.NewGreater($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5345,10 +5679,11 @@ static_operation: $$ = binary.NewSmallerOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5357,10 +5692,11 @@ static_operation: $$ = binary.NewGreaterOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5369,11 +5705,12 @@ static_operation: $$ = expr.NewTernary($1, nil, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5382,11 +5719,12 @@ static_operation: $$ = expr.NewTernary($1, $3, $5) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5395,10 +5733,10 @@ static_operation: $$ = expr.NewUnaryPlus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PlusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5407,10 +5745,10 @@ static_operation: $$ = expr.NewUnaryMinus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MinusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5419,8 +5757,8 @@ static_operation: $$ = $2 // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5439,8 +5777,11 @@ general_constant: $$ = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5448,12 +5789,14 @@ general_constant: { name := name.NewRelative($3) $$ = expr.NewConstFetch(name) - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + + // save position + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5463,11 +5806,11 @@ general_constant: $$ = expr.NewConstFetch(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition(name)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5480,11 +5823,11 @@ scalar: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.StringVarnameToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5511,10 +5854,10 @@ scalar: $$ = scalar.NewEncapsed($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoubleQuoteToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5523,10 +5866,10 @@ scalar: $$ = scalar.NewHeredoc($1.Value, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5535,10 +5878,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5557,7 +5900,7 @@ static_array_pair_list: // save comments if $2 != nil { - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -5582,11 +5925,12 @@ non_empty_static_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, $4, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).MoveFreeFloating($3, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5596,10 +5940,11 @@ non_empty_static_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).MoveFreeFloating($3, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5609,10 +5954,11 @@ non_empty_static_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, $2, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating($1, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5622,7 +5968,10 @@ non_empty_static_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5646,13 +5995,33 @@ expr: parenthesis_expr: '(' expr ')' { - $$ = $2 + $$ = $2 + + // save comments + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($2, freefloating.Start, append((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken], (*$2.GetFreeFloating())[freefloating.Start]...)) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($2, freefloating.End, append((*$2.GetFreeFloating())[freefloating.End], (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]...)) + } + yylex.(*Parser).setFreeFloating($2, freefloating.OpenParenthesisToken, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).setFreeFloating($2, freefloating.CloseParenthesisToken, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | '(' yield_expr ')' { - $$ = $2 + $$ = $2 + + // save comments + if len((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($2, freefloating.Start, append((*$2.GetFreeFloating())[freefloating.OpenParenthesisToken], (*$2.GetFreeFloating())[freefloating.Start]...)) + } + if len((*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]) > 0 { + yylex.(*Parser).setFreeFloating($2, freefloating.End, append((*$2.GetFreeFloating())[freefloating.End], (*$2.GetFreeFloating())[freefloating.CloseParenthesisToken]...)) + } + yylex.(*Parser).setFreeFloating($2, freefloating.OpenParenthesisToken, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).setFreeFloating($2, freefloating.CloseParenthesisToken, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5698,24 +6067,27 @@ variable: } // save comments - yylex.(*Parser).comments.AddFromToken($3[0], $2, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating($3[0], freefloating.Var, $2.FreeFloating) for _, n := range($3) { switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.PropertyFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.MethodCall: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) } } @@ -5723,18 +6095,21 @@ variable: switch nn := n.(type) { case *expr.ArrayDimFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.PropertyFetch: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) case *expr.MethodCall: nn.Variable = $$ - yylex.(*Parser).positions.AddPosition(nn, yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) + nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) $$ = nn + yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) } } @@ -5775,7 +6150,7 @@ variable_property: $$ = $2 // save comments - yylex.(*Parser).comments.AddFromToken($2[0], $1, comment.ObjectOperatorToken) + yylex.(*Parser).setFreeFloating($2[0], freefloating.Var, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5788,11 +6163,11 @@ array_method_dereference: $$ = append($1, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, $4, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5802,11 +6177,11 @@ array_method_dereference: $$ = []node.Node{$1, fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, $4, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5818,7 +6193,7 @@ method: $$ = expr.NewMethodCall(nil, nil, $1.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5857,7 +6232,7 @@ variable_without_objects: $1.last.SetVarName($2) for _, n := range($1.all) { - yylex.(*Parser).positions[n] = yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2) + n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2)) } $$ = $1.all[0] @@ -5872,10 +6247,11 @@ static_member: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5884,10 +6260,11 @@ static_member: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5908,11 +6285,12 @@ array_function_dereference: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5921,11 +6299,12 @@ array_function_dereference: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5965,7 +6344,7 @@ base_variable: $1.last.SetVarName($2) for _, n := range($1.all) { - yylex.(*Parser).positions[n] = yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2) + n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2)) } $$ = $1.all[0] @@ -5986,11 +6365,12 @@ reference_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5999,11 +6379,12 @@ reference_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6023,11 +6404,12 @@ compound_variable: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6036,12 +6418,13 @@ compound_variable: $$ = expr.NewVariable($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($3, freefloating.Start, append($2.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($2), (*$3.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($3, freefloating.End, append((*$3.GetFreeFloating())[freefloating.End], append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6076,7 +6459,7 @@ object_property: $$ = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6089,11 +6472,11 @@ object_dim_list: $$ = append($1, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(fetch, $4, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6103,11 +6486,11 @@ object_dim_list: $$ = append($1, fetch) // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(fetch, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(fetch, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6117,7 +6500,7 @@ object_dim_list: $$ = []node.Node{fetch} // save position - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6129,10 +6512,10 @@ variable_name: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6141,11 +6524,11 @@ variable_name: $$ = $2 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6158,10 +6541,11 @@ simple_indirect_reference: $$ = simpleIndirectReference{[]*expr.Variable{n}, n} // save position - yylex.(*Parser).positions.AddPosition(n, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(n, $1, comment.DollarToken) + yylex.(*Parser).setFreeFloating(n, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6175,10 +6559,11 @@ simple_indirect_reference: $$ = $1 // save position - yylex.(*Parser).positions.AddPosition(n, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken(n, $2, comment.DollarToken) + yylex.(*Parser).setFreeFloating(n, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6188,21 +6573,19 @@ assignment_list: assignment_list ',' assignment_list_element { if len($1) == 0 { - $1 = []node.Node{nil} + $1 = []node.Node{expr.NewArrayItem(nil, nil)} } $$ = append($1, $3) // save comments - if lastNode($1) != nil { - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - } + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | assignment_list_element { - if $1 == nil { + if $1.(*expr.ArrayItem).Key == nil && $1.(*expr.ArrayItem).Val == nil { $$ = []node.Node{} } else { $$ = []node.Node{$1} @@ -6219,29 +6602,32 @@ assignment_list_element: $$ = expr.NewArrayItem(nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_LIST '(' assignment_list ')' { - item := expr.NewList($3) - $$ = expr.NewArrayItem(nil, item) + listNode := expr.NewList($3) + $$ = expr.NewArrayItem(nil, listNode) // save position - yylex.(*Parser).positions.AddPosition(item, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition(item)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(listNode)) // save comments - yylex.(*Parser).comments.AddFromToken(item, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(item, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(item, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | /* empty */ { - $$ = nil + $$ = expr.NewArrayItem(nil, nil) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6260,12 +6646,12 @@ array_pair_list: $$ = $1 if $2 != nil { - $$ = append($1, nil) + $$ = append($1, expr.NewArrayItem(nil, nil)) } // save comments if $2 != nil { - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -6279,11 +6665,12 @@ non_empty_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, $4, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).MoveFreeFloating($3, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6293,10 +6680,11 @@ non_empty_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition($3)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).MoveFreeFloating($3, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6306,10 +6694,11 @@ non_empty_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, $2, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating($1, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6319,7 +6708,10 @@ non_empty_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, arrayItem) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6330,13 +6722,14 @@ non_empty_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition($5, $6)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($3, $6)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($5, $6)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(arrayItem, $4, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, $5, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).MoveFreeFloating($3, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6347,12 +6740,12 @@ non_empty_array_pair_list: $$ = append($1, arrayItem) // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - yylex.(*Parser).comments.AddFromToken(reference, $3, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6363,12 +6756,13 @@ non_empty_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(arrayItem, $2, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, $3, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, arrayItem) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6379,11 +6773,11 @@ non_empty_array_pair_list: $$ = []node.Node{arrayItem} // save position - yylex.(*Parser).positions.AddPosition(reference, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - yylex.(*Parser).positions.AddPosition(arrayItem, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, $1, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6402,10 +6796,10 @@ encaps_list: $$ = append($1, encapsed) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, $2, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6421,10 +6815,10 @@ encaps_list: $$ = []node.Node{encapsed, $2} // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, $1, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6437,11 +6831,12 @@ encaps_var: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6452,14 +6847,14 @@ encaps_var: $$ = expr.NewArrayDimFetch(variable, $3) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6471,44 +6866,47 @@ encaps_var: $$ = expr.NewPropertyFetch(variable, fetch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) - yylex.(*Parser).comments.AddFromToken(fetch, $3, comment.StringToken) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { - $$ = expr.NewVariable($2) + variable := expr.NewVariable($2) + + $$ = variable // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { name := node.NewIdentifier($2.Value) - $$ = expr.NewVariable(name) + variable := expr.NewVariable(name) + + $$ = variable // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6519,16 +6917,15 @@ encaps_var: $$ = expr.NewArrayDimFetch(variable, $4) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(variable, $2, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($5.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($5)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($6.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($6)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6536,6 +6933,10 @@ encaps_var: { $$ = $2; + // save comments + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } ; @@ -6546,10 +6947,10 @@ encaps_var_offset: $$ = scalar.NewString($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6563,10 +6964,10 @@ encaps_var_offset: } // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NumStringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6576,11 +6977,12 @@ encaps_var_offset: $$ = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6592,12 +6994,12 @@ internal_functions_in_yacc: $$ = expr.NewIsset($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IssetToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Isset, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6606,12 +7008,12 @@ internal_functions_in_yacc: $$ = expr.NewEmpty($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Empty, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6620,12 +7022,12 @@ internal_functions_in_yacc: $$ = expr.NewEmpty($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Empty, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6634,10 +7036,10 @@ internal_functions_in_yacc: $$ = expr.NewInclude($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncludeToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6646,10 +7048,10 @@ internal_functions_in_yacc: $$ = expr.NewIncludeOnce($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncludeOnceToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6658,12 +7060,12 @@ internal_functions_in_yacc: $$ = expr.NewEval($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EvalToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Eval, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6672,10 +7074,10 @@ internal_functions_in_yacc: $$ = expr.NewRequire($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.RequireToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6684,10 +7086,10 @@ internal_functions_in_yacc: $$ = expr.NewRequireOnce($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.RequireOnceToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6705,7 +7107,7 @@ isset_variables: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6733,11 +7135,13 @@ class_constant: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6747,11 +7151,13 @@ class_constant: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6764,11 +7170,13 @@ static_class_name_scalar: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -6781,11 +7189,13 @@ class_name_scalar: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } diff --git a/php5/php5_test.go b/php5/php5_test.go index f753d5d..dbf370f 100644 --- a/php5/php5_test.go +++ b/php5/php5_test.go @@ -2,37 +2,23 @@ package php5_test import ( "bytes" - "reflect" "testing" - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/errors" + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/assign" "github.com/z7zmey/php-parser/node/expr/binary" "github.com/z7zmey/php-parser/node/expr/cast" "github.com/z7zmey/php-parser/node/name" "github.com/z7zmey/php-parser/node/scalar" + "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/position" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/node/stmt" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - - } -} - func TestPhp5(t *testing.T) { src := ` "}, - &stmt.Interface{ - PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{}, + &stmt.Nop{ + Position: &position.Position{ + StartLine: 105, + EndLine: 105, + StartPos: 2451, + EndPos: 2452, + }, + }, + &stmt.InlineHtml{ + Position: &position.Position{ + StartLine: 105, + EndLine: 105, + StartPos: 2454, + EndPos: 2465, + }, + Value: "
", }, &stmt.Interface{ + Position: &position.Position{ + StartLine: 106, + EndLine: 106, + StartPos: 2471, + EndPos: 2486, + }, PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 106, + EndLine: 106, + StartPos: 2481, + EndPos: 2483, + }, + Value: "Foo", + }, + Stmts: []node.Node{}, + }, + &stmt.Interface{ + Position: &position.Position{ + StartLine: 107, + EndLine: 107, + StartPos: 2490, + EndPos: 2517, + }, + PhpDocComment: "", + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 107, + EndLine: 107, + StartPos: 2500, + EndPos: 2502, + }, + Value: "Foo", + }, Extends: &stmt.InterfaceExtends{ + Position: &position.Position{ + StartLine: 107, + EndLine: 107, + StartPos: 2504, + EndPos: 2514, + }, InterfaceNames: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 107, + EndLine: 107, + StartPos: 2512, + EndPos: 2514, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 107, + EndLine: 107, + StartPos: 2512, + EndPos: 2514, + }, + Value: "Bar", + }, }, }, }, @@ -1253,18 +5462,66 @@ func TestPhp5(t *testing.T) { Stmts: []node.Node{}, }, &stmt.Interface{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2521, + EndPos: 2553, + }, PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2531, + EndPos: 2533, + }, + Value: "Foo", + }, Extends: &stmt.InterfaceExtends{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2535, + EndPos: 2550, + }, InterfaceNames: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2543, + EndPos: 2545, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2543, + EndPos: 2545, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2548, + EndPos: 2550, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 108, + EndLine: 108, + StartPos: 2548, + EndPos: 2550, + }, + Value: "Baz", + }, }, }, }, @@ -1272,245 +5529,1085 @@ func TestPhp5(t *testing.T) { Stmts: []node.Node{}, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 109, + EndLine: 109, + StartPos: 2557, + EndPos: 2570, + }, NamespaceName: &name.Name{ + Position: &position.Position{ + StartLine: 109, + EndLine: 109, + StartPos: 2567, + EndPos: 2569, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 109, + EndLine: 109, + StartPos: 2567, + EndPos: 2569, + }, + Value: "Foo", + }, }, }, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 110, + EndLine: 110, + StartPos: 2574, + EndPos: 2593, + }, NamespaceName: &name.Name{ + Position: &position.Position{ + StartLine: 110, + EndLine: 110, + StartPos: 2584, + EndPos: 2590, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 110, + EndLine: 110, + StartPos: 2584, + EndPos: 2586, + }, + Value: "Foo", + }, + &name.NamePart{ + Position: &position.Position{ + StartLine: 110, + EndLine: 110, + StartPos: 2588, + EndPos: 2590, + }, + Value: "Bar", + }, }, }, Stmts: []node.Node{}, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 111, + EndLine: 111, + StartPos: 2597, + EndPos: 2608, + }, Stmts: []node.Node{}, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2612, + EndPos: 2630, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2618, + EndPos: 2620, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.PropertyList{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2623, + EndPos: 2629, + }, Modifiers: []node.Node{ - &node.Identifier{Value: "var"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2623, + EndPos: 2625, + }, + Value: "var", + }, }, Properties: []node.Node{ &stmt.Property{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2627, + EndPos: 2628, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2627, + EndPos: 2628, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2627, + EndPos: 2628, + }, + Value: "a", + }, + }, }, }, }, }, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2634, + EndPos: 2670, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2640, + EndPos: 2642, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.PropertyList{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2645, + EndPos: 2669, + }, Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - &node.Identifier{Value: "static"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2645, + EndPos: 2650, + }, + Value: "public", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2652, + EndPos: 2657, + }, + Value: "static", + }, }, Properties: []node.Node{ &stmt.Property{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2659, + EndPos: 2660, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2659, + EndPos: 2660, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2659, + EndPos: 2660, + }, + Value: "a", + }, + }, }, &stmt.Property{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2663, + EndPos: 2668, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2663, + EndPos: 2664, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2663, + EndPos: 2664, + }, + Value: "b", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2668, + EndPos: 2668, + }, + Value: "1", + }, }, }, }, }, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2674, + EndPos: 2710, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2680, + EndPos: 2682, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.PropertyList{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2685, + EndPos: 2709, + }, Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - &node.Identifier{Value: "static"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2685, + EndPos: 2690, + }, + Value: "public", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2692, + EndPos: 2697, + }, + Value: "static", + }, }, Properties: []node.Node{ &stmt.Property{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2699, + EndPos: 2704, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2699, + EndPos: 2700, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2699, + EndPos: 2700, + }, + Value: "a", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2704, + EndPos: 2704, + }, + Value: "1", + }, }, &stmt.Property{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2707, + EndPos: 2708, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2707, + EndPos: 2708, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2707, + EndPos: 2708, + }, + Value: "b", + }, + }, }, }, }, }, }, &stmt.Static{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2714, + EndPos: 2731, + }, Vars: []node.Node{ &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2721, + EndPos: 2722, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2721, + EndPos: 2722, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2721, + EndPos: 2722, + }, + Value: "a", + }, + }, }, &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2725, + EndPos: 2730, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2725, + EndPos: 2726, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2725, + EndPos: 2726, + }, + Value: "b", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2730, + EndPos: 2730, + }, + Value: "1", + }, }, }, }, &stmt.Static{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2735, + EndPos: 2752, + }, Vars: []node.Node{ &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2742, + EndPos: 2747, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2742, + EndPos: 2743, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2742, + EndPos: 2743, + }, + Value: "a", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2747, + EndPos: 2747, + }, + Value: "1", + }, }, &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2750, + EndPos: 2751, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2750, + EndPos: 2751, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2750, + EndPos: 2751, + }, + Value: "b", + }, + }, }, }, }, &stmt.AltSwitch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 118, + EndLine: 122, + StartPos: 2757, + EndPos: 2815, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2765, + EndPos: 2765, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 119, + EndLine: -1, + StartPos: 2773, + EndPos: -1, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 119, + EndLine: -1, + StartPos: 2773, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2778, + EndPos: 2778, + }, + Value: "1", + }, Stmts: []node.Node{}, }, &stmt.Default{ + Position: &position.Position{ + StartLine: 120, + EndLine: -1, + StartPos: 2784, + EndPos: -1, + }, Stmts: []node.Node{}, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 121, + EndLine: -1, + StartPos: 2796, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 121, + EndLine: 121, + StartPos: 2801, + EndPos: 2801, + }, + Value: "2", + }, Stmts: []node.Node{}, }, }, }, }, &stmt.AltSwitch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 124, + EndLine: 127, + StartPos: 2820, + EndPos: 2867, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 124, + EndLine: 124, + StartPos: 2828, + EndPos: 2828, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 125, + EndLine: -1, + StartPos: 2837, + EndPos: -1, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 125, + EndLine: -1, + StartPos: 2837, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 125, + EndLine: 125, + StartPos: 2842, + EndPos: 2842, + }, + Value: "1", + }, Stmts: []node.Node{}, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 126, + EndLine: -1, + StartPos: 2848, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 126, + EndLine: 126, + StartPos: 2853, + EndPos: 2853, + }, + Value: "2", + }, Stmts: []node.Node{}, }, }, }, }, &stmt.Switch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 129, + EndLine: 132, + StartPos: 2874, + EndPos: 2925, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 129, + EndLine: 129, + StartPos: 2882, + EndPos: 2882, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 129, + EndLine: 132, + StartPos: 2885, + EndPos: 2925, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 130, + EndLine: 130, + StartPos: 2890, + EndPos: 2903, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 130, + EndLine: 130, + StartPos: 2895, + EndPos: 2895, + }, + Value: "1", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 130, + EndLine: 130, + StartPos: 2898, + EndPos: 2903, + }, + }, }, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 131, + EndLine: 131, + StartPos: 2908, + EndPos: 2921, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 131, + EndLine: 131, + StartPos: 2913, + EndPos: 2913, + }, + Value: "2", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 131, + EndLine: 131, + StartPos: 2916, + EndPos: 2921, + }, + }, }, }, }, }, }, &stmt.Switch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 134, + EndLine: 137, + StartPos: 2932, + EndPos: 2984, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 134, + EndLine: 134, + StartPos: 2940, + EndPos: 2940, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 134, + EndLine: 137, + StartPos: 2943, + EndPos: 2984, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 2949, + EndPos: 2962, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 2954, + EndPos: 2954, + }, + Value: "1", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 2957, + EndPos: 2962, + }, + }, }, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 136, + EndLine: 136, + StartPos: 2967, + EndPos: 2980, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 136, + EndLine: 136, + StartPos: 2972, + EndPos: 2972, + }, + Value: "2", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 136, + EndLine: 136, + StartPos: 2975, + EndPos: 2980, + }, + }, }, }, }, }, }, &stmt.Throw{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, + Position: &position.Position{ + StartLine: 138, + EndLine: 138, + StartPos: 2988, + EndPos: 2996, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 138, + EndLine: 138, + StartPos: 2994, + EndPos: 2995, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 138, + EndLine: 138, + StartPos: 2994, + EndPos: 2995, + }, + Value: "e", + }, + }, }, &stmt.Trait{ + Position: &position.Position{ + StartLine: 139, + EndLine: 139, + StartPos: 3000, + EndPos: 3011, + }, PhpDocComment: "", - TraitName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{}, + TraitName: &node.Identifier{ + Position: &position.Position{ + StartLine: 139, + EndLine: 139, + StartPos: 3006, + EndPos: 3008, + }, + Value: "Foo", + }, + Stmts: []node.Node{}, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3015, + EndPos: 3036, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3021, + EndPos: 3023, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3027, + EndPos: 3034, + }, Traits: []node.Node{ &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3031, + EndPos: 3033, }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3031, + EndPos: 3033, + }, + Value: "Bar", + }, + }, + }, + }, + TraitAdaptationList: &stmt.Nop{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3034, + EndPos: 3034, }, }, }, }, }, &stmt.Class{ - PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{ - &stmt.TraitUse{ - Traits: []node.Node{ - &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, - }, - }, - &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{}, - }, + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3040, + EndPos: 3068, }, - }, - &stmt.Class{ PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3046, + EndPos: 3048, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3052, + EndPos: 3066, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3056, + EndPos: 3058, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3056, + EndPos: 3058, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3061, + EndPos: 3063, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3061, + EndPos: 3063, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 141, + EndLine: 141, + StartPos: 3065, + EndPos: 3066, + }, + }, + }, + }, + }, + &stmt.Class{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3072, + EndPos: 3116, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3078, + EndPos: 3080, + }, + Value: "Foo", + }, + Stmts: []node.Node{ + &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3084, + EndPos: 3114, + }, + Traits: []node.Node{ + &name.Name{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3088, + EndPos: 3090, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3088, + EndPos: 3090, + }, + Value: "Bar", + }, + }, + }, + &name.Name{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3093, + EndPos: 3095, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3093, + EndPos: 3095, + }, + Value: "Baz", + }, + }, + }, + }, + TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3097, + EndPos: 3114, + }, Adaptations: []node.Node{ &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "one"}, + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3099, + EndPos: 3111, + }, + Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3099, + EndPos: 3101, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3099, + EndPos: 3101, + }, + Value: "one", + }, + }, + Modifier: &node.Identifier{ + Position: &position.Position{ + StartLine: 142, + EndLine: 142, + StartPos: 3106, + EndPos: 3111, + }, + Value: "public", }, - Modifier: &node.Identifier{Value: "public"}, }, }, }, @@ -1518,30 +6615,120 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3120, + EndPos: 3168, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3126, + EndPos: 3128, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3132, + EndPos: 3166, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3136, + EndPos: 3138, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3136, + EndPos: 3138, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3141, + EndPos: 3143, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3141, + EndPos: 3143, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3145, + EndPos: 3166, + }, Adaptations: []node.Node{ &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "one"}, + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3147, + EndPos: 3163, + }, + Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3147, + EndPos: 3149, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3147, + EndPos: 3149, + }, + Value: "one", + }, + }, + Modifier: &node.Identifier{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3154, + EndPos: 3159, + }, + Value: "public", + }, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3161, + EndPos: 3163, + }, + Value: "two", }, - Modifier: &node.Identifier{Value: "public"}, - Alias: &node.Identifier{Value: "two"}, }, }, }, @@ -1549,56 +6736,214 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3172, + EndPos: 3248, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3178, + EndPos: 3180, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3184, + EndPos: 3246, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3188, + EndPos: 3190, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3188, + EndPos: 3190, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3193, + EndPos: 3195, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3193, + EndPos: 3195, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3197, + EndPos: 3246, + }, Adaptations: []node.Node{ &stmt.TraitUsePrecedence{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3199, + EndPos: 3226, + }, Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3199, + EndPos: 3206, + }, Trait: &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3199, + EndPos: 3201, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3199, + EndPos: 3201, + }, + Value: "Bar", + }, }, }, - Method: &node.Identifier{Value: "one"}, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3204, + EndPos: 3206, + }, + Value: "one", + }, }, Insteadof: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3218, + EndPos: 3220, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3218, + EndPos: 3220, + }, + Value: "Baz", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3223, + EndPos: 3226, + }, Parts: []node.Node{ - &name.NamePart{Value: "Quux"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3223, + EndPos: 3226, + }, + Value: "Quux", + }, }, }, }, }, &stmt.TraitUseAlias{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3229, + EndPos: 3243, + }, Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3229, + EndPos: 3236, + }, Trait: &name.Name{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3229, + EndPos: 3231, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3229, + EndPos: 3231, + }, + Value: "Baz", + }, }, }, - Method: &node.Identifier{Value: "one"}, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3234, + EndPos: 3236, + }, + Value: "one", + }, + }, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 144, + EndLine: 144, + StartPos: 3241, + EndPos: 3243, + }, + Value: "two", }, - Alias: &node.Identifier{Value: "two"}, }, }, }, @@ -1606,545 +6951,2446 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 146, + EndLine: -1, + StartPos: 3253, + EndPos: -1, + }, Stmts: []node.Node{}, Catches: []node.Node{}, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3262, + EndPos: 3291, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3269, + EndPos: 3291, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3276, + EndPos: 3284, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3276, + EndPos: 3284, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3286, + EndPos: 3287, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3286, + EndPos: 3287, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3295, + EndPos: 3355, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3302, + EndPos: 3324, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3309, + EndPos: 3317, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3309, + EndPos: 3317, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3319, + EndPos: 3320, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3319, + EndPos: 3320, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, &stmt.Catch{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3326, + EndPos: 3355, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3333, + EndPos: 3348, + }, Parts: []node.Node{ - &name.NamePart{Value: "RuntimeException"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3333, + EndPos: 3348, + }, + Value: "RuntimeException", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3350, + EndPos: 3351, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3350, + EndPos: 3351, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3359, + EndPos: 3462, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3366, + EndPos: 3388, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3373, + EndPos: 3381, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3373, + EndPos: 3381, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3383, + EndPos: 3384, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3383, + EndPos: 3384, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, &stmt.Catch{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3390, + EndPos: 3420, + }, Types: []node.Node{ &name.FullyQualified{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3397, + EndPos: 3413, + }, Parts: []node.Node{ - &name.NamePart{Value: "RuntimeException"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3398, + EndPos: 3413, + }, + Value: "RuntimeException", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3415, + EndPos: 3416, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3415, + EndPos: 3416, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, &stmt.Catch{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3422, + EndPos: 3462, + }, Types: []node.Node{ &name.Relative{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3429, + EndPos: 3455, + }, Parts: []node.Node{ - &name.NamePart{Value: "AdditionException"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3439, + EndPos: 3455, + }, + Value: "AdditionException", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3457, + EndPos: 3458, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3457, + EndPos: 3458, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3466, + EndPos: 3506, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3473, + EndPos: 3495, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3480, + EndPos: 3488, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3480, + EndPos: 3488, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3490, + EndPos: 3491, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3490, + EndPos: 3491, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, Finally: &stmt.Finally{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3497, + EndPos: 3506, + }, Stmts: []node.Node{}, }, }, &stmt.Unset{ + Position: &position.Position{ + StartLine: 152, + EndLine: 152, + StartPos: 3511, + EndPos: 3524, + }, Vars: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + &expr.Variable{ + Position: &position.Position{ + StartLine: 152, + EndLine: 152, + StartPos: 3517, + EndPos: 3518, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 152, + EndLine: 152, + StartPos: 3517, + EndPos: 3518, + }, + Value: "a", + }, + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 152, + EndLine: 152, + StartPos: 3521, + EndPos: 3522, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 152, + EndLine: 152, + StartPos: 3521, + EndPos: 3522, + }, + Value: "b", + }, + }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3529, + EndPos: 3536, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3533, + EndPos: 3535, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3533, + EndPos: 3535, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3533, + EndPos: 3535, + }, + Value: "Foo", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3540, + EndPos: 3548, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3545, + EndPos: 3547, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3545, + EndPos: 3547, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3545, + EndPos: 3547, + }, + Value: "Foo", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3552, + EndPos: 3567, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3557, + EndPos: 3566, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3557, + EndPos: 3559, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3557, + EndPos: 3559, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "Bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3564, + EndPos: 3566, + }, + Value: "Bar", + }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3571, + EndPos: 3583, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3575, + EndPos: 3577, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3575, + EndPos: 3577, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3575, + EndPos: 3577, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3580, + EndPos: 3582, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3580, + EndPos: 3582, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3580, + EndPos: 3582, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3587, + EndPos: 3606, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3591, + EndPos: 3593, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3591, + EndPos: 3593, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3591, + EndPos: 3593, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3596, + EndPos: 3605, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3596, + EndPos: 3598, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3596, + EndPos: 3598, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "Baz"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 158, + EndLine: 158, + StartPos: 3603, + EndPos: 3605, + }, + Value: "Baz", + }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3610, + EndPos: 3632, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3614, + EndPos: 3621, + }, + Value: "function", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3623, + EndPos: 3625, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3623, + EndPos: 3625, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3623, + EndPos: 3625, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3629, + EndPos: 3631, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3629, + EndPos: 3631, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3629, + EndPos: 3631, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3636, + EndPos: 3672, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3640, + EndPos: 3647, + }, + Value: "function", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3649, + EndPos: 3658, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3649, + EndPos: 3651, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3649, + EndPos: 3651, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "foo"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3656, + EndPos: 3658, + }, + Value: "foo", + }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3662, + EndPos: 3671, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3662, + EndPos: 3664, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3662, + EndPos: 3664, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 160, + EndLine: 160, + StartPos: 3669, + EndPos: 3671, + }, + Value: "bar", + }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3676, + EndPos: 3695, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3680, + EndPos: 3684, + }, + Value: "const", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3686, + EndPos: 3688, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3686, + EndPos: 3688, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3686, + EndPos: 3688, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3692, + EndPos: 3694, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3692, + EndPos: 3694, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3692, + EndPos: 3694, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3699, + EndPos: 3732, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3703, + EndPos: 3707, + }, + Value: "const", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3709, + EndPos: 3718, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3709, + EndPos: 3711, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3709, + EndPos: 3711, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "foo"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3716, + EndPos: 3718, + }, + Value: "foo", + }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3722, + EndPos: 3731, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3722, + EndPos: 3724, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3722, + EndPos: 3724, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3729, + EndPos: 3731, + }, + Value: "bar", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3737, + EndPos: 3742, + }, Expr: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Dim: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3737, + EndPos: 3741, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3737, + EndPos: 3738, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3737, + EndPos: 3738, + }, + Value: "a", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3740, + EndPos: 3740, + }, + Value: "1", + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3746, + EndPos: 3754, + }, Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3746, + EndPos: 3753, + }, Variable: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Dim: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3746, + EndPos: 3750, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3746, + EndPos: 3747, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3746, + EndPos: 3747, + }, + Value: "a", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3749, + EndPos: 3749, + }, + Value: "1", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3752, + EndPos: 3752, + }, + Value: "2", }, - Dim: &scalar.Lnumber{Value: "2"}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3758, + EndPos: 3765, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3758, + EndPos: 3764, + }, Items: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3769, + EndPos: 3777, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3769, + EndPos: 3776, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.Array{ - Items: []node.Node{ - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - nil, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.Array{ - Items: []node.Node{ - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "3"}, - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.Array{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "3"}, - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.BitwiseNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.BooleanNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ConstantName: &node.Identifier{Value: "Bar"}, - }, - }, - &stmt.Expression{ - Expr: &expr.Clone{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Clone{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - ClosureUse: &expr.ClosureUse{ - Uses: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - ClosureUse: &expr.ClosureUse{ - Uses: []node.Node{ - &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "c"}}}, - &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.Relative{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Empty{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Empty{ - Expr: &expr.ConstFetch{ - Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.ErrorSuppress{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Eval{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Exit{}, - }, - &stmt.Expression{ - Expr: &expr.Exit{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Die{}, - }, - &stmt.Expression{ - Expr: &expr.Die{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - ArgumentList: &node.ArgumentList{ - Arguments: []node.Node{ - &node.Argument{ - Variadic: false, - IsReference: true, - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3775, + EndPos: 3775, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3775, + EndPos: 3775, + }, + Value: "1", }, }, }, }, }, &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3781, + EndPos: 3798, + }, + Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3781, + EndPos: 3797, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3787, + EndPos: 3790, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3787, + EndPos: 3787, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3790, + EndPos: 3790, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3793, + EndPos: 3795, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3793, + EndPos: 3795, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3794, + EndPos: 3795, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3794, + EndPos: 3795, + }, + Value: "b", + }, + }, + }, + }, + &expr.ArrayItem{}, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3802, + EndPos: 3816, + }, + Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3802, + EndPos: 3815, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3808, + EndPos: 3814, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3808, + EndPos: 3808, + }, + Value: "3", + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3812, + EndPos: 3814, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3813, + EndPos: 3814, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3813, + EndPos: 3814, + }, + Value: "b", + }, + }, + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3820, + EndPos: 3848, + }, + Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3820, + EndPos: 3847, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3826, + EndPos: 3828, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3826, + EndPos: 3828, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3827, + EndPos: 3828, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3827, + EndPos: 3828, + }, + Value: "b", + }, + }, + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3831, + EndPos: 3834, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3831, + EndPos: 3831, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3834, + EndPos: 3834, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3837, + EndPos: 3837, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3837, + EndPos: 3837, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3840, + EndPos: 3846, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3840, + EndPos: 3840, + }, + Value: "3", + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3844, + EndPos: 3846, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3845, + EndPos: 3846, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 170, + EndLine: 170, + StartPos: 3845, + EndPos: 3846, + }, + Value: "b", + }, + }, + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3852, + EndPos: 3855, + }, + Expr: &expr.BitwiseNot{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3852, + EndPos: 3854, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3853, + EndPos: 3854, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3853, + EndPos: 3854, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3859, + EndPos: 3862, + }, + Expr: &expr.BooleanNot{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3859, + EndPos: 3861, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3860, + EndPos: 3861, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3860, + EndPos: 3861, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3867, + EndPos: 3875, + }, + Expr: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3867, + EndPos: 3874, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3867, + EndPos: 3869, + }, Parts: []node.Node{ - &name.NamePart{Value: "foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3867, + EndPos: 3869, + }, + Value: "Foo", + }, + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3872, + EndPos: 3874, + }, + Value: "Bar", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3879, + EndPos: 3888, + }, + Expr: &expr.Clone{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3879, + EndPos: 3886, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3885, + EndPos: 3886, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3885, + EndPos: 3886, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 176, + EndLine: 176, + StartPos: 3892, + EndPos: 3900, + }, + Expr: &expr.Clone{ + Position: &position.Position{ + StartLine: 176, + EndLine: 176, + StartPos: 3892, + EndPos: 3899, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 176, + EndLine: 176, + StartPos: 3898, + EndPos: 3899, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 176, + EndLine: 176, + StartPos: 3898, + EndPos: 3899, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3904, + EndPos: 3916, + }, + Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3904, + EndPos: 3915, + }, + PhpDocComment: "", + ReturnsRef: false, + Static: false, + Stmts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3920, + EndPos: 3953, + }, + Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3920, + EndPos: 3952, + }, + ReturnsRef: false, + Static: false, + PhpDocComment: "", + Params: []node.Node{ + &node.Parameter{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3929, + EndPos: 3930, + }, + ByRef: false, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3929, + EndPos: 3930, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3929, + EndPos: 3930, + }, + Value: "a", + }, + }, + }, + &node.Parameter{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3933, + EndPos: 3934, + }, + ByRef: false, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3933, + EndPos: 3934, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3933, + EndPos: 3934, + }, + Value: "b", + }, + }, + }, + }, + ClosureUse: &expr.ClosureUse{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3937, + EndPos: 3949, + }, + Uses: []node.Node{ + &expr.Variable{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3942, + EndPos: 3943, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3942, + EndPos: 3943, + }, + Value: "c", + }, + }, + &expr.Reference{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3946, + EndPos: 3948, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3947, + EndPos: 3948, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3947, + EndPos: 3948, + }, + Value: "d", + }, + }, + }, + }, + }, + Stmts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3957, + EndPos: 3990, + }, + Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3957, + EndPos: 3989, + }, + ReturnsRef: false, + Static: false, + PhpDocComment: "", + Params: []node.Node{ + &node.Parameter{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3966, + EndPos: 3967, + }, + ByRef: false, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3966, + EndPos: 3967, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3966, + EndPos: 3967, + }, + Value: "a", + }, + }, + }, + &node.Parameter{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3970, + EndPos: 3971, + }, + ByRef: false, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3970, + EndPos: 3971, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3970, + EndPos: 3971, + }, + Value: "b", + }, + }, + }, + }, + ClosureUse: &expr.ClosureUse{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3974, + EndPos: 3986, + }, + Uses: []node.Node{ + &expr.Reference{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3979, + EndPos: 3981, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3980, + EndPos: 3981, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3980, + EndPos: 3981, + }, + Value: "c", + }, + }, + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3984, + EndPos: 3985, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 3984, + EndPos: 3985, + }, + Value: "d", + }, + }, + }, + }, + Stmts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 3994, + EndPos: 4007, + }, + Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 3994, + EndPos: 4006, + }, + ReturnsRef: false, + Static: false, + PhpDocComment: "", + Stmts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4011, + EndPos: 4014, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4011, + EndPos: 4013, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4011, + EndPos: 4013, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4011, + EndPos: 4013, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4018, + EndPos: 4031, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4018, + EndPos: 4030, + }, + Constant: &name.Relative{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4018, + EndPos: 4030, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4028, + EndPos: 4030, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4035, + EndPos: 4039, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4035, + EndPos: 4038, + }, + Constant: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4035, + EndPos: 4038, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4036, + EndPos: 4038, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4044, + EndPos: 4053, + }, + Expr: &expr.Empty{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4044, + EndPos: 4052, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4050, + EndPos: 4051, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4050, + EndPos: 4051, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4057, + EndPos: 4067, + }, + Expr: &expr.Empty{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4057, + EndPos: 4066, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4063, + EndPos: 4065, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4063, + EndPos: 4065, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4063, + EndPos: 4065, + }, + Value: "Foo", + }, + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4071, + EndPos: 4074, + }, + Expr: &expr.ErrorSuppress{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4071, + EndPos: 4073, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4072, + EndPos: 4073, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4072, + EndPos: 4073, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4078, + EndPos: 4086, + }, + Expr: &expr.Eval{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4078, + EndPos: 4085, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4083, + EndPos: 4084, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4083, + EndPos: 4084, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 189, + EndLine: 189, + StartPos: 4090, + EndPos: 4094, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 189, + EndLine: 189, + StartPos: 4090, + EndPos: 4093, + }, + Die: false, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4098, + EndPos: 4106, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4098, + EndPos: 4105, + }, + Die: false, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4103, + EndPos: 4104, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4103, + EndPos: 4104, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4110, + EndPos: 4115, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4110, + EndPos: 4114, + }, + Die: true, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4119, + EndPos: 4126, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4119, + EndPos: 4125, + }, + Die: true, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4123, + EndPos: 4124, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4123, + EndPos: 4124, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4130, + EndPos: 4135, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4130, + EndPos: 4134, + }, + Function: &name.Name{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4130, + EndPos: 4132, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4130, + EndPos: 4132, + }, + Value: "foo", + }, }, }, ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4133, + EndPos: 4134, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4139, + EndPos: 4157, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4139, + EndPos: 4156, + }, + Function: &name.Relative{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4139, + EndPos: 4151, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4149, + EndPos: 4151, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4152, + EndPos: 4156, + }, Arguments: []node.Node{ &node.Argument{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4154, + EndPos: 4155, + }, + Variadic: false, + IsReference: true, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4154, + EndPos: 4155, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4154, + EndPos: 4155, + }, + Value: "a", + }, + }, + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4161, + EndPos: 4169, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4161, + EndPos: 4168, + }, + Function: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4161, + EndPos: 4164, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4162, + EndPos: 4164, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4165, + EndPos: 4168, + }, + Arguments: []node.Node{ + &node.Argument{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4166, + EndPos: 4167, + }, Variadic: false, IsReference: false, Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 195, + EndLine: 195, + StartPos: 4166, + EndPos: 4167, + }, Items: []node.Node{}, }, }, @@ -2153,15 +9399,77 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4173, + EndPos: 4187, + }, Expr: &expr.FunctionCall{ - Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4173, + EndPos: 4186, + }, + Function: &expr.Variable{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4173, + EndPos: 4176, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4173, + EndPos: 4176, + }, + Value: "foo", + }, + }, ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4177, + EndPos: 4186, + }, Arguments: []node.Node{ &node.Argument{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4178, + EndPos: 4185, + }, Variadic: false, IsReference: false, Expr: &expr.Yield{ - Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4178, + EndPos: 4185, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4184, + EndPos: 4185, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4184, + EndPos: 4185, + }, + Value: "a", + }, + }, }, }, }, @@ -2169,1392 +9477,8159 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4192, + EndPos: 4196, + }, Expr: &expr.PostDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4192, + EndPos: 4195, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4192, + EndPos: 4193, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4192, + EndPos: 4193, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4200, + EndPos: 4204, + }, Expr: &expr.PostInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4200, + EndPos: 4203, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4200, + EndPos: 4201, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4200, + EndPos: 4201, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4208, + EndPos: 4212, + }, Expr: &expr.PreDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4208, + EndPos: 4211, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4210, + EndPos: 4211, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4210, + EndPos: 4211, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4216, + EndPos: 4220, + }, Expr: &expr.PreInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4216, + EndPos: 4219, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4218, + EndPos: 4219, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4218, + EndPos: 4219, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4225, + EndPos: 4235, + }, Expr: &expr.Include{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4225, + EndPos: 4234, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4233, + EndPos: 4234, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4233, + EndPos: 4234, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4239, + EndPos: 4254, + }, Expr: &expr.IncludeOnce{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4239, + EndPos: 4253, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4252, + EndPos: 4253, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4252, + EndPos: 4253, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4258, + EndPos: 4268, + }, Expr: &expr.Require{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4258, + EndPos: 4267, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4266, + EndPos: 4267, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4266, + EndPos: 4267, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4272, + EndPos: 4287, + }, Expr: &expr.RequireOnce{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4272, + EndPos: 4286, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4285, + EndPos: 4286, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4285, + EndPos: 4286, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4292, + EndPos: 4309, + }, Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4292, + EndPos: 4308, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4292, + EndPos: 4293, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4292, + EndPos: 4293, + }, + Value: "a", + }, + }, Class: &name.Name{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4306, + EndPos: 4308, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4306, + EndPos: 4308, + }, + Value: "Foo", + }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4313, + EndPos: 4340, + }, Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4313, + EndPos: 4339, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4313, + EndPos: 4314, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4313, + EndPos: 4314, + }, + Value: "a", + }, + }, Class: &name.Relative{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4327, + EndPos: 4339, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4337, + EndPos: 4339, + }, + Value: "Foo", + }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4344, + EndPos: 4362, + }, Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4344, + EndPos: 4361, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4344, + EndPos: 4345, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4344, + EndPos: 4345, + }, + Value: "a", + }, + }, Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4358, + EndPos: 4361, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4359, + EndPos: 4361, + }, + Value: "Foo", + }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4367, + EndPos: 4380, + }, Expr: &expr.Isset{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4367, + EndPos: 4379, + }, Variables: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + &expr.Variable{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4373, + EndPos: 4374, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4373, + EndPos: 4374, + }, + Value: "a", + }, + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4377, + EndPos: 4378, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 212, + EndLine: 212, + StartPos: 4377, + EndPos: 4378, + }, + Value: "b", + }, + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4384, + EndPos: 4394, + }, Expr: &expr.Isset{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4384, + EndPos: 4393, + }, Variables: []node.Node{ &expr.ConstFetch{ - Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4390, + EndPos: 4392, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4390, + EndPos: 4392, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4390, + EndPos: 4392, + }, + Value: "Foo", + }, + }, + }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4398, + EndPos: 4409, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4398, + EndPos: 4408, + }, Variable: &expr.List{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4398, + EndPos: 4403, + }, Items: []node.Node{}, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Assign{ - Variable: &expr.List{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4407, + EndPos: 4408, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4407, + EndPos: 4408, }, + Value: "b", }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4413, + EndPos: 4430, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4413, + EndPos: 4429, + }, Variable: &expr.List{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4413, + EndPos: 4424, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4418, + EndPos: 4419, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4418, + EndPos: 4419, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4418, + EndPos: 4419, + }, + Value: "a", + }, + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4422, + EndPos: 4423, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4422, + EndPos: 4423, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4422, + EndPos: 4423, + }, + Value: "b", + }, }, }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4428, + EndPos: 4429, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4428, + EndPos: 4429, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4434, + EndPos: 4449, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4434, + EndPos: 4448, + }, Variable: &expr.List{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4434, + EndPos: 4443, + }, Items: []node.Node{ &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4439, + EndPos: 4442, + }, + Val: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4439, + EndPos: 4442, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4439, + EndPos: 4440, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4439, + EndPos: 4440, + }, + Value: "a", + }, + }, + }, + }, + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4447, + EndPos: 4448, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4447, + EndPos: 4448, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4453, + EndPos: 4472, + }, + Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4453, + EndPos: 4471, + }, + Variable: &expr.List{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4453, + EndPos: 4466, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4458, + EndPos: 4465, + }, Val: &expr.List{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4458, + EndPos: 4465, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Method: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.Print{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "foo"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "foo"}, - }, - Dim: &scalar.Lnumber{Value: "1"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.MethodCall{ - Variable: &expr.PropertyFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "foo"}, - }, - Property: &node.Identifier{Value: "bar"}, - }, - Method: &node.Identifier{Value: "baz"}, - ArgumentList: &node.ArgumentList{}, - }, - Property: &node.Identifier{Value: "quux"}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Method: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - Dim: &scalar.Lnumber{Value: "1"}, - }, - Dim: &scalar.Lnumber{Value: "1"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ShellExec{ - Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "cmd "}, - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.ShellExec{ - Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "cmd"}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.ShellExec{ - Parts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ShortArray{ - Items: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - nil, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - }, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.UnaryMinus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.UnaryPlus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - }, - &stmt.Expression{ - Expr: &expr.Variable{VarName: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}}, - }, - &stmt.Expression{ - Expr: &expr.Yield{}, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Value: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Value: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ConstantName: &node.Identifier{Value: "class"}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Value: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ConstantName: &node.Identifier{Value: "class"}, - }, - }, - }, - &stmt.Expression{ - Expr: &cast.Array{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Bool{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Bool{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Double{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Double{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Int{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Int{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Object{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.String{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Unset{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BooleanAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BooleanOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Concat{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Div{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Equal{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.GreaterOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Greater{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Identical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Minus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Mod{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Mul{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.NotEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.NotIdentical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Plus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Pow{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.ShiftLeft{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.ShiftRight{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.SmallerOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Smaller{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.New{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &assign.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.New{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{ - Arguments: []node.Node{ - &node.Argument{ - Variadic: false, - IsReference: false, - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &assign.Assign{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.BitwiseAnd{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.BitwiseOr{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.BitwiseXor{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Concat{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Div{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Minus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Mod{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Mul{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Plus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Pow{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.ShiftLeft{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.ShiftRight{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.PropertyFetch{ - Variable: &expr.MethodCall{ - Variable: &expr.New{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - Method: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, - }, - Property: &node.Identifier{Value: "baz"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.New{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - &stmt.Expression{ - Expr: &expr.MethodCall{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.New{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - ArgumentList: &node.ArgumentList{}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - Method: &node.Identifier{Value: "bar"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.Array{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "0"}, + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4463, + EndPos: 4464, }, - }, - }, - }, - }, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &scalar.String{Value: "\"foo\""}, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ConstFetch{ - Constant: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ClassConstFetch{ - Class: &node.Identifier{Value: "static"}, - ConstantName: &node.Identifier{Value: "foo"}, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &expr.StaticPropertyFetch{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &expr.ArrayDimFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "b"}, - }, - Dim: &scalar.Lnumber{Value: "0"}, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.New{ - Class: &expr.ArrayDimFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "b"}, - }, - Dim: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.ConstFetch{ - Constant: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "null"}, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4463, + EndPos: 4464, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4463, + EndPos: 4464, + }, + Value: "a", }, }, }, }, }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, }, - Property: &node.Identifier{Value: "d"}, }, - Dim: &scalar.Lnumber{Value: "0"}, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4470, + EndPos: 4471, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 217, + EndLine: 217, + StartPos: 4470, + EndPos: 4471, + }, + Value: "b", + }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4477, + EndPos: 4486, + }, + Expr: &expr.MethodCall{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4477, + EndPos: 4485, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4477, + EndPos: 4478, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4477, + EndPos: 4478, + }, + Value: "a", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4481, + EndPos: 4483, + }, + Value: "foo", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4484, + EndPos: 4485, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4490, + EndPos: 4497, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4490, + EndPos: 4496, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4494, + EndPos: 4496, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4494, + EndPos: 4496, + }, + Value: "Foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 221, + EndLine: 221, + StartPos: 4501, + EndPos: 4520, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 221, + EndLine: 221, + StartPos: 4501, + EndPos: 4519, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 221, + EndLine: 221, + StartPos: 4505, + EndPos: 4517, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 221, + EndLine: 221, + StartPos: 4515, + EndPos: 4517, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 221, + EndLine: 221, + StartPos: 4518, + EndPos: 4519, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4524, + EndPos: 4534, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4524, + EndPos: 4533, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4528, + EndPos: 4531, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4529, + EndPos: 4531, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4532, + EndPos: 4533, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4538, + EndPos: 4547, + }, + Expr: &expr.Print{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4538, + EndPos: 4545, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4544, + EndPos: 4545, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4544, + EndPos: 4545, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4551, + EndPos: 4558, + }, + Expr: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4551, + EndPos: 4557, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4551, + EndPos: 4552, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4551, + EndPos: 4552, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4555, + EndPos: 4557, + }, + Value: "foo", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4562, + EndPos: 4572, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4562, + EndPos: 4570, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4562, + EndPos: 4568, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4562, + EndPos: 4563, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4562, + EndPos: 4563, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4566, + EndPos: 4568, + }, + Value: "foo", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4570, + EndPos: 4570, + }, + Value: "1", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4604, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4602, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4600, + }, + Variable: &expr.MethodCall{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4594, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4587, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4582, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4577, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4576, + EndPos: 4577, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4580, + EndPos: 4582, + }, + Value: "foo", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4585, + EndPos: 4587, + }, + Value: "bar", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4590, + EndPos: 4592, + }, + Value: "baz", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4593, + EndPos: 4594, + }, + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4597, + EndPos: 4600, + }, + Value: "quux", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 226, + EndLine: 226, + StartPos: 4602, + EndPos: 4602, + }, + Value: "0", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4623, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4621, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4618, + }, + Variable: &expr.MethodCall{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4616, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4609, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4608, + EndPos: 4609, + }, + Value: "a", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4612, + EndPos: 4614, + }, + Value: "foo", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4615, + EndPos: 4616, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4618, + EndPos: 4618, + }, + Value: "1", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4621, + EndPos: 4621, + }, + Value: "1", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4627, + EndPos: 4635, + }, + Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4627, + EndPos: 4634, + }, + Parts: []node.Node{ + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4628, + EndPos: 4631, + }, + Value: "cmd ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4632, + EndPos: 4633, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4632, + EndPos: 4633, + }, + Value: "a", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4639, + EndPos: 4644, + }, + Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4639, + EndPos: 4643, + }, + Parts: []node.Node{ + &scalar.EncapsedStringPart{ + Value: "cmd", + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4640, + EndPos: 4642, + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4648, + EndPos: 4650, + }, + Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4648, + EndPos: 4649, + }, + Parts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4654, + EndPos: 4656, + }, + Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4654, + EndPos: 4655, + }, + Items: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4660, + EndPos: 4663, + }, + Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4660, + EndPos: 4662, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4661, + EndPos: 4661, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4661, + EndPos: 4661, + }, + Value: "1", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4667, + EndPos: 4679, + }, + Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4667, + EndPos: 4678, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4668, + EndPos: 4671, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4668, + EndPos: 4668, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4671, + EndPos: 4671, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4674, + EndPos: 4676, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4674, + EndPos: 4676, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4675, + EndPos: 4676, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4675, + EndPos: 4676, + }, + Value: "b", }, }, }, - Dim: &scalar.Lnumber{Value: "0"}, + }, + &expr.ArrayItem{}, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4684, + EndPos: 4694, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4684, + EndPos: 4693, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4684, + EndPos: 4686, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4684, + EndPos: 4686, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4689, + EndPos: 4691, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4692, + EndPos: 4693, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.BooleanNot{ - Expr: &scalar.Lnumber{Value: "1"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4698, + EndPos: 4718, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4698, + EndPos: 4717, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4698, + EndPos: 4710, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4708, + EndPos: 4710, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4713, + EndPos: 4715, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4716, + EndPos: 4717, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.BitwiseNot{ - Expr: &scalar.Lnumber{Value: "1"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4722, + EndPos: 4733, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4722, + EndPos: 4732, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4722, + EndPos: 4725, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4723, + EndPos: 4725, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4728, + EndPos: 4730, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4731, + EndPos: 4732, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.UnaryPlus{ - Expr: &scalar.Lnumber{Value: "1"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4737, + EndPos: 4748, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4737, + EndPos: 4747, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4737, + EndPos: 4739, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4737, + EndPos: 4739, + }, + Value: "Foo", + }, + }, + }, + Call: &expr.Variable{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4742, + EndPos: 4745, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4742, + EndPos: 4745, + }, + Value: "bar", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4746, + EndPos: 4747, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.UnaryMinus{ - Expr: &scalar.Lnumber{Value: "1"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4752, + EndPos: 4764, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4752, + EndPos: 4763, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4752, + EndPos: 4755, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4752, + EndPos: 4755, + }, + Value: "foo", + }, + }, + Call: &expr.Variable{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4758, + EndPos: 4761, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4758, + EndPos: 4761, + }, + Value: "bar", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4762, + EndPos: 4763, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &scalar.Lnumber{Value: "1"}, - }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4768, + EndPos: 4777, }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.Ternary{ - Condition: &scalar.Lnumber{Value: "1"}, - IfFalse: &scalar.Lnumber{Value: "2"}, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4768, + EndPos: 4776, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4768, + EndPos: 4770, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4768, + EndPos: 4770, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4773, + EndPos: 4776, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 240, + EndLine: 240, + StartPos: 4773, + EndPos: 4776, + }, + Value: "bar", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.Ternary{ - Condition: &scalar.Lnumber{Value: "1"}, - IfTrue: &scalar.Lnumber{Value: "2"}, - IfFalse: &scalar.Lnumber{Value: "3"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4781, + EndPos: 4800, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4781, + EndPos: 4799, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4781, + EndPos: 4793, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4791, + EndPos: 4793, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4796, + EndPos: 4799, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4796, + EndPos: 4799, + }, + Value: "bar", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.BitwiseAnd{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4804, + EndPos: 4814, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4804, + EndPos: 4813, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4804, + EndPos: 4807, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4805, + EndPos: 4807, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4810, + EndPos: 4813, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4810, + EndPos: 4813, + }, + Value: "bar", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.BitwiseOr{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4818, + EndPos: 4830, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4818, + EndPos: 4829, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4818, + EndPos: 4819, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4818, + EndPos: 4819, + }, + Value: "a", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4823, + EndPos: 4824, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4823, + EndPos: 4824, + }, + Value: "b", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4828, + EndPos: 4829, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4828, + EndPos: 4829, + }, + Value: "c", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.BitwiseXor{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4834, + EndPos: 4843, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4834, + EndPos: 4842, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4834, + EndPos: 4835, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4834, + EndPos: 4835, + }, + Value: "a", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4841, + EndPos: 4842, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4841, + EndPos: 4842, + }, + Value: "c", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.BooleanAnd{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4847, + EndPos: 4869, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4847, + EndPos: 4868, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4847, + EndPos: 4848, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4847, + EndPos: 4848, + }, + Value: "a", + }, + }, + IfTrue: &expr.Ternary{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4852, + EndPos: 4863, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4852, + EndPos: 4853, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4852, + EndPos: 4853, + }, + Value: "b", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4857, + EndPos: 4858, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4857, + EndPos: 4858, + }, + Value: "c", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4862, + EndPos: 4863, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4862, + EndPos: 4863, + }, + Value: "d", + }, + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4867, + EndPos: 4868, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4867, + EndPos: 4868, + }, + Value: "e", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.BooleanOr{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4873, + EndPos: 4895, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4873, + EndPos: 4894, + }, + Condition: &expr.Ternary{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4873, + EndPos: 4884, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4873, + EndPos: 4874, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4873, + EndPos: 4874, + }, + Value: "a", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4878, + EndPos: 4879, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4878, + EndPos: 4879, + }, + Value: "b", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4883, + EndPos: 4884, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4883, + EndPos: 4884, + }, + Value: "c", + }, + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4888, + EndPos: 4889, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4888, + EndPos: 4889, + }, + Value: "d", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4893, + EndPos: 4894, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4893, + EndPos: 4894, + }, + Value: "e", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Concat{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4899, + EndPos: 4902, + }, + Expr: &expr.UnaryMinus{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4899, + EndPos: 4901, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4900, + EndPos: 4901, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4900, + EndPos: 4901, + }, + Value: "a", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Div{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4906, + EndPos: 4909, + }, + Expr: &expr.UnaryPlus{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4906, + EndPos: 4908, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4907, + EndPos: 4908, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4907, + EndPos: 4908, + }, + Value: "a", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Equal{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4913, + EndPos: 4916, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4913, + EndPos: 4915, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4914, + EndPos: 4915, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4914, + EndPos: 4915, + }, + Value: "a", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.GreaterOrEqual{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4920, + EndPos: 4924, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4920, + EndPos: 4923, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4921, + EndPos: 4923, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4922, + EndPos: 4923, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4922, + EndPos: 4923, + }, + Value: "a", + }, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Greater{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4928, + EndPos: 4933, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4928, + EndPos: 4932, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4937, + EndPos: 4945, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4937, + EndPos: 4944, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4943, + EndPos: 4944, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4943, + EndPos: 4944, + }, + Value: "a", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Identical{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4949, + EndPos: 4963, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4949, + EndPos: 4962, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4955, + EndPos: 4956, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4955, + EndPos: 4956, + }, + Value: "a", + }, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4961, + EndPos: 4962, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4961, + EndPos: 4962, + }, + Value: "b", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.LogicalAnd{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4967, + EndPos: 4983, }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.LogicalOr{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4967, + EndPos: 4982, }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.LogicalXor{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, + Value: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4973, + EndPos: 4982, }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Minus{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Mod{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Mul{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.NotEqual{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.NotIdentical{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Plus{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Pow{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.ShiftLeft{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.ShiftRight{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.SmallerOrEqual{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &binary.Smaller{ - Left: &scalar.Lnumber{Value: "1"}, - Right: &scalar.Lnumber{Value: "2"}, - }, - }, - }, - }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4973, + EndPos: 4975, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4973, + EndPos: 4975, + }, + Value: "Foo", }, }, - ConstantName: &node.Identifier{Value: "bar"}, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4978, + EndPos: 4982, + }, + Value: "class", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4987, + EndPos: 5009, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4987, + EndPos: 5008, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4993, + EndPos: 4994, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4993, + EndPos: 4994, + }, + Value: "a", + }, + }, + Value: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4999, + EndPos: 5008, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4999, + EndPos: 5001, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 4999, + EndPos: 5001, + }, + Value: "Foo", }, }, - ConstantName: &node.Identifier{Value: "class"}, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 5004, + EndPos: 5008, + }, + Value: "class", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &scalar.MagicConstant{Value: "__CLASS__"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5016, + EndPos: 5025, + }, + Expr: &cast.Array{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5016, + EndPos: 5024, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5023, + EndPos: 5024, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5023, + EndPos: 5024, + }, + Value: "a", + }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ConstFetch{ - Constant: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5029, + EndPos: 5040, + }, + Expr: &cast.Bool{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5029, + EndPos: 5039, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5038, + EndPos: 5039, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5038, + EndPos: 5039, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5044, + EndPos: 5052, + }, + Expr: &cast.Bool{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5044, + EndPos: 5051, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5050, + EndPos: 5051, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5050, + EndPos: 5051, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5056, + EndPos: 5066, + }, + Expr: &cast.Double{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5056, + EndPos: 5065, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5064, + EndPos: 5065, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5064, + EndPos: 5065, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5070, + EndPos: 5079, + }, + Expr: &cast.Double{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5070, + EndPos: 5078, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5077, + EndPos: 5078, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5077, + EndPos: 5078, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 262, + EndLine: 262, + StartPos: 5083, + EndPos: 5094, + }, + Expr: &cast.Int{ + Position: &position.Position{ + StartLine: 262, + EndLine: 262, + StartPos: 5083, + EndPos: 5093, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 262, + EndLine: 262, + StartPos: 5092, + EndPos: 5093, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 262, + EndLine: 262, + StartPos: 5092, + EndPos: 5093, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5098, + EndPos: 5105, + }, + Expr: &cast.Int{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5098, + EndPos: 5104, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5103, + EndPos: 5104, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5103, + EndPos: 5104, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5109, + EndPos: 5119, + }, + Expr: &cast.Object{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5109, + EndPos: 5118, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5117, + EndPos: 5118, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5117, + EndPos: 5118, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5123, + EndPos: 5133, + }, + Expr: &cast.String{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5123, + EndPos: 5132, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5131, + EndPos: 5132, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5131, + EndPos: 5132, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5137, + EndPos: 5146, + }, + Expr: &cast.Unset{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5137, + EndPos: 5145, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5144, + EndPos: 5145, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5144, + EndPos: 5145, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5151, + EndPos: 5158, + }, + Expr: &binary.BitwiseAnd{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5151, + EndPos: 5157, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5151, + EndPos: 5152, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5151, + EndPos: 5152, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5156, + EndPos: 5157, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5156, + EndPos: 5157, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5162, + EndPos: 5169, + }, + Expr: &binary.BitwiseOr{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5162, + EndPos: 5168, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5162, + EndPos: 5163, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5162, + EndPos: 5163, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5167, + EndPos: 5168, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5167, + EndPos: 5168, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5173, + EndPos: 5180, + }, + Expr: &binary.BitwiseXor{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5173, + EndPos: 5179, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5173, + EndPos: 5174, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5173, + EndPos: 5174, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5178, + EndPos: 5179, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5178, + EndPos: 5179, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5184, + EndPos: 5192, + }, + Expr: &binary.BooleanAnd{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5184, + EndPos: 5191, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5184, + EndPos: 5185, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5184, + EndPos: 5185, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5190, + EndPos: 5191, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5190, + EndPos: 5191, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5196, + EndPos: 5204, + }, + Expr: &binary.BooleanOr{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5196, + EndPos: 5203, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5196, + EndPos: 5197, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5196, + EndPos: 5197, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5202, + EndPos: 5203, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5202, + EndPos: 5203, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5208, + EndPos: 5215, + }, + Expr: &binary.Concat{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5208, + EndPos: 5214, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5208, + EndPos: 5209, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5208, + EndPos: 5209, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5213, + EndPos: 5214, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 273, + EndLine: 273, + StartPos: 5213, + EndPos: 5214, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5219, + EndPos: 5226, + }, + Expr: &binary.Div{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5219, + EndPos: 5225, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5219, + EndPos: 5220, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5219, + EndPos: 5220, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5224, + EndPos: 5225, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5224, + EndPos: 5225, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5230, + EndPos: 5238, + }, + Expr: &binary.Equal{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5230, + EndPos: 5237, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5230, + EndPos: 5231, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5230, + EndPos: 5231, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5236, + EndPos: 5237, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5236, + EndPos: 5237, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5242, + EndPos: 5250, + }, + Expr: &binary.GreaterOrEqual{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5242, + EndPos: 5249, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5242, + EndPos: 5243, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5242, + EndPos: 5243, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5248, + EndPos: 5249, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5248, + EndPos: 5249, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5254, + EndPos: 5261, + }, + Expr: &binary.Greater{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5254, + EndPos: 5260, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5254, + EndPos: 5255, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5254, + EndPos: 5255, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5259, + EndPos: 5260, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5259, + EndPos: 5260, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5265, + EndPos: 5274, + }, + Expr: &binary.Identical{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5265, + EndPos: 5273, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5265, + EndPos: 5266, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5265, + EndPos: 5266, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5272, + EndPos: 5273, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5272, + EndPos: 5273, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5278, + EndPos: 5287, + }, + Expr: &binary.LogicalAnd{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5278, + EndPos: 5286, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5278, + EndPos: 5279, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5278, + EndPos: 5279, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5285, + EndPos: 5286, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5285, + EndPos: 5286, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5291, + EndPos: 5299, + }, + Expr: &binary.LogicalOr{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5291, + EndPos: 5298, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5291, + EndPos: 5292, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5291, + EndPos: 5292, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5297, + EndPos: 5298, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5297, + EndPos: 5298, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5303, + EndPos: 5312, + }, + Expr: &binary.LogicalXor{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5303, + EndPos: 5311, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5303, + EndPos: 5304, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5303, + EndPos: 5304, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5310, + EndPos: 5311, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5310, + EndPos: 5311, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5316, + EndPos: 5323, + }, + Expr: &binary.Minus{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5316, + EndPos: 5322, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5316, + EndPos: 5317, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5316, + EndPos: 5317, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5321, + EndPos: 5322, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5321, + EndPos: 5322, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5327, + EndPos: 5334, + }, + Expr: &binary.Mod{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5327, + EndPos: 5333, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5327, + EndPos: 5328, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5327, + EndPos: 5328, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5332, + EndPos: 5333, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5332, + EndPos: 5333, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5338, + EndPos: 5345, + }, + Expr: &binary.Mul{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5338, + EndPos: 5344, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5338, + EndPos: 5339, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5338, + EndPos: 5339, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5343, + EndPos: 5344, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5343, + EndPos: 5344, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5349, + EndPos: 5357, + }, + Expr: &binary.NotEqual{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5349, + EndPos: 5356, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5349, + EndPos: 5350, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5349, + EndPos: 5350, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5355, + EndPos: 5356, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5355, + EndPos: 5356, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5361, + EndPos: 5370, + }, + Expr: &binary.NotIdentical{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5361, + EndPos: 5369, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5361, + EndPos: 5362, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5361, + EndPos: 5362, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5368, + EndPos: 5369, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5368, + EndPos: 5369, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5374, + EndPos: 5381, + }, + Expr: &binary.Plus{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5374, + EndPos: 5380, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5374, + EndPos: 5375, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5374, + EndPos: 5375, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5379, + EndPos: 5380, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5379, + EndPos: 5380, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5385, + EndPos: 5393, + }, + Expr: &binary.Pow{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5385, + EndPos: 5392, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5385, + EndPos: 5386, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5385, + EndPos: 5386, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5391, + EndPos: 5392, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5391, + EndPos: 5392, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5397, + EndPos: 5405, + }, + Expr: &binary.ShiftLeft{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5397, + EndPos: 5404, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5397, + EndPos: 5398, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5397, + EndPos: 5398, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5403, + EndPos: 5404, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5403, + EndPos: 5404, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5409, + EndPos: 5417, + }, + Expr: &binary.ShiftRight{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5409, + EndPos: 5416, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5409, + EndPos: 5410, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5409, + EndPos: 5410, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5415, + EndPos: 5416, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5415, + EndPos: 5416, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5421, + EndPos: 5429, + }, + Expr: &binary.SmallerOrEqual{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5421, + EndPos: 5428, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5421, + EndPos: 5422, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5421, + EndPos: 5422, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5427, + EndPos: 5428, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5427, + EndPos: 5428, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5433, + EndPos: 5440, + }, + Expr: &binary.Smaller{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5433, + EndPos: 5439, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5433, + EndPos: 5434, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5433, + EndPos: 5434, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5438, + EndPos: 5439, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5438, + EndPos: 5439, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5445, + EndPos: 5453, + }, + Expr: &assign.Reference{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5445, + EndPos: 5452, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5445, + EndPos: 5446, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5445, + EndPos: 5446, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5451, + EndPos: 5452, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5451, + EndPos: 5452, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5457, + EndPos: 5470, + }, + Expr: &assign.Reference{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5457, + EndPos: 5469, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5457, + EndPos: 5458, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5457, + EndPos: 5458, + }, + Value: "a", + }, + }, + Expression: &expr.New{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5463, + EndPos: 5469, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5467, + EndPos: 5469, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5467, + EndPos: 5469, + }, + Value: "Foo", }, }, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ConstFetch{ - Constant: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5474, + EndPos: 5491, + }, + Expr: &assign.Reference{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5474, + EndPos: 5490, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5474, + EndPos: 5475, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5474, + EndPos: 5475, + }, + Value: "a", + }, + }, + Expression: &expr.New{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5480, + EndPos: 5490, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5484, + EndPos: 5486, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5484, + EndPos: 5486, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5487, + EndPos: 5490, + }, + Arguments: []node.Node{ + &node.Argument{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5488, + EndPos: 5489, + }, + Variadic: false, + IsReference: false, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5488, + EndPos: 5489, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5488, + EndPos: 5489, + }, + Value: "b", + }, + }, }, }, }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ConstFetch{ - Constant: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5495, + EndPos: 5502, + }, + Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5495, + EndPos: 5501, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5495, + EndPos: 5496, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5495, + EndPos: 5496, }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5500, + EndPos: 5501, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5500, + EndPos: 5501, + }, + Value: "b", }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.Array{}, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5506, + EndPos: 5514, + }, + Expr: &assign.BitwiseAnd{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5506, + EndPos: 5513, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5506, + EndPos: 5507, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5506, + EndPos: 5507, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5512, + EndPos: 5513, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5512, + EndPos: 5513, + }, + Value: "b", + }, }, }, }, - &stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.Array{ + &stmt.Expression{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5518, + EndPos: 5526, + }, + Expr: &assign.BitwiseOr{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5518, + EndPos: 5525, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5518, + EndPos: 5519, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5518, + EndPos: 5519, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5524, + EndPos: 5525, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5524, + EndPos: 5525, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5530, + EndPos: 5538, + }, + Expr: &assign.BitwiseXor{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5530, + EndPos: 5537, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5530, + EndPos: 5531, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5530, + EndPos: 5531, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5536, + EndPos: 5537, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5536, + EndPos: 5537, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5542, + EndPos: 5550, + }, + Expr: &assign.Concat{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5542, + EndPos: 5549, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5542, + EndPos: 5543, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5542, + EndPos: 5543, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5548, + EndPos: 5549, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 301, + EndLine: 301, + StartPos: 5548, + EndPos: 5549, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5554, + EndPos: 5562, + }, + Expr: &assign.Div{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5554, + EndPos: 5561, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5554, + EndPos: 5555, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5554, + EndPos: 5555, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5560, + EndPos: 5561, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5560, + EndPos: 5561, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5566, + EndPos: 5574, + }, + Expr: &assign.Minus{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5566, + EndPos: 5573, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5566, + EndPos: 5567, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5566, + EndPos: 5567, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5572, + EndPos: 5573, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5572, + EndPos: 5573, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5578, + EndPos: 5586, + }, + Expr: &assign.Mod{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5578, + EndPos: 5585, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5578, + EndPos: 5579, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5578, + EndPos: 5579, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5584, + EndPos: 5585, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5584, + EndPos: 5585, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5590, + EndPos: 5598, + }, + Expr: &assign.Mul{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5590, + EndPos: 5597, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5590, + EndPos: 5591, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5590, + EndPos: 5591, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5596, + EndPos: 5597, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5596, + EndPos: 5597, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5602, + EndPos: 5610, + }, + Expr: &assign.Plus{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5602, + EndPos: 5609, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5602, + EndPos: 5603, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5602, + EndPos: 5603, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5608, + EndPos: 5609, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5608, + EndPos: 5609, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5614, + EndPos: 5623, + }, + Expr: &assign.Pow{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5614, + EndPos: 5622, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5614, + EndPos: 5615, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5614, + EndPos: 5615, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5621, + EndPos: 5622, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5621, + EndPos: 5622, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5627, + EndPos: 5636, + }, + Expr: &assign.ShiftLeft{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5627, + EndPos: 5635, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5627, + EndPos: 5628, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5627, + EndPos: 5628, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5634, + EndPos: 5635, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5634, + EndPos: 5635, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5649, + }, + Expr: &assign.ShiftRight{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5648, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5641, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5641, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5647, + EndPos: 5648, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5647, + EndPos: 5648, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5656, + EndPos: 5667, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5656, + EndPos: 5665, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5660, + EndPos: 5663, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5661, + EndPos: 5663, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5664, + EndPos: 5665, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5692, + EndPos: 5695, + }, + Expr: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5692, + EndPos: 5694, + }, + Variable: &expr.MethodCall{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5688, + EndPos: 5689, + }, + Variable: &expr.New{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5672, + EndPos: 5681, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5676, + EndPos: 5679, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5677, + EndPos: 5679, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5680, + EndPos: 5681, + }, + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5685, + EndPos: 5687, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5688, + EndPos: 5689, + }, + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5692, + EndPos: 5694, + }, + Value: "baz", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5715, + EndPos: 5717, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5715, + EndPos: 5715, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5712, + EndPos: 5712, + }, + Variable: &expr.New{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5700, + EndPos: 5709, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5704, + EndPos: 5707, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5705, + EndPos: 5707, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5708, + EndPos: 5709, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5712, + EndPos: 5712, + }, + Value: "0", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5715, + EndPos: 5715, + }, + Value: "0", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5741, + EndPos: 5743, + }, + Expr: &expr.MethodCall{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5741, + EndPos: 5742, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5734, + EndPos: 5734, + }, + Variable: &expr.New{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5722, + EndPos: 5731, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5726, + EndPos: 5729, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5727, + EndPos: 5729, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5730, + EndPos: 5731, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5734, + EndPos: 5734, + }, + Value: "0", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5738, + EndPos: 5740, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5741, + EndPos: 5742, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5748, + EndPos: 5764, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5748, + EndPos: 5763, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5748, + EndPos: 5760, + }, + Variable: &expr.Array{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5748, + EndPos: 5757, + }, Items: []node.Node{ &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5754, + EndPos: 5756, + }, + Val: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5754, + EndPos: 5756, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5755, + EndPos: 5755, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5755, + EndPos: 5755, + }, + Value: "0", + }, + }, + }, + }, }, - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "2"}, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5759, + EndPos: 5759, + }, + Value: "0", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5762, + EndPos: 5762, + }, + Value: "0", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5768, + EndPos: 5776, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5768, + EndPos: 5775, + }, + Variable: &scalar.String{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5768, + EndPos: 5772, + }, + Value: "\"foo\"", + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5774, + EndPos: 5774, + }, + Value: "0", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5780, + EndPos: 5786, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5780, + EndPos: 5785, + }, + Variable: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5780, + EndPos: 5782, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5780, + EndPos: 5782, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5780, + EndPos: 5782, + }, + Value: "foo", + }, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 319, + EndLine: 319, + StartPos: 5784, + EndPos: 5784, + }, + Value: "0", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5790, + EndPos: 5801, + }, + Expr: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5790, + EndPos: 5800, + }, + Class: &node.Identifier{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5790, + EndPos: 5795, + }, + Value: "static", + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5798, + EndPos: 5800, + }, + Value: "foo", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5806, + EndPos: 5814, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5806, + EndPos: 5813, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5810, + EndPos: 5813, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5810, + EndPos: 5813, + }, + Value: "foo", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5818, + EndPos: 5832, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5818, + EndPos: 5831, + }, + Class: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5822, + EndPos: 5831, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5822, + EndPos: 5825, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5822, + EndPos: 5825, + }, + Value: "foo", + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5828, + EndPos: 5831, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5828, + EndPos: 5831, + }, + Value: "bar", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5836, + EndPos: 5848, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5836, + EndPos: 5846, + }, + Class: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5846, + EndPos: 5846, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5844, + EndPos: 5846, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5840, + EndPos: 5844, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5840, + EndPos: 5841, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5844, + EndPos: 5844, + }, + Value: "b", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5846, + EndPos: 5846, + }, + Value: "0", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5852, + EndPos: 5883, + }, + Expr: &expr.New{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5852, + EndPos: 5881, + }, + Class: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5881, + EndPos: 5881, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5879, + EndPos: 5881, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5875, + EndPos: 5879, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5862, + EndPos: 5876, + }, + Variable: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5860, + EndPos: 5871, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5856, + EndPos: 5860, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5856, + EndPos: 5857, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5860, + EndPos: 5860, + }, + Value: "b", + }, + }, + Dim: &expr.Ternary{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5862, + EndPos: 5871, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5862, + EndPos: 5863, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5862, + EndPos: 5863, + }, + Value: "b", + }, + }, + IfFalse: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5868, + EndPos: 5871, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5868, + EndPos: 5871, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5868, + EndPos: 5871, + }, + Value: "null", + }, + }, + }, + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5875, + EndPos: 5876, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5875, + EndPos: 5876, + }, + Value: "c", + }, + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5879, + EndPos: 5879, + }, + Value: "d", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5881, + EndPos: 5881, + }, + Value: "0", + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5884, + EndPos: 5902, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5891, + EndPos: 5901, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5891, + EndPos: 5892, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5891, + EndPos: 5892, + }, + Value: "a", + }, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5896, + EndPos: 5901, + }, + Variable: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5896, + EndPos: 5898, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5897, + EndPos: 5897, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5897, + EndPos: 5897, + }, + Value: "1", + }, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5900, + EndPos: 5900, + }, + Value: "0", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5907, + EndPos: 5921, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5914, + EndPos: 5920, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5914, + EndPos: 5915, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5914, + EndPos: 5915, + }, + Value: "a", + }, + }, + Expr: &expr.BooleanNot{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5919, + EndPos: 5920, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 327, + EndLine: 327, + StartPos: 5920, + EndPos: 5920, + }, + Value: "1", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5925, + EndPos: 5939, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5932, + EndPos: 5938, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5932, + EndPos: 5933, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5932, + EndPos: 5933, + }, + Value: "a", + }, + }, + Expr: &expr.BitwiseNot{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5937, + EndPos: 5938, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5938, + EndPos: 5938, + }, + Value: "1", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5943, + EndPos: 5957, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5950, + EndPos: 5956, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5950, + EndPos: 5951, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5950, + EndPos: 5951, + }, + Value: "a", + }, + }, + Expr: &expr.UnaryPlus{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5955, + EndPos: 5956, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5956, + EndPos: 5956, + }, + Value: "1", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5961, + EndPos: 5975, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5968, + EndPos: 5974, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5968, + EndPos: 5969, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5968, + EndPos: 5969, + }, + Value: "a", + }, + }, + Expr: &expr.UnaryMinus{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5973, + EndPos: 5974, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5974, + EndPos: 5974, + }, + Value: "1", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 331, + EndLine: 331, + StartPos: 5979, + EndPos: 5994, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 331, + EndLine: 331, + StartPos: 5986, + EndPos: 5992, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 331, + EndLine: 331, + StartPos: 5986, + EndPos: 5987, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 331, + EndLine: 331, + StartPos: 5986, + EndPos: 5987, + }, + Value: "a", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 331, + EndLine: 331, + StartPos: 5992, + EndPos: 5992, + }, + Value: "1", + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 5998, + EndPos: 6016, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6005, + EndPos: 6015, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6005, + EndPos: 6006, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6005, + EndPos: 6006, + }, + Value: "a", + }, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6010, + EndPos: 6015, + }, + Condition: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6010, + EndPos: 6010, + }, + Value: "1", + }, + IfFalse: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6015, + EndPos: 6015, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6020, + EndPos: 6041, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6027, + EndPos: 6040, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6027, + EndPos: 6028, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6027, + EndPos: 6028, + }, + Value: "a", + }, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6032, + EndPos: 6040, + }, + Condition: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6032, + EndPos: 6032, + }, + Value: "1", + }, + IfTrue: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6036, + EndPos: 6036, + }, + Value: "2", + }, + IfFalse: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6040, + EndPos: 6040, + }, + Value: "3", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6045, + EndPos: 6062, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6052, + EndPos: 6061, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6052, + EndPos: 6053, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6052, + EndPos: 6053, + }, + Value: "a", + }, + }, + Expr: &binary.BitwiseAnd{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6057, + EndPos: 6061, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6057, + EndPos: 6057, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6061, + EndPos: 6061, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6066, + EndPos: 6083, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6073, + EndPos: 6082, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6073, + EndPos: 6074, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6073, + EndPos: 6074, + }, + Value: "a", + }, + }, + Expr: &binary.BitwiseOr{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6078, + EndPos: 6082, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6078, + EndPos: 6078, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6082, + EndPos: 6082, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6087, + EndPos: 6104, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6094, + EndPos: 6103, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6094, + EndPos: 6095, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6094, + EndPos: 6095, + }, + Value: "a", + }, + }, + Expr: &binary.BitwiseXor{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6099, + EndPos: 6103, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6099, + EndPos: 6099, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6103, + EndPos: 6103, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6108, + EndPos: 6126, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6115, + EndPos: 6125, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6115, + EndPos: 6116, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6115, + EndPos: 6116, + }, + Value: "a", + }, + }, + Expr: &binary.BooleanAnd{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6120, + EndPos: 6125, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6120, + EndPos: 6120, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6125, + EndPos: 6125, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6130, + EndPos: 6148, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6137, + EndPos: 6147, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6137, + EndPos: 6138, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6137, + EndPos: 6138, + }, + Value: "a", + }, + }, + Expr: &binary.BooleanOr{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6142, + EndPos: 6147, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6142, + EndPos: 6142, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6147, + EndPos: 6147, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6152, + EndPos: 6169, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6159, + EndPos: 6168, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6159, + EndPos: 6160, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6159, + EndPos: 6160, + }, + Value: "a", + }, + }, + Expr: &binary.Concat{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6164, + EndPos: 6168, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6164, + EndPos: 6164, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 339, + EndLine: 339, + StartPos: 6168, + EndPos: 6168, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6173, + EndPos: 6190, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6180, + EndPos: 6189, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6180, + EndPos: 6181, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6180, + EndPos: 6181, + }, + Value: "a", + }, + }, + Expr: &binary.Div{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6185, + EndPos: 6189, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6185, + EndPos: 6185, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6189, + EndPos: 6189, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6194, + EndPos: 6212, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6201, + EndPos: 6211, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6201, + EndPos: 6202, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6201, + EndPos: 6202, + }, + Value: "a", + }, + }, + Expr: &binary.Equal{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6206, + EndPos: 6211, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6206, + EndPos: 6206, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6211, + EndPos: 6211, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6216, + EndPos: 6234, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6223, + EndPos: 6233, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6223, + EndPos: 6224, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6223, + EndPos: 6224, + }, + Value: "a", + }, + }, + Expr: &binary.GreaterOrEqual{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6228, + EndPos: 6233, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6228, + EndPos: 6228, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 342, + EndLine: 342, + StartPos: 6233, + EndPos: 6233, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6238, + EndPos: 6255, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6245, + EndPos: 6254, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6245, + EndPos: 6246, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6245, + EndPos: 6246, + }, + Value: "a", + }, + }, + Expr: &binary.Greater{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6250, + EndPos: 6254, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6250, + EndPos: 6250, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6254, + EndPos: 6254, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6259, + EndPos: 6278, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6266, + EndPos: 6277, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6266, + EndPos: 6267, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6266, + EndPos: 6267, + }, + Value: "a", + }, + }, + Expr: &binary.Identical{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6271, + EndPos: 6277, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6271, + EndPos: 6271, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6277, + EndPos: 6277, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6282, + EndPos: 6301, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6289, + EndPos: 6300, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6289, + EndPos: 6290, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6289, + EndPos: 6290, + }, + Value: "a", + }, + }, + Expr: &binary.LogicalAnd{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6294, + EndPos: 6300, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6294, + EndPos: 6294, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 345, + EndLine: 345, + StartPos: 6300, + EndPos: 6300, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6305, + EndPos: 6323, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6312, + EndPos: 6322, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6312, + EndPos: 6313, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6312, + EndPos: 6313, + }, + Value: "a", + }, + }, + Expr: &binary.LogicalOr{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6317, + EndPos: 6322, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6317, + EndPos: 6317, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6322, + EndPos: 6322, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6327, + EndPos: 6346, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6334, + EndPos: 6345, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6334, + EndPos: 6335, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6334, + EndPos: 6335, + }, + Value: "a", + }, + }, + Expr: &binary.LogicalXor{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6339, + EndPos: 6345, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6339, + EndPos: 6339, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 347, + EndLine: 347, + StartPos: 6345, + EndPos: 6345, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6350, + EndPos: 6367, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6357, + EndPos: 6366, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6357, + EndPos: 6358, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6357, + EndPos: 6358, + }, + Value: "a", + }, + }, + Expr: &binary.Minus{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6362, + EndPos: 6366, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6362, + EndPos: 6362, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6366, + EndPos: 6366, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6371, + EndPos: 6388, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6378, + EndPos: 6387, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6378, + EndPos: 6379, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6378, + EndPos: 6379, + }, + Value: "a", + }, + }, + Expr: &binary.Mod{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6383, + EndPos: 6387, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6383, + EndPos: 6383, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 349, + EndLine: 349, + StartPos: 6387, + EndPos: 6387, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6392, + EndPos: 6409, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6399, + EndPos: 6408, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6399, + EndPos: 6400, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6399, + EndPos: 6400, + }, + Value: "a", + }, + }, + Expr: &binary.Mul{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6404, + EndPos: 6408, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6404, + EndPos: 6404, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 350, + EndLine: 350, + StartPos: 6408, + EndPos: 6408, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6413, + EndPos: 6431, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6420, + EndPos: 6430, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6420, + EndPos: 6421, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6420, + EndPos: 6421, + }, + Value: "a", + }, + }, + Expr: &binary.NotEqual{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6425, + EndPos: 6430, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6425, + EndPos: 6425, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 351, + EndLine: 351, + StartPos: 6430, + EndPos: 6430, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6435, + EndPos: 6454, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6442, + EndPos: 6453, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6442, + EndPos: 6443, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6442, + EndPos: 6443, + }, + Value: "a", + }, + }, + Expr: &binary.NotIdentical{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6447, + EndPos: 6453, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6447, + EndPos: 6447, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 352, + EndLine: 352, + StartPos: 6453, + EndPos: 6453, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6458, + EndPos: 6475, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6465, + EndPos: 6474, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6465, + EndPos: 6466, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6465, + EndPos: 6466, + }, + Value: "a", + }, + }, + Expr: &binary.Plus{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6470, + EndPos: 6474, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6470, + EndPos: 6470, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 353, + EndLine: 353, + StartPos: 6474, + EndPos: 6474, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6479, + EndPos: 6497, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6486, + EndPos: 6496, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6486, + EndPos: 6487, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6486, + EndPos: 6487, + }, + Value: "a", + }, + }, + Expr: &binary.Pow{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6491, + EndPos: 6496, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6491, + EndPos: 6491, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 354, + EndLine: 354, + StartPos: 6496, + EndPos: 6496, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6501, + EndPos: 6519, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6508, + EndPos: 6518, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6508, + EndPos: 6509, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6508, + EndPos: 6509, + }, + Value: "a", + }, + }, + Expr: &binary.ShiftLeft{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6513, + EndPos: 6518, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6513, + EndPos: 6513, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 355, + EndLine: 355, + StartPos: 6518, + EndPos: 6518, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6523, + EndPos: 6541, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6530, + EndPos: 6540, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6530, + EndPos: 6531, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6530, + EndPos: 6531, + }, + Value: "a", + }, + }, + Expr: &binary.ShiftRight{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6535, + EndPos: 6540, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6535, + EndPos: 6535, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 356, + EndLine: 356, + StartPos: 6540, + EndPos: 6540, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6545, + EndPos: 6563, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6552, + EndPos: 6562, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6552, + EndPos: 6553, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6552, + EndPos: 6553, + }, + Value: "a", + }, + }, + Expr: &binary.SmallerOrEqual{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6557, + EndPos: 6562, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6557, + EndPos: 6557, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 357, + EndLine: 357, + StartPos: 6562, + EndPos: 6562, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6567, + EndPos: 6584, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6574, + EndPos: 6583, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6574, + EndPos: 6575, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6574, + EndPos: 6575, + }, + Value: "a", + }, + }, + Expr: &binary.Smaller{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6579, + EndPos: 6583, + }, + Left: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6579, + EndPos: 6579, + }, + Value: "1", + }, + Right: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 358, + EndLine: 358, + StartPos: 6583, + EndPos: 6583, + }, + Value: "2", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6588, + EndPos: 6608, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6595, + EndPos: 6607, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6595, + EndPos: 6596, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6595, + EndPos: 6596, + }, + Value: "a", + }, + }, + Expr: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6600, + EndPos: 6607, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6600, + EndPos: 6602, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6600, + EndPos: 6602, + }, + Value: "Foo", + }, + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 359, + EndLine: 359, + StartPos: 6605, + EndPos: 6607, + }, + Value: "bar", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6612, + EndPos: 6634, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6619, + EndPos: 6633, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6619, + EndPos: 6620, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6619, + EndPos: 6620, + }, + Value: "a", + }, + }, + Expr: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6624, + EndPos: 6633, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6624, + EndPos: 6626, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6624, + EndPos: 6626, + }, + Value: "Foo", + }, + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 360, + EndLine: 360, + StartPos: 6629, + EndPos: 6633, + }, + Value: "class", + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 361, + EndLine: 361, + StartPos: 6638, + EndPos: 6659, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 361, + EndLine: 361, + StartPos: 6645, + EndPos: 6658, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 361, + EndLine: 361, + StartPos: 6645, + EndPos: 6646, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 361, + EndLine: 361, + StartPos: 6645, + EndPos: 6646, + }, + Value: "a", + }, + }, + Expr: &scalar.MagicConstant{ + Position: &position.Position{ + StartLine: 361, + EndLine: 361, + StartPos: 6650, + EndPos: 6658, + }, + Value: "__CLASS__", + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6663, + EndPos: 6678, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6670, + EndPos: 6677, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6670, + EndPos: 6671, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6670, + EndPos: 6671, + }, + Value: "a", + }, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6675, + EndPos: 6677, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6675, + EndPos: 6677, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 362, + EndLine: 362, + StartPos: 6675, + EndPos: 6677, + }, + Value: "Foo", + }, }, }, }, @@ -3562,88 +17637,773 @@ func TestPhp5(t *testing.T) { }, }, &stmt.Static{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6682, + EndPos: 6707, + }, Vars: []node.Node{ &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "2"}, - Val: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6689, + EndPos: 6706, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6689, + EndPos: 6690, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6689, + EndPos: 6690, + }, + Value: "a", + }, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6694, + EndPos: 6706, + }, + Constant: &name.Relative{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6694, + EndPos: 6706, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 363, + EndLine: 363, + StartPos: 6704, + EndPos: 6706, + }, + Value: "Foo", }, }, }, - Dim: &scalar.Lnumber{Value: "0"}, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6711, + EndPos: 6727, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6718, + EndPos: 6726, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6718, + EndPos: 6719, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6718, + EndPos: 6719, + }, + Value: "a", + }, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6723, + EndPos: 6726, + }, + Constant: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6723, + EndPos: 6726, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 364, + EndLine: 364, + StartPos: 6724, + EndPos: 6726, + }, + Value: "Foo", + }, + }, + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 365, + EndLine: 365, + StartPos: 6731, + EndPos: 6750, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 365, + EndLine: 365, + StartPos: 6738, + EndPos: 6749, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 365, + EndLine: 365, + StartPos: 6738, + EndPos: 6739, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 365, + EndLine: 365, + StartPos: 6738, + EndPos: 6739, + }, + Value: "a", + }, + }, + Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 365, + EndLine: 365, + StartPos: 6743, + EndPos: 6749, + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6754, + EndPos: 6782, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6761, + EndPos: 6781, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6761, + EndPos: 6762, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6761, + EndPos: 6762, + }, + Value: "a", + }, + }, + Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6766, + EndPos: 6781, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6772, + EndPos: 6777, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6772, + EndPos: 6772, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6777, + EndPos: 6777, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6780, + EndPos: 6780, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 366, + EndLine: 366, + StartPos: 6780, + EndPos: 6780, + }, + Value: "2", + }, + }, + }, + }, + }, + }, + }, + &stmt.Static{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6786, + EndPos: 6812, + }, + Vars: []node.Node{ + &stmt.StaticVar{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6793, + EndPos: 6811, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6793, + EndPos: 6794, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6793, + EndPos: 6794, + }, + Value: "a", + }, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6798, + EndPos: 6811, + }, + Variable: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6798, + EndPos: 6808, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6799, + EndPos: 6799, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6799, + EndPos: 6799, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6802, + EndPos: 6807, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6802, + EndPos: 6802, + }, + Value: "2", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6807, + EndPos: 6807, + }, + Value: "2", + }, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 367, + EndLine: 367, + StartPos: 6810, + EndPos: 6810, + }, + Value: "0", + }, }, }, }, }, &stmt.If{ + Position: &position.Position{ + StartLine: 369, + EndLine: 369, + StartPos: 6817, + EndPos: 6831, + }, Cond: &expr.Yield{ - Value: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 369, + EndLine: 369, + StartPos: 6821, + EndPos: 6827, + }, + Value: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 369, + EndLine: 369, + StartPos: 6827, + EndPos: 6827, + }, + Value: "1", + }, }, Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 369, + EndLine: 369, + StartPos: 6830, + EndPos: 6831, + }, Stmts: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6835, + EndPos: 6845, + }, Expr: &expr.StaticPropertyFetch{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Property: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ArrayDimFetch{ - Variable: &expr.ArrayDimFetch{ - Variable: &expr.FunctionCall{ - Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - ArgumentList: &node.ArgumentList{}, - }, - Dim: &scalar.Lnumber{Value: "0"}, + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6835, + EndPos: 6844, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6835, + EndPos: 6837, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6835, + EndPos: 6837, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6840, + EndPos: 6844, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6841, + EndPos: 6844, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 370, + EndLine: 370, + StartPos: 6841, + EndPos: 6844, + }, + Value: "bar", + }, + }, }, - Dim: &scalar.Lnumber{Value: "0"}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 372, + EndLine: 372, + StartPos: 6850, + EndPos: 6856, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 372, + EndLine: 372, + StartPos: 6850, + EndPos: 6855, + }, + Function: &expr.Variable{ + Position: &position.Position{ + StartLine: 372, + EndLine: 372, + StartPos: 6850, + EndPos: 6853, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 372, + EndLine: 372, + StartPos: 6850, + EndPos: 6853, + }, + Value: "foo", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 372, + EndLine: 372, + StartPos: 6854, + EndPos: 6855, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6872, + }, Expr: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Dim: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6871, + }, + Variable: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6868, + }, + Variable: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6865, + }, + Function: &expr.Variable{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6863, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6860, + EndPos: 6863, + }, + Value: "foo", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6864, + EndPos: 6865, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6867, + EndPos: 6867, + }, + Value: "0", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 373, + EndLine: 373, + StartPos: 6870, + EndPos: 6870, + }, + Value: "0", + }, }, }, &stmt.Expression{ - Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6876, + EndPos: 6882, + }, + Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6876, + EndPos: 6881, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6876, + EndPos: 6877, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6876, + EndPos: 6877, + }, + Value: "a", + }, + }, + Dim: &expr.Variable{ + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6879, + EndPos: 6880, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 374, + EndLine: 374, + StartPos: 6879, + EndPos: 6880, + }, + Value: "b", + }, + }, + }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 375, + EndLine: 375, + StartPos: 6886, + EndPos: 6891, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 375, + EndLine: 375, + StartPos: 6886, + EndPos: 6890, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 375, + EndLine: 375, + StartPos: 6888, + EndPos: 6889, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 375, + EndLine: 375, + StartPos: 6888, + EndPos: 6889, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6895, + EndPos: 6909, + }, Expr: &expr.StaticCall{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6895, + EndPos: 6908, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6895, + EndPos: 6898, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6895, + EndPos: 6898, + }, + Value: "foo", + }, + }, + Call: &expr.Variable{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6901, + EndPos: 6906, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6902, + EndPos: 6905, + }, + Value: "bar", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 376, + EndLine: 376, + StartPos: 6907, + EndPos: 6908, + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 377, + EndLine: 377, + StartPos: 6913, + EndPos: 6922, + }, Expr: &expr.ClassConstFetch{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - ConstantName: &node.Identifier{Value: "bar"}, + Position: &position.Position{ + StartLine: 377, + EndLine: 377, + StartPos: 6913, + EndPos: 6921, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 377, + EndLine: 377, + StartPos: 6913, + EndPos: 6916, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 377, + EndLine: 377, + StartPos: 6913, + EndPos: 6916, + }, + Value: "foo", + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 377, + EndLine: 377, + StartPos: 6919, + EndPos: 6921, + }, + Value: "bar", + }, + }, + }, + &stmt.HaltCompiler{ + Position: &position.Position{ + StartLine: 379, + EndLine: 379, + StartPos: 6927, + EndPos: 6944, }, }, - &stmt.HaltCompiler{}, }, } php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual := php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp5Strings(t *testing.T) { @@ -3660,21 +18420,97 @@ func TestPhp5Strings(t *testing.T) { ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 10, + StartPos: 6, + EndPos: 70, + }, Stmts: []node.Node{ &stmt.Expression{ - Expr: &scalar.String{Value: "\"test\""}, + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 6, + EndPos: 12, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 6, + EndPos: 11, + }, + Value: "\"test\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "\"\\$test\""}, + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 16, + EndPos: 24, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 16, + EndPos: 23, + }, + Value: "\"\\$test\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "\"\n\t\t\ttest\n\t\t\""}, + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 28, + EndPos: 41, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 28, + EndPos: 40, + }, + Value: "\"\n\t\t\ttest\n\t\t\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "'$test'"}, + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 45, + EndPos: 52, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 45, + EndPos: 51, + }, + Value: "'$test'", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "'\n\t\t\t$test\n\t\t'"}, + Position: &position.Position{ + StartLine: 8, + EndLine: 10, + StartPos: 56, + EndPos: 70, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 8, + EndLine: 10, + StartPos: 56, + EndPos: 69, + }, + Value: "'\n\t\t\t$test\n\t\t'", + }, }, }, } @@ -3682,7 +18518,7 @@ func TestPhp5Strings(t *testing.T) { php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual := php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp5Heredoc(t *testing.T) { @@ -3704,43 +18540,156 @@ CAD; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 15, + StartPos: 9, + EndPos: 120, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 3, + StartPos: 9, + EndPos: 16, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 2, + EndLine: 3, + StartPos: 9, + EndPos: 15, + }, Label: "CAD", }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 23, + EndPos: 37, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 23, + EndPos: 36, + }, Label: "CAD", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 27, + EndPos: 32, + }, + Value: "\thello", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 7, + EndLine: 9, + StartPos: 44, + EndPos: 60, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 7, + EndLine: 9, + StartPos: 44, + EndPos: 59, + }, Label: "\"CAD\"", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 8, + EndLine: 8, + StartPos: 50, + EndPos: 55, + }, + Value: "\thello", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 10, + EndLine: 12, + StartPos: 67, + EndPos: 90, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 10, + EndLine: 12, + StartPos: 67, + EndPos: 89, + }, Label: "\"CAD\"", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello "}, - &expr.Variable{VarName: &node.Identifier{Value: "world"}}, - &scalar.EncapsedStringPart{Value: "\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 73, + EndPos: 79, + }, + Value: "\thello ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 80, + EndPos: 85, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 80, + EndPos: 85, + }, + Value: "world", + }, + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 13, + EndLine: 15, + StartPos: 97, + EndPos: 120, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 13, + EndLine: 15, + StartPos: 97, + EndPos: 119, + }, Label: "'CAD'", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello $world\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 103, + EndPos: 115, + }, + Value: "\thello $world", + }, }, }, }, @@ -3750,7 +18699,7 @@ CAD; php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual := php5parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp5ControlCharsErrors(t *testing.T) { @@ -3770,5 +18719,5 @@ func TestPhp5ControlCharsErrors(t *testing.T) { php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser.Parse() actual := php5parser.GetErrors() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/php7/parser.go b/php7/parser.go index 27b8da8..a161e52 100644 --- a/php7/parser.go +++ b/php7/parser.go @@ -2,10 +2,13 @@ package php7 import ( "io" + "strings" "github.com/z7zmey/php-parser/errors" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/parser" + "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/scanner" ) @@ -20,8 +23,6 @@ type Parser struct { currentToken *scanner.Token positionBuilder *parser.PositionBuilder rootNode node.Node - comments parser.Comments - positions parser.Positions } // NewParser creates and returns new Parser @@ -34,8 +35,6 @@ func NewParser(src io.Reader, path string) *Parser { nil, nil, nil, - nil, - nil, } } @@ -47,7 +46,18 @@ func (l *Parser) Lex(lval *yySymType) int { } func (l *Parser) Error(msg string) { - l.Lexer.Errors = append(l.Lexer.Errors, errors.NewError(msg, l.currentToken.Position)) + pos := &position.Position{ + StartLine: l.currentToken.StartLine, + EndLine: l.currentToken.EndLine, + StartPos: l.currentToken.StartPos, + EndPos: l.currentToken.EndPos, + } + + l.Lexer.Errors = append(l.Lexer.Errors, errors.NewError(msg, pos)) +} + +func (l *Parser) WithFreeFloating() { + l.Lexer.WithFreeFloating = true } // Parse the php7 Parser entrypoint @@ -55,12 +65,7 @@ func (l *Parser) Parse() int { // init l.Lexer.Errors = nil l.rootNode = nil - l.comments = parser.Comments{} - l.positions = parser.Positions{} - l.positionBuilder = &parser.PositionBuilder{ - Positions: &l.positions, - PositionPool: &l.PositionPool, - } + l.positionBuilder = &parser.PositionBuilder{} // parse @@ -82,16 +87,6 @@ func (l *Parser) GetErrors() []*errors.Error { return l.Lexer.Errors } -// GetComments returns comments list -func (l *Parser) GetComments() parser.Comments { - return l.comments -} - -// GetPositions returns positions list -func (l *Parser) GetPositions() parser.Positions { - return l.positions -} - // helpers func lastNode(nn []node.Node) node.Node { @@ -109,11 +104,128 @@ func isDollar(r rune) bool { return r == '$' } +func (l *Parser) MoveFreeFloating(src node.Node, dst node.Node) { + if l.Lexer.WithFreeFloating == false { + return + } + + if src.GetFreeFloating() == nil { + return + } + + l.setFreeFloating(dst, freefloating.Start, (*src.GetFreeFloating())[freefloating.Start]) + delete((*src.GetFreeFloating()), freefloating.Start) +} + +func (l *Parser) setFreeFloating(dst node.Node, p freefloating.Position, strings []freefloating.String) { + if l.Lexer.WithFreeFloating == false { + return + } + + if len(strings) == 0 { + return + } + + dstCollection := dst.GetFreeFloating() + if *dstCollection == nil { + *dstCollection = make(freefloating.Collection) + } + + (*dstCollection)[p] = strings +} + +func (l *Parser) GetFreeFloatingToken(t *scanner.Token) []freefloating.String { + if l.Lexer.WithFreeFloating == false { + return []freefloating.String{} + } + + return t.GetFreeFloatingToken() +} + +func (l *Parser) addDollarToken(v node.Node) { + if l.Lexer.WithFreeFloating == false { + return + } + + l.setFreeFloating(v, freefloating.Dollar, []freefloating.String{ + { + StringType: freefloating.TokenType, + Value: "$", + Position: &position.Position{ + StartLine: v.GetPosition().StartLine, + EndLine: v.GetPosition().StartLine, + StartPos: v.GetPosition().StartPos, + EndPos: v.GetPosition().StartPos + 1, + }, + }, + }) +} + +func (l *Parser) splitSemiColonAndPhpCloseTag(htmlNode node.Node, prevNode node.Node) { + if l.Lexer.WithFreeFloating == false { + return + } + + semiColon := (*prevNode.GetFreeFloating())[freefloating.SemiColon] + delete((*prevNode.GetFreeFloating()), freefloating.SemiColon) + if len(semiColon) == 0 { + return + } + + p := semiColon[0].Position + if semiColon[0].Value[0] == ';' { + l.setFreeFloating(prevNode, freefloating.SemiColon, []freefloating.String{ + { + StringType: freefloating.TokenType, + Value: ";", + Position: &position.Position{ + StartLine: p.StartLine, + EndLine: p.StartLine, + StartPos: p.StartPos, + EndPos: p.StartPos + 1, + }, + }, + }) + } + + vlen := len(semiColon[0].Value) + tlen := 2 + if strings.HasSuffix(semiColon[0].Value, "?>\n") { + tlen = 3 + } + + phpCloseTag := []freefloating.String{} + if vlen-tlen > 1 { + phpCloseTag = append(phpCloseTag, freefloating.String{ + StringType: freefloating.WhiteSpaceType, + Value: semiColon[0].Value[1 : vlen-tlen], + Position: &position.Position{ + StartLine: p.StartLine, + EndLine: p.EndLine, + StartPos: p.StartPos + 1, + EndPos: p.EndPos - tlen, + }, + }) + } + + phpCloseTag = append(phpCloseTag, freefloating.String{ + StringType: freefloating.WhiteSpaceType, + Value: semiColon[0].Value[vlen-tlen:], + Position: &position.Position{ + StartLine: p.EndLine, + EndLine: p.EndLine, + StartPos: p.EndPos - tlen, + EndPos: p.EndPos, + }, + }) + + l.setFreeFloating(htmlNode, freefloating.Start, append(phpCloseTag, (*htmlNode.GetFreeFloating())[freefloating.Start]...)) +} + func (p *Parser) returnTokenToPool(yyDollar []yySymType, yyVAL *yySymType) { for i := 1; i < len(yyDollar); i++ { if yyDollar[i].token != nil { p.TokenPool.Put(yyDollar[i].token) - p.PositionPool.Put(yyDollar[i].token.Position) } yyDollar[i].token = nil } diff --git a/php7/php7.go b/php7/php7.go index 9b96805..b3c5ada 100644 --- a/php7/php7.go +++ b/php7/php7.go @@ -1,5 +1,3 @@ -// Code generated by goyacc -o php7/php7.go php7/php7.y. DO NOT EDIT. - //line php7/php7.y:2 package php7 @@ -10,7 +8,7 @@ import ( "strconv" "strings" - "github.com/z7zmey/php-parser/comment" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/assign" @@ -348,7 +346,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line php7/php7.y:5348 +//line php7/php7.y:5618 //line yacctab:1 var yyExca = [...]int{ @@ -2121,470 +2119,479 @@ yydefault: yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) // save position - yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + if yylex.(*Parser).currentToken.Value == "\xff" { + yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) + } } case 2: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 3: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 4: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 5: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 6: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 7: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 8: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 9: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:311 + //line php7/php7.y:315 { yyVAL.token = yyDollar[1].token } case 10: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 11: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 12: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 13: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 14: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 15: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 16: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 17: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 18: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 19: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 20: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 21: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:312 + //line php7/php7.y:316 { yyVAL.token = yyDollar[1].token } case 22: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 23: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 24: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 25: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 26: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 27: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 28: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 29: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 30: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 31: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:313 + //line php7/php7.y:317 { yyVAL.token = yyDollar[1].token } case 32: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 33: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 34: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 35: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 36: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 37: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 38: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 39: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 40: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 41: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:314 + //line php7/php7.y:318 { yyVAL.token = yyDollar[1].token } case 42: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 43: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 44: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 45: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 46: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 47: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 48: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 49: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 50: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 51: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 52: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:315 + //line php7/php7.y:319 { yyVAL.token = yyDollar[1].token } case 53: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 54: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 55: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 56: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 57: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 58: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 59: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 60: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:316 + //line php7/php7.y:320 { yyVAL.token = yyDollar[1].token } case 61: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 62: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 63: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 64: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 65: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 66: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 67: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 68: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:317 + //line php7/php7.y:321 { yyVAL.token = yyDollar[1].token } case 69: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:322 + //line php7/php7.y:326 { yyVAL.token = yyDollar[1].token } case 70: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 71: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 72: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 73: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 74: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 75: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:325 + //line php7/php7.y:329 { yyVAL.token = yyDollar[1].token } case 76: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:330 + //line php7/php7.y:334 { yyVAL.token = yyDollar[1].token } case 77: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:334 + //line php7/php7.y:338 { yyVAL.token = yyDollar[1].token } case 78: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:341 + //line php7/php7.y:345 { + if inlineHtmlNode, ok := yyDollar[2].node.(*stmt.InlineHtml); ok && len(yyDollar[1].list) > 0 { + prevNode := lastNode(yyDollar[1].list) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if yyDollar[2].node != nil { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) } @@ -2593,7 +2600,7 @@ yydefault: } case 79: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:349 + //line php7/php7.y:358 { yyVAL.list = []node.Node{} @@ -2601,78 +2608,81 @@ yydefault: } case 80: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:358 + //line php7/php7.y:367 { namePart := name.NewNamePart(yyDollar[1].token.Value) yyVAL.list = []node.Node{namePart} // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(namePart, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 81: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:371 + //line php7/php7.y:380 { namePart := name.NewNamePart(yyDollar[3].token.Value) yyVAL.list = append(yyDollar[1].list, namePart) // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(namePart, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 82: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:388 + //line php7/php7.y:397 { yyVAL.node = name.NewName(yyDollar[1].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 83: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:397 + //line php7/php7.y:409 { yyVAL.node = name.NewRelative(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 84: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:410 + //line php7/php7.y:422 { yyVAL.node = name.NewFullyQualified(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 85: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:425 + //line php7/php7.y:437 { // error yyVAL.node = nil @@ -2681,7 +2691,7 @@ yydefault: } case 86: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:432 + //line php7/php7.y:444 { yyVAL.node = yyDollar[1].node @@ -2689,7 +2699,7 @@ yydefault: } case 87: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:438 + //line php7/php7.y:450 { yyVAL.node = yyDollar[1].node @@ -2697,7 +2707,7 @@ yydefault: } case 88: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:444 + //line php7/php7.y:456 { yyVAL.node = yyDollar[1].node @@ -2705,7 +2715,7 @@ yydefault: } case 89: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:450 + //line php7/php7.y:462 { yyVAL.node = yyDollar[1].node @@ -2713,7 +2723,7 @@ yydefault: } case 90: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:456 + //line php7/php7.y:468 { yyVAL.node = yyDollar[1].node @@ -2721,18 +2731,19 @@ yydefault: } case 91: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:462 + //line php7/php7.y:474 { yyVAL.node = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.HaltCompiller, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OpenParenthesisToken, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -2740,270 +2751,286 @@ yydefault: } case 92: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:479 + //line php7/php7.y:492 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewNamespace(name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 93: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:494 + //line php7/php7.y:509 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewNamespace(name, yyDollar[4].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 94: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:510 + //line php7/php7.y:526 { yyVAL.node = stmt.NewNamespace(nil, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Namespace, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 95: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:524 + //line php7/php7.y:540 { yyVAL.node = yyDollar[2].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 96: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:537 + //line php7/php7.y:554 { yyVAL.node = yyDollar[3].node.(*stmt.GroupUse).SetUseType(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 97: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:550 + //line php7/php7.y:568 { yyVAL.node = stmt.NewUseList(nil, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 98: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:563 + //line php7/php7.y:582 { yyVAL.node = stmt.NewUseList(yyDollar[2].node, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseDeclarationList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 99: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:576 + //line php7/php7.y:596 { yyVAL.node = stmt.NewConstList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 100: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:592 + //line php7/php7.y:613 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FunctionToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 101: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:604 + //line php7/php7.y:625 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 102: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:619 + //line php7/php7.y:640 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[4].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[6].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yyDollar[3].token.FreeFloating) if yyDollar[5].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, append(yyDollar[5].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token), yyDollar[6].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[6].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 103: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:638 + //line php7/php7.y:661 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[5].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.UseType, yyDollar[1].token.FreeFloating) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yyDollar[4].token.FreeFloating) if yyDollar[6].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, append(yyDollar[6].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token), yyDollar[7].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[7].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 104: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:661 + //line php7/php7.y:686 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[4].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[6].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yyDollar[3].token.FreeFloating) if yyDollar[5].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, append(yyDollar[5].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token), yyDollar[6].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[6].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 105: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:680 + //line php7/php7.y:707 { name := name.NewName(yyDollar[2].list) yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[5].list) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Use, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).MoveFreeFloating(yyDollar[2].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yyDollar[4].token.FreeFloating) if yyDollar[6].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, append(yyDollar[6].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token), yyDollar[7].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[7].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 106: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:703 + //line php7/php7.y:732 { yyVAL.token = nil } case 107: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:707 + //line php7/php7.y:736 { yyVAL.token = yyDollar[1].token } case 108: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:714 + //line php7/php7.y:743 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 109: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:723 + //line php7/php7.y:752 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3011,18 +3038,18 @@ yydefault: } case 110: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:732 + //line php7/php7.y:761 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 111: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:741 + //line php7/php7.y:770 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3030,18 +3057,18 @@ yydefault: } case 112: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:750 + //line php7/php7.y:779 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 113: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:759 + //line php7/php7.y:788 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3049,7 +3076,7 @@ yydefault: } case 114: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:768 + //line php7/php7.y:797 { yyVAL.node = yyDollar[1].node @@ -3057,7 +3084,7 @@ yydefault: } case 115: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:774 + //line php7/php7.y:803 { yyVAL.node = yyDollar[2].node.(*stmt.Use).SetUseType(yyDollar[1].node) @@ -3065,69 +3092,80 @@ yydefault: } case 116: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:783 + //line php7/php7.y:812 { name := name.NewName(yyDollar[1].list) yyVAL.node = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 117: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:794 + //line php7/php7.y:826 { name := name.NewName(yyDollar[1].list) alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 118: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:814 + //line php7/php7.y:847 { yyVAL.node = yyDollar[1].node + // save coments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node.(*stmt.Use).Use, yyVAL.node) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 119: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:820 + //line php7/php7.y:856 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 120: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:832 + //line php7/php7.y:872 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 121: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:841 + //line php7/php7.y:881 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3135,8 +3173,13 @@ yydefault: } case 122: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:850 + //line php7/php7.y:890 { + if inlineHtmlNode, ok := yyDollar[2].node.(*stmt.InlineHtml); ok && len(yyDollar[1].list) > 0 { + prevNode := lastNode(yyDollar[1].list) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if yyDollar[2].node != nil { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) } @@ -3145,7 +3188,7 @@ yydefault: } case 123: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:858 + //line php7/php7.y:903 { yyVAL.list = []node.Node{} @@ -3153,7 +3196,7 @@ yydefault: } case 124: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:867 + //line php7/php7.y:912 { // error yyVAL.node = nil @@ -3162,7 +3205,7 @@ yydefault: } case 125: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:874 + //line php7/php7.y:919 { yyVAL.node = yyDollar[1].node @@ -3170,7 +3213,7 @@ yydefault: } case 126: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:880 + //line php7/php7.y:925 { yyVAL.node = yyDollar[1].node @@ -3178,7 +3221,7 @@ yydefault: } case 127: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:886 + //line php7/php7.y:931 { yyVAL.node = yyDollar[1].node @@ -3186,7 +3229,7 @@ yydefault: } case 128: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:892 + //line php7/php7.y:937 { yyVAL.node = yyDollar[1].node @@ -3194,7 +3237,7 @@ yydefault: } case 129: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:898 + //line php7/php7.y:943 { yyVAL.node = yyDollar[1].node @@ -3202,39 +3245,40 @@ yydefault: } case 130: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:904 + //line php7/php7.y:949 { yyVAL.node = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.HaltCompiller, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OpenParenthesisToken, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 131: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:921 + //line php7/php7.y:967 { yyVAL.node = stmt.NewStmtList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 132: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:934 + //line php7/php7.y:980 { yyVAL.node = yyDollar[1].node @@ -3242,7 +3286,7 @@ yydefault: } case 133: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:940 + //line php7/php7.y:986 { yyVAL.node = yyDollar[1].node @@ -3250,7 +3294,7 @@ yydefault: } case 134: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:946 + //line php7/php7.y:992 { switch n := yyDollar[5].node.(type) { case *stmt.While: @@ -3262,36 +3306,37 @@ yydefault: yyVAL.node = yyDollar[5].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.While, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 135: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:967 + //line php7/php7.y:1013 { yyVAL.node = stmt.NewDo(yyDollar[2].node, yyDollar[5].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.While, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[7].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 136: yyDollar = yyS[yypt-9 : yypt+1] - //line php7/php7.y:983 + //line php7/php7.y:1030 { switch n := yyDollar[9].node.(type) { case *stmt.For: @@ -3307,20 +3352,20 @@ yydefault: yyVAL.node = yyDollar[9].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.ForInitSemicolonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.ForCondSemicolonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.For, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.InitExpr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CondExpr, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.IncExpr, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 137: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:1010 + //line php7/php7.y:1057 { switch n := yyDollar[5].node.(type) { case *stmt.Switch: @@ -3334,156 +3379,167 @@ yydefault: yyVAL.node = yyDollar[5].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SwitchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Switch, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 138: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1033 + //line php7/php7.y:1080 { yyVAL.node = stmt.NewBreak(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 139: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1046 + //line php7/php7.y:1094 { yyVAL.node = stmt.NewContinue(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 140: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1059 + //line php7/php7.y:1108 { yyVAL.node = stmt.NewReturn(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 141: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1072 + //line php7/php7.y:1122 { yyVAL.node = stmt.NewGlobal(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.GlobalToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 142: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1085 + //line php7/php7.y:1136 { yyVAL.node = stmt.NewStatic(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 143: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1098 + //line php7/php7.y:1150 { yyVAL.node = stmt.NewEcho(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EchoToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Echo, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 144: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1111 + //line php7/php7.y:1165 { yyVAL.node = stmt.NewInlineHtml(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.InlineHTMLToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 145: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1123 + //line php7/php7.y:1177 { yyVAL.node = stmt.NewExpression(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 146: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1135 + //line php7/php7.y:1191 { yyVAL.node = stmt.NewUnset(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UnsetToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Unset, yyDollar[2].token.FreeFloating) if yyDollar[4].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, append(yyDollar[4].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token), yyDollar[5].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[5].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.CloseParenthesisToken, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 147: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:1153 + //line php7/php7.y:1211 { switch n := yyDollar[7].node.(type) { case *stmt.Foreach: @@ -3497,19 +3553,19 @@ yydefault: yyVAL.node = yyDollar[7].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[7].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[7].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Foreach, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[6].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 148: yyDollar = yyS[yypt-9 : yypt+1] - //line php7/php7.y:1177 + //line php7/php7.y:1236 { switch n := yyDollar[9].node.(type) { case *stmt.Foreach: @@ -3525,119 +3581,123 @@ yydefault: yyVAL.node = yyDollar[9].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Foreach, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Key, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 149: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:1204 + //line php7/php7.y:1263 { - yyVAL.node = stmt.NewDeclare(yyDollar[3].list, yyDollar[5].node) + yyVAL.node = yyDollar[5].node + yyVAL.node.(*stmt.Declare).Consts = yyDollar[3].list // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DeclareToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Declare, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ConstList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 150: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1218 + //line php7/php7.y:1278 { yyVAL.node = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 151: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1230 + //line php7/php7.y:1291 { if yyDollar[6].node == nil { yyVAL.node = stmt.NewTry(yyDollar[3].list, yyDollar[5].list, yyDollar[6].node) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[5].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[5].list)) } else { yyVAL.node = stmt.NewTry(yyDollar[3].list, yyDollar[5].list, yyDollar[6].node) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TryToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Try, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 152: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1247 + //line php7/php7.y:1308 { yyVAL.node = stmt.NewThrow(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ThrowToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 153: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1260 + //line php7/php7.y:1322 { label := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewGoto(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.GotoToken) - yylex.(*Parser).comments.AddFromToken(label, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(label, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Label, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 154: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1276 + //line php7/php7.y:1339 { label := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewLabel(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(label, yyDollar[1].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Label, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 155: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1293 + //line php7/php7.y:1356 { yyVAL.list = []node.Node{} @@ -3645,7 +3705,7 @@ yydefault: } case 156: yyDollar = yyS[yypt-9 : yypt+1] - //line php7/php7.y:1299 + //line php7/php7.y:1362 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[5].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -3653,23 +3713,24 @@ yydefault: yyVAL.list = append(yyDollar[1].list, catch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[5].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[5].token)) - yylex.(*Parser).positions.AddPosition(catch, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[9].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[5].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[5].token)) + catch.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[9].token)) // save comments - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[2].token, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[3].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[5].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[6].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[7].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(catch, yyDollar[9].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(catch, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Catch, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[5].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(catch, freefloating.Var, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Cond, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Stmts, yyDollar[9].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 157: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1323 + //line php7/php7.y:1387 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3677,18 +3738,18 @@ yydefault: } case 158: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1329 + //line php7/php7.y:1393 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.VerticalBarToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 159: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1341 + //line php7/php7.y:1405 { yyVAL.node = nil @@ -3696,23 +3757,23 @@ yydefault: } case 160: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1347 + //line php7/php7.y:1411 { yyVAL.node = stmt.NewFinally(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FinallyToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Finally, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 161: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1364 + //line php7/php7.y:1428 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3720,18 +3781,18 @@ yydefault: } case 162: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1370 + //line php7/php7.y:1434 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 163: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1382 + //line php7/php7.y:1446 { yyVAL.node = yyDollar[1].node @@ -3739,93 +3800,106 @@ yydefault: } case 164: yyDollar = yyS[yypt-11 : yypt+1] - //line php7/php7.y:1391 + //line php7/php7.y:1455 { name := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewFunction(name, yyDollar[2].token != nil, yyDollar[6].list, yyDollar[8].node, yyDollar[10].list, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FunctionToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[3].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParamList, yyDollar[7].token.FreeFloating) + if yyDollar[8].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyDollar[8].node.GetFreeFloating())[freefloating.Colon]) + delete((*yyDollar[8].node.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ReturnType, yyDollar[9].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[11].token.FreeFloating) + + // normalize + if yyDollar[8].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.ReturnType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.ReturnType) } - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[9].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[11].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 165: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1417 + //line php7/php7.y:1491 { yyVAL.token = nil } case 166: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1421 + //line php7/php7.y:1495 { yyVAL.token = yyDollar[1].token } case 167: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1428 + //line php7/php7.y:1502 { yyVAL.token = nil } case 168: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1432 + //line php7/php7.y:1506 { yyVAL.token = yyDollar[1].token } case 169: yyDollar = yyS[yypt-9 : yypt+1] - //line php7/php7.y:1439 + //line php7/php7.y:1513 { name := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewClass(name, yyDollar[1].list, nil, yyDollar[4].ClassExtends, yyDollar[5].ClassImplements, yyDollar[8].list, yyDollar[6].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition(yyDollar[1].list, yyDollar[2].token, yyDollar[9].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition(yyDollar[1].list, yyDollar[2].token, yyDollar[9].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[3].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[9].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[7].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[9].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 170: yyDollar = yyS[yypt-8 : yypt+1] - //line php7/php7.y:1456 + //line php7/php7.y:1531 { name := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewClass(name, nil, nil, yyDollar[3].ClassExtends, yyDollar[4].ClassImplements, yyDollar[7].list, yyDollar[5].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 171: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1476 + //line php7/php7.y:1551 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -3833,7 +3907,7 @@ yydefault: } case 172: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1482 + //line php7/php7.y:1557 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -3841,73 +3915,73 @@ yydefault: } case 173: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1491 + //line php7/php7.y:1566 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AbstractToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 174: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1503 + //line php7/php7.y:1578 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FinalToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 175: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1518 + //line php7/php7.y:1593 { name := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewTrait(name, yyDollar[5].list, yyDollar[3].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TraitToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[6].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 176: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:1538 + //line php7/php7.y:1613 { name := node.NewIdentifier(yyDollar[2].token.Value) yyVAL.node = stmt.NewInterface(name, yyDollar[3].InterfaceExtends, yyDollar[6].list, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.InterfaceToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[7].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 177: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1558 + //line php7/php7.y:1633 { yyVAL.ClassExtends = nil @@ -3915,21 +3989,21 @@ yydefault: } case 178: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1564 + //line php7/php7.y:1639 { yyVAL.ClassExtends = stmt.NewClassExtends(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.ClassExtends, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.ClassExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.ClassExtends, yyDollar[1].token, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating(yyVAL.ClassExtends, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 179: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1579 + //line php7/php7.y:1654 { yyVAL.InterfaceExtends = nil @@ -3937,21 +4011,21 @@ yydefault: } case 180: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1585 + //line php7/php7.y:1660 { yyVAL.InterfaceExtends = stmt.NewInterfaceExtends(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.InterfaceExtends, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.InterfaceExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.InterfaceExtends, yyDollar[1].token, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating(yyVAL.InterfaceExtends, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 181: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1600 + //line php7/php7.y:1675 { yyVAL.ClassImplements = nil @@ -3959,21 +4033,21 @@ yydefault: } case 182: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1606 + //line php7/php7.y:1681 { yyVAL.ClassImplements = stmt.NewClassImplements(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.ClassImplements, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) + yyVAL.ClassImplements.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.ClassImplements, yyDollar[1].token, comment.ImplementsToken) + yylex.(*Parser).setFreeFloating(yyVAL.ClassImplements, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 183: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1621 + //line php7/php7.y:1696 { yyVAL.node = yyDollar[1].node @@ -3981,207 +4055,217 @@ yydefault: } case 184: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:1627 + //line php7/php7.y:1702 { yyVAL.node = expr.NewReference(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyDollar[2].node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 185: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1639 + //line php7/php7.y:1714 { yyVAL.node = expr.NewList(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 186: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1653 + //line php7/php7.y:1728 { yyVAL.node = expr.NewShortList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseSquareBracket) + // save commentsc + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 187: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1669 + //line php7/php7.y:1744 { yyVAL.node = stmt.NewFor(nil, nil, nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 188: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1678 + //line php7/php7.y:1753 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltFor(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndforToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 189: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1697 + //line php7/php7.y:1773 { yyVAL.node = stmt.NewForeach(nil, nil, nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 190: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1706 + //line php7/php7.y:1782 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltForeach(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndforeachToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 191: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1725 + //line php7/php7.y:1802 { - yyVAL.node = yyDollar[1].node + yyVAL.node = stmt.NewDeclare(nil, yyDollar[1].node, false) + + // save position + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 192: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1731 + //line php7/php7.y:1811 { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) + stmtList := stmt.NewStmtList(yyDollar[2].list) + yyVAL.node = stmt.NewDeclare(nil, stmtList, true) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EnddeclareToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 193: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1748 + //line php7/php7.y:1831 { caseList := stmt.NewCaseList(yyDollar[2].list) yyVAL.node = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 194: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1763 + //line php7/php7.y:1846 { caseList := stmt.NewCaseList(yyDollar[3].list) yyVAL.node = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[2].token, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 195: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1779 + //line php7/php7.y:1862 { caseList := stmt.NewCaseList(yyDollar[2].list) yyVAL.node = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[3].token, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 196: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:1795 + //line php7/php7.y:1879 { caseList := stmt.NewCaseList(yyDollar[3].list) yyVAL.node = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[2].token, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, yyDollar[4].token, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 197: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:1816 + //line php7/php7.y:1901 { yyVAL.list = []node.Node{} @@ -4189,114 +4273,117 @@ yydefault: } case 198: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:1822 + //line php7/php7.y:1907 { _case := stmt.NewCase(yyDollar[3].node, yyDollar[5].list) yyVAL.list = append(yyDollar[1].list, _case) // save position - yylex.(*Parser).positions.AddPosition(_case, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) + _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_case, yyDollar[2].token, comment.CaseToken) - yylex.(*Parser).comments.AddFromToken(_case, yyDollar[4].token, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_case, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.Expr, append(yyDollar[4].token.FreeFloating)) + yylex.(*Parser).setFreeFloating(_case, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 199: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1836 + //line php7/php7.y:1922 { _default := stmt.NewDefault(yyDollar[4].list) yyVAL.list = append(yyDollar[1].list, _default) // save position - yylex.(*Parser).positions.AddPosition(_default, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) + _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_default, yyDollar[2].token, comment.DefaultToken) - yylex.(*Parser).comments.AddFromToken(_default, yyDollar[3].token, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_default, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.Default, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 200: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1853 + //line php7/php7.y:1940 { yyVAL.token = yyDollar[1].token } case 201: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1857 + //line php7/php7.y:1944 { yyVAL.token = yyDollar[1].token } case 202: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1864 + //line php7/php7.y:1951 { yyVAL.node = stmt.NewWhile(nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 203: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:1873 + //line php7/php7.y:1960 { stmtList := stmt.NewStmtList(yyDollar[2].list) yyVAL.node = stmt.NewAltWhile(nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EndwhileToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 204: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:1892 + //line php7/php7.y:1980 { yyVAL.node = stmt.NewIf(yyDollar[3].node, yyDollar[5].node, nil, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IfToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.If, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 205: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1906 + //line php7/php7.y:1994 { _elseIf := stmt.NewElseIf(yyDollar[4].node, yyDollar[6].node) yyVAL.node = yyDollar[1].node.(*stmt.If).AddElseIf(_elseIf) // save position - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[2].token, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[3].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[5].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 206: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:1925 + //line php7/php7.y:2013 { yyVAL.node = yyDollar[1].node @@ -4304,98 +4391,100 @@ yydefault: } case 207: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1931 + //line php7/php7.y:2019 { _else := stmt.NewElse(yyDollar[3].node) yyVAL.node = yyDollar[1].node.(*stmt.If).SetElse(_else) // save position - yylex.(*Parser).positions.AddPosition(_else, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[3].node)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + _else.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ElseToken) + yylex.(*Parser).setFreeFloating(_else, freefloating.Start, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 208: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1948 + //line php7/php7.y:2036 { stmts := stmt.NewStmtList(yyDollar[6].list) yyVAL.node = stmt.NewAltIf(yyDollar[3].node, stmts, nil, nil) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[6].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[6].list)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[6].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[6].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IfToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.If, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 209: yyDollar = yyS[yypt-7 : yypt+1] - //line php7/php7.y:1965 + //line php7/php7.y:2053 { stmts := stmt.NewStmtList(yyDollar[7].list) _elseIf := stmt.NewAltElseIf(yyDollar[4].node, stmts) yyVAL.node = yyDollar[1].node.(*stmt.AltIf).AddElseIf(_elseIf) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[7].list)) - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[7].list)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[7].list)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[7].list)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[2].token, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[3].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[5].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, yyDollar[6].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Cond, yyDollar[6].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 210: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:1986 + //line php7/php7.y:2074 { yyVAL.node = yyDollar[1].node // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 211: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:1999 + //line php7/php7.y:2088 { stmts := stmt.NewStmtList(yyDollar[4].list) _else := stmt.NewAltElse(stmts) yyVAL.node = yyDollar[1].node.(*stmt.AltIf).SetElse(_else) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[4].list)) - yylex.(*Parser).positions.AddPosition(_else, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[4].list)) + _else.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(_else, yyDollar[2].token, comment.ElseToken) - yylex.(*Parser).comments.AddFromToken(_else, yyDollar[3].token, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(_else, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(_else, freefloating.Else, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[5].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AltEnd, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 212: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2021 + //line php7/php7.y:2111 { yyVAL.list = yyDollar[1].list @@ -4403,7 +4492,7 @@ yydefault: } case 213: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2027 + //line php7/php7.y:2117 { yyVAL.list = nil @@ -4411,7 +4500,7 @@ yydefault: } case 214: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2036 + //line php7/php7.y:2126 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4419,83 +4508,119 @@ yydefault: } case 215: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2042 + //line php7/php7.y:2132 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 216: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2054 + //line php7/php7.y:2144 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, nil, yyDollar[2].token != nil, yyDollar[3].token != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].node != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) } else if yyDollar[2].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) } else if yyDollar[3].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) } // save comments + if yyDollar[1].node != nil { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + } if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) } if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Variadic, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + + // normalize + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, (*yyVAL.node.GetFreeFloating())[freefloating.Variadic]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Variadic) + } + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, (*yyVAL.node.GetFreeFloating())[freefloating.Ampersand]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Ampersand) + } + if yyDollar[1].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, (*yyVAL.node.GetFreeFloating())[freefloating.OptionalType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.VariableToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 217: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:2084 + //line php7/php7.y:2189 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = node.NewParameter(yyDollar[1].node, variable, yyDollar[6].node, yyDollar[2].token != nil, yyDollar[3].token != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].node != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) } else if yyDollar[2].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) } else if yyDollar[3].token != nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) } // save comments + if yyDollar[1].node != nil { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + } if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) } if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[3].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Variadic, yyDollar[4].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[5].token.FreeFloating) + + // normalize + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, (*yyVAL.node.GetFreeFloating())[freefloating.Variadic]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Variadic) + } + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.OptionalType, (*yyVAL.node.GetFreeFloating())[freefloating.Ampersand]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.Ampersand) + } + if yyDollar[1].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, (*yyVAL.node.GetFreeFloating())[freefloating.OptionalType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[4].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.EqualToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 218: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2118 + //line php7/php7.y:2238 { yyVAL.node = nil @@ -4503,7 +4628,7 @@ yydefault: } case 219: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2124 + //line php7/php7.y:2244 { yyVAL.node = yyDollar[1].node @@ -4511,7 +4636,7 @@ yydefault: } case 220: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2133 + //line php7/php7.y:2253 { yyVAL.node = yyDollar[1].node @@ -4519,49 +4644,49 @@ yydefault: } case 221: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2139 + //line php7/php7.y:2259 { yyVAL.node = node.NewNullable(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.QuestionMarkToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 222: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2154 + //line php7/php7.y:2274 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 223: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2166 + //line php7/php7.y:2286 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.CallableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 224: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2178 + //line php7/php7.y:2298 { yyVAL.node = yyDollar[1].node @@ -4569,7 +4694,7 @@ yydefault: } case 225: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2187 + //line php7/php7.y:2307 { yyVAL.node = nil @@ -4577,51 +4702,52 @@ yydefault: } case 226: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2193 + //line php7/php7.y:2313 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Colon, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 227: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2205 + //line php7/php7.y:2325 { yyVAL.node = node.NewArgumentList(nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 228: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2218 + //line php7/php7.y:2338 { yyVAL.node = node.NewArgumentList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, append(yyDollar[3].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token), yyDollar[4].token.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArgumentList, yyDollar[4].token.FreeFloating) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 229: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2237 + //line php7/php7.y:2358 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4629,54 +4755,57 @@ yydefault: } case 230: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2243 + //line php7/php7.y:2364 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 231: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2255 + //line php7/php7.y:2376 { yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 232: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2264 + //line php7/php7.y:2388 { yyVAL.node = node.NewArgument(yyDollar[2].node, true, false) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 233: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2279 + //line php7/php7.y:2403 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 234: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2288 + //line php7/php7.y:2412 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4684,7 +4813,7 @@ yydefault: } case 235: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2297 + //line php7/php7.y:2421 { yyVAL.node = yyDollar[1].node @@ -4692,18 +4821,18 @@ yydefault: } case 236: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2306 + //line php7/php7.y:2430 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 237: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2315 + //line php7/php7.y:2439 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4711,44 +4840,46 @@ yydefault: } case 238: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2324 + //line php7/php7.y:2448 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = stmt.NewStaticVar(variable, nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 239: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2340 + //line php7/php7.y:2465 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = stmt.NewStaticVar(variable, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 240: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2360 + //line php7/php7.y:2486 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -4756,7 +4887,7 @@ yydefault: } case 241: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2366 + //line php7/php7.y:2492 { yyVAL.list = []node.Node{} @@ -4764,86 +4895,95 @@ yydefault: } case 242: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2375 + //line php7/php7.y:2501 { yyVAL.node = stmt.NewPropertyList(yyDollar[1].list, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.PropertyList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 243: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2387 + //line php7/php7.y:2515 { yyVAL.node = stmt.NewClassConstList(yyDollar[1].list, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition(yyDollar[1].list, yyDollar[2].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition(yyDollar[1].list, yyDollar[2].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.SemiColonToken) + if len(yyDollar[1].list) > 0 { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[2].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ConstList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 244: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2400 + //line php7/php7.y:2534 { - var adaptationList *stmt.TraitAdaptationList - - switch n := yyDollar[3].node.(type) { - case *stmt.TraitAdaptationList: - adaptationList = n - default: - adaptationList = nil - yylex.(*Parser).comments.AddFromChildNode(yyVAL.node, yyDollar[3].node) - } - - yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, adaptationList) + yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UseToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 245: yyDollar = yyS[yypt-10 : yypt+1] - //line php7/php7.y:2422 + //line php7/php7.y:2546 { name := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewClassMethod(name, yyDollar[1].list, yyDollar[3].token != nil, yyDollar[7].list, yyDollar[9].node, yyDollar[10].node, yyDollar[5].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) if yyDollar[1].list == nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[10].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[10].node)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[10].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[10].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.FunctionToken) - if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + if len(yyDollar[1].list) > 0 { + yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ModifierList, yyDollar[2].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[2].token.FreeFloating) + } + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[4].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[4].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[8].token.FreeFloating) + if yyDollar[9].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyDollar[9].node.GetFreeFloating())[freefloating.Colon]) + delete((*yyDollar[9].node.GetFreeFloating()), freefloating.Colon) } - yylex.(*Parser).comments.AddFromToken(name, yyDollar[4].token, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 246: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2449 + //line php7/php7.y:2583 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4851,59 +4991,60 @@ yydefault: } case 247: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2455 + //line php7/php7.y:2589 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 248: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2467 + //line php7/php7.y:2601 { yyVAL.node = stmt.NewNop() - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 249: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2479 + //line php7/php7.y:2614 { yyVAL.node = stmt.NewTraitAdaptationList(nil) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AdaptationList, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 250: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2491 + //line php7/php7.y:2626 { yyVAL.node = stmt.NewTraitAdaptationList(yyDollar[2].list) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.AdaptationList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 251: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2506 + //line php7/php7.y:2641 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -4911,7 +5052,7 @@ yydefault: } case 252: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2512 + //line php7/php7.y:2647 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -4919,124 +5060,131 @@ yydefault: } case 253: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2521 + //line php7/php7.y:2656 { yyVAL.node = yyDollar[1].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.NameList, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 254: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2530 + //line php7/php7.y:2666 { yyVAL.node = yyDollar[1].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Alias, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 255: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2542 + //line php7/php7.y:2679 { yyVAL.node = stmt.NewTraitUsePrecedence(yyDollar[1].node, yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.InsteadofToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 256: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2557 + //line php7/php7.y:2695 { alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, nil, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 257: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2572 + //line php7/php7.y:2711 { alias := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, nil, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 258: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2587 + //line php7/php7.y:2727 { alias := node.NewIdentifier(yyDollar[4].token.Value) yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, yyDollar[4].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 259: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2602 + //line php7/php7.y:2743 { yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ref, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 260: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2617 + //line php7/php7.y:2759 { name := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewTraitMethodRef(nil, name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 261: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2631 + //line php7/php7.y:2773 { yyVAL.node = yyDollar[1].node @@ -5044,53 +5192,55 @@ yydefault: } case 262: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2640 + //line php7/php7.y:2782 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = stmt.NewTraitMethodRef(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, yyDollar[3].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 263: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2658 + //line php7/php7.y:2801 { yyVAL.node = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 264: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2670 + //line php7/php7.y:2814 { yyVAL.node = stmt.NewStmtList(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 265: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2686 + //line php7/php7.y:2830 { yyVAL.list = yyDollar[1].list @@ -5098,22 +5248,22 @@ yydefault: } case 266: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2692 + //line php7/php7.y:2836 { modifier := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.list = []node.Node{modifier} // save position - yylex.(*Parser).positions.AddPosition(modifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(modifier, yyDollar[1].token, comment.VarToken) + yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 267: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2708 + //line php7/php7.y:2852 { yyVAL.list = nil @@ -5121,7 +5271,7 @@ yydefault: } case 268: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2714 + //line php7/php7.y:2858 { yyVAL.list = yyDollar[1].list @@ -5129,7 +5279,7 @@ yydefault: } case 269: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2723 + //line php7/php7.y:2867 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5137,7 +5287,7 @@ yydefault: } case 270: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2729 + //line php7/php7.y:2873 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -5145,102 +5295,102 @@ yydefault: } case 271: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2738 + //line php7/php7.y:2882 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PublicToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 272: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2750 + //line php7/php7.y:2894 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ProtectedToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 273: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2762 + //line php7/php7.y:2906 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PrivateToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 274: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2774 + //line php7/php7.y:2918 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 275: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2786 + //line php7/php7.y:2930 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AbstractToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 276: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2798 + //line php7/php7.y:2942 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FinalToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 277: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2813 + //line php7/php7.y:2957 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 278: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2822 + //line php7/php7.y:2966 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5248,55 +5398,57 @@ yydefault: } case 279: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:2831 + //line php7/php7.y:2975 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = stmt.NewProperty(variable, nil, yyDollar[2].str) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 280: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2847 + //line php7/php7.y:2992 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = stmt.NewProperty(variable, yyDollar[3].node, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 281: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2867 + //line php7/php7.y:3013 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 282: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2876 + //line php7/php7.y:3022 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5304,52 +5456,52 @@ yydefault: } case 283: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2885 + //line php7/php7.y:3031 { name := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewConstant(name, yyDollar[3].node, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 284: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:2903 + //line php7/php7.y:3049 { name := node.NewIdentifier(yyDollar[1].token.Value) yyVAL.node = stmt.NewConstant(name, yyDollar[3].node, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(name, yyDollar[1].token, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 285: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2921 + //line php7/php7.y:3067 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 286: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2930 + //line php7/php7.y:3076 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5357,7 +5509,7 @@ yydefault: } case 287: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2939 + //line php7/php7.y:3085 { yyVAL.node = yyDollar[1].node @@ -5365,7 +5517,7 @@ yydefault: } case 288: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:2948 + //line php7/php7.y:3094 { yyVAL.list = nil @@ -5373,7 +5525,7 @@ yydefault: } case 289: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2954 + //line php7/php7.y:3100 { yyVAL.list = yyDollar[1].list @@ -5381,18 +5533,18 @@ yydefault: } case 290: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:2963 + //line php7/php7.y:3109 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 291: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:2972 + //line php7/php7.y:3118 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -5400,7 +5552,7 @@ yydefault: } case 292: yyDollar = yyS[yypt-8 : yypt+1] - //line php7/php7.y:2981 + //line php7/php7.y:3127 { if yyDollar[2].node != nil { yyVAL.node = stmt.NewClass(nil, nil, yyDollar[2].node.(*node.ArgumentList), yyDollar[3].ClassExtends, yyDollar[4].ClassImplements, yyDollar[7].list, yyDollar[5].str) @@ -5409,799 +5561,843 @@ yydefault: } // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[8].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[6].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[8].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 293: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3002 + //line php7/php7.y:3148 { if yyDollar[3].node != nil { yyVAL.node = expr.NewNew(yyDollar[2].node, yyDollar[3].node.(*node.ArgumentList)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) } else { yyVAL.node = expr.NewNew(yyDollar[2].node, nil) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NewToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 294: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3017 + //line php7/php7.y:3163 { yyVAL.node = expr.NewNew(yyDollar[2].node, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NewToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 295: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:3032 + //line php7/php7.y:3178 { - list := expr.NewList(yyDollar[3].list) - yyVAL.node = assign.NewAssign(list, yyDollar[6].node) + listNode := expr.NewList(yyDollar[3].list) + yyVAL.node = assign.NewAssign(listNode, yyDollar[6].node) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) // save comments - yylex.(*Parser).comments.AddFromToken(list, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[4].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[5].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 296: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:3049 + //line php7/php7.y:3195 { shortList := expr.NewShortList(yyDollar[2].list) yyVAL.node = assign.NewAssign(shortList, yyDollar[5].node) // save position - yylex.(*Parser).positions.AddPosition(shortList, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) + shortList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(shortList, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(shortList, yyDollar[3].token, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.EqualToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(shortList, freefloating.ArrayPairList, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 297: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3065 + //line php7/php7.y:3211 { yyVAL.node = assign.NewAssign(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 298: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:3077 + //line php7/php7.y:3224 { yyVAL.node = assign.NewReference(yyDollar[1].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 299: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3090 + //line php7/php7.y:3238 { yyVAL.node = expr.NewClone(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.CloneToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 300: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3102 + //line php7/php7.y:3250 { yyVAL.node = assign.NewPlus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PlusEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 301: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3114 + //line php7/php7.y:3263 { yyVAL.node = assign.NewMinus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MinusEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 302: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3126 + //line php7/php7.y:3276 { yyVAL.node = assign.NewMul(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MulEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 303: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3138 + //line php7/php7.y:3289 { yyVAL.node = assign.NewPow(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PowEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 304: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3150 + //line php7/php7.y:3302 { yyVAL.node = assign.NewDiv(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DivEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 305: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3162 + //line php7/php7.y:3315 { yyVAL.node = assign.NewConcat(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ConcatEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 306: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3174 + //line php7/php7.y:3328 { yyVAL.node = assign.NewMod(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ModEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 307: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3186 + //line php7/php7.y:3341 { yyVAL.node = assign.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AndEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 308: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3198 + //line php7/php7.y:3354 { yyVAL.node = assign.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 309: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3210 + //line php7/php7.y:3367 { yyVAL.node = assign.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.XorEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 310: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3222 + //line php7/php7.y:3380 { yyVAL.node = assign.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 311: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3234 + //line php7/php7.y:3393 { yyVAL.node = assign.NewShiftRight(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 312: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3246 + //line php7/php7.y:3406 { yyVAL.node = expr.NewPostInc(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IncToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 313: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3258 + //line php7/php7.y:3419 { yyVAL.node = expr.NewPreInc(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 314: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3270 + //line php7/php7.y:3431 { yyVAL.node = expr.NewPostDec(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DecToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 315: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3282 + //line php7/php7.y:3444 { yyVAL.node = expr.NewPreDec(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DecToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 316: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3294 + //line php7/php7.y:3456 { yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 317: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3306 + //line php7/php7.y:3469 { yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 318: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3318 + //line php7/php7.y:3482 { yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 319: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3330 + //line php7/php7.y:3495 { yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 320: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3342 + //line php7/php7.y:3508 { yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 321: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3354 + //line php7/php7.y:3521 { yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 322: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3366 + //line php7/php7.y:3534 { yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 323: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3378 + //line php7/php7.y:3547 { yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 324: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3390 + //line php7/php7.y:3560 { yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DotToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 325: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3402 + //line php7/php7.y:3573 { yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 326: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3414 + //line php7/php7.y:3586 { yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 327: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3426 + //line php7/php7.y:3599 { yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 328: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3438 + //line php7/php7.y:3612 { yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 329: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3450 + //line php7/php7.y:3625 { yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 330: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3462 + //line php7/php7.y:3638 { yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 331: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3474 + //line php7/php7.y:3651 { yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SlToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 332: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3486 + //line php7/php7.y:3664 { yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SrToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 333: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3498 + //line php7/php7.y:3677 { yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PlusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 334: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3510 + //line php7/php7.y:3689 { yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MinusToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 335: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3522 + //line php7/php7.y:3701 { yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 336: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3534 + //line php7/php7.y:3713 { yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TildeToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 337: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3546 + //line php7/php7.y:3725 { yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 338: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3558 + //line php7/php7.y:3738 { yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 339: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3570 + //line php7/php7.y:3751 { yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 340: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3582 + //line php7/php7.y:3764 { yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 341: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3594 + //line php7/php7.y:3778 { yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.LessToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 342: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3606 + //line php7/php7.y:3791 { yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 343: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3618 + //line php7/php7.y:3804 { yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 344: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3630 + //line php7/php7.y:3817 { yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 345: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3642 + //line php7/php7.y:3830 { yyVAL.node = binary.NewSpaceship(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.SpaceshipToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 346: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3654 + //line php7/php7.y:3843 { yyVAL.node = expr.NewInstanceOf(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.InstanceofToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 347: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3666 + //line php7/php7.y:3856 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 348: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:3676 + //line php7/php7.y:3866 { yyVAL.node = yyDollar[1].node @@ -6209,51 +6405,54 @@ yydefault: } case 349: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:3682 + //line php7/php7.y:3872 { yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 350: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:3695 + //line php7/php7.y:3886 { yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cond, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.True, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 351: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3708 + //line php7/php7.y:3900 { yyVAL.node = binary.NewCoalesce(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.CoalesceToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 352: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:3720 + //line php7/php7.y:3913 { yyVAL.node = yyDollar[1].node @@ -6261,151 +6460,155 @@ yydefault: } case 353: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3726 + //line php7/php7.y:3919 { yyVAL.node = cast.NewInt(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IntCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 354: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3738 + //line php7/php7.y:3932 { yyVAL.node = cast.NewDouble(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoubleCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 355: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3750 + //line php7/php7.y:3945 { yyVAL.node = cast.NewString(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 356: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3762 + //line php7/php7.y:3958 { yyVAL.node = cast.NewArray(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 357: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3774 + //line php7/php7.y:3971 { yyVAL.node = cast.NewObject(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ObjectCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 358: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3786 + //line php7/php7.y:3984 { yyVAL.node = cast.NewBool(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BoolCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 359: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3798 + //line php7/php7.y:3997 { yyVAL.node = cast.NewUnset(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.UnsetCastToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 360: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3810 + //line php7/php7.y:4010 { - if strings.EqualFold(yyDollar[1].token.Value, "die") { - yyVAL.node = expr.NewDie(nil) - if yyDollar[2].node != nil { - yyVAL.node.(*expr.Die).Expr = yyDollar[2].node.(*expr.Exit).Expr - } + var e *expr.Exit + if yyDollar[2].node != nil { + e = yyDollar[2].node.(*expr.Exit) } else { - yyVAL.node = expr.NewExit(nil) - if yyDollar[2].node != nil { - yyVAL.node.(*expr.Exit).Expr = yyDollar[2].node.(*expr.Exit).Expr - } + e = expr.NewExit(nil) + } + + yyVAL.node = e + + if strings.EqualFold(yyDollar[1].token.Value, "die") { + e.Die = true } // save position if yyDollar[2].node == nil { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) } else { - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) } // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ExitToken) - - if yyDollar[2].node != nil { - yylex.(*Parser).comments.AddFromChildNode(yyVAL.node, yyDollar[2].node) - } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 361: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3840 + //line php7/php7.y:4037 { yyVAL.node = expr.NewErrorSuppress(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AtToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 362: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:3852 + //line php7/php7.y:4049 { yyVAL.node = yyDollar[1].node @@ -6413,136 +6616,167 @@ yydefault: } case 363: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:3858 + //line php7/php7.y:4055 { yyVAL.node = expr.NewShellExec(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.BackquoteToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.BackquoteToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 364: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3871 + //line php7/php7.y:4067 { yyVAL.node = expr.NewPrint(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.PrintToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 365: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:3883 + //line php7/php7.y:4079 { yyVAL.node = expr.NewYield(nil, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 366: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3895 + //line php7/php7.y:4091 { yyVAL.node = expr.NewYield(nil, yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 367: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:3907 + //line php7/php7.y:4103 { yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 368: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:3920 + //line php7/php7.y:4116 { yyVAL.node = expr.NewYieldFrom(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.YieldFromToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 369: yyDollar = yyS[yypt-11 : yypt+1] - //line php7/php7.y:3932 + //line php7/php7.y:4128 { yyVAL.node = expr.NewClosure(yyDollar[5].list, yyDollar[7].ClosureUse, yyDollar[8].node, yyDollar[10].list, false, yyDollar[2].token != nil, yyDollar[3].str) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FunctionToken) - if yyDollar[2].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + if yyDollar[2].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[4].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[4].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[6].token.FreeFloating) + if yyDollar[8].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, (*yyDollar[8].node.GetFreeFloating())[freefloating.Colon]) + delete((*yyDollar[8].node.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ReturnType, yyDollar[9].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[11].token.FreeFloating) + + // normalize + if yyDollar[8].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, (*yyVAL.node.GetFreeFloating())[freefloating.ReturnType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.ReturnType) + } + if yyDollar[7].ClosureUse == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.LexicalVarList]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.LexicalVarList) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[9].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[11].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 370: yyDollar = yyS[yypt-12 : yypt+1] - //line php7/php7.y:3951 + //line php7/php7.y:4160 { yyVAL.node = expr.NewClosure(yyDollar[6].list, yyDollar[8].ClosureUse, yyDollar[9].node, yyDollar[11].list, true, yyDollar[3].token != nil, yyDollar[4].str) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[12].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[12].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.FunctionToken) - if yyDollar[3].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Static, yyDollar[2].token.FreeFloating) + if yyDollar[3].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[5].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Function, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Ampersand, yyDollar[5].token.FreeFloating) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ParameterList, yyDollar[7].token.FreeFloating) + if yyDollar[9].node != nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, (*yyDollar[9].node.GetFreeFloating())[freefloating.Colon]) + delete((*yyDollar[9].node.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ReturnType, yyDollar[10].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Stmts, yyDollar[12].token.FreeFloating) + + // normalize + if yyDollar[9].node == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.LexicalVars, (*yyVAL.node.GetFreeFloating())[freefloating.ReturnType]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.ReturnType) + } + if yyDollar[8].ClosureUse == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.LexicalVarList]) + delete((*yyVAL.node.GetFreeFloating()), freefloating.LexicalVarList) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[7].token, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[10].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[12].token, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 371: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:3974 + //line php7/php7.y:4196 { yyVAL.str = yylex.(*Parser).PhpDocComment yylex.(*Parser).PhpDocComment = "" @@ -6551,19 +6785,19 @@ yydefault: } case 372: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:3984 + //line php7/php7.y:4206 { yyVAL.token = nil } case 373: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:3988 + //line php7/php7.y:4210 { yyVAL.token = yyDollar[1].token } case 374: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:3995 + //line php7/php7.y:4217 { yyVAL.ClosureUse = nil @@ -6571,34 +6805,34 @@ yydefault: } case 375: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4001 + //line php7/php7.y:4223 { yyVAL.ClosureUse = expr.NewClosureUse(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.ClosureUse, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.ClosureUse.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.ClosureUse, yyDollar[1].token, comment.UseToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.ClosureUse, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.ClosureUse, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.Use, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.ClosureUse, freefloating.LexicalVarList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 376: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4018 + //line php7/php7.y:4240 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 377: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4027 + //line php7/php7.y:4249 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -6606,106 +6840,116 @@ yydefault: } case 378: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4036 + //line php7/php7.y:4258 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 379: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4050 + //line php7/php7.y:4273 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = expr.NewReference(variable) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.AmpersandToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[2].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, yyDollar[2].token.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 380: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4070 + //line php7/php7.y:4294 { yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 381: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4079 + //line php7/php7.y:4306 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 382: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4091 + //line php7/php7.y:4319 { yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 383: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4103 + //line php7/php7.y:4332 { yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[2].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 384: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4115 + //line php7/php7.y:4347 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StaticToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 385: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4127 + //line php7/php7.y:4359 { yyVAL.node = yyDollar[1].node @@ -6713,7 +6957,7 @@ yydefault: } case 386: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4136 + //line php7/php7.y:4368 { yyVAL.node = yyDollar[1].node @@ -6721,7 +6965,7 @@ yydefault: } case 387: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4142 + //line php7/php7.y:4374 { yyVAL.node = yyDollar[1].node @@ -6729,7 +6973,7 @@ yydefault: } case 388: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:4151 + //line php7/php7.y:4383 { yyVAL.node = nil @@ -6737,22 +6981,22 @@ yydefault: } case 389: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4157 + //line php7/php7.y:4389 { yyVAL.node = expr.NewExit(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Exit, append(yyDollar[1].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 390: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:4173 + //line php7/php7.y:4405 { yyVAL.list = []node.Node{} @@ -6760,15 +7004,19 @@ yydefault: } case 391: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4179 + //line php7/php7.y:4411 { - yyVAL.list = []node.Node{scalar.NewEncapsedStringPart(yyDollar[1].token.Value)} + part := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) + yyVAL.list = []node.Node{part} + + // save position + part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 392: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4185 + //line php7/php7.y:4421 { yyVAL.list = yyDollar[1].list @@ -6776,7 +7024,7 @@ yydefault: } case 393: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:4194 + //line php7/php7.y:4430 { yyVAL.node = nil @@ -6784,7 +7032,7 @@ yydefault: } case 394: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4200 + //line php7/php7.y:4436 { yyVAL.node = yyDollar[1].node @@ -6792,250 +7040,250 @@ yydefault: } case 395: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4209 + //line php7/php7.y:4445 { yyVAL.node = expr.NewArray(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Array, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 396: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4223 + //line php7/php7.y:4459 { yyVAL.node = expr.NewShortArray(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ArrayPairList, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 397: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4236 + //line php7/php7.y:4472 { yyVAL.node = scalar.NewString(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ConstantEncapsedStringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 398: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4251 + //line php7/php7.y:4487 { yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.LnumberToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 399: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4263 + //line php7/php7.y:4499 { yyVAL.node = scalar.NewDnumber(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DnumberToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 400: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4275 + //line php7/php7.y:4511 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.LineToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 401: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4287 + //line php7/php7.y:4523 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FileToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 402: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4299 + //line php7/php7.y:4535 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DirToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 403: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4311 + //line php7/php7.y:4547 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.TraitCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 404: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4323 + //line php7/php7.y:4559 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MethodCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 405: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4335 + //line php7/php7.y:4571 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.FuncCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 406: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4347 + //line php7/php7.y:4583 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NsCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 407: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4359 + //line php7/php7.y:4595 { yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.ClassCToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 408: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4371 + //line php7/php7.y:4607 { encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, []node.Node{encapsed}) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 409: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4385 + //line php7/php7.y:4621 { yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, nil) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 410: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4397 + //line php7/php7.y:4633 { yyVAL.node = scalar.NewEncapsed(yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DoubleQuoteToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 411: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4409 + //line php7/php7.y:4645 { yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, yyDollar[2].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 412: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4421 + //line php7/php7.y:4657 { yyVAL.node = yyDollar[1].node @@ -7043,7 +7291,7 @@ yydefault: } case 413: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4427 + //line php7/php7.y:4663 { yyVAL.node = yyDollar[1].node @@ -7051,52 +7299,57 @@ yydefault: } case 414: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4436 + //line php7/php7.y:4672 { yyVAL.node = expr.NewConstFetch(yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 415: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4445 + //line php7/php7.y:4684 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, yyDollar[3].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 416: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4460 + //line php7/php7.y:4700 { target := node.NewIdentifier(yyDollar[3].token.Value) yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, yyDollar[3].token, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 417: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4478 + //line php7/php7.y:4719 { yyVAL.node = yyDollar[1].node @@ -7104,7 +7357,7 @@ yydefault: } case 418: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4484 + //line php7/php7.y:4725 { yyVAL.node = yyDollar[1].node @@ -7112,7 +7365,7 @@ yydefault: } case 419: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:4493 + //line php7/php7.y:4734 { yyVAL.node = nil @@ -7120,7 +7373,7 @@ yydefault: } case 420: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4499 + //line php7/php7.y:4740 { yyVAL.node = yyDollar[1].node @@ -7128,7 +7381,7 @@ yydefault: } case 421: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4508 + //line php7/php7.y:4749 { yyVAL.node = yyDollar[1].node @@ -7136,7 +7389,7 @@ yydefault: } case 422: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4517 + //line php7/php7.y:4758 { yyVAL.node = yyDollar[1].node @@ -7144,19 +7397,19 @@ yydefault: } case 423: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4523 + //line php7/php7.y:4764 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 424: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4533 + //line php7/php7.y:4774 { yyVAL.node = yyDollar[1].node @@ -7164,7 +7417,7 @@ yydefault: } case 425: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4542 + //line php7/php7.y:4783 { yyVAL.node = yyDollar[1].node @@ -7172,19 +7425,19 @@ yydefault: } case 426: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4548 + //line php7/php7.y:4789 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 427: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4558 + //line php7/php7.y:4799 { yyVAL.node = yyDollar[1].node @@ -7192,7 +7445,7 @@ yydefault: } case 428: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4567 + //line php7/php7.y:4808 { yyVAL.node = yyDollar[1].node @@ -7200,66 +7453,70 @@ yydefault: } case 429: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4573 + //line php7/php7.y:4814 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 430: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4586 + //line php7/php7.y:4828 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 431: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4599 + //line php7/php7.y:4842 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 432: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4612 + //line php7/php7.y:4856 { yyVAL.node = expr.NewMethodCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 433: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4624 + //line php7/php7.y:4869 { yyVAL.node = yyDollar[1].node @@ -7267,7 +7524,7 @@ yydefault: } case 434: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4633 + //line php7/php7.y:4878 { yyVAL.node = yyDollar[1].node @@ -7275,7 +7532,7 @@ yydefault: } case 435: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4639 + //line php7/php7.y:4884 { yyVAL.node = yyDollar[1].node @@ -7283,95 +7540,101 @@ yydefault: } case 436: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4645 + //line php7/php7.y:4890 { yyVAL.node = expr.NewPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 437: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4660 + //line php7/php7.y:4906 { name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 438: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4674 + //line php7/php7.y:4921 { yyVAL.node = expr.NewVariable(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.Start, append(yyDollar[2].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token), (*yyDollar[3].node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyDollar[3].node, freefloating.End, append((*yyDollar[3].node.GetFreeFloating())[freefloating.End], append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 439: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4688 + //line php7/php7.y:4936 { yyVAL.node = expr.NewVariable(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 440: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4703 + //line php7/php7.y:4952 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 441: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4715 + //line php7/php7.y:4965 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Name, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 442: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4730 + //line php7/php7.y:4981 { yyVAL.node = yyDollar[1].node @@ -7379,105 +7642,110 @@ yydefault: } case 443: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4736 + //line php7/php7.y:4987 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 444: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4749 + //line php7/php7.y:5001 { yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 445: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4762 + //line php7/php7.y:5015 { yyVAL.node = expr.NewPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 446: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4774 + //line php7/php7.y:5028 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 447: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4786 + //line php7/php7.y:5041 { yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 448: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4801 + //line php7/php7.y:5057 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 449: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4813 + //line php7/php7.y:5069 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 450: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4823 + //line php7/php7.y:5079 { yyVAL.node = yyDollar[1].node @@ -7485,33 +7753,33 @@ yydefault: } case 451: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4832 + //line php7/php7.y:5088 { yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 452: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4844 + //line php7/php7.y:5100 { yyVAL.node = yyDollar[2].node // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, append(yyDollar[1].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token), (*yyVAL.node.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append((*yyVAL.node.GetFreeFloating())[freefloating.End], append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 453: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4854 + //line php7/php7.y:5110 { yyVAL.node = yyDollar[1].node @@ -7519,27 +7787,23 @@ yydefault: } case 454: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4863 + //line php7/php7.y:5119 { - if len(yyDollar[1].list) == 1 && yyDollar[1].list[0] == nil { - yyVAL.list = yyDollar[1].list[:0] - } else { - yyVAL.list = yyDollar[1].list - } + yyVAL.list = yyDollar[1].list yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 455: yyDollar = yyS[yypt-0 : yypt+1] - //line php7/php7.y:4876 + //line php7/php7.y:5128 { - yyVAL.node = nil + yyVAL.node = expr.NewArrayItem(nil, nil) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 456: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4882 + //line php7/php7.y:5134 { yyVAL.node = yyDollar[1].node @@ -7547,123 +7811,137 @@ yydefault: } case 457: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4891 + //line php7/php7.y:5143 { + if len(yyDollar[1].list) == 0 { + yyDollar[1].list = []node.Node{expr.NewArrayItem(nil, nil)} + } + yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - if lastNode(yyDollar[1].list) != nil { - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) - } + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 458: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4902 + //line php7/php7.y:5156 { - yyVAL.list = []node.Node{yyDollar[1].node} + if yyDollar[1].node.(*expr.ArrayItem).Key == nil && yyDollar[1].node.(*expr.ArrayItem).Val == nil { + yyVAL.list = []node.Node{} + } else { + yyVAL.list = []node.Node{yyDollar[1].node} + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 459: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:4911 + //line php7/php7.y:5169 { yyVAL.node = expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 460: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:4923 + //line php7/php7.y:5182 { yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) + + // save comments + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 461: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4932 + //line php7/php7.y:5194 { reference := expr.NewReference(yyDollar[4].node) yyVAL.node = expr.NewArrayItem(yyDollar[1].node, reference) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[4].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[3].token, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 462: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4946 + //line php7/php7.y:5210 { reference := expr.NewReference(yyDollar[2].node) yyVAL.node = expr.NewArrayItem(nil, reference) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, yyDollar[1].token, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 463: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:4959 + //line php7/php7.y:5224 { // TODO: Cannot use list() as standalone expression - list := expr.NewList(yyDollar[5].list) - yyVAL.node = expr.NewArrayItem(yyDollar[1].node, list) + listNode := expr.NewList(yyDollar[5].list) + yyVAL.node = expr.NewArrayItem(yyDollar[1].node, listNode) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[6].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[6].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[3].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[4].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[6].token, comment.CloseParenthesisToken) + yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.Start, yyDollar[3].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, yyDollar[4].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, yyDollar[6].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 464: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:4977 + //line php7/php7.y:5243 { // TODO: Cannot use list() as standalone expression - list := expr.NewList(yyDollar[3].list) - yyVAL.node = expr.NewArrayItem(nil, list) + listNode := expr.NewList(yyDollar[3].list) + yyVAL.node = expr.NewArrayItem(nil, listNode) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(list, yyDollar[1].token, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 465: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:4997 + //line php7/php7.y:5263 { yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) @@ -7671,22 +7949,22 @@ yydefault: } case 466: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5003 + //line php7/php7.y:5269 { encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) yyVAL.list = append(yyDollar[1].list, encapsed) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, yyDollar[2].token, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 467: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5016 + //line php7/php7.y:5282 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -7694,58 +7972,59 @@ yydefault: } case 468: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5022 + //line php7/php7.y:5288 { encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) yyVAL.list = []node.Node{encapsed, yyDollar[2].node} // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, yyDollar[1].token, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 469: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5038 + //line php7/php7.y:5304 { name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 470: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:5052 + //line php7/php7.y:5319 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseSquareBracket) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[2].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[2].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[4].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 471: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:5070 + //line php7/php7.y:5337 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) variable := expr.NewVariable(identifier) @@ -7753,98 +8032,104 @@ yydefault: yyVAL.node = expr.NewPropertyFetch(variable, fetch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[1].token, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.ObjectOperatorToken) - yylex.(*Parser).comments.AddFromToken(fetch, yyDollar[3].token, comment.StringToken) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Start, yyDollar[3].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 472: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:5090 + //line php7/php7.y:5357 { - yyVAL.node = expr.NewVariable(yyDollar[2].node) + variable := expr.NewVariable(yyDollar[2].node) + + yyVAL.node = variable // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 473: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:5103 + //line php7/php7.y:5372 { name := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = expr.NewVariable(name) + variable := expr.NewVariable(name) + + yyVAL.node = variable // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(name, yyDollar[2].token, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 474: yyDollar = yyS[yypt-6 : yypt+1] - //line php7/php7.y:5119 + //line php7/php7.y:5389 { identifier := node.NewIdentifier(yyDollar[2].token.Value) variable := expr.NewVariable(identifier) yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[4].node) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(variable, yyDollar[2].token, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[3].token, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[6].token, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Var, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, append(yyDollar[5].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[5].token)...)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[6].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[6].token)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 475: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:5139 + //line php7/php7.y:5408 { yyVAL.node = yyDollar[2].node + // save comments + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken(yyDollar[1].token)) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.End, append(yyDollar[3].token.FreeFloating, yylex.(*Parser).GetFreeFloatingToken(yyDollar[3].token)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 476: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5148 + //line php7/php7.y:5421 { yyVAL.node = scalar.NewString(yyDollar[1].token.Value) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.StringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 477: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5160 + //line php7/php7.y:5433 { // TODO: add option to handle 64 bit integer if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil { @@ -7854,16 +8139,16 @@ yydefault: } // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.NumStringToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 478: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5177 + //line php7/php7.y:5450 { var lnumber *scalar.Lnumber // TODO: add option to handle 64 bit integer @@ -7880,146 +8165,143 @@ yydefault: // save position if isInt { - yylex.(*Parser).positions.AddPosition(lnumber, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + lnumber.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) } - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.MinusToken) - if isInt { - yylex.(*Parser).comments.AddFromToken(lnumber, yyDollar[2].token, comment.NumStringToken) - } else { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.NumStringToken) - } + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 479: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5208 + //line php7/php7.y:5476 { identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) yyVAL.node = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.VariableToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).addDollarToken(yyVAL.node) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 480: yyDollar = yyS[yypt-5 : yypt+1] - //line php7/php7.y:5225 + //line php7/php7.y:5494 { yyVAL.node = expr.NewIsset(yyDollar[3].list) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IssetToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - if yyDollar[4].token != nil { - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Isset, yyDollar[2].token.FreeFloating) + if yyDollar[4].token == nil { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, yyDollar[5].token.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.VarList, append(yyDollar[4].token.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken(yyDollar[4].token), yyDollar[5].token.FreeFloating...)...)) } - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[5].token, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 481: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:5242 + //line php7/php7.y:5512 { yyVAL.node = expr.NewEmpty(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Empty, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 482: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5256 + //line php7/php7.y:5526 { yyVAL.node = expr.NewInclude(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncludeToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 483: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5268 + //line php7/php7.y:5538 { yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.IncludeOnceToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 484: yyDollar = yyS[yypt-4 : yypt+1] - //line php7/php7.y:5280 + //line php7/php7.y:5550 { yyVAL.node = expr.NewEval(yyDollar[3].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.EvalToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[2].token, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[4].token, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Eval, yyDollar[2].token.FreeFloating) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Expr, yyDollar[4].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 485: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5294 + //line php7/php7.y:5564 { yyVAL.node = expr.NewRequire(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.RequireToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 486: yyDollar = yyS[yypt-2 : yypt+1] - //line php7/php7.y:5306 + //line php7/php7.y:5576 { yyVAL.node = expr.NewRequireOnce(yyDollar[2].node) // save position - yylex.(*Parser).positions.AddPosition(yyVAL.node, yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) + yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) // save comments - yylex.(*Parser).comments.AddFromToken(yyVAL.node, yyDollar[1].token, comment.RequireOnceToken) + yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 487: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5321 + //line php7/php7.y:5591 { yyVAL.list = []node.Node{yyDollar[1].node} @@ -8027,18 +8309,18 @@ yydefault: } case 488: yyDollar = yyS[yypt-3 : yypt+1] - //line php7/php7.y:5327 + //line php7/php7.y:5597 { yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } case 489: yyDollar = yyS[yypt-1 : yypt+1] - //line php7/php7.y:5339 + //line php7/php7.y:5609 { yyVAL.node = yyDollar[1].node diff --git a/php7/php7.y b/php7/php7.y index a8ba7e6..3ff11c0 100644 --- a/php7/php7.y +++ b/php7/php7.y @@ -5,7 +5,7 @@ import ( "strings" "strconv" - "github.com/z7zmey/php-parser/comment" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/scanner" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/scalar" @@ -301,9 +301,13 @@ start: yylex.(*Parser).rootNode = node.NewRoot($1) // save position - yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) + + if yylex.(*Parser).currentToken.Value == "\xff" { + yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) + } } ; @@ -339,6 +343,11 @@ identifier: top_statement_list: top_statement_list top_statement { + if inlineHtmlNode, ok := $2.(*stmt.InlineHtml); ok && len($1) > 0 { + prevNode := lastNode($1) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if $2 != nil { $$ = append($1, $2) } @@ -360,10 +369,10 @@ namespace_name: $$ = []node.Node{namePart} // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(namePart, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -373,11 +382,11 @@ namespace_name: $$ = append($1, namePart) // save position - yylex.(*Parser).positions.AddPosition(namePart, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken(namePart, $3, comment.StringToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -389,7 +398,10 @@ name: $$ = name.NewName($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -398,11 +410,11 @@ name: $$ = name.NewRelative($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -411,10 +423,10 @@ name: $$ = name.NewFullyQualified($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -463,13 +475,14 @@ top_statement: $$ = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.HaltCompiller, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.OpenParenthesisToken, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -481,12 +494,14 @@ top_statement: $$ = stmt.NewNamespace(name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -496,13 +511,14 @@ top_statement: $$ = stmt.NewNamespace(name, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -511,12 +527,12 @@ top_statement: $$ = stmt.NewNamespace(nil, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NamespaceToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -525,11 +541,12 @@ top_statement: $$ = $2 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -538,11 +555,12 @@ top_statement: $$ = $3.(*stmt.GroupUse).SetUseType($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -551,11 +569,12 @@ top_statement: $$ = stmt.NewUseList(nil, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -564,11 +583,12 @@ top_statement: $$ = stmt.NewUseList($2, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.UseDeclarationList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -577,11 +597,12 @@ top_statement: $$ = stmt.NewConstList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -593,10 +614,10 @@ use_type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -605,10 +626,10 @@ use_type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -621,16 +642,18 @@ group_use_declaration: $$ = stmt.NewGroupUse(nil, name, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, $3.FreeFloating) if $5 != nil { - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, append($5.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($5), $6.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -640,17 +663,19 @@ group_use_declaration: $$ = stmt.NewGroupUse(nil, name, $5) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.UseType, $1.FreeFloating) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, $4.FreeFloating) if $6 != nil { - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, append($6.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($6), $7.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -663,17 +688,19 @@ mixed_group_use_declaration: $$ = stmt.NewGroupUse(nil, name, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, $3.FreeFloating) if $5 != nil { - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, append($5.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($5), $6.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) - + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' @@ -682,17 +709,19 @@ mixed_group_use_declaration: $$ = stmt.NewGroupUse(nil, name, $5) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.NsSeparatorToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Use, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).MoveFreeFloating($2[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, $4.FreeFloating) if $6 != nil { - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, append($6.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($6), $7.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -715,7 +744,7 @@ inline_use_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -733,7 +762,7 @@ unprefixed_use_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -751,7 +780,7 @@ use_declarations: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -785,8 +814,11 @@ unprefixed_use_declaration: $$ = stmt.NewUse(nil, name, nil) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1[0], name) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -797,13 +829,14 @@ unprefixed_use_declaration: $$ = stmt.NewUse(nil, name, alias) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1[0], name) + yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -814,6 +847,9 @@ use_declaration: { $$ = $1 + // save coments + yylex.(*Parser).MoveFreeFloating($1.(*stmt.Use).Use, $$) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_NS_SEPARATOR unprefixed_use_declaration @@ -821,7 +857,11 @@ use_declaration: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsSeparatorToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) + + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Slash, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -833,7 +873,7 @@ const_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -848,6 +888,11 @@ const_list: inner_statement_list: inner_statement_list inner_statement { + if inlineHtmlNode, ok := $2.(*stmt.InlineHtml); ok && len($1) > 0 { + prevNode := lastNode($1) + yylex.(*Parser).splitSemiColonAndPhpCloseTag(inlineHtmlNode, prevNode) + } + if $2 != nil { $$ = append($1, $2) } @@ -905,13 +950,14 @@ inner_statement: $$ = stmt.NewHaltCompiler() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.HaltCompilerToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.HaltCompiller, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.OpenParenthesisToken, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -922,11 +968,11 @@ statement: $$ = stmt.NewStmtList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -954,12 +1000,12 @@ statement: $$ = $5 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.While, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -968,14 +1014,15 @@ statement: $$ = stmt.NewDo($2, $5) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.WhileToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.While, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $7.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($7)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -995,14 +1042,14 @@ statement: $$ = $9 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.ForInitSemicolonToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.ForCondSemicolonToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.For, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.InitExpr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.CondExpr, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.IncExpr, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1020,12 +1067,12 @@ statement: $$ = $5 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SwitchToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Switch, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1034,11 +1081,12 @@ statement: $$ = stmt.NewBreak($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BreakToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1047,11 +1095,12 @@ statement: $$ = stmt.NewContinue($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ContinueToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1060,11 +1109,12 @@ statement: $$ = stmt.NewReturn($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ReturnToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1073,11 +1123,12 @@ statement: $$ = stmt.NewGlobal($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.GlobalToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1086,11 +1137,12 @@ statement: $$ = stmt.NewStatic($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1099,11 +1151,13 @@ statement: $$ = stmt.NewEcho($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EchoToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Echo, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1112,10 +1166,10 @@ statement: $$ = stmt.NewInlineHtml($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.InlineHTMLToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1124,10 +1178,12 @@ statement: $$ = stmt.NewExpression($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1136,16 +1192,18 @@ statement: $$ = stmt.NewUnset($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UnsetToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Unset, $2.FreeFloating) if $4 != nil { - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, append($4.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($4), $5.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $5.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.CloseParenthesisToken, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($6)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1163,13 +1221,14 @@ statement: $$ = $7 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $7)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Foreach, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $6.FreeFloating) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1189,28 +1248,29 @@ statement: $$ = $9 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ForeachToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.AsToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Foreach, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Key, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DECLARE '(' const_list ')' declare_statement { - $$ = stmt.NewDeclare($3, $5) + $$ = $5 + $$.(*stmt.Declare).Consts = $3 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DeclareToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Declare, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ConstList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1219,10 +1279,11 @@ statement: $$ = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1230,16 +1291,16 @@ statement: { if $6 == nil { $$ = stmt.NewTry($3, $5, $6) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) } else { $$ = stmt.NewTry($3, $5, $6) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TryToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Try, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1248,11 +1309,12 @@ statement: $$ = stmt.NewThrow($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ThrowToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1262,13 +1324,14 @@ statement: $$ = stmt.NewGoto(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.GotoToken) - yylex.(*Parser).comments.AddFromToken(label, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(label, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Label, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1278,12 +1341,12 @@ statement: $$ = stmt.NewLabel(label) // save position - yylex.(*Parser).positions.AddPosition(label, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(label, $1, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Label, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1303,17 +1366,18 @@ catch_list: $$ = append($1, catch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($5)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($5)) - yylex.(*Parser).positions.AddPosition(catch, yylex.(*Parser).positionBuilder.NewTokensPosition($2, $9)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($5)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($5)) + catch.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($2, $9)) // save comments - yylex.(*Parser).comments.AddFromToken(catch, $2, comment.CatchToken) - yylex.(*Parser).comments.AddFromToken(catch, $3, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(variable, $5, comment.StringToken) - yylex.(*Parser).comments.AddFromToken(catch, $6, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(catch, $7, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(catch, $9, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(catch, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Catch, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $5.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating(catch, freefloating.Var, $6.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Cond, $7.FreeFloating) + yylex.(*Parser).setFreeFloating(catch, freefloating.Stmts, $9.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1330,7 +1394,7 @@ catch_name_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.VerticalBarToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1348,12 +1412,12 @@ finally_statement: $$ = stmt.NewFinally($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FinallyToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Finally, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1371,7 +1435,7 @@ unset_variables: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1393,20 +1457,30 @@ function_declaration_statement: $$ = stmt.NewFunction(name, $2 != nil, $6, $8, $10, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $3.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ParamList, $7.FreeFloating) + if $8 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$8.GetFreeFloating())[freefloating.Colon]); delete((*$8.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ReturnType, $9.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $11.FreeFloating) + + // normalize + if $8 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.ReturnType]); delete((*$$.GetFreeFloating()), freefloating.ReturnType) } - yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $9, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $11, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1441,14 +1515,15 @@ class_declaration_statement: $$ = stmt.NewClass(name, $1, nil, $4, $5, $8, $6) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $9)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $9)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken(name, $3, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $9, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $7.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $9.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1458,14 +1533,14 @@ class_declaration_statement: $$ = stmt.NewClass(name, nil, nil, $3, $4, $7, $5) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1492,10 +1567,10 @@ class_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AbstractToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1504,10 +1579,10 @@ class_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FinalToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1520,14 +1595,14 @@ trait_declaration_statement: $$ = stmt.NewTrait(name, $5, $3) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TraitToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1540,14 +1615,14 @@ interface_declaration_statement: $$ = stmt.NewInterface(name, $3, $6, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.InterfaceToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(name, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1565,10 +1640,10 @@ extends_from: $$ = stmt.NewClassExtends($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1586,10 +1661,10 @@ interface_extends_list: $$ = stmt.NewInterfaceExtends($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExtendsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1607,10 +1682,10 @@ implements_list: $$ = stmt.NewClassImplements($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ImplementsToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1628,10 +1703,10 @@ foreach_variable: $$ = expr.NewReference($2) // save position - yylex.(*Parser).positions.AddPosition($2, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1640,12 +1715,12 @@ foreach_variable: $$ = expr.NewList($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1654,11 +1729,11 @@ foreach_variable: $$ = expr.NewShortList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseSquareBracket) + // save commentsc + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1670,7 +1745,7 @@ for_statement: $$ = stmt.NewFor(nil, nil, nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1680,13 +1755,14 @@ for_statement: $$ = stmt.NewAltFor(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndforToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1698,7 +1774,7 @@ foreach_statement: $$ = stmt.NewForeach(nil, nil, nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1708,13 +1784,14 @@ foreach_statement: $$ = stmt.NewAltForeach(nil, nil, nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndforeachToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1723,21 +1800,27 @@ foreach_statement: declare_statement: statement { - $$ = $1 + $$ = stmt.NewDeclare(nil, $1, false) + + // save position + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | ':' inner_statement_list T_ENDDECLARE ';' { - $$ = stmt.NewStmtList($2) + stmtList := stmt.NewStmtList($2) + $$ = stmt.NewDeclare(nil, stmtList, true) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EnddeclareToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1750,12 +1833,12 @@ switch_case_list: $$ = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1765,13 +1848,13 @@ switch_case_list: $$ = stmt.NewSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(caseList, $2, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1781,13 +1864,14 @@ switch_case_list: $$ = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $3, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1798,14 +1882,15 @@ switch_case_list: $$ = stmt.NewAltSwitch(nil, caseList) // save position - yylex.(*Parser).positions.AddPosition(caseList, yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(caseList, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $2, comment.SemiColonToken) - yylex.(*Parser).comments.AddFromToken(caseList, $4, comment.EndswitchToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListStart, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($5)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1824,11 +1909,12 @@ case_list: $$ = append($1, _case) // save position - yylex.(*Parser).positions.AddPosition(_case, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) + _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(_case, $2, comment.CaseToken) - yylex.(*Parser).comments.AddFromToken(_case, $4, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_case, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_case, freefloating.Expr, append($4.FreeFloating)) + yylex.(*Parser).setFreeFloating(_case, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1838,11 +1924,12 @@ case_list: $$ = append($1, _default) // save position - yylex.(*Parser).positions.AddPosition(_default, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) + _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(_default, $2, comment.DefaultToken) - yylex.(*Parser).comments.AddFromToken(_default, $3, comment.CaseSeparatorToken) + yylex.(*Parser).setFreeFloating(_default, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.Default, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(_default, freefloating.CaseSeparator, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1865,7 +1952,7 @@ while_statement: $$ = stmt.NewWhile(nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1875,13 +1962,14 @@ while_statement: $$ = stmt.NewAltWhile(nil, stmtList) // save position - yylex.(*Parser).positions.AddPosition(stmtList, yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EndwhileToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1893,12 +1981,12 @@ if_stmt_without_else: $$ = stmt.NewIf($3, $5, nil, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IfToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.If, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1908,13 +1996,13 @@ if_stmt_without_else: $$ = $1.(*stmt.If).AddElseIf(_elseIf) // save position - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, $2, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $3, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $5, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1933,11 +2021,11 @@ if_stmt: $$ = $1.(*stmt.If).SetElse(_else) // save position - yylex.(*Parser).positions.AddPosition(_else, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + _else.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ElseToken) + yylex.(*Parser).setFreeFloating(_else, freefloating.Start, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1950,14 +2038,14 @@ alt_if_stmt_without_else: $$ = stmt.NewAltIf($3, stmts, nil, nil) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($6)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $6)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IfToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.ColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.If, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1968,14 +2056,14 @@ alt_if_stmt_without_else: $$ = $1.(*stmt.AltIf).AddElseIf(_elseIf) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($7)) - yylex.(*Parser).positions.AddPosition(_elseIf, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $7)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($7)) + _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $7)) // save comments - yylex.(*Parser).comments.AddFromToken(_elseIf, $2, comment.ElseifToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $3, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $5, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken(_elseIf, $6, comment.ColonToken) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.ElseIf, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Expr, $5.FreeFloating) + yylex.(*Parser).setFreeFloating(_elseIf, freefloating.Cond, $6.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -1987,11 +2075,12 @@ alt_if_stmt: $$ = $1 // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2002,15 +2091,16 @@ alt_if_stmt: $$ = $1.(*stmt.AltIf).SetElse(_else) // save position - yylex.(*Parser).positions.AddPosition(stmts, yylex.(*Parser).positionBuilder.NewNodeListPosition($4)) - yylex.(*Parser).positions.AddPosition(_else, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $6)) + stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($4)) + _else.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(_else, $2, comment.ElseToken) - yylex.(*Parser).comments.AddFromToken(_else, $3, comment.ColonToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.EndifToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating(_else, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(_else, freefloating.Else, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $5.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AltEnd, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($6)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2043,7 +2133,7 @@ non_empty_parameter_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2057,26 +2147,41 @@ parameter: $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) } else if $2 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) } else if $3 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) } // save comments + if $1 != nil { + yylex.(*Parser).MoveFreeFloating($1, $$) + } if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) } if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Variadic, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + + // normalize + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, (*$$.GetFreeFloating())[freefloating.Variadic]); delete((*$$.GetFreeFloating()), freefloating.Variadic) + } + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, (*$$.GetFreeFloating())[freefloating.Ampersand]); delete((*$$.GetFreeFloating()), freefloating.Ampersand) + } + if $1 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, (*$$.GetFreeFloating())[freefloating.OptionalType]); delete((*$$.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2087,27 +2192,42 @@ parameter: $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) } else if $2 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) } else if $3 != nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) } // save comments + if $1 != nil { + yylex.(*Parser).MoveFreeFloating($1, $$) + } if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) } if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $3.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Variadic, $4.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $5.FreeFloating) + + // normalize + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, (*$$.GetFreeFloating())[freefloating.Variadic]); delete((*$$.GetFreeFloating()), freefloating.Variadic) + } + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, (*$$.GetFreeFloating())[freefloating.Ampersand]); delete((*$$.GetFreeFloating()), freefloating.Ampersand) + } + if $1 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, (*$$.GetFreeFloating())[freefloating.OptionalType]); delete((*$$.GetFreeFloating()), freefloating.OptionalType) } - yylex.(*Parser).comments.AddFromToken(variable, $4, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2140,10 +2260,10 @@ type_expr: $$ = node.NewNullable($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.QuestionMarkToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2155,10 +2275,10 @@ type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2167,10 +2287,10 @@ type: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.CallableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2194,7 +2314,7 @@ return_type: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Colon, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2206,11 +2326,11 @@ argument_list: $$ = node.NewArgumentList(nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2219,14 +2339,15 @@ argument_list: $$ = node.NewArgumentList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, append($3.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($3), $4.FreeFloating...)...)) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $4.FreeFloating) } - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2244,7 +2365,7 @@ non_empty_argument_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2256,7 +2377,10 @@ argument: $$ = node.NewArgument($1, false, false) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2265,10 +2389,10 @@ argument: $$ = node.NewArgument($2, true, false) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EllipsisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2280,7 +2404,7 @@ global_var_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2307,7 +2431,7 @@ static_var_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2327,12 +2451,13 @@ static_var: $$ = stmt.NewStaticVar(variable, nil) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2343,13 +2468,14 @@ static_var: $$ = stmt.NewStaticVar(variable, $3) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2376,10 +2502,12 @@ class_statement: $$ = stmt.NewPropertyList($1, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $3, comment.SemiColonToken) + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.PropertyList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($3)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2388,33 +2516,29 @@ class_statement: $$ = stmt.NewClassConstList($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ConstToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.SemiColonToken) + if len($1) > 0 { + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $2.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ConstList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_USE name_list trait_adaptations { - var adaptationList *stmt.TraitAdaptationList - - switch n := $3.(type) { - case *stmt.TraitAdaptationList: - adaptationList = n - default: - adaptationList = nil - yylex.(*Parser).comments.AddFromChildNode($$, $3) - } - - $$ = stmt.NewTraitUse($2, adaptationList) + $$ = stmt.NewTraitUse($2, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2424,21 +2548,31 @@ class_statement: $$ = stmt.NewClassMethod(name, $1, $3 != nil, $7, $9, $10, $5) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) if $1 == nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $10)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $10)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $10)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $10)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) - if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + if len($1) > 0 { + yylex.(*Parser).MoveFreeFloating($1[0], $$) + yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $2.FreeFloating) + } + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $4.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $4.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $8.FreeFloating) + if $9 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$9.GetFreeFloating())[freefloating.Colon]); delete((*$9.GetFreeFloating()), freefloating.Colon) } - yylex.(*Parser).comments.AddFromToken(name, $4, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2456,7 +2590,7 @@ name_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2467,10 +2601,11 @@ trait_adaptations: { $$ = stmt.NewNop() - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) @@ -2479,11 +2614,11 @@ trait_adaptations: { $$ = stmt.NewTraitAdaptationList(nil) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2491,11 +2626,11 @@ trait_adaptations: { $$ = stmt.NewTraitAdaptationList($2) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2522,7 +2657,8 @@ trait_adaptation: $$ = $1; // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.NameList, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2531,7 +2667,8 @@ trait_adaptation: $$ = $1; // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Alias, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2543,10 +2680,11 @@ trait_precedence: $$ = stmt.NewTraitUsePrecedence($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.InsteadofToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2559,12 +2697,13 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, nil, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2574,12 +2713,13 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, nil, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $3, comment.StringToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2589,12 +2729,13 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, $3, alias) // save position - yylex.(*Parser).positions.AddPosition(alias, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) - yylex.(*Parser).comments.AddFromToken(alias, $4, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2603,10 +2744,11 @@ trait_alias: $$ = stmt.NewTraitUseAlias($1, $3, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2619,11 +2761,11 @@ trait_method_reference: $$ = stmt.NewTraitMethodRef(nil, name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2642,12 +2784,13 @@ absolute_trait_method_reference: $$ = stmt.NewTraitMethodRef($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, $3, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2659,10 +2802,11 @@ method_body: $$ = stmt.NewNop() // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2671,11 +2815,11 @@ method_body: $$ = stmt.NewStmtList($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2694,10 +2838,10 @@ variable_modifiers: $$ = []node.Node{modifier} // save position - yylex.(*Parser).positions.AddPosition(modifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(modifier, $1, comment.VarToken) + yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2739,10 +2883,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PublicToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2751,10 +2895,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ProtectedToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2763,10 +2907,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PrivateToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2775,10 +2919,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2787,10 +2931,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AbstractToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2799,10 +2943,10 @@ member_modifier: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FinalToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2814,7 +2958,7 @@ property_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2834,12 +2978,13 @@ property: $$ = stmt.NewProperty(variable, nil, $2) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2850,13 +2995,14 @@ property: $$ = stmt.NewProperty(variable, $3, $4) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2868,7 +3014,7 @@ class_const_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2887,12 +3033,12 @@ class_const_decl: $$ = stmt.NewConstant(name, $3, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.IdentifierToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2905,12 +3051,12 @@ const_decl: $$ = stmt.NewConstant(name, $3, $4) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(name, $1, comment.StringToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2922,7 +3068,7 @@ echo_expr_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2964,7 +3110,7 @@ non_empty_for_exprs: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -2986,12 +3132,12 @@ anonymous_class: } // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $8, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $6.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $8.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3002,14 +3148,14 @@ new_expr: { if $3 != nil { $$ = expr.NewNew($2, $3.(*node.ArgumentList)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) } else { $$ = expr.NewNew($2, nil) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NewToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3018,10 +3164,10 @@ new_expr: $$ = expr.NewNew($2, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NewToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3030,18 +3176,18 @@ new_expr: expr_without_variable: T_LIST '(' array_pair_list ')' '=' expr { - list := expr.NewList($3) - $$ = assign.NewAssign(list, $6) + listNode := expr.NewList($3) + $$ = assign.NewAssign(listNode, $6) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken(list, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, $4, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, $4.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $5.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3051,13 +3197,13 @@ expr_without_variable: $$ = assign.NewAssign(shortList, $5) // save position - yylex.(*Parser).positions.AddPosition(shortList, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) + shortList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken(shortList, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken(shortList, $3, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.EqualToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(shortList, freefloating.ArrayPairList, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3066,10 +3212,11 @@ expr_without_variable: $$ = assign.NewAssign($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3078,11 +3225,12 @@ expr_without_variable: $$ = assign.NewReference($1, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.EqualToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3091,10 +3239,10 @@ expr_without_variable: $$ = expr.NewClone($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.CloneToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3103,10 +3251,11 @@ expr_without_variable: $$ = assign.NewPlus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PlusEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3115,10 +3264,11 @@ expr_without_variable: $$ = assign.NewMinus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MinusEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3127,10 +3277,11 @@ expr_without_variable: $$ = assign.NewMul($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MulEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3139,10 +3290,11 @@ expr_without_variable: $$ = assign.NewPow($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PowEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3151,10 +3303,11 @@ expr_without_variable: $$ = assign.NewDiv($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DivEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3163,10 +3316,11 @@ expr_without_variable: $$ = assign.NewConcat($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ConcatEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3175,10 +3329,11 @@ expr_without_variable: $$ = assign.NewMod($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ModEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3187,10 +3342,11 @@ expr_without_variable: $$ = assign.NewBitwiseAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AndEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3199,10 +3355,11 @@ expr_without_variable: $$ = assign.NewBitwiseOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3211,10 +3368,11 @@ expr_without_variable: $$ = assign.NewBitwiseXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.XorEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3223,10 +3381,11 @@ expr_without_variable: $$ = assign.NewShiftLeft($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3235,10 +3394,11 @@ expr_without_variable: $$ = assign.NewShiftRight($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3247,10 +3407,11 @@ expr_without_variable: $$ = expr.NewPostInc($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IncToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3259,10 +3420,10 @@ expr_without_variable: $$ = expr.NewPreInc($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3271,10 +3432,11 @@ expr_without_variable: $$ = expr.NewPostDec($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DecToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3283,10 +3445,10 @@ expr_without_variable: $$ = expr.NewPreDec($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DecToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3295,10 +3457,11 @@ expr_without_variable: $$ = binary.NewBooleanOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3307,10 +3470,11 @@ expr_without_variable: $$ = binary.NewBooleanAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.BooleanAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3319,10 +3483,11 @@ expr_without_variable: $$ = binary.NewLogicalOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalOrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3331,10 +3496,11 @@ expr_without_variable: $$ = binary.NewLogicalAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalAndToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3343,10 +3509,11 @@ expr_without_variable: $$ = binary.NewLogicalXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LogicalXorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3355,10 +3522,11 @@ expr_without_variable: $$ = binary.NewBitwiseOr($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.VerticalBarToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3367,10 +3535,11 @@ expr_without_variable: $$ = binary.NewBitwiseAnd($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3379,10 +3548,11 @@ expr_without_variable: $$ = binary.NewBitwiseXor($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CaretToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3391,10 +3561,11 @@ expr_without_variable: $$ = binary.NewConcat($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DotToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3403,10 +3574,11 @@ expr_without_variable: $$ = binary.NewPlus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PlusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3415,10 +3587,11 @@ expr_without_variable: $$ = binary.NewMinus($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.MinusToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3427,10 +3600,11 @@ expr_without_variable: $$ = binary.NewMul($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AsteriskToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3439,10 +3613,11 @@ expr_without_variable: $$ = binary.NewPow($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PowToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3451,10 +3626,11 @@ expr_without_variable: $$ = binary.NewDiv($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlashToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3463,10 +3639,11 @@ expr_without_variable: $$ = binary.NewMod($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PercentToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3475,10 +3652,11 @@ expr_without_variable: $$ = binary.NewShiftLeft($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SlToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3487,10 +3665,11 @@ expr_without_variable: $$ = binary.NewShiftRight($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SrToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3499,10 +3678,10 @@ expr_without_variable: $$ = expr.NewUnaryPlus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PlusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3511,10 +3690,10 @@ expr_without_variable: $$ = expr.NewUnaryMinus($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MinusToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3523,10 +3702,10 @@ expr_without_variable: $$ = expr.NewBooleanNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExclamationMarkToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3535,10 +3714,10 @@ expr_without_variable: $$ = expr.NewBitwiseNot($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TildeToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3547,10 +3726,11 @@ expr_without_variable: $$ = binary.NewIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3559,10 +3739,11 @@ expr_without_variable: $$ = binary.NewNotIdentical($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotIdenticalToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3571,10 +3752,11 @@ expr_without_variable: $$ = binary.NewEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3583,10 +3765,12 @@ expr_without_variable: $$ = binary.NewNotEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsNotEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Equal, yylex.(*Parser).GetFreeFloatingToken($2)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3595,10 +3779,11 @@ expr_without_variable: $$ = binary.NewSmaller($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.LessToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3607,10 +3792,11 @@ expr_without_variable: $$ = binary.NewSmallerOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsSmallerOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3619,10 +3805,11 @@ expr_without_variable: $$ = binary.NewGreater($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.GreaterToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3631,10 +3818,11 @@ expr_without_variable: $$ = binary.NewGreaterOrEqual($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.IsGreaterOrEqualToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3643,10 +3831,11 @@ expr_without_variable: $$ = binary.NewSpaceship($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.SpaceshipToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3655,10 +3844,11 @@ expr_without_variable: $$ = expr.NewInstanceOf($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.InstanceofToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3667,8 +3857,8 @@ expr_without_variable: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3683,11 +3873,12 @@ expr_without_variable: $$ = expr.NewTernary($1, $3, $5) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3696,11 +3887,12 @@ expr_without_variable: $$ = expr.NewTernary($1, nil, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.QuestionMarkToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.ColonToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3709,10 +3901,11 @@ expr_without_variable: $$ = binary.NewCoalesce($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.CoalesceToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3727,10 +3920,11 @@ expr_without_variable: $$ = cast.NewInt($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IntCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3739,10 +3933,11 @@ expr_without_variable: $$ = cast.NewDouble($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoubleCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3751,10 +3946,11 @@ expr_without_variable: $$ = cast.NewString($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3763,10 +3959,11 @@ expr_without_variable: $$ = cast.NewArray($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3775,10 +3972,11 @@ expr_without_variable: $$ = cast.NewObject($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ObjectCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3787,10 +3985,11 @@ expr_without_variable: $$ = cast.NewBool($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BoolCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3799,40 +3998,38 @@ expr_without_variable: $$ = cast.NewUnset($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UnsetCastToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_EXIT exit_expr { - if (strings.EqualFold($1.Value, "die")) { - $$ = expr.NewDie(nil) - if $2 != nil { - $$.(*expr.Die).Expr = $2.(*expr.Exit).Expr - } + var e *expr.Exit; + if $2 != nil { + e = $2.(*expr.Exit) } else { - $$ = expr.NewExit(nil) - if $2 != nil { - $$.(*expr.Exit).Expr = $2.(*expr.Exit).Expr - } + e = expr.NewExit(nil) + } + + $$ = e + + if (strings.EqualFold($1.Value, "die")) { + e.Die = true } // save position if $2 == nil { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) } else { - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) } // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ExitToken) - - if $2 != nil { - yylex.(*Parser).comments.AddFromChildNode($$, $2) - } + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3841,10 +4038,10 @@ expr_without_variable: $$ = expr.NewErrorSuppress($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AtToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3859,11 +4056,10 @@ expr_without_variable: $$ = expr.NewShellExec($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.BackquoteToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.BackquoteToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3872,10 +4068,10 @@ expr_without_variable: $$ = expr.NewPrint($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.PrintToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3884,10 +4080,10 @@ expr_without_variable: $$ = expr.NewYield(nil, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3896,10 +4092,10 @@ expr_without_variable: $$ = expr.NewYield(nil, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3908,11 +4104,11 @@ expr_without_variable: $$ = expr.NewYield($2, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.DoubleArrowToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3921,10 +4117,10 @@ expr_without_variable: $$ = expr.NewYieldFrom($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.YieldFromToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3933,17 +4129,30 @@ expr_without_variable: $$ = expr.NewClosure($5, $7, $8, $10, false, $2 != nil, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FunctionToken) - if $2 != nil { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + if $2 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $4.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $4.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $6.FreeFloating) + if $8 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, (*$8.GetFreeFloating())[freefloating.Colon]); delete((*$8.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ReturnType, $9.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $11.FreeFloating) + + // normalize + if $8 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, (*$$.GetFreeFloating())[freefloating.ReturnType]); delete((*$$.GetFreeFloating()), freefloating.ReturnType) + } + if $7 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.LexicalVarList]); delete((*$$.GetFreeFloating()), freefloating.LexicalVarList) } - yylex.(*Parser).comments.AddFromToken($$, $4, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $9, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $11, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -3952,18 +4161,31 @@ expr_without_variable: $$ = expr.NewClosure($6, $8, $9, $11, true, $3 != nil, $4) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $12)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $12)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) - if $3 != nil { - yylex.(*Parser).comments.AddFromToken($$, $3, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Static, $2.FreeFloating) + if $3 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $5.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.Function, $3.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Ampersand, $5.FreeFloating) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $7.FreeFloating) + if $9 != nil { + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, (*$9.GetFreeFloating())[freefloating.Colon]); delete((*$9.GetFreeFloating()), freefloating.Colon) + } + yylex.(*Parser).setFreeFloating($$, freefloating.ReturnType, $10.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $12.FreeFloating) + + // normalize + if $9 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVars, (*$$.GetFreeFloating())[freefloating.ReturnType]); delete((*$$.GetFreeFloating()), freefloating.ReturnType) + } + if $8 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.LexicalVarList]); delete((*$$.GetFreeFloating()), freefloating.LexicalVarList) } - yylex.(*Parser).comments.AddFromToken($$, $5, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $7, comment.CloseParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $10, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $12, comment.CloseCurlyBracesToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4002,12 +4224,12 @@ lexical_vars: $$ = expr.NewClosureUse($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Use, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.LexicalVarList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4019,7 +4241,7 @@ lexical_var_list: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4038,11 +4260,12 @@ lexical_var: $$ = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4053,13 +4276,14 @@ lexical_var: $$ = expr.NewReference(variable) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.AmpersandToken) - yylex.(*Parser).comments.AddFromToken(variable, $2, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $2.FreeFloating) + yylex.(*Parser).addDollarToken(variable) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4071,7 +4295,10 @@ function_call: $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4080,10 +4307,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4092,10 +4320,11 @@ function_call: $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4104,7 +4333,10 @@ function_call: $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4116,10 +4348,10 @@ class_name: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StaticToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4158,11 +4390,11 @@ exit_expr: $$ = expr.NewExit($2); // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Exit, append($1.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($1)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4177,7 +4409,11 @@ backticks_expr: } | T_ENCAPSED_AND_WHITESPACE { - $$ = []node.Node{scalar.NewEncapsedStringPart($1.Value)} + part := scalar.NewEncapsedStringPart($1.Value) + $$ = []node.Node{part} + + // save position + part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4210,12 +4446,12 @@ dereferencable_scalar: $$ = expr.NewArray($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ArrayToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Array, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4224,11 +4460,11 @@ dereferencable_scalar: $$ = expr.NewShortArray($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseSquareBracket) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4237,10 +4473,10 @@ dereferencable_scalar: $$ = scalar.NewString($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ConstantEncapsedStringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4252,10 +4488,10 @@ scalar: $$ = scalar.NewLnumber($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.LnumberToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4264,10 +4500,10 @@ scalar: $$ = scalar.NewDnumber($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DnumberToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4276,10 +4512,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.LineToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4288,10 +4524,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FileToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4300,10 +4536,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DirToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4312,10 +4548,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.TraitCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4324,10 +4560,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MethodCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4336,10 +4572,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.FuncCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4348,10 +4584,10 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NsCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4360,24 +4596,24 @@ scalar: $$ = scalar.NewMagicConstant($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.ClassCToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } - | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC + | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { encapsed := scalar.NewEncapsedStringPart($2.Value) $$ = scalar.NewHeredoc($1.Value, []node.Node{encapsed}) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4386,10 +4622,10 @@ scalar: $$ = scalar.NewHeredoc($1.Value, nil) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4398,10 +4634,10 @@ scalar: $$ = scalar.NewEncapsed($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DoubleQuoteToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4410,10 +4646,10 @@ scalar: $$ = scalar.NewHeredoc($1.Value, $2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StartHeredocToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4437,7 +4673,10 @@ constant: $$ = expr.NewConstFetch($1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4447,12 +4686,13 @@ constant: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, $3, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4462,12 +4702,13 @@ constant: $$ = expr.NewClassConstFetch($1, target) // save position - yylex.(*Parser).positions.AddPosition(target, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) + target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) - yylex.(*Parser).comments.AddFromToken(target, $3, comment.IdentifierToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4524,8 +4765,8 @@ dereferencable: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4549,8 +4790,8 @@ callable_expr: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4574,11 +4815,12 @@ callable_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4587,11 +4829,12 @@ callable_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4600,11 +4843,12 @@ callable_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4613,10 +4857,11 @@ callable_variable: $$ = expr.NewMethodCall($1, $3, $4.(*node.ArgumentList)) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4646,10 +4891,11 @@ variable: $$ = expr.NewPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4662,11 +4908,12 @@ simple_variable: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4675,12 +4922,13 @@ simple_variable: $$ = expr.NewVariable($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($3, freefloating.Start, append($2.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($2), (*$3.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($3, freefloating.End, append((*$3.GetFreeFloating())[freefloating.End], append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4689,10 +4937,11 @@ simple_variable: $$ = expr.NewVariable($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4704,10 +4953,11 @@ static_member: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4716,10 +4966,11 @@ static_member: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4737,11 +4988,12 @@ new_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4750,11 +5002,12 @@ new_variable: $$ = expr.NewArrayDimFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseCurlyBracesToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4763,10 +5016,11 @@ new_variable: $$ = expr.NewPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4775,10 +5029,11 @@ new_variable: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4787,10 +5042,11 @@ new_variable: $$ = expr.NewStaticPropertyFetch($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4802,10 +5058,10 @@ member_name: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IdentifierToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4814,8 +5070,8 @@ member_name: $$ = $2; // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4833,20 +5089,20 @@ property_name: $$ = node.NewIdentifier($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | '{' expr '}' { $$ = $2; - + // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, append($1.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($1), (*$$.GetFreeFloating())[freefloating.Start]...)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append((*$$.GetFreeFloating())[freefloating.End], append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4861,11 +5117,7 @@ property_name: array_pair_list: non_empty_array_pair_list { - if (len($1) == 1 && $1[0] == nil) { - $$ = $1[:0] - } else { - $$ = $1 - } + $$ = $1 yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4874,7 +5126,7 @@ array_pair_list: possible_array_pair: /* empty */ { - $$ = nil + $$ = expr.NewArrayItem(nil, nil) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4889,18 +5141,24 @@ possible_array_pair: non_empty_array_pair_list: non_empty_array_pair_list ',' possible_array_pair { + if len($1) == 0 { + $1 = []node.Node{expr.NewArrayItem(nil, nil)} + } + $$ = append($1, $3) // save comments - if lastNode($1) != nil { - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) - } + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | possible_array_pair { - $$ = []node.Node{$1} + if $1.(*expr.ArrayItem).Key == nil && $1.(*expr.ArrayItem).Val == nil { + $$ = []node.Node{} + } else { + $$ = []node.Node{$1} + } yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4912,10 +5170,11 @@ array_pair: $$ = expr.NewArrayItem($1, $3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DoubleArrowToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4924,7 +5183,10 @@ array_pair: $$ = expr.NewArrayItem(nil, $1) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) + + // save comments + yylex.(*Parser).MoveFreeFloating($1, $$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4934,11 +5196,13 @@ array_pair: $$ = expr.NewArrayItem($1, reference) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(reference, $3, comment.AmpersandToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -4948,45 +5212,47 @@ array_pair: $$ = expr.NewArrayItem(nil, reference) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken(reference, $1, comment.AmpersandToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | expr T_DOUBLE_ARROW T_LIST '(' array_pair_list ')' { // TODO: Cannot use list() as standalone expression - list := expr.NewList($5) - $$ = expr.NewArrayItem($1, list) + listNode := expr.NewList($5) + $$ = expr.NewArrayItem($1, listNode) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition($3, $6)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $6)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $6)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $2, comment.DoubleArrowToken) - yylex.(*Parser).comments.AddFromToken(list, $3, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, $4, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, $6, comment.CloseParenthesisToken) + yylex.(*Parser).MoveFreeFloating($1, $$) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.Start, $3.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, $4.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, $6.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_LIST '(' array_pair_list ')' { // TODO: Cannot use list() as standalone expression - list := expr.NewList($3) - $$ = expr.NewArrayItem(nil, list) + listNode := expr.NewList($3) + $$ = expr.NewArrayItem(nil, listNode) // save position - yylex.(*Parser).positions.AddPosition(list, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(list, $1, comment.ListToken) - yylex.(*Parser).comments.AddFromToken(list, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken(list, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.List, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(listNode, freefloating.ArrayPairList, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5005,10 +5271,10 @@ encaps_list: $$ = append($1, encapsed) // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, $2, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5024,10 +5290,10 @@ encaps_list: $$ = []node.Node{encapsed, $2} // save position - yylex.(*Parser).positions.AddPosition(encapsed, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken(encapsed, $1, comment.EncapsedAndWhitespaceToken) + yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5040,11 +5306,12 @@ encaps_var: $$ = expr.NewVariable(name) // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5055,14 +5322,14 @@ encaps_var: $$ = expr.NewArrayDimFetch(variable, $3) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseSquareBracket) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($2.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($2)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($4.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($4)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5074,44 +5341,47 @@ encaps_var: $$ = expr.NewPropertyFetch(variable, fetch) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition(fetch, yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + fetch.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken(variable, $1, comment.VariableToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) - yylex.(*Parser).comments.AddFromToken(fetch, $3, comment.StringToken) + yylex.(*Parser).addDollarToken(variable) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) + yylex.(*Parser).setFreeFloating(fetch, freefloating.Start, $3.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { - $$ = expr.NewVariable($2) + variable := expr.NewVariable($2) + + $$ = variable // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { name := node.NewIdentifier($2.Value) - $$ = expr.NewVariable(name) + variable := expr.NewVariable(name) + + $$ = variable // save position - yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) + name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(name, $2, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5122,16 +5392,15 @@ encaps_var: $$ = expr.NewArrayDimFetch(variable, $4) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition(variable, yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.DollarOpenCurlyBracesToken) - yylex.(*Parser).comments.AddFromToken(variable, $2, comment.StringVarnameToken) - yylex.(*Parser).comments.AddFromToken($$, $3, comment.OpenSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseSquareBracket) - yylex.(*Parser).comments.AddFromToken($$, $6, comment.CloseCurlyBracesToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.Var, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, append($5.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($5)...)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($6.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($6)...)) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5139,6 +5408,10 @@ encaps_var: { $$ = $2; + // save comments + yylex.(*Parser).setFreeFloating($$, freefloating.Start, yylex.(*Parser).GetFreeFloatingToken($1)) + yylex.(*Parser).setFreeFloating($$, freefloating.End, append($3.FreeFloating, yylex.(*Parser).GetFreeFloatingToken($3)...)) + yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } ; @@ -5149,10 +5422,10 @@ encaps_var_offset: $$ = scalar.NewString($1.Value) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.StringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5166,10 +5439,10 @@ encaps_var_offset: } // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.NumStringToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5190,17 +5463,12 @@ encaps_var_offset: // save position if isInt { - yylex.(*Parser).positions.AddPosition(lnumber, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + lnumber.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) } - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.MinusToken) - if isInt { - yylex.(*Parser).comments.AddFromToken(lnumber, $2, comment.NumStringToken) - } else { - yylex.(*Parser).comments.AddFromToken($$, $2, comment.NumStringToken) - } + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5210,11 +5478,12 @@ encaps_var_offset: $$ = expr.NewVariable(identifier) // save position - yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.VariableToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).addDollarToken($$) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5226,15 +5495,16 @@ internal_functions_in_yacc: $$ = expr.NewIsset($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IssetToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - if $4 != nil { - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CommaToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Isset, $2.FreeFloating) + if $4 == nil { + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, $5.FreeFloating) + } else { + yylex.(*Parser).setFreeFloating($$, freefloating.VarList, append($4.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($4), $5.FreeFloating...)...)) } - yylex.(*Parser).comments.AddFromToken($$, $5, comment.CloseParenthesisToken) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5243,12 +5513,12 @@ internal_functions_in_yacc: $$ = expr.NewEmpty($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EmptyToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Empty, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5257,10 +5527,10 @@ internal_functions_in_yacc: $$ = expr.NewInclude($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncludeToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5269,10 +5539,10 @@ internal_functions_in_yacc: $$ = expr.NewIncludeOnce($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.IncludeOnceToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5281,12 +5551,12 @@ internal_functions_in_yacc: $$ = expr.NewEval($3) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.EvalToken) - yylex.(*Parser).comments.AddFromToken($$, $2, comment.OpenParenthesisToken) - yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Eval, $2.FreeFloating) + yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $4.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5295,10 +5565,10 @@ internal_functions_in_yacc: $$ = expr.NewRequire($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.RequireToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5307,10 +5577,10 @@ internal_functions_in_yacc: $$ = expr.NewRequireOnce($2) // save position - yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) + $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) // save comments - yylex.(*Parser).comments.AddFromToken($$, $1, comment.RequireOnceToken) + yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } @@ -5328,7 +5598,7 @@ isset_variables: $$ = append($1, $3) // save comments - yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken) + yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) } diff --git a/php7/php7_test.go b/php7/php7_test.go index 4727cd5..df49ce0 100644 --- a/php7/php7_test.go +++ b/php7/php7_test.go @@ -2,37 +2,23 @@ package php7_test import ( "bytes" - "reflect" "testing" - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" + "github.com/z7zmey/php-parser/errors" + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/assign" "github.com/z7zmey/php-parser/node/expr/binary" "github.com/z7zmey/php-parser/node/expr/cast" "github.com/z7zmey/php-parser/node/name" "github.com/z7zmey/php-parser/node/scalar" - "github.com/z7zmey/php-parser/position" - - "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/position" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - - } -} - func TestPhp7(t *testing.T) { src := ` "}, - &stmt.Interface{ - PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{}, + &stmt.Nop{ + Position: &position.Position{ + StartLine: 111, + EndLine: 111, + StartPos: 2623, + EndPos: 2624, + }, + }, + &stmt.InlineHtml{ + Position: &position.Position{ + StartLine: 111, + EndLine: 111, + StartPos: 2626, + EndPos: 2637, + }, + Value: "
", }, &stmt.Interface{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2643, + EndPos: 2658, + }, PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 112, + EndLine: 112, + StartPos: 2653, + EndPos: 2655, + }, + Value: "Foo", + }, + Stmts: []node.Node{}, + }, + &stmt.Interface{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2662, + EndPos: 2689, + }, + PhpDocComment: "", + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2672, + EndPos: 2674, + }, + Value: "Foo", + }, Extends: &stmt.InterfaceExtends{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2676, + EndPos: 2686, + }, InterfaceNames: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2684, + EndPos: 2686, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 113, + EndLine: 113, + StartPos: 2684, + EndPos: 2686, + }, + Value: "Bar", + }, }, }, }, @@ -1315,18 +5969,66 @@ func TestPhp7(t *testing.T) { Stmts: []node.Node{}, }, &stmt.Interface{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2693, + EndPos: 2725, + }, PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "Foo"}, + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2703, + EndPos: 2705, + }, + Value: "Foo", + }, Extends: &stmt.InterfaceExtends{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2707, + EndPos: 2722, + }, InterfaceNames: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2715, + EndPos: 2717, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2715, + EndPos: 2717, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2720, + EndPos: 2722, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 114, + EndLine: 114, + StartPos: 2720, + EndPos: 2722, + }, + Value: "Baz", + }, }, }, }, @@ -1334,211 +6036,896 @@ func TestPhp7(t *testing.T) { Stmts: []node.Node{}, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2729, + EndPos: 2742, + }, NamespaceName: &name.Name{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2739, + EndPos: 2741, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 115, + EndLine: 115, + StartPos: 2739, + EndPos: 2741, + }, + Value: "Foo", + }, }, }, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2746, + EndPos: 2761, + }, NamespaceName: &name.Name{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2756, + EndPos: 2758, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 116, + EndLine: 116, + StartPos: 2756, + EndPos: 2758, + }, + Value: "Foo", + }, }, }, Stmts: []node.Node{}, }, &stmt.Namespace{ + Position: &position.Position{ + StartLine: 117, + EndLine: 117, + StartPos: 2765, + EndPos: 2776, + }, Stmts: []node.Node{}, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2780, + EndPos: 2798, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2786, + EndPos: 2788, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.PropertyList{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2791, + EndPos: 2797, + }, Modifiers: []node.Node{ - &node.Identifier{Value: "var"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2791, + EndPos: 2793, + }, + Value: "var", + }, }, Properties: []node.Node{ &stmt.Property{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2795, + EndPos: 2796, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2795, + EndPos: 2796, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 118, + EndLine: 118, + StartPos: 2795, + EndPos: 2796, + }, + Value: "a", + }, + }, }, }, }, }, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2802, + EndPos: 2838, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2808, + EndPos: 2810, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.PropertyList{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2813, + EndPos: 2837, + }, Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - &node.Identifier{Value: "static"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2813, + EndPos: 2818, + }, + Value: "public", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2820, + EndPos: 2825, + }, + Value: "static", + }, }, Properties: []node.Node{ &stmt.Property{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2827, + EndPos: 2828, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2827, + EndPos: 2828, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2827, + EndPos: 2828, + }, + Value: "a", + }, + }, }, &stmt.Property{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2831, + EndPos: 2836, + }, PhpDocComment: "", - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2831, + EndPos: 2832, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2831, + EndPos: 2832, + }, + Value: "b", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 119, + EndLine: 119, + StartPos: 2836, + EndPos: 2836, + }, + Value: "1", + }, }, }, }, }, }, &stmt.Static{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2842, + EndPos: 2859, + }, Vars: []node.Node{ &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2849, + EndPos: 2850, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2849, + EndPos: 2850, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2849, + EndPos: 2850, + }, + Value: "a", + }, + }, }, &stmt.StaticVar{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - Expr: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2853, + EndPos: 2858, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2853, + EndPos: 2854, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2853, + EndPos: 2854, + }, + Value: "b", + }, + }, + Expr: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 120, + EndLine: 120, + StartPos: 2858, + EndPos: 2858, + }, + Value: "1", + }, }, }, }, &stmt.AltSwitch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 122, + EndLine: 126, + StartPos: 2864, + EndPos: 2922, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 122, + EndLine: 122, + StartPos: 2872, + EndPos: 2872, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 123, + EndLine: -1, + StartPos: 2880, + EndPos: -1, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 123, + EndLine: -1, + StartPos: 2880, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 123, + EndLine: 123, + StartPos: 2885, + EndPos: 2885, + }, + Value: "1", + }, Stmts: []node.Node{}, }, &stmt.Default{ + Position: &position.Position{ + StartLine: 124, + EndLine: -1, + StartPos: 2891, + EndPos: -1, + }, Stmts: []node.Node{}, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 125, + EndLine: -1, + StartPos: 2903, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 125, + EndLine: 125, + StartPos: 2908, + EndPos: 2908, + }, + Value: "2", + }, Stmts: []node.Node{}, }, }, }, }, &stmt.AltSwitch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 128, + EndLine: 131, + StartPos: 2927, + EndPos: 2974, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 128, + EndLine: 128, + StartPos: 2935, + EndPos: 2935, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 129, + EndLine: -1, + StartPos: 2944, + EndPos: -1, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 129, + EndLine: -1, + StartPos: 2944, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 129, + EndLine: 129, + StartPos: 2949, + EndPos: 2949, + }, + Value: "1", + }, Stmts: []node.Node{}, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 130, + EndLine: -1, + StartPos: 2955, + EndPos: -1, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 130, + EndLine: 130, + StartPos: 2960, + EndPos: 2960, + }, + Value: "2", + }, Stmts: []node.Node{}, }, }, }, }, &stmt.Switch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 133, + EndLine: 136, + StartPos: 2981, + EndPos: 3032, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 133, + EndLine: 133, + StartPos: 2989, + EndPos: 2989, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 133, + EndLine: 136, + StartPos: 2992, + EndPos: 3032, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 134, + EndLine: 134, + StartPos: 2997, + EndPos: 3010, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 134, + EndLine: 134, + StartPos: 3002, + EndPos: 3002, + }, + Value: "1", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 134, + EndLine: 134, + StartPos: 3005, + EndPos: 3010, + }, + }, }, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 3015, + EndPos: 3028, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 3020, + EndPos: 3020, + }, + Value: "2", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 135, + EndLine: 135, + StartPos: 3023, + EndPos: 3028, + }, + }, }, }, }, }, }, &stmt.Switch{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 138, + EndLine: 141, + StartPos: 3039, + EndPos: 3091, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 138, + EndLine: 138, + StartPos: 3047, + EndPos: 3047, + }, + Value: "1", + }, CaseList: &stmt.CaseList{ + Position: &position.Position{ + StartLine: 138, + EndLine: 141, + StartPos: 3050, + EndPos: 3091, + }, Cases: []node.Node{ &stmt.Case{ - Cond: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 139, + EndLine: 139, + StartPos: 3056, + EndPos: 3069, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 139, + EndLine: 139, + StartPos: 3061, + EndPos: 3061, + }, + Value: "1", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 139, + EndLine: 139, + StartPos: 3064, + EndPos: 3069, + }, + }, }, }, &stmt.Case{ - Cond: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3074, + EndPos: 3087, + }, + Cond: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3079, + EndPos: 3079, + }, + Value: "2", + }, Stmts: []node.Node{ - &stmt.Break{}, + &stmt.Break{ + Position: &position.Position{ + StartLine: 140, + EndLine: 140, + StartPos: 3082, + EndPos: 3087, + }, + }, }, }, }, }, }, &stmt.Throw{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3096, + EndPos: 3104, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3102, + EndPos: 3103, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 143, + EndLine: 143, + StartPos: 3102, + EndPos: 3103, + }, + Value: "e", + }, + }, }, &stmt.Trait{ + Position: &position.Position{ + StartLine: 145, + EndLine: 145, + StartPos: 3109, + EndPos: 3120, + }, PhpDocComment: "", - TraitName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{}, + TraitName: &node.Identifier{ + Position: &position.Position{ + StartLine: 145, + EndLine: 145, + StartPos: 3115, + EndPos: 3117, + }, + Value: "Foo", + }, + Stmts: []node.Node{}, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3124, + EndPos: 3145, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3130, + EndPos: 3132, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3136, + EndPos: 3143, + }, Traits: []node.Node{ &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3140, + EndPos: 3142, }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3140, + EndPos: 3142, + }, + Value: "Bar", + }, + }, + }, + }, + TraitAdaptationList: &stmt.Nop{ + Position: &position.Position{ + StartLine: 146, + EndLine: 146, + StartPos: 3143, + EndPos: 3143, }, }, }, }, }, &stmt.Class{ - PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{ - &stmt.TraitUse{ - Traits: []node.Node{ - &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, - }, - }, - &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{}, - }, + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3149, + EndPos: 3177, }, - }, - &stmt.Class{ PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3155, + EndPos: 3157, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3161, + EndPos: 3175, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3165, + EndPos: 3167, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3165, + EndPos: 3167, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3170, + EndPos: 3172, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3170, + EndPos: 3172, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 147, + EndLine: 147, + StartPos: 3174, + EndPos: 3175, + }, + }, + }, + }, + }, + &stmt.Class{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3181, + EndPos: 3226, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3187, + EndPos: 3189, + }, + Value: "Foo", + }, + Stmts: []node.Node{ + &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3193, + EndPos: 3224, + }, + Traits: []node.Node{ + &name.Name{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3197, + EndPos: 3199, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3197, + EndPos: 3199, + }, + Value: "Bar", + }, + }, + }, + &name.Name{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3202, + EndPos: 3204, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3202, + EndPos: 3204, + }, + Value: "Baz", + }, + }, + }, + }, + TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3206, + EndPos: 3224, + }, Adaptations: []node.Node{ &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "one"}, + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3208, + EndPos: 3221, + }, + Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3208, + EndPos: 3210, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3208, + EndPos: 3210, + }, + Value: "one", + }, + }, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 148, + EndLine: 148, + StartPos: 3215, + EndPos: 3221, + }, + Value: "include", }, - Alias: &node.Identifier{Value: "include"}, }, }, }, @@ -1546,29 +6933,111 @@ func TestPhp7(t *testing.T) { }, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3230, + EndPos: 3274, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3236, + EndPos: 3238, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3242, + EndPos: 3272, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3246, + EndPos: 3248, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3246, + EndPos: 3248, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3251, + EndPos: 3253, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3251, + EndPos: 3253, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3255, + EndPos: 3272, + }, Adaptations: []node.Node{ &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "one"}, + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3257, + EndPos: 3269, + }, + Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3257, + EndPos: 3259, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3257, + EndPos: 3259, + }, + Value: "one", + }, + }, + Modifier: &node.Identifier{ + Position: &position.Position{ + StartLine: 149, + EndLine: 149, + StartPos: 3264, + EndPos: 3269, + }, + Value: "public", }, - Modifier: &node.Identifier{Value: "public"}, }, }, }, @@ -1576,30 +7045,120 @@ func TestPhp7(t *testing.T) { }, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3278, + EndPos: 3326, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3284, + EndPos: 3286, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3290, + EndPos: 3324, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3294, + EndPos: 3296, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3294, + EndPos: 3296, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3299, + EndPos: 3301, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3299, + EndPos: 3301, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3303, + EndPos: 3324, + }, Adaptations: []node.Node{ &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "one"}, + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3305, + EndPos: 3321, + }, + Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3305, + EndPos: 3307, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3305, + EndPos: 3307, + }, + Value: "one", + }, + }, + Modifier: &node.Identifier{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3312, + EndPos: 3317, + }, + Value: "public", + }, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 150, + EndLine: 150, + StartPos: 3319, + EndPos: 3321, + }, + Value: "two", }, - Modifier: &node.Identifier{Value: "public"}, - Alias: &node.Identifier{Value: "two"}, }, }, }, @@ -1607,56 +7166,214 @@ func TestPhp7(t *testing.T) { }, }, &stmt.Class{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3330, + EndPos: 3406, + }, PhpDocComment: "", - ClassName: &node.Identifier{Value: "Foo"}, + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3336, + EndPos: 3338, + }, + Value: "Foo", + }, Stmts: []node.Node{ &stmt.TraitUse{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3342, + EndPos: 3404, + }, Traits: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3346, + EndPos: 3348, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3346, + EndPos: 3348, + }, + Value: "Bar", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3351, + EndPos: 3353, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3351, + EndPos: 3353, + }, + Value: "Baz", + }, }, }, }, TraitAdaptationList: &stmt.TraitAdaptationList{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3355, + EndPos: 3404, + }, Adaptations: []node.Node{ &stmt.TraitUsePrecedence{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3357, + EndPos: 3384, + }, Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3357, + EndPos: 3364, + }, Trait: &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3357, + EndPos: 3359, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3357, + EndPos: 3359, + }, + Value: "Bar", + }, }, }, - Method: &node.Identifier{Value: "one"}, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3362, + EndPos: 3364, + }, + Value: "one", + }, }, Insteadof: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3376, + EndPos: 3378, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3376, + EndPos: 3378, + }, + Value: "Baz", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3381, + EndPos: 3384, + }, Parts: []node.Node{ - &name.NamePart{Value: "Quux"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3381, + EndPos: 3384, + }, + Value: "Quux", + }, }, }, }, }, &stmt.TraitUseAlias{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3387, + EndPos: 3401, + }, Ref: &stmt.TraitMethodRef{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3387, + EndPos: 3394, + }, Trait: &name.Name{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3387, + EndPos: 3389, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3387, + EndPos: 3389, + }, + Value: "Baz", + }, }, }, - Method: &node.Identifier{Value: "one"}, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3392, + EndPos: 3394, + }, + Value: "one", + }, + }, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 151, + EndLine: 151, + StartPos: 3399, + EndPos: 3401, + }, + Value: "two", }, - Alias: &node.Identifier{Value: "two"}, }, }, }, @@ -1664,761 +7381,3488 @@ func TestPhp7(t *testing.T) { }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 153, + EndLine: -1, + StartPos: 3411, + EndPos: -1, + }, Stmts: []node.Node{}, Catches: []node.Node{}, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3420, + EndPos: 3449, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3427, + EndPos: 3449, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3434, + EndPos: 3442, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3434, + EndPos: 3442, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3444, + EndPos: 3445, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 154, + EndLine: 154, + StartPos: 3444, + EndPos: 3445, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3453, + EndPos: 3499, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3460, + EndPos: 3499, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3467, + EndPos: 3475, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3467, + EndPos: 3475, + }, + Value: "Exception", + }, }, }, &name.Name{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3477, + EndPos: 3492, + }, Parts: []node.Node{ - &name.NamePart{Value: "RuntimeException"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3477, + EndPos: 3492, + }, + Value: "RuntimeException", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3494, + EndPos: 3495, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 155, + EndLine: 155, + StartPos: 3494, + EndPos: 3495, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3503, + EndPos: 3563, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3510, + EndPos: 3532, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3517, + EndPos: 3525, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3517, + EndPos: 3525, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3527, + EndPos: 3528, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3527, + EndPos: 3528, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, &stmt.Catch{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3534, + EndPos: 3563, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3541, + EndPos: 3556, + }, Parts: []node.Node{ - &name.NamePart{Value: "RuntimeException"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3541, + EndPos: 3556, + }, + Value: "RuntimeException", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3558, + EndPos: 3559, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 156, + EndLine: 156, + StartPos: 3558, + EndPos: 3559, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, }, &stmt.Try{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3567, + EndPos: 3607, + }, Stmts: []node.Node{}, Catches: []node.Node{ &stmt.Catch{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3574, + EndPos: 3596, + }, Types: []node.Node{ &name.Name{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3581, + EndPos: 3589, + }, Parts: []node.Node{ - &name.NamePart{Value: "Exception"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3581, + EndPos: 3589, + }, + Value: "Exception", + }, }, }, }, Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "e"}, + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3591, + EndPos: 3592, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3591, + EndPos: 3592, + }, + Value: "e", + }, }, Stmts: []node.Node{}, }, }, Finally: &stmt.Finally{ + Position: &position.Position{ + StartLine: 157, + EndLine: 157, + StartPos: 3598, + EndPos: 3607, + }, Stmts: []node.Node{}, }, }, &stmt.Unset{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3612, + EndPos: 3626, + }, Vars: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + &expr.Variable{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3618, + EndPos: 3619, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3618, + EndPos: 3619, + }, + Value: "a", + }, + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3622, + EndPos: 3623, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 159, + EndLine: 159, + StartPos: 3622, + EndPos: 3623, + }, + Value: "b", + }, + }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3631, + EndPos: 3638, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3635, + EndPos: 3637, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3635, + EndPos: 3637, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 161, + EndLine: 161, + StartPos: 3635, + EndPos: 3637, + }, + Value: "Foo", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3642, + EndPos: 3650, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3647, + EndPos: 3649, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3647, + EndPos: 3649, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 162, + EndLine: 162, + StartPos: 3647, + EndPos: 3649, + }, + Value: "Foo", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 163, + EndLine: 163, + StartPos: 3654, + EndPos: 3669, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 163, + EndLine: 163, + StartPos: 3659, + EndPos: 3668, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 163, + EndLine: 163, + StartPos: 3659, + EndPos: 3661, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 163, + EndLine: 163, + StartPos: 3659, + EndPos: 3661, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "Bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 163, + EndLine: 163, + StartPos: 3666, + EndPos: 3668, + }, + Value: "Bar", + }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3673, + EndPos: 3685, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3677, + EndPos: 3679, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3677, + EndPos: 3679, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3677, + EndPos: 3679, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3682, + EndPos: 3684, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3682, + EndPos: 3684, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 164, + EndLine: 164, + StartPos: 3682, + EndPos: 3684, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3689, + EndPos: 3708, + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3693, + EndPos: 3695, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3693, + EndPos: 3695, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3693, + EndPos: 3695, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3698, + EndPos: 3707, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3698, + EndPos: 3700, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3698, + EndPos: 3700, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "Baz"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 165, + EndLine: 165, + StartPos: 3705, + EndPos: 3707, + }, + Value: "Baz", + }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3712, + EndPos: 3734, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3716, + EndPos: 3723, + }, + Value: "function", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3725, + EndPos: 3727, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3725, + EndPos: 3727, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3725, + EndPos: 3727, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3731, + EndPos: 3733, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3731, + EndPos: 3733, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 166, + EndLine: 166, + StartPos: 3731, + EndPos: 3733, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3738, + EndPos: 3774, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3742, + EndPos: 3749, + }, + Value: "function", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3751, + EndPos: 3760, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3751, + EndPos: 3753, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3751, + EndPos: 3753, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "foo"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3758, + EndPos: 3760, + }, + Value: "foo", + }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3764, + EndPos: 3773, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3764, + EndPos: 3766, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3764, + EndPos: 3766, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 167, + EndLine: 167, + StartPos: 3771, + EndPos: 3773, + }, + Value: "bar", + }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3778, + EndPos: 3797, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3782, + EndPos: 3786, + }, + Value: "const", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3788, + EndPos: 3790, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3788, + EndPos: 3790, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3788, + EndPos: 3790, + }, + Value: "Foo", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3794, + EndPos: 3796, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3794, + EndPos: 3796, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 168, + EndLine: 168, + StartPos: 3794, + EndPos: 3796, + }, + Value: "Bar", + }, }, }, }, }, }, &stmt.UseList{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3801, + EndPos: 3834, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3805, + EndPos: 3809, + }, + Value: "const", + }, Uses: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3811, + EndPos: 3820, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3811, + EndPos: 3813, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3811, + EndPos: 3813, + }, + Value: "Foo", + }, }, }, - Alias: &node.Identifier{Value: "foo"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3818, + EndPos: 3820, + }, + Value: "foo", + }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3824, + EndPos: 3833, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3824, + EndPos: 3826, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3824, + EndPos: 3826, + }, + Value: "Bar", + }, }, }, - Alias: &node.Identifier{Value: "bar"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 169, + EndLine: 169, + StartPos: 3831, + EndPos: 3833, + }, + Value: "bar", + }, }, }, }, &stmt.GroupUse{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3839, + EndPos: 3858, + }, Prefix: &name.Name{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3844, + EndPos: 3846, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3844, + EndPos: 3846, + }, + Value: "Foo", + }, }, }, UseList: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3849, + EndPos: 3851, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3849, + EndPos: 3851, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3849, + EndPos: 3851, + }, + Value: "Bar", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3854, + EndPos: 3856, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3854, + EndPos: 3856, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 171, + EndLine: 171, + StartPos: 3854, + EndPos: 3856, + }, + Value: "Baz", + }, }, }, }, }, }, &stmt.GroupUse{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3862, + EndPos: 3888, + }, Prefix: &name.Name{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3866, + EndPos: 3868, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3866, + EndPos: 3868, + }, + Value: "Foo", + }, }, }, UseList: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3871, + EndPos: 3873, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3871, + EndPos: 3873, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3871, + EndPos: 3873, + }, + Value: "Bar", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3876, + EndPos: 3886, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3876, + EndPos: 3878, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3876, + EndPos: 3878, + }, + Value: "Baz", + }, }, }, - Alias: &node.Identifier{Value: "quux"}, + Alias: &node.Identifier{ + Position: &position.Position{ + StartLine: 172, + EndLine: 172, + StartPos: 3883, + EndPos: 3886, + }, + Value: "quux", + }, }, }, }, &stmt.GroupUse{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3892, + EndPos: 3919, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3896, + EndPos: 3903, + }, + Value: "function", + }, Prefix: &name.Name{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3905, + EndPos: 3907, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3905, + EndPos: 3907, + }, + Value: "Foo", + }, }, }, UseList: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3910, + EndPos: 3912, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3910, + EndPos: 3912, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3910, + EndPos: 3912, + }, + Value: "Bar", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3915, + EndPos: 3917, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3915, + EndPos: 3917, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 173, + EndLine: 173, + StartPos: 3915, + EndPos: 3917, + }, + Value: "Baz", + }, }, }, }, }, }, &stmt.GroupUse{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3923, + EndPos: 3948, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3927, + EndPos: 3931, + }, + Value: "const", + }, Prefix: &name.Name{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3934, + EndPos: 3936, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3934, + EndPos: 3936, + }, + Value: "Foo", + }, }, }, UseList: []node.Node{ &stmt.Use{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3939, + EndPos: 3941, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3939, + EndPos: 3941, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3939, + EndPos: 3941, + }, + Value: "Bar", + }, }, }, }, &stmt.Use{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3944, + EndPos: 3946, + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3944, + EndPos: 3946, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 174, + EndLine: 174, + StartPos: 3944, + EndPos: 3946, + }, + Value: "Baz", + }, }, }, }, }, }, &stmt.GroupUse{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3952, + EndPos: 3985, + }, Prefix: &name.Name{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3956, + EndPos: 3958, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3956, + EndPos: 3958, + }, + Value: "Foo", + }, }, }, UseList: []node.Node{ &stmt.Use{ - UseType: &node.Identifier{Value: "const"}, + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3967, + EndPos: 3969, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3961, + EndPos: 3965, + }, + Value: "const", + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3967, + EndPos: 3969, + }, Parts: []node.Node{ - &name.NamePart{Value: "Bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3967, + EndPos: 3969, + }, + Value: "Bar", + }, }, }, }, &stmt.Use{ - UseType: &node.Identifier{Value: "function"}, + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3981, + EndPos: 3983, + }, + UseType: &node.Identifier{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3972, + EndPos: 3979, + }, + Value: "function", + }, Use: &name.Name{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3981, + EndPos: 3983, + }, Parts: []node.Node{ - &name.NamePart{Value: "Baz"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 175, + EndLine: 175, + StartPos: 3981, + EndPos: 3983, + }, + Value: "Baz", + }, }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3990, + EndPos: 3995, + }, Expr: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Dim: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3990, + EndPos: 3994, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3990, + EndPos: 3991, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3990, + EndPos: 3991, + }, + Value: "a", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 177, + EndLine: 177, + StartPos: 3993, + EndPos: 3993, + }, + Value: "1", + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3999, + EndPos: 4007, + }, Expr: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3999, + EndPos: 4006, + }, Variable: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Dim: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3999, + EndPos: 4003, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3999, + EndPos: 4000, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 3999, + EndPos: 4000, + }, + Value: "a", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 4002, + EndPos: 4002, + }, + Value: "1", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 178, + EndLine: 178, + StartPos: 4005, + EndPos: 4005, + }, + Value: "2", }, - Dim: &scalar.Lnumber{Value: "2"}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 4011, + EndPos: 4018, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 179, + EndLine: 179, + StartPos: 4011, + EndPos: 4017, + }, Items: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 4022, + EndPos: 4030, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 4022, + EndPos: 4029, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 4028, + EndPos: 4028, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 180, + EndLine: 180, + StartPos: 4028, + EndPos: 4028, + }, + Value: "1", + }, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4034, + EndPos: 4051, + }, Expr: &expr.Array{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4034, + EndPos: 4050, + }, Items: []node.Node{ &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4040, + EndPos: 4043, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4040, + EndPos: 4040, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4043, + EndPos: 4043, + }, + Value: "1", + }, }, &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4046, + EndPos: 4048, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4046, + EndPos: 4048, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4047, + EndPos: 4048, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 181, + EndLine: 181, + StartPos: 4047, + EndPos: 4048, + }, + Value: "b", + }, + }, + }, }, - nil, + &expr.ArrayItem{}, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4055, + EndPos: 4058, + }, Expr: &expr.BitwiseNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.BooleanNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ClassConstFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4055, + EndPos: 4057, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4056, + EndPos: 4057, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 182, + EndLine: 182, + StartPos: 4056, + EndPos: 4057, + }, + Value: "a", }, }, - ConstantName: &node.Identifier{Value: "Bar"}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4062, + EndPos: 4065, + }, + Expr: &expr.BooleanNot{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4062, + EndPos: 4064, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4063, + EndPos: 4064, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 183, + EndLine: 183, + StartPos: 4063, + EndPos: 4064, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4070, + EndPos: 4078, + }, Expr: &expr.ClassConstFetch{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - ConstantName: &node.Identifier{Value: "Bar"}, + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4070, + EndPos: 4077, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4070, + EndPos: 4072, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4070, + EndPos: 4072, + }, + Value: "Foo", + }, + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 185, + EndLine: 185, + StartPos: 4075, + EndPos: 4077, + }, + Value: "Bar", + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4082, + EndPos: 4091, + }, + Expr: &expr.ClassConstFetch{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4082, + EndPos: 4090, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4082, + EndPos: 4085, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4082, + EndPos: 4085, + }, + Value: "foo", + }, + }, + ConstantName: &node.Identifier{ + Position: &position.Position{ + StartLine: 186, + EndLine: 186, + StartPos: 4088, + EndPos: 4090, + }, + Value: "Bar", + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4095, + EndPos: 4104, + }, Expr: &expr.Clone{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4095, + EndPos: 4102, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4101, + EndPos: 4102, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 187, + EndLine: 187, + StartPos: 4101, + EndPos: 4102, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4108, + EndPos: 4116, + }, Expr: &expr.Clone{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4108, + EndPos: 4115, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4114, + EndPos: 4115, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 188, + EndLine: 188, + StartPos: 4114, + EndPos: 4115, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 189, + EndLine: 189, + StartPos: 4120, + EndPos: 4132, + }, Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 189, + EndLine: 189, + StartPos: 4120, + EndPos: 4131, + }, + PhpDocComment: "", ReturnsRef: false, Static: false, - PhpDocComment: "", Stmts: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4136, + EndPos: 4169, + }, Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4136, + EndPos: 4168, + }, ReturnsRef: false, Static: false, PhpDocComment: "", Params: []node.Node{ &node.Parameter{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4145, + EndPos: 4146, + }, ByRef: false, Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - ClosureUse: &expr.ClosureUse{ - Uses: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - ReturnType: &name.Name{ - Parts: []node.Node{&name.NamePart{Value: "void"}}, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.Relative{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Empty{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.ErrorSuppress{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Eval{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Exit{}, - }, - &stmt.Expression{ - Expr: &expr.Exit{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Die{}, - }, - &stmt.Expression{ - Expr: &expr.Die{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - }, - }, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.PostDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.PostInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.PreDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.PreInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Include{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.IncludeOnce{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Require{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.RequireOnce{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.Isset{ - Variables: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - }, - &stmt.Expression{ - Expr: &assign.Assign{ - Variable: &expr.List{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4145, + EndPos: 4146, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4145, + EndPos: 4146, + }, + Value: "a", + }, }, }, - }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Assign{ - Variable: &expr.List{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + &node.Parameter{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4149, + EndPos: 4150, + }, + ByRef: false, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4149, + EndPos: 4150, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4149, + EndPos: 4150, + }, + Value: "b", }, }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + ClosureUse: &expr.ClosureUse{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4153, + EndPos: 4165, + }, + Uses: []node.Node{ + &expr.Variable{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4158, + EndPos: 4159, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4158, + EndPos: 4159, + }, + Value: "c", + }, + }, + &expr.Reference{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4162, + EndPos: 4164, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4163, + EndPos: 4164, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 190, + EndLine: 190, + StartPos: 4163, + EndPos: 4164, + }, + Value: "d", + }, + }, + }, + }, + }, + Stmts: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4173, + EndPos: 4192, + }, + Expr: &expr.Closure{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4173, + EndPos: 4191, + }, + ReturnsRef: false, + Static: false, + PhpDocComment: "", + ReturnType: &name.Name{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4185, + EndPos: 4188, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 191, + EndLine: 191, + StartPos: 4185, + EndPos: 4188, + }, + Value: "void", + }, + }, + }, + Stmts: []node.Node{}, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4196, + EndPos: 4199, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4196, + EndPos: 4198, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4196, + EndPos: 4198, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 192, + EndLine: 192, + StartPos: 4196, + EndPos: 4198, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4203, + EndPos: 4216, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4203, + EndPos: 4215, + }, + Constant: &name.Relative{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4203, + EndPos: 4215, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 193, + EndLine: 193, + StartPos: 4213, + EndPos: 4215, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4220, + EndPos: 4224, + }, + Expr: &expr.ConstFetch{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4220, + EndPos: 4223, + }, + Constant: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4220, + EndPos: 4223, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 194, + EndLine: 194, + StartPos: 4221, + EndPos: 4223, + }, + Value: "foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4229, + EndPos: 4238, + }, + Expr: &expr.Empty{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4229, + EndPos: 4237, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4235, + EndPos: 4236, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 196, + EndLine: 196, + StartPos: 4235, + EndPos: 4236, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 197, + EndLine: 197, + StartPos: 4242, + EndPos: 4245, + }, + Expr: &expr.ErrorSuppress{ + Position: &position.Position{ + StartLine: 197, + EndLine: 197, + StartPos: 4242, + EndPos: 4244, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 197, + EndLine: 197, + StartPos: 4243, + EndPos: 4244, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 197, + EndLine: 197, + StartPos: 4243, + EndPos: 4244, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4249, + EndPos: 4257, + }, + Expr: &expr.Eval{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4249, + EndPos: 4256, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4254, + EndPos: 4255, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 198, + EndLine: 198, + StartPos: 4254, + EndPos: 4255, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4261, + EndPos: 4265, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 199, + EndLine: 199, + StartPos: 4261, + EndPos: 4264, + }, + Die: false, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4269, + EndPos: 4277, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4269, + EndPos: 4276, + }, + Die: false, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4274, + EndPos: 4275, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 200, + EndLine: 200, + StartPos: 4274, + EndPos: 4275, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4281, + EndPos: 4284, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 201, + EndLine: 201, + StartPos: 4281, + EndPos: 4283, + }, + Die: true, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 202, + EndLine: 202, + StartPos: 4288, + EndPos: 4295, + }, + Expr: &expr.Exit{ + Position: &position.Position{ + StartLine: 202, + EndLine: 202, + StartPos: 4288, + EndPos: 4294, + }, + Die: true, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 202, + EndLine: 202, + StartPos: 4292, + EndPos: 4293, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 202, + EndLine: 202, + StartPos: 4292, + EndPos: 4293, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4299, + EndPos: 4304, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4299, + EndPos: 4303, + }, + Function: &name.Name{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4299, + EndPos: 4301, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4299, + EndPos: 4301, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 203, + EndLine: 203, + StartPos: 4302, + EndPos: 4303, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4308, + EndPos: 4323, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4308, + EndPos: 4322, + }, + Function: &name.Relative{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4308, + EndPos: 4320, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4318, + EndPos: 4320, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 204, + EndLine: 204, + StartPos: 4321, + EndPos: 4322, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4327, + EndPos: 4333, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4327, + EndPos: 4332, + }, + Function: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4327, + EndPos: 4330, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4328, + EndPos: 4330, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 205, + EndLine: 205, + StartPos: 4331, + EndPos: 4332, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4337, + EndPos: 4343, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4337, + EndPos: 4342, + }, + Function: &expr.Variable{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4337, + EndPos: 4340, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4337, + EndPos: 4340, + }, + Value: "foo", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 206, + EndLine: 206, + StartPos: 4341, + EndPos: 4342, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4348, + EndPos: 4352, + }, + Expr: &expr.PostDec{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4348, + EndPos: 4351, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4348, + EndPos: 4349, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 208, + EndLine: 208, + StartPos: 4348, + EndPos: 4349, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4356, + EndPos: 4360, + }, + Expr: &expr.PostInc{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4356, + EndPos: 4359, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4356, + EndPos: 4357, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 209, + EndLine: 209, + StartPos: 4356, + EndPos: 4357, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4364, + EndPos: 4368, + }, + Expr: &expr.PreDec{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4364, + EndPos: 4367, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4366, + EndPos: 4367, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 210, + EndLine: 210, + StartPos: 4366, + EndPos: 4367, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 211, + EndLine: 211, + StartPos: 4372, + EndPos: 4376, + }, + Expr: &expr.PreInc{ + Position: &position.Position{ + StartLine: 211, + EndLine: 211, + StartPos: 4372, + EndPos: 4375, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 211, + EndLine: 211, + StartPos: 4374, + EndPos: 4375, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 211, + EndLine: 211, + StartPos: 4374, + EndPos: 4375, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4381, + EndPos: 4391, + }, + Expr: &expr.Include{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4381, + EndPos: 4390, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4389, + EndPos: 4390, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 213, + EndLine: 213, + StartPos: 4389, + EndPos: 4390, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4395, + EndPos: 4410, + }, + Expr: &expr.IncludeOnce{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4395, + EndPos: 4409, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4408, + EndPos: 4409, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 214, + EndLine: 214, + StartPos: 4408, + EndPos: 4409, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4414, + EndPos: 4424, + }, + Expr: &expr.Require{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4414, + EndPos: 4423, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4422, + EndPos: 4423, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 215, + EndLine: 215, + StartPos: 4422, + EndPos: 4423, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4428, + EndPos: 4443, + }, + Expr: &expr.RequireOnce{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4428, + EndPos: 4442, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4441, + EndPos: 4442, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 216, + EndLine: 216, + StartPos: 4441, + EndPos: 4442, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4448, + EndPos: 4465, + }, + Expr: &expr.InstanceOf{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4448, + EndPos: 4464, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4448, + EndPos: 4449, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4448, + EndPos: 4449, + }, + Value: "a", + }, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4462, + EndPos: 4464, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 218, + EndLine: 218, + StartPos: 4462, + EndPos: 4464, + }, + Value: "Foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4469, + EndPos: 4496, + }, + Expr: &expr.InstanceOf{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4469, + EndPos: 4495, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4469, + EndPos: 4470, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4469, + EndPos: 4470, + }, + Value: "a", + }, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4483, + EndPos: 4495, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 219, + EndLine: 219, + StartPos: 4493, + EndPos: 4495, + }, + Value: "Foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4500, + EndPos: 4518, + }, + Expr: &expr.InstanceOf{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4500, + EndPos: 4517, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4500, + EndPos: 4501, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4500, + EndPos: 4501, + }, + Value: "a", + }, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4514, + EndPos: 4517, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 220, + EndLine: 220, + StartPos: 4515, + EndPos: 4517, + }, + Value: "Foo", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4523, + EndPos: 4536, + }, + Expr: &expr.Isset{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4523, + EndPos: 4535, + }, + Variables: []node.Node{ + &expr.Variable{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4529, + EndPos: 4530, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4529, + EndPos: 4530, + }, + Value: "a", + }, + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4533, + EndPos: 4534, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 222, + EndLine: 222, + StartPos: 4533, + EndPos: 4534, + }, + Value: "b", + }, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4540, + EndPos: 4553, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4540, + EndPos: 4552, + }, Variable: &expr.List{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4540, + EndPos: 4547, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.List{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4545, + EndPos: 4546, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4545, + EndPos: 4546, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4545, + EndPos: 4546, + }, + Value: "a", + }, + }, + }, + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4551, + EndPos: 4552, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 223, + EndLine: 223, + StartPos: 4551, + EndPos: 4552, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4557, + EndPos: 4572, + }, + Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4557, + EndPos: 4571, + }, + Variable: &expr.List{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4557, + EndPos: 4566, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4562, + EndPos: 4565, + }, + Val: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4562, + EndPos: 4565, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4562, + EndPos: 4563, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4562, + EndPos: 4563, + }, + Value: "a", }, }, }, }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4570, + EndPos: 4571, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 224, + EndLine: 224, + StartPos: 4570, + EndPos: 4571, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4576, + EndPos: 4595, + }, + Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4576, + EndPos: 4594, + }, + Variable: &expr.List{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4576, + EndPos: 4589, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4581, + EndPos: 4588, + }, + Val: &expr.List{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4581, + EndPos: 4588, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4586, + EndPos: 4587, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4586, + EndPos: 4587, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4586, + EndPos: 4587, + }, + Value: "a", + }, + }, + }, + }, + }, + }, + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4593, + EndPos: 4594, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 225, + EndLine: 225, + StartPos: 4593, + EndPos: 4594, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4600, + EndPos: 4609, + }, Expr: &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Method: &node.Identifier{Value: "foo"}, - - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4600, + EndPos: 4608, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4600, + EndPos: 4601, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4600, + EndPos: 4601, + }, + Value: "a", + }, + }, + Method: &node.Identifier{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4604, + EndPos: 4606, + }, + Value: "foo", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 227, + EndLine: 227, + StartPos: 4607, + EndPos: 4608, + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4613, + EndPos: 4622, + }, Expr: &expr.New{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4613, + EndPos: 4621, + }, Class: &name.Name{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4617, + EndPos: 4619, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4617, + EndPos: 4619, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 228, + EndLine: 228, + StartPos: 4620, + EndPos: 4621, }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4626, + EndPos: 4645, + }, Expr: &expr.New{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4626, + EndPos: 4644, + }, Class: &name.Relative{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4630, + EndPos: 4642, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4640, + EndPos: 4642, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 229, + EndLine: 229, + StartPos: 4643, + EndPos: 4644, }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4649, + EndPos: 4659, + }, Expr: &expr.New{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4649, + EndPos: 4658, + }, Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4653, + EndPos: 4656, + }, Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4654, + EndPos: 4656, + }, + Value: "Foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 230, + EndLine: 230, + StartPos: 4657, + EndPos: 4658, }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4663, + EndPos: 4687, + }, Expr: &expr.New{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4663, + EndPos: 4686, + }, Class: &stmt.Class{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4667, + EndPos: 4686, + }, PhpDocComment: "", - ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4673, + EndPos: 4683, + }, Arguments: []node.Node{ - &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + &node.Argument{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4674, + EndPos: 4675, + }, + Variadic: false, + IsReference: false, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4674, + EndPos: 4675, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4674, + EndPos: 4675, + }, + Value: "a", + }, + }, + }, + &node.Argument{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4678, + EndPos: 4682, + }, + IsReference: false, + Variadic: true, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4681, + EndPos: 4682, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 231, + EndLine: 231, + StartPos: 4681, + EndPos: 4682, + }, + Value: "b", + }, + }, + }, }, }, Stmts: []node.Node{}, @@ -2426,795 +10870,5243 @@ func TestPhp7(t *testing.T) { }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4691, + EndPos: 4700, + }, Expr: &expr.Print{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4691, + EndPos: 4698, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4697, + EndPos: 4698, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 232, + EndLine: 232, + StartPos: 4697, + EndPos: 4698, + }, + Value: "a", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4704, + EndPos: 4711, + }, Expr: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Property: &node.Identifier{Value: "foo"}, - }, - }, - &stmt.Expression{ - Expr: &expr.ShellExec{ - Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "cmd "}, - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4704, + EndPos: 4710, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4704, + EndPos: 4705, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4704, + EndPos: 4705, + }, + Value: "a", + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 233, + EndLine: 233, + StartPos: 4708, + EndPos: 4710, + }, + Value: "foo", }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 234, + EndLine: 234, + StartPos: 4715, + EndPos: 4723, + }, Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 234, + EndLine: 234, + StartPos: 4715, + EndPos: 4722, + }, Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "cmd"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 234, + EndLine: 234, + StartPos: 4716, + EndPos: 4719, + }, + Value: "cmd ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 234, + EndLine: 234, + StartPos: 4720, + EndPos: 4721, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 234, + EndLine: 234, + StartPos: 4720, + EndPos: 4721, + }, + Value: "a", + }, + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4727, + EndPos: 4732, + }, Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4727, + EndPos: 4731, + }, + Parts: []node.Node{ + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 235, + EndLine: 235, + StartPos: 4728, + EndPos: 4730, + }, + Value: "cmd", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4736, + EndPos: 4738, + }, + Expr: &expr.ShellExec{ + Position: &position.Position{ + StartLine: 236, + EndLine: 236, + StartPos: 4736, + EndPos: 4737, + }, Parts: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4742, + EndPos: 4744, + }, Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 237, + EndLine: 237, + StartPos: 4742, + EndPos: 4743, + }, Items: []node.Node{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4748, + EndPos: 4751, + }, Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4748, + EndPos: 4750, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, - }, - }, - }, - }, - &stmt.Expression{ - Expr: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &scalar.Lnumber{Value: "1"}, - }, - &expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - nil, - }, - }, - }, - &stmt.Expression{ - Expr: &assign.Assign{ - Variable: &expr.ShortList{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4749, + EndPos: 4749, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 238, + EndLine: 238, + StartPos: 4749, + EndPos: 4749, + }, + Value: "1", }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4755, + EndPos: 4767, + }, + Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4755, + EndPos: 4766, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4756, + EndPos: 4759, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4756, + EndPos: 4756, + }, + Value: "1", + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4759, + EndPos: 4759, + }, + Value: "1", + }, + }, + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4762, + EndPos: 4764, + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4762, + EndPos: 4764, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4763, + EndPos: 4764, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 239, + EndLine: 239, + StartPos: 4763, + EndPos: 4764, + }, + Value: "b", + }, + }, + }, + }, + &expr.ArrayItem{}, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4772, + EndPos: 4781, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4772, + EndPos: 4780, + }, Variable: &expr.ShortList{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4772, + EndPos: 4775, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4773, + EndPos: 4774, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4773, + EndPos: 4774, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4773, + EndPos: 4774, + }, + Value: "a", + }, }, }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4779, + EndPos: 4780, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 241, + EndLine: 241, + StartPos: 4779, + EndPos: 4780, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4785, + EndPos: 4796, + }, Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4785, + EndPos: 4795, + }, Variable: &expr.ShortList{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4785, + EndPos: 4790, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.List{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4786, + EndPos: 4789, + }, + Val: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4786, + EndPos: 4789, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4786, + EndPos: 4787, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4786, + EndPos: 4787, + }, + Value: "a", }, }, }, }, }, }, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4794, + EndPos: 4795, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 242, + EndLine: 242, + StartPos: 4794, + EndPos: 4795, + }, + Value: "b", }, }, - Call: &node.Identifier{Value: "bar"}, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &node.Identifier{Value: "bar"}, - - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4800, + EndPos: 4815, }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Call: &node.Identifier{Value: "bar"}, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.Relative{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticPropertyFetch{ - Class: &name.FullyQualified{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - }, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Ternary{ - Condition: &expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - }, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.UnaryMinus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.UnaryPlus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - }, - &stmt.Expression{ - Expr: &expr.Yield{}, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Value: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &expr.YieldFrom{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Array{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Bool{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Bool{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Double{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Double{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Int{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Int{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Object{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.String{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &cast.Unset{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BitwiseXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BooleanAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.BooleanOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Coalesce{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Concat{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Div{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Equal{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.GreaterOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Greater{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Identical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.LogicalXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Minus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Mod{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Mul{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.NotEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.NotIdentical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Plus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Pow{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.ShiftLeft{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.ShiftRight{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.SmallerOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Smaller{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &binary.Spaceship{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ - Expr: &assign.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - &stmt.Expression{ Expr: &assign.Assign{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4800, + EndPos: 4814, + }, + Variable: &expr.ShortList{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4800, + EndPos: 4809, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4801, + EndPos: 4808, + }, + Val: &expr.List{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4801, + EndPos: 4808, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4806, + EndPos: 4807, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4806, + EndPos: 4807, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4806, + EndPos: 4807, + }, + Value: "a", + }, + }, + }, + }, + }, + }, + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4813, + EndPos: 4814, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 243, + EndLine: 243, + StartPos: 4813, + EndPos: 4814, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4819, + EndPos: 4829, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4819, + EndPos: 4828, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4819, + EndPos: 4821, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4819, + EndPos: 4821, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4824, + EndPos: 4826, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 244, + EndLine: 244, + StartPos: 4827, + EndPos: 4828, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4833, + EndPos: 4853, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4833, + EndPos: 4852, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4833, + EndPos: 4845, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4843, + EndPos: 4845, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4848, + EndPos: 4850, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 245, + EndLine: 245, + StartPos: 4851, + EndPos: 4852, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4857, + EndPos: 4868, + }, + Expr: &expr.StaticCall{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4857, + EndPos: 4867, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4857, + EndPos: 4860, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4858, + EndPos: 4860, + }, + Value: "Foo", + }, + }, + }, + Call: &node.Identifier{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4863, + EndPos: 4865, + }, + Value: "bar", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 246, + EndLine: 246, + StartPos: 4866, + EndPos: 4867, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4872, + EndPos: 4881, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4872, + EndPos: 4880, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4872, + EndPos: 4874, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4872, + EndPos: 4874, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4877, + EndPos: 4880, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 247, + EndLine: 247, + StartPos: 4877, + EndPos: 4880, + }, + Value: "bar", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4885, + EndPos: 4895, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4885, + EndPos: 4894, + }, + Class: &expr.Variable{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4885, + EndPos: 4888, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4885, + EndPos: 4888, + }, + Value: "foo", + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4891, + EndPos: 4894, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 248, + EndLine: 248, + StartPos: 4891, + EndPos: 4894, + }, + Value: "bar", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4899, + EndPos: 4918, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4899, + EndPos: 4917, + }, + Class: &name.Relative{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4899, + EndPos: 4911, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4909, + EndPos: 4911, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4914, + EndPos: 4917, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 249, + EndLine: 249, + StartPos: 4914, + EndPos: 4917, + }, + Value: "bar", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4922, + EndPos: 4932, + }, + Expr: &expr.StaticPropertyFetch{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4922, + EndPos: 4931, + }, + Class: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4922, + EndPos: 4925, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4923, + EndPos: 4925, + }, + Value: "Foo", + }, + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4928, + EndPos: 4931, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 250, + EndLine: 250, + StartPos: 4928, + EndPos: 4931, + }, + Value: "bar", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4936, + EndPos: 4948, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4936, + EndPos: 4947, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4936, + EndPos: 4937, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4936, + EndPos: 4937, + }, + Value: "a", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4941, + EndPos: 4942, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4941, + EndPos: 4942, + }, + Value: "b", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4946, + EndPos: 4947, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 251, + EndLine: 251, + StartPos: 4946, + EndPos: 4947, + }, + Value: "c", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4952, + EndPos: 4961, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4952, + EndPos: 4960, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4952, + EndPos: 4953, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4952, + EndPos: 4953, + }, + Value: "a", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4959, + EndPos: 4960, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 252, + EndLine: 252, + StartPos: 4959, + EndPos: 4960, + }, + Value: "c", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4965, + EndPos: 4987, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4965, + EndPos: 4986, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4965, + EndPos: 4966, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4965, + EndPos: 4966, + }, + Value: "a", + }, + }, + IfTrue: &expr.Ternary{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4970, + EndPos: 4981, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4970, + EndPos: 4971, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4970, + EndPos: 4971, + }, + Value: "b", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4975, + EndPos: 4976, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4975, + EndPos: 4976, + }, + Value: "c", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4980, + EndPos: 4981, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4980, + EndPos: 4981, + }, + Value: "d", + }, + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4985, + EndPos: 4986, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 253, + EndLine: 253, + StartPos: 4985, + EndPos: 4986, + }, + Value: "e", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4991, + EndPos: 5013, + }, + Expr: &expr.Ternary{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4991, + EndPos: 5012, + }, + Condition: &expr.Ternary{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4991, + EndPos: 5002, + }, + Condition: &expr.Variable{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4991, + EndPos: 4992, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4991, + EndPos: 4992, + }, + Value: "a", + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4996, + EndPos: 4997, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 4996, + EndPos: 4997, + }, + Value: "b", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5001, + EndPos: 5002, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5001, + EndPos: 5002, + }, + Value: "c", + }, + }, + }, + IfTrue: &expr.Variable{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5006, + EndPos: 5007, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5006, + EndPos: 5007, + }, + Value: "d", + }, + }, + IfFalse: &expr.Variable{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5011, + EndPos: 5012, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 254, + EndLine: 254, + StartPos: 5011, + EndPos: 5012, + }, + Value: "e", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 5017, + EndPos: 5020, + }, + Expr: &expr.UnaryMinus{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 5017, + EndPos: 5019, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 5018, + EndPos: 5019, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 255, + EndLine: 255, + StartPos: 5018, + EndPos: 5019, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 256, + EndLine: 256, + StartPos: 5024, + EndPos: 5027, + }, + Expr: &expr.UnaryPlus{ + Position: &position.Position{ + StartLine: 256, + EndLine: 256, + StartPos: 5024, + EndPos: 5026, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 256, + EndLine: 256, + StartPos: 5025, + EndPos: 5026, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 256, + EndLine: 256, + StartPos: 5025, + EndPos: 5026, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5031, + EndPos: 5034, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5031, + EndPos: 5033, + }, + VarName: &expr.Variable{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5032, + EndPos: 5033, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 257, + EndLine: 257, + StartPos: 5032, + EndPos: 5033, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5038, + EndPos: 5043, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 258, + EndLine: 258, + StartPos: 5038, + EndPos: 5042, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5047, + EndPos: 5055, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5047, + EndPos: 5054, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5053, + EndPos: 5054, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 259, + EndLine: 259, + StartPos: 5053, + EndPos: 5054, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5059, + EndPos: 5073, + }, + Expr: &expr.Yield{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5059, + EndPos: 5072, + }, + Key: &expr.Variable{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5065, + EndPos: 5066, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5065, + EndPos: 5066, + }, + Value: "a", + }, + }, + Value: &expr.Variable{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5071, + EndPos: 5072, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 260, + EndLine: 260, + StartPos: 5071, + EndPos: 5072, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5077, + EndPos: 5090, + }, + Expr: &expr.YieldFrom{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5077, + EndPos: 5089, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5088, + EndPos: 5089, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 261, + EndLine: 261, + StartPos: 5088, + EndPos: 5089, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5097, + EndPos: 5106, + }, + Expr: &cast.Array{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5097, + EndPos: 5105, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5104, + EndPos: 5105, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 263, + EndLine: 263, + StartPos: 5104, + EndPos: 5105, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5110, + EndPos: 5121, + }, + Expr: &cast.Bool{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5110, + EndPos: 5120, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5119, + EndPos: 5120, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 264, + EndLine: 264, + StartPos: 5119, + EndPos: 5120, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5125, + EndPos: 5133, + }, + Expr: &cast.Bool{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5125, + EndPos: 5132, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5131, + EndPos: 5132, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 265, + EndLine: 265, + StartPos: 5131, + EndPos: 5132, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5137, + EndPos: 5147, + }, + Expr: &cast.Double{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5137, + EndPos: 5146, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5145, + EndPos: 5146, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 266, + EndLine: 266, + StartPos: 5145, + EndPos: 5146, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 267, + EndLine: 267, + StartPos: 5151, + EndPos: 5160, + }, + Expr: &cast.Double{ + Position: &position.Position{ + StartLine: 267, + EndLine: 267, + StartPos: 5151, + EndPos: 5159, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 267, + EndLine: 267, + StartPos: 5158, + EndPos: 5159, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 267, + EndLine: 267, + StartPos: 5158, + EndPos: 5159, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5164, + EndPos: 5175, + }, + Expr: &cast.Int{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5164, + EndPos: 5174, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5173, + EndPos: 5174, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 268, + EndLine: 268, + StartPos: 5173, + EndPos: 5174, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5179, + EndPos: 5186, + }, + Expr: &cast.Int{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5179, + EndPos: 5185, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5184, + EndPos: 5185, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 269, + EndLine: 269, + StartPos: 5184, + EndPos: 5185, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5190, + EndPos: 5200, + }, + Expr: &cast.Object{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5190, + EndPos: 5199, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5198, + EndPos: 5199, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 270, + EndLine: 270, + StartPos: 5198, + EndPos: 5199, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5204, + EndPos: 5214, + }, + Expr: &cast.String{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5204, + EndPos: 5213, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5212, + EndPos: 5213, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 271, + EndLine: 271, + StartPos: 5212, + EndPos: 5213, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5218, + EndPos: 5227, + }, + Expr: &cast.Unset{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5218, + EndPos: 5226, + }, + Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5225, + EndPos: 5226, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 272, + EndLine: 272, + StartPos: 5225, + EndPos: 5226, + }, + Value: "a", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5232, + EndPos: 5239, + }, + Expr: &binary.BitwiseAnd{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5232, + EndPos: 5238, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5232, + EndPos: 5233, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5232, + EndPos: 5233, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5237, + EndPos: 5238, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 274, + EndLine: 274, + StartPos: 5237, + EndPos: 5238, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5243, + EndPos: 5250, + }, + Expr: &binary.BitwiseOr{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5243, + EndPos: 5249, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5243, + EndPos: 5244, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5243, + EndPos: 5244, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5248, + EndPos: 5249, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 275, + EndLine: 275, + StartPos: 5248, + EndPos: 5249, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5254, + EndPos: 5261, + }, + Expr: &binary.BitwiseXor{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5254, + EndPos: 5260, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5254, + EndPos: 5255, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5254, + EndPos: 5255, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5259, + EndPos: 5260, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 276, + EndLine: 276, + StartPos: 5259, + EndPos: 5260, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5265, + EndPos: 5273, + }, + Expr: &binary.BooleanAnd{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5265, + EndPos: 5272, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5265, + EndPos: 5266, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5265, + EndPos: 5266, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5271, + EndPos: 5272, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 277, + EndLine: 277, + StartPos: 5271, + EndPos: 5272, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5277, + EndPos: 5285, + }, + Expr: &binary.BooleanOr{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5277, + EndPos: 5284, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5277, + EndPos: 5278, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5277, + EndPos: 5278, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5283, + EndPos: 5284, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 278, + EndLine: 278, + StartPos: 5283, + EndPos: 5284, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5289, + EndPos: 5297, + }, + Expr: &binary.Coalesce{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5289, + EndPos: 5296, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5289, + EndPos: 5290, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5289, + EndPos: 5290, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5295, + EndPos: 5296, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 279, + EndLine: 279, + StartPos: 5295, + EndPos: 5296, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5301, + EndPos: 5308, + }, + Expr: &binary.Concat{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5301, + EndPos: 5307, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5301, + EndPos: 5302, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5301, + EndPos: 5302, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5306, + EndPos: 5307, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 280, + EndLine: 280, + StartPos: 5306, + EndPos: 5307, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5312, + EndPos: 5319, + }, + Expr: &binary.Div{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5312, + EndPos: 5318, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5312, + EndPos: 5313, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5312, + EndPos: 5313, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5317, + EndPos: 5318, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 281, + EndLine: 281, + StartPos: 5317, + EndPos: 5318, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5323, + EndPos: 5331, + }, + Expr: &binary.Equal{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5323, + EndPos: 5330, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5323, + EndPos: 5324, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5323, + EndPos: 5324, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5329, + EndPos: 5330, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 282, + EndLine: 282, + StartPos: 5329, + EndPos: 5330, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5335, + EndPos: 5343, + }, + Expr: &binary.GreaterOrEqual{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5335, + EndPos: 5342, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5335, + EndPos: 5336, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5335, + EndPos: 5336, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5341, + EndPos: 5342, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 283, + EndLine: 283, + StartPos: 5341, + EndPos: 5342, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5347, + EndPos: 5354, + }, + Expr: &binary.Greater{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5347, + EndPos: 5353, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5347, + EndPos: 5348, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5347, + EndPos: 5348, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5352, + EndPos: 5353, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 284, + EndLine: 284, + StartPos: 5352, + EndPos: 5353, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5358, + EndPos: 5367, + }, + Expr: &binary.Identical{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5358, + EndPos: 5366, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5358, + EndPos: 5359, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5358, + EndPos: 5359, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5365, + EndPos: 5366, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 285, + EndLine: 285, + StartPos: 5365, + EndPos: 5366, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5371, + EndPos: 5380, + }, + Expr: &binary.LogicalAnd{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5371, + EndPos: 5379, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5371, + EndPos: 5372, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5371, + EndPos: 5372, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5378, + EndPos: 5379, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 286, + EndLine: 286, + StartPos: 5378, + EndPos: 5379, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5384, + EndPos: 5392, + }, + Expr: &binary.LogicalOr{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5384, + EndPos: 5391, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5384, + EndPos: 5385, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5384, + EndPos: 5385, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5390, + EndPos: 5391, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 287, + EndLine: 287, + StartPos: 5390, + EndPos: 5391, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5396, + EndPos: 5405, + }, + Expr: &binary.LogicalXor{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5396, + EndPos: 5404, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5396, + EndPos: 5397, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5396, + EndPos: 5397, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5403, + EndPos: 5404, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 288, + EndLine: 288, + StartPos: 5403, + EndPos: 5404, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5409, + EndPos: 5416, + }, + Expr: &binary.Minus{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5409, + EndPos: 5415, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5409, + EndPos: 5410, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5409, + EndPos: 5410, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5414, + EndPos: 5415, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 289, + EndLine: 289, + StartPos: 5414, + EndPos: 5415, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5420, + EndPos: 5427, + }, + Expr: &binary.Mod{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5420, + EndPos: 5426, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5420, + EndPos: 5421, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5420, + EndPos: 5421, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5425, + EndPos: 5426, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 290, + EndLine: 290, + StartPos: 5425, + EndPos: 5426, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5431, + EndPos: 5438, + }, + Expr: &binary.Mul{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5431, + EndPos: 5437, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5431, + EndPos: 5432, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5431, + EndPos: 5432, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5436, + EndPos: 5437, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 291, + EndLine: 291, + StartPos: 5436, + EndPos: 5437, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5442, + EndPos: 5450, + }, + Expr: &binary.NotEqual{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5442, + EndPos: 5449, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5442, + EndPos: 5443, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5442, + EndPos: 5443, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5448, + EndPos: 5449, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 292, + EndLine: 292, + StartPos: 5448, + EndPos: 5449, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5454, + EndPos: 5463, + }, + Expr: &binary.NotIdentical{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5454, + EndPos: 5462, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5454, + EndPos: 5455, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5454, + EndPos: 5455, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5461, + EndPos: 5462, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 293, + EndLine: 293, + StartPos: 5461, + EndPos: 5462, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5467, + EndPos: 5474, + }, + Expr: &binary.Plus{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5467, + EndPos: 5473, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5467, + EndPos: 5468, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5467, + EndPos: 5468, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5472, + EndPos: 5473, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 294, + EndLine: 294, + StartPos: 5472, + EndPos: 5473, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5478, + EndPos: 5486, + }, + Expr: &binary.Pow{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5478, + EndPos: 5485, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5478, + EndPos: 5479, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5478, + EndPos: 5479, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5484, + EndPos: 5485, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 295, + EndLine: 295, + StartPos: 5484, + EndPos: 5485, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5490, + EndPos: 5498, + }, + Expr: &binary.ShiftLeft{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5490, + EndPos: 5497, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5490, + EndPos: 5491, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5490, + EndPos: 5491, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5496, + EndPos: 5497, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 296, + EndLine: 296, + StartPos: 5496, + EndPos: 5497, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5502, + EndPos: 5510, + }, + Expr: &binary.ShiftRight{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5502, + EndPos: 5509, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5502, + EndPos: 5503, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5502, + EndPos: 5503, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5508, + EndPos: 5509, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 297, + EndLine: 297, + StartPos: 5508, + EndPos: 5509, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5514, + EndPos: 5522, + }, + Expr: &binary.SmallerOrEqual{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5514, + EndPos: 5521, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5514, + EndPos: 5515, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5514, + EndPos: 5515, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5520, + EndPos: 5521, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 298, + EndLine: 298, + StartPos: 5520, + EndPos: 5521, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5526, + EndPos: 5533, + }, + Expr: &binary.Smaller{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5526, + EndPos: 5532, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5526, + EndPos: 5527, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5526, + EndPos: 5527, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5531, + EndPos: 5532, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 299, + EndLine: 299, + StartPos: 5531, + EndPos: 5532, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5537, + EndPos: 5546, + }, + Expr: &binary.Spaceship{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5537, + EndPos: 5545, + }, + Left: &expr.Variable{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5537, + EndPos: 5538, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5537, + EndPos: 5538, + }, + Value: "a", + }, + }, + Right: &expr.Variable{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5544, + EndPos: 5545, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 300, + EndLine: 300, + StartPos: 5544, + EndPos: 5545, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5551, + EndPos: 5559, + }, + Expr: &assign.Reference{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5551, + EndPos: 5558, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5551, + EndPos: 5552, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5551, + EndPos: 5552, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5557, + EndPos: 5558, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 302, + EndLine: 302, + StartPos: 5557, + EndPos: 5558, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5563, + EndPos: 5570, + }, + Expr: &assign.Assign{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5563, + EndPos: 5569, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5563, + EndPos: 5564, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5563, + EndPos: 5564, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5568, + EndPos: 5569, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 303, + EndLine: 303, + StartPos: 5568, + EndPos: 5569, + }, + Value: "b", + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5574, + EndPos: 5582, + }, Expr: &assign.BitwiseAnd{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5574, + EndPos: 5581, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5574, + EndPos: 5575, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5574, + EndPos: 5575, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5580, + EndPos: 5581, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 304, + EndLine: 304, + StartPos: 5580, + EndPos: 5581, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5586, + EndPos: 5594, + }, Expr: &assign.BitwiseOr{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5586, + EndPos: 5593, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5586, + EndPos: 5587, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5586, + EndPos: 5587, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5592, + EndPos: 5593, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 305, + EndLine: 305, + StartPos: 5592, + EndPos: 5593, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5598, + EndPos: 5606, + }, Expr: &assign.BitwiseXor{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5598, + EndPos: 5605, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5598, + EndPos: 5599, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5598, + EndPos: 5599, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5604, + EndPos: 5605, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 306, + EndLine: 306, + StartPos: 5604, + EndPos: 5605, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5610, + EndPos: 5618, + }, Expr: &assign.Concat{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5610, + EndPos: 5617, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5610, + EndPos: 5611, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5610, + EndPos: 5611, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5616, + EndPos: 5617, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 307, + EndLine: 307, + StartPos: 5616, + EndPos: 5617, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5622, + EndPos: 5630, + }, Expr: &assign.Div{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5622, + EndPos: 5629, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5622, + EndPos: 5623, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5622, + EndPos: 5623, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5628, + EndPos: 5629, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 308, + EndLine: 308, + StartPos: 5628, + EndPos: 5629, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5634, + EndPos: 5642, + }, Expr: &assign.Minus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5634, + EndPos: 5641, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5634, + EndPos: 5635, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5634, + EndPos: 5635, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5641, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 309, + EndLine: 309, + StartPos: 5640, + EndPos: 5641, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5646, + EndPos: 5654, + }, Expr: &assign.Mod{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5646, + EndPos: 5653, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5646, + EndPos: 5647, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5646, + EndPos: 5647, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5652, + EndPos: 5653, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 310, + EndLine: 310, + StartPos: 5652, + EndPos: 5653, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5658, + EndPos: 5666, + }, Expr: &assign.Mul{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5658, + EndPos: 5665, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5658, + EndPos: 5659, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5658, + EndPos: 5659, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5664, + EndPos: 5665, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 311, + EndLine: 311, + StartPos: 5664, + EndPos: 5665, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5670, + EndPos: 5678, + }, Expr: &assign.Plus{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5670, + EndPos: 5677, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5670, + EndPos: 5671, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5670, + EndPos: 5671, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5676, + EndPos: 5677, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 312, + EndLine: 312, + StartPos: 5676, + EndPos: 5677, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5682, + EndPos: 5691, + }, Expr: &assign.Pow{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5682, + EndPos: 5690, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5682, + EndPos: 5683, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5682, + EndPos: 5683, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5689, + EndPos: 5690, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 313, + EndLine: 313, + StartPos: 5689, + EndPos: 5690, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5695, + EndPos: 5704, + }, Expr: &assign.ShiftLeft{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5695, + EndPos: 5703, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5695, + EndPos: 5696, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5695, + EndPos: 5696, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5702, + EndPos: 5703, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 314, + EndLine: 314, + StartPos: 5702, + EndPos: 5703, + }, + Value: "b", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5708, + EndPos: 5717, + }, Expr: &assign.ShiftRight{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5708, + EndPos: 5716, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5708, + EndPos: 5709, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5708, + EndPos: 5709, + }, + Value: "a", + }, + }, + Expression: &expr.Variable{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5715, + EndPos: 5716, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 315, + EndLine: 315, + StartPos: 5715, + EndPos: 5716, + }, + Value: "b", + }, + }, }, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5722, + EndPos: 5760, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5728, + EndPos: 5730, + }, + Value: "foo", + }, Stmts: []node.Node{ &stmt.ClassMethod{ - MethodName: &node.Identifier{Value: "class"}, - Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5733, + EndPos: 5758, + }, + ReturnsRef: false, + PhpDocComment: "", + MethodName: &node.Identifier{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5749, + EndPos: 5753, + }, + Value: "class", + }, + Modifiers: []node.Node{ + &node.Identifier{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5733, + EndPos: 5738, + }, + Value: "public", + }, + }, Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 317, + EndLine: 317, + StartPos: 5757, + EndPos: 5758, + }, Stmts: []node.Node{}, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5764, + EndPos: 5774, + }, Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5764, + EndPos: 5773, + }, Function: &name.FullyQualified{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5764, + EndPos: 5771, + }, Parts: []node.Node{ - &name.NamePart{Value: "foo"}, - &name.NamePart{Value: "bar"}, + &name.NamePart{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5765, + EndPos: 5767, + }, + Value: "foo", + }, + &name.NamePart{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5769, + EndPos: 5771, + }, + Value: "bar", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 318, + EndLine: 318, + StartPos: 5772, + EndPos: 5773, }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Function{ - FunctionName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 320, + EndLine: 326, + StartPos: 5779, + EndPos: 5905, + }, + ReturnsRef: false, + PhpDocComment: "", + FunctionName: &node.Identifier{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5788, + EndPos: 5790, + }, + Value: "foo", + }, Params: []node.Node{ &node.Parameter{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5792, + EndPos: 5794, + }, ByRef: true, Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5793, + EndPos: 5794, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5793, + EndPos: 5794, + }, + Value: "a", + }, + }, }, &node.Parameter{ - ByRef: false, + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5797, + EndPos: 5801, + }, Variadic: true, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + ByRef: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5800, + EndPos: 5801, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 320, + EndLine: 320, + StartPos: 5800, + EndPos: 5801, + }, + Value: "b", + }, + }, }, }, Stmts: []node.Node{ - &stmt.HaltCompiler{}, + &stmt.HaltCompiler{ + Position: &position.Position{ + StartLine: 321, + EndLine: 321, + StartPos: 5809, + EndPos: 5826, + }, + }, &stmt.Function{ - FunctionName: &node.Identifier{Value: "bar"}, - Stmts: []node.Node{}, + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5831, + EndPos: 5847, + }, + ReturnsRef: false, + PhpDocComment: "", + FunctionName: &node.Identifier{ + Position: &position.Position{ + StartLine: 322, + EndLine: 322, + StartPos: 5840, + EndPos: 5842, + }, + Value: "bar", + }, + Stmts: []node.Node{}, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "Baz"}, - Stmts: []node.Node{}, + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5852, + EndPos: 5863, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 323, + EndLine: 323, + StartPos: 5858, + EndPos: 5860, + }, + Value: "Baz", + }, + Stmts: []node.Node{}, }, &stmt.Trait{ - TraitName: &node.Identifier{Value: "Quux"}, - Stmts: []node.Node{}, + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5868, + EndPos: 5879, + }, + PhpDocComment: "", + TraitName: &node.Identifier{ + Position: &position.Position{ + StartLine: 324, + EndLine: 324, + StartPos: 5874, + EndPos: 5877, + }, + Value: "Quux", + }, + Stmts: []node.Node{}, }, &stmt.Interface{ - InterfaceName: &node.Identifier{Value: "Quuux"}, - Stmts: []node.Node{}, + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5884, + EndPos: 5901, + }, + PhpDocComment: "", + InterfaceName: &node.Identifier{ + Position: &position.Position{ + StartLine: 325, + EndLine: 325, + StartPos: 5894, + EndPos: 5898, + }, + Value: "Quuux", + }, + Stmts: []node.Node{}, }, }, }, &stmt.Function{ - FunctionName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5912, + EndPos: 5954, + }, + ReturnsRef: false, + PhpDocComment: "", + FunctionName: &node.Identifier{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5921, + EndPos: 5923, + }, + Value: "foo", + }, Params: []node.Node{ &node.Parameter{ - ByRef: true, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - DefaultValue: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5925, + EndPos: 5931, + }, + ByRef: true, + Variadic: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5926, + EndPos: 5927, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5926, + EndPos: 5927, + }, + Value: "a", + }, + }, + DefaultValue: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5931, + EndPos: 5931, + }, + Value: "1", + }, }, &node.Parameter{ - ByRef: false, - Variadic: true, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - DefaultValue: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5934, + EndPos: 5942, + }, + ByRef: false, + Variadic: true, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5937, + EndPos: 5938, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5937, + EndPos: 5938, + }, + Value: "b", + }, + }, + DefaultValue: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5942, + EndPos: 5942, + }, + Value: "1", + }, }, &node.Parameter{ - ByRef: false, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - DefaultValue: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5945, + EndPos: 5950, + }, + Variadic: false, + ByRef: false, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5945, + EndPos: 5946, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5945, + EndPos: 5946, + }, + Value: "c", + }, + }, + DefaultValue: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 328, + EndLine: 328, + StartPos: 5950, + EndPos: 5950, + }, + Value: "1", + }, }, }, Stmts: []node.Node{}, }, &stmt.Function{ - FunctionName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5958, + EndPos: 5995, + }, + PhpDocComment: "", + ReturnsRef: false, + FunctionName: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5967, + EndPos: 5969, + }, + Value: "foo", + }, Params: []node.Node{ &node.Parameter{ - ByRef: false, - Variadic: false, - VariableType: &node.Identifier{Value: "array"}, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5971, + EndPos: 5978, + }, + ByRef: false, + Variadic: false, + VariableType: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5971, + EndPos: 5975, + }, + Value: "array", + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5977, + EndPos: 5978, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5977, + EndPos: 5978, + }, + Value: "a", + }, + }, }, &node.Parameter{ - ByRef: false, - Variadic: false, - VariableType: &node.Identifier{Value: "callable"}, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5981, + EndPos: 5991, + }, + ByRef: false, + Variadic: false, + VariableType: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5981, + EndPos: 5988, + }, + Value: "callable", + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5990, + EndPos: 5991, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 329, + EndLine: 329, + StartPos: 5990, + EndPos: 5991, + }, + Value: "b", + }, + }, }, }, Stmts: []node.Node{}, }, &stmt.Class{ - ClassName: &node.Identifier{Value: "foo"}, + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5999, + EndPos: 6100, + }, + PhpDocComment: "", + ClassName: &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6020, + EndPos: 6022, + }, + Value: "foo", + }, Modifiers: []node.Node{ - &node.Identifier{Value: "abstract"}, - &node.Identifier{Value: "final"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 5999, + EndPos: 6006, + }, + Value: "abstract", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6008, + EndPos: 6012, + }, + Value: "final", + }, }, Stmts: []node.Node{ &stmt.ClassMethod{ - MethodName: &node.Identifier{Value: "bar"}, - Modifiers: []node.Node{ - &node.Identifier{Value: "abstract"}, - &node.Identifier{Value: "protected"}, - &node.Identifier{Value: "static"}, + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6026, + EndPos: 6066, + }, + ReturnsRef: false, + PhpDocComment: "", + MethodName: &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6061, + EndPos: 6063, + }, + Value: "bar", + }, + Modifiers: []node.Node{ + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6026, + EndPos: 6033, + }, + Value: "abstract", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6035, + EndPos: 6043, + }, + Value: "protected", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6045, + EndPos: 6050, + }, + Value: "static", + }, + }, + Stmt: &stmt.Nop{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6066, + EndPos: 6066, + }, }, - Stmt: &stmt.Nop{}, }, &stmt.ClassMethod{ - MethodName: &node.Identifier{Value: "baz"}, + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6068, + EndPos: 6098, + }, + ReturnsRef: false, + PhpDocComment: "", + MethodName: &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6091, + EndPos: 6093, + }, + Value: "baz", + }, Modifiers: []node.Node{ - &node.Identifier{Value: "final"}, - &node.Identifier{Value: "private"}, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6068, + EndPos: 6072, + }, + Value: "final", + }, + &node.Identifier{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6074, + EndPos: 6080, + }, + Value: "private", + }, }, Stmt: &stmt.StmtList{ + Position: &position.Position{ + StartLine: 330, + EndLine: 330, + StartPos: 6097, + EndPos: 6098, + }, Stmts: []node.Node{}, }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6106, + EndPos: 6119, + }, Expr: &expr.PropertyFetch{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6106, + EndPos: 6118, + }, Variable: &expr.New{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6106, + EndPos: 6112, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6110, + EndPos: 6112, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6110, + EndPos: 6112, + }, + Value: "Foo", + }, + }, + }, + }, + Property: &node.Identifier{ + Position: &position.Position{ + StartLine: 332, + EndLine: 332, + StartPos: 6116, + EndPos: 6118, + }, + Value: "bar", }, - Property: &node.Identifier{Value: "bar"}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6124, + EndPos: 6134, + }, Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6124, + EndPos: 6133, + }, Function: &expr.New{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - }, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &expr.ArrayDimFetch{ - Variable: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6124, + EndPos: 6130, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6128, + EndPos: 6130, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6128, + EndPos: 6130, + }, + Value: "Foo", }, }, }, - Dim: &scalar.Lnumber{Value: "0"}, }, - - ArgumentList: &node.ArgumentList{}, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 333, + EndLine: 333, + StartPos: 6132, + EndPos: 6133, + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6138, + EndPos: 6149, + }, Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6138, + EndPos: 6148, + }, Function: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6138, + EndPos: 6146, + }, + Variable: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6138, + EndPos: 6143, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6139, + EndPos: 6142, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6139, + EndPos: 6142, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6139, + EndPos: 6142, + }, + Value: "foo", + }, + }, + }, + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6145, + EndPos: 6145, + }, + Value: "0", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 334, + EndLine: 334, + StartPos: 6147, + EndPos: 6148, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6161, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6160, + }, + Function: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6158, + }, Variable: &expr.ConstFetch{ - Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - }, - Dim: &scalar.Lnumber{Value: "1"}, - }, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &scalar.String{Value: "\"foo\""}, - - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.FunctionCall{ - Function: &expr.ArrayDimFetch{ - Variable: &expr.ShortArray{ - Items: []node.Node{ - &expr.ArrayItem{ - Val: &scalar.Lnumber{Value: "1"}, + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6155, + }, + Constant: &name.Name{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6155, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6153, + EndPos: 6155, + }, + Value: "foo", + }, }, }, }, - Dim: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6157, + EndPos: 6157, + }, + Value: "1", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 335, + EndLine: 335, + StartPos: 6159, + EndPos: 6160, + }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6165, + EndPos: 6172, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6165, + EndPos: 6171, + }, + Function: &scalar.String{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6165, + EndPos: 6169, + }, + Value: "\"foo\"", + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 336, + EndLine: 336, + StartPos: 6170, + EndPos: 6171, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6176, + EndPos: 6187, + }, + Expr: &expr.FunctionCall{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6176, + EndPos: 6186, + }, + Function: &expr.ArrayDimFetch{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6176, + EndPos: 6184, + }, + Variable: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6176, + EndPos: 6178, + }, + Items: []node.Node{ + &expr.ArrayItem{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6177, + EndPos: 6177, + }, + Val: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6177, + EndPos: 6177, + }, + Value: "1", + }, + }, + }, + }, + Dim: &expr.Variable{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6180, + EndPos: 6183, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6180, + EndPos: 6183, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 337, + EndLine: 337, + StartPos: 6185, + EndPos: 6186, + }, + }, + }, + }, + &stmt.Expression{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6191, + EndPos: 6199, + }, Expr: &expr.Variable{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6191, + EndPos: 6198, + }, VarName: &expr.FunctionCall{ - Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, - - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6193, + EndPos: 6197, + }, + Function: &name.Name{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6193, + EndPos: 6195, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6193, + EndPos: 6195, + }, + Value: "foo", + }, + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 338, + EndLine: 338, + StartPos: 6196, + EndPos: 6197, + }, + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6204, + EndPos: 6215, + }, Expr: &expr.StaticCall{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - - ArgumentList: &node.ArgumentList{}, + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6204, + EndPos: 6214, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6204, + EndPos: 6206, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6204, + EndPos: 6206, + }, + Value: "Foo", + }, + }, + }, + Call: &expr.Variable{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6209, + EndPos: 6212, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6209, + EndPos: 6212, + }, + Value: "bar", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 340, + EndLine: 340, + StartPos: 6213, + EndPos: 6214, + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6219, + EndPos: 6235, + }, Expr: &expr.StaticCall{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6219, + EndPos: 6234, + }, + Class: &name.Name{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6219, + EndPos: 6221, + }, + Parts: []node.Node{ + &name.NamePart{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6219, + EndPos: 6221, + }, + Value: "Foo", + }, + }, + }, Call: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - Dim: &scalar.Lnumber{Value: "0"}, + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6225, + EndPos: 6231, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6225, + EndPos: 6228, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6225, + EndPos: 6228, + }, + Value: "bar", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6230, + EndPos: 6230, + }, + Value: "0", + }, + }, + ArgumentList: &node.ArgumentList{ + Position: &position.Position{ + StartLine: 341, + EndLine: 341, + StartPos: 6233, + EndPos: 6234, + }, }, - - ArgumentList: &node.ArgumentList{}, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6242, + EndPos: 6252, + }, Expr: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6242, + EndPos: 6251, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6242, + EndPos: 6245, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6242, + EndPos: 6245, + }, + Value: "foo", + }, + }, + Property: &expr.Variable{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6248, + EndPos: 6251, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 343, + EndLine: 343, + StartPos: 6248, + EndPos: 6251, + }, + Value: "bar", + }, + }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6256, + EndPos: 6271, + }, Expr: &expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6256, + EndPos: 6269, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6256, + EndPos: 6259, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6256, + EndPos: 6259, + }, + Value: "foo", + }, + }, Property: &expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - Dim: &scalar.Lnumber{Value: "0"}, + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6263, + EndPos: 6269, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6263, + EndPos: 6266, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6263, + EndPos: 6266, + }, + Value: "bar", + }, + }, + Dim: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 344, + EndLine: 344, + StartPos: 6268, + EndPos: 6268, + }, + Value: "0", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6276, + EndPos: 6297, + }, Expr: &expr.ShortArray{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6276, + EndPos: 6296, + }, Items: []node.Node{ &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "1"}, - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6277, + EndPos: 6282, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6277, + EndPos: 6277, + }, + Value: "1", + }, + Val: &expr.Reference{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6280, + EndPos: 6282, + }, + Variable: &expr.Variable{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6281, + EndPos: 6282, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6281, + EndPos: 6282, + }, + Value: "a", + }, + }, + }, }, &expr.ArrayItem{ - Key: &scalar.Lnumber{Value: "2"}, + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6285, + EndPos: 6295, + }, + Key: &scalar.Lnumber{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6285, + EndPos: 6285, + }, + Value: "2", + }, Val: &expr.List{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6288, + EndPos: 6295, + }, Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6293, + EndPos: 6294, + }, + Val: &expr.Variable{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6293, + EndPos: 6294, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 346, + EndLine: 346, + StartPos: 6293, + EndPos: 6294, + }, + Value: "b", + }, + }, }, }, }, @@ -3222,14 +16114,21 @@ func TestPhp7(t *testing.T) { }, }, }, - &stmt.HaltCompiler{}, + &stmt.HaltCompiler{ + Position: &position.Position{ + StartLine: 348, + EndLine: 348, + StartPos: 6302, + EndPos: 6319, + }, + }, }, } php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp5Strings(t *testing.T) { @@ -3246,21 +16145,97 @@ func TestPhp5Strings(t *testing.T) { ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 10, + StartPos: 6, + EndPos: 70, + }, Stmts: []node.Node{ &stmt.Expression{ - Expr: &scalar.String{Value: "\"test\""}, + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 6, + EndPos: 12, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 6, + EndPos: 11, + }, + Value: "\"test\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "\"\\$test\""}, + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 16, + EndPos: 24, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 16, + EndPos: 23, + }, + Value: "\"\\$test\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "\"\n\t\t\ttest\n\t\t\""}, + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 28, + EndPos: 41, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 28, + EndPos: 40, + }, + Value: "\"\n\t\t\ttest\n\t\t\"", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "'$test'"}, + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 45, + EndPos: 52, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 45, + EndPos: 51, + }, + Value: "'$test'", + }, }, &stmt.Expression{ - Expr: &scalar.String{Value: "'\n\t\t\t$test\n\t\t'"}, + Position: &position.Position{ + StartLine: 8, + EndLine: 10, + StartPos: 56, + EndPos: 70, + }, + Expr: &scalar.String{ + Position: &position.Position{ + StartLine: 8, + EndLine: 10, + StartPos: 56, + EndPos: 69, + }, + Value: "'\n\t\t\t$test\n\t\t'", + }, }, }, } @@ -3268,7 +16243,7 @@ func TestPhp5Strings(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp5Heredoc(t *testing.T) { @@ -3290,43 +16265,156 @@ CAD; ` expected := &node.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 15, + StartPos: 9, + EndPos: 120, + }, Stmts: []node.Node{ &stmt.Expression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 3, + StartPos: 9, + EndPos: 16, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 2, + EndLine: 3, + StartPos: 9, + EndPos: 15, + }, Label: "CAD", }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 23, + EndPos: 37, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 4, + EndLine: 6, + StartPos: 23, + EndPos: 36, + }, Label: "CAD", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 27, + EndPos: 32, + }, + Value: "\thello", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 7, + EndLine: 9, + StartPos: 44, + EndPos: 60, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 7, + EndLine: 9, + StartPos: 44, + EndPos: 59, + }, Label: "\"CAD\"", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 8, + EndLine: 8, + StartPos: 50, + EndPos: 55, + }, + Value: "\thello", + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 10, + EndLine: 12, + StartPos: 67, + EndPos: 90, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 10, + EndLine: 12, + StartPos: 67, + EndPos: 89, + }, Label: "\"CAD\"", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello "}, - &expr.Variable{VarName: &node.Identifier{Value: "world"}}, - &scalar.EncapsedStringPart{Value: "\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 73, + EndPos: 79, + }, + Value: "\thello ", + }, + &expr.Variable{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 80, + EndPos: 85, + }, + VarName: &node.Identifier{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 80, + EndPos: 85, + }, + Value: "world", + }, + }, }, }, }, &stmt.Expression{ + Position: &position.Position{ + StartLine: 13, + EndLine: 15, + StartPos: 97, + EndPos: 120, + }, Expr: &scalar.Heredoc{ + Position: &position.Position{ + StartLine: 13, + EndLine: 15, + StartPos: 97, + EndPos: 119, + }, Label: "'CAD'", Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "\thello $world\n"}, + &scalar.EncapsedStringPart{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 103, + EndPos: 115, + }, + Value: "\thello $world", + }, }, }, }, @@ -3336,7 +16424,7 @@ CAD; php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetRootNode() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestPhp7ControlCharsErrors(t *testing.T) { @@ -3356,5 +16444,5 @@ func TestPhp7ControlCharsErrors(t *testing.T) { php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser.Parse() actual := php7parser.GetErrors() - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } diff --git a/printer/pretty_printer.go b/printer/pretty_printer.go new file mode 100644 index 0000000..b8f0d29 --- /dev/null +++ b/printer/pretty_printer.go @@ -0,0 +1,2199 @@ +package printer + +import ( + "io" + "strings" + + "github.com/z7zmey/php-parser/node/stmt" + + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/node/expr/assign" + "github.com/z7zmey/php-parser/node/expr/binary" + "github.com/z7zmey/php-parser/node/expr/cast" + "github.com/z7zmey/php-parser/node/name" + "github.com/z7zmey/php-parser/node/scalar" +) + +type PrettyPrinter struct { + w io.Writer + indentStr string + indentDepth int +} + +// NewPrettyPrinter - Constructor for PrettyPrinter +func NewPrettyPrinter(w io.Writer, indentStr string) *PrettyPrinter { + return &PrettyPrinter{ + w: w, + indentStr: indentStr, + indentDepth: 0, + } +} + +func (p *PrettyPrinter) Print(n node.Node) { + p.printNode(n) +} + +func (p *PrettyPrinter) joinPrint(glue string, nn []node.Node) { + for k, n := range nn { + if k > 0 { + io.WriteString(p.w, glue) + } + + p.Print(n) + } +} + +func (p *PrettyPrinter) printNodes(nn []node.Node) { + p.indentDepth++ + l := len(nn) - 1 + for k, n := range nn { + p.printIndent() + p.Print(n) + if k < l { + io.WriteString(p.w, "\n") + } + } + p.indentDepth-- +} + +func (p *PrettyPrinter) printIndent() { + for i := 0; i < p.indentDepth; i++ { + io.WriteString(p.w, p.indentStr) + } +} + +func (p *PrettyPrinter) printNode(n node.Node) { + switch n.(type) { + + // node + + case *node.Root: + p.printNodeRoot(n) + case *node.Identifier: + p.printNodeIdentifier(n) + case *node.Parameter: + p.printNodeParameter(n) + case *node.Nullable: + p.printNodeNullable(n) + case *node.Argument: + p.printNodeArgument(n) + + // name + + case *name.NamePart: + p.printNameNamePart(n) + case *name.Name: + p.printNameName(n) + case *name.FullyQualified: + p.printNameFullyQualified(n) + case *name.Relative: + p.printNameRelative(n) + + // scalar + + case *scalar.Lnumber: + p.printScalarLNumber(n) + case *scalar.Dnumber: + p.printScalarDNumber(n) + case *scalar.String: + p.printScalarString(n) + case *scalar.EncapsedStringPart: + p.printScalarEncapsedStringPart(n) + case *scalar.Encapsed: + p.printScalarEncapsed(n) + case *scalar.Heredoc: + p.printScalarHeredoc(n) + case *scalar.MagicConstant: + p.printScalarMagicConstant(n) + + // assign + + case *assign.Assign: + p.printAssign(n) + case *assign.Reference: + p.printReference(n) + case *assign.BitwiseAnd: + p.printAssignBitwiseAnd(n) + case *assign.BitwiseOr: + p.printAssignBitwiseOr(n) + case *assign.BitwiseXor: + p.printAssignBitwiseXor(n) + case *assign.Concat: + p.printAssignConcat(n) + case *assign.Div: + p.printAssignDiv(n) + case *assign.Minus: + p.printAssignMinus(n) + case *assign.Mod: + p.printAssignMod(n) + case *assign.Mul: + p.printAssignMul(n) + case *assign.Plus: + p.printAssignPlus(n) + case *assign.Pow: + p.printAssignPow(n) + case *assign.ShiftLeft: + p.printAssignShiftLeft(n) + case *assign.ShiftRight: + p.printAssignShiftRight(n) + + // binary + + case *binary.BitwiseAnd: + p.printBinaryBitwiseAnd(n) + case *binary.BitwiseOr: + p.printBinaryBitwiseOr(n) + case *binary.BitwiseXor: + p.printBinaryBitwiseXor(n) + case *binary.BooleanAnd: + p.printBinaryBooleanAnd(n) + case *binary.BooleanOr: + p.printBinaryBooleanOr(n) + case *binary.Coalesce: + p.printBinaryCoalesce(n) + case *binary.Concat: + p.printBinaryConcat(n) + case *binary.Div: + p.printBinaryDiv(n) + case *binary.Equal: + p.printBinaryEqual(n) + case *binary.GreaterOrEqual: + p.printBinaryGreaterOrEqual(n) + case *binary.Greater: + p.printBinaryGreater(n) + case *binary.Identical: + p.printBinaryIdentical(n) + case *binary.LogicalAnd: + p.printBinaryLogicalAnd(n) + case *binary.LogicalOr: + p.printBinaryLogicalOr(n) + case *binary.LogicalXor: + p.printBinaryLogicalXor(n) + case *binary.Minus: + p.printBinaryMinus(n) + case *binary.Mod: + p.printBinaryMod(n) + case *binary.Mul: + p.printBinaryMul(n) + case *binary.NotEqual: + p.printBinaryNotEqual(n) + case *binary.NotIdentical: + p.printBinaryNotIdentical(n) + case *binary.Plus: + p.printBinaryPlus(n) + case *binary.Pow: + p.printBinaryPow(n) + case *binary.ShiftLeft: + p.printBinaryShiftLeft(n) + case *binary.ShiftRight: + p.printBinaryShiftRight(n) + case *binary.SmallerOrEqual: + p.printBinarySmallerOrEqual(n) + case *binary.Smaller: + p.printBinarySmaller(n) + case *binary.Spaceship: + p.printBinarySpaceship(n) + + // cast + + case *cast.Array: + p.printArray(n) + case *cast.Bool: + p.printBool(n) + case *cast.Double: + p.printDouble(n) + case *cast.Int: + p.printInt(n) + case *cast.Object: + p.printObject(n) + case *cast.String: + p.printString(n) + case *cast.Unset: + p.printUnset(n) + + // expr + + case *expr.ArrayDimFetch: + p.printExprArrayDimFetch(n) + case *expr.ArrayItem: + p.printExprArrayItem(n) + case *expr.Array: + p.printExprArray(n) + case *expr.BitwiseNot: + p.printExprBitwiseNot(n) + case *expr.BooleanNot: + p.printExprBooleanNot(n) + case *expr.ClassConstFetch: + p.printExprClassConstFetch(n) + case *expr.Clone: + p.printExprClone(n) + case *expr.ClosureUse: + p.printExprClosureUse(n) + case *expr.Closure: + p.printExprClosure(n) + case *expr.ConstFetch: + p.printExprConstFetch(n) + case *expr.Empty: + p.printExprEmpty(n) + case *expr.ErrorSuppress: + p.printExprErrorSuppress(n) + case *expr.Eval: + p.printExprEval(n) + case *expr.Exit: + p.printExprExit(n) + case *expr.FunctionCall: + p.printExprFunctionCall(n) + case *expr.Include: + p.printExprInclude(n) + case *expr.IncludeOnce: + p.printExprIncludeOnce(n) + case *expr.InstanceOf: + p.printExprInstanceOf(n) + case *expr.Isset: + p.printExprIsset(n) + case *expr.List: + p.printExprList(n) + case *expr.MethodCall: + p.printExprMethodCall(n) + case *expr.New: + p.printExprNew(n) + case *expr.PostDec: + p.printExprPostDec(n) + case *expr.PostInc: + p.printExprPostInc(n) + case *expr.PreDec: + p.printExprPreDec(n) + case *expr.PreInc: + p.printExprPreInc(n) + case *expr.Print: + p.printExprPrint(n) + case *expr.PropertyFetch: + p.printExprPropertyFetch(n) + case *expr.Reference: + p.printExprReference(n) + case *expr.Require: + p.printExprRequire(n) + case *expr.RequireOnce: + p.printExprRequireOnce(n) + case *expr.ShellExec: + p.printExprShellExec(n) + case *expr.ShortArray: + p.printExprShortArray(n) + case *expr.ShortList: + p.printExprShortList(n) + case *expr.StaticCall: + p.printExprStaticCall(n) + case *expr.StaticPropertyFetch: + p.printExprStaticPropertyFetch(n) + case *expr.Ternary: + p.printExprTernary(n) + case *expr.UnaryMinus: + p.printExprUnaryMinus(n) + case *expr.UnaryPlus: + p.printExprUnaryPlus(n) + case *expr.Variable: + p.printExprVariable(n) + case *expr.YieldFrom: + p.printExprYieldFrom(n) + case *expr.Yield: + p.printExprYield(n) + + // stmt + + case *stmt.AltElseIf: + p.printStmtAltElseIf(n) + case *stmt.AltElse: + p.printStmtAltElse(n) + case *stmt.AltFor: + p.printStmtAltFor(n) + case *stmt.AltForeach: + p.printStmtAltForeach(n) + case *stmt.AltIf: + p.printStmtAltIf(n) + case *stmt.AltSwitch: + p.printStmtAltSwitch(n) + case *stmt.AltWhile: + p.printStmtAltWhile(n) + case *stmt.Break: + p.printStmtBreak(n) + case *stmt.Case: + p.printStmtCase(n) + case *stmt.Catch: + p.printStmtCatch(n) + case *stmt.ClassMethod: + p.printStmtClassMethod(n) + case *stmt.Class: + p.printStmtClass(n) + case *stmt.ClassConstList: + p.printStmtClassConstList(n) + case *stmt.Constant: + p.printStmtConstant(n) + case *stmt.Continue: + p.printStmtContinue(n) + case *stmt.Declare: + p.printStmtDeclare(n) + case *stmt.Default: + p.printStmtDefault(n) + case *stmt.Do: + p.printStmtDo(n) + case *stmt.Echo: + p.printStmtEcho(n) + case *stmt.ElseIf: + p.printStmtElseif(n) + case *stmt.Else: + p.printStmtElse(n) + case *stmt.Expression: + p.printStmtExpression(n) + case *stmt.Finally: + p.printStmtFinally(n) + case *stmt.For: + p.printStmtFor(n) + case *stmt.Foreach: + p.printStmtForeach(n) + case *stmt.Function: + p.printStmtFunction(n) + case *stmt.Global: + p.printStmtGlobal(n) + case *stmt.Goto: + p.printStmtGoto(n) + case *stmt.GroupUse: + p.printStmtGroupUse(n) + case *stmt.HaltCompiler: + p.printStmtHaltCompiler(n) + case *stmt.If: + p.printStmtIf(n) + case *stmt.InlineHtml: + p.printStmtInlineHTML(n) + case *stmt.Interface: + p.printStmtInterface(n) + case *stmt.Label: + p.printStmtLabel(n) + case *stmt.Namespace: + p.printStmtNamespace(n) + case *stmt.Nop: + p.printStmtNop(n) + case *stmt.PropertyList: + p.printStmtPropertyList(n) + case *stmt.Property: + p.printStmtProperty(n) + case *stmt.Return: + p.printStmtReturn(n) + case *stmt.StaticVar: + p.printStmtStaticVar(n) + case *stmt.Static: + p.printStmtStatic(n) + case *stmt.StmtList: + p.printStmtStmtList(n) + case *stmt.Switch: + p.printStmtSwitch(n) + case *stmt.Throw: + p.printStmtThrow(n) + case *stmt.TraitMethodRef: + p.printStmtTraitMethodRef(n) + case *stmt.TraitUseAlias: + p.printStmtTraitUseAlias(n) + case *stmt.TraitUsePrecedence: + p.printStmtTraitUsePrecedence(n) + case *stmt.TraitUse: + p.printStmtTraitUse(n) + case *stmt.Trait: + p.printStmtTrait(n) + case *stmt.Try: + p.printStmtTry(n) + case *stmt.Unset: + p.printStmtUnset(n) + case *stmt.UseList: + p.printStmtUseList(n) + case *stmt.Use: + p.printStmtUse(n) + case *stmt.While: + p.printStmtWhile(n) + } +} + +// node + +func (p *PrettyPrinter) printNodeRoot(n node.Node) { + v := n.(*node.Root) + + if len(v.Stmts) > 0 { + firstStmt := v.Stmts[0] + v.Stmts = v.Stmts[1:] + + switch fs := firstStmt.(type) { + case *stmt.InlineHtml: + io.WriteString(p.w, fs.Value) + io.WriteString(p.w, " 0 { + io.WriteString(p.w, "\\") + } + + p.Print(part) + } +} + +func (p *PrettyPrinter) printNameFullyQualified(n node.Node) { + nn := n.(*name.FullyQualified) + + for _, part := range nn.Parts { + io.WriteString(p.w, "\\") + p.Print(part) + } +} + +func (p *PrettyPrinter) printNameRelative(n node.Node) { + nn := n.(*name.Relative) + + io.WriteString(p.w, "namespace") + for _, part := range nn.Parts { + io.WriteString(p.w, "\\") + p.Print(part) + } +} + +// scalar + +func (p *PrettyPrinter) printScalarLNumber(n node.Node) { + v := n.(*scalar.Lnumber).Value + io.WriteString(p.w, v) +} + +func (p *PrettyPrinter) printScalarDNumber(n node.Node) { + v := n.(*scalar.Dnumber).Value + io.WriteString(p.w, v) +} + +func (p *PrettyPrinter) printScalarString(n node.Node) { + v := n.(*scalar.String).Value + + io.WriteString(p.w, v) +} + +func (p *PrettyPrinter) printScalarEncapsedStringPart(n node.Node) { + v := n.(*scalar.EncapsedStringPart).Value + io.WriteString(p.w, v) +} + +func (p *PrettyPrinter) printScalarEncapsed(n node.Node) { + nn := n.(*scalar.Encapsed) + io.WriteString(p.w, "\"") + + for _, part := range nn.Parts { + switch part.(type) { + case *scalar.EncapsedStringPart: + p.Print(part) + default: + io.WriteString(p.w, "{") + p.Print(part) + io.WriteString(p.w, "}") + } + } + + io.WriteString(p.w, "\"") +} + +func (p *PrettyPrinter) printScalarHeredoc(n node.Node) { + nn := n.(*scalar.Heredoc) + + io.WriteString(p.w, "<<<") + io.WriteString(p.w, nn.Label) + io.WriteString(p.w, "\n") + + for _, part := range nn.Parts { + switch part.(type) { + case *scalar.EncapsedStringPart: + p.Print(part) + default: + io.WriteString(p.w, "{") + p.Print(part) + io.WriteString(p.w, "}") + } + } + + io.WriteString(p.w, strings.Trim(nn.Label, "\"'")) +} + +func (p *PrettyPrinter) printScalarMagicConstant(n node.Node) { + v := n.(*scalar.MagicConstant).Value + io.WriteString(p.w, v) +} + +// Assign + +func (p *PrettyPrinter) printAssign(n node.Node) { + nn := n.(*assign.Assign) + p.Print(nn.Variable) + io.WriteString(p.w, " = ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printReference(n node.Node) { + nn := n.(*assign.Reference) + p.Print(nn.Variable) + io.WriteString(p.w, " =& ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignBitwiseAnd(n node.Node) { + nn := n.(*assign.BitwiseAnd) + p.Print(nn.Variable) + io.WriteString(p.w, " &= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignBitwiseOr(n node.Node) { + nn := n.(*assign.BitwiseOr) + p.Print(nn.Variable) + io.WriteString(p.w, " |= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignBitwiseXor(n node.Node) { + nn := n.(*assign.BitwiseXor) + p.Print(nn.Variable) + io.WriteString(p.w, " ^= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignConcat(n node.Node) { + nn := n.(*assign.Concat) + p.Print(nn.Variable) + io.WriteString(p.w, " .= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignDiv(n node.Node) { + nn := n.(*assign.Div) + p.Print(nn.Variable) + io.WriteString(p.w, " /= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignMinus(n node.Node) { + nn := n.(*assign.Minus) + p.Print(nn.Variable) + io.WriteString(p.w, " -= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignMod(n node.Node) { + nn := n.(*assign.Mod) + p.Print(nn.Variable) + io.WriteString(p.w, " %= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignMul(n node.Node) { + nn := n.(*assign.Mul) + p.Print(nn.Variable) + io.WriteString(p.w, " *= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignPlus(n node.Node) { + nn := n.(*assign.Plus) + p.Print(nn.Variable) + io.WriteString(p.w, " += ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignPow(n node.Node) { + nn := n.(*assign.Pow) + p.Print(nn.Variable) + io.WriteString(p.w, " **= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignShiftLeft(n node.Node) { + nn := n.(*assign.ShiftLeft) + p.Print(nn.Variable) + io.WriteString(p.w, " <<= ") + p.Print(nn.Expression) +} + +func (p *PrettyPrinter) printAssignShiftRight(n node.Node) { + nn := n.(*assign.ShiftRight) + p.Print(nn.Variable) + io.WriteString(p.w, " >>= ") + p.Print(nn.Expression) +} + +// binary + +func (p *PrettyPrinter) printBinaryBitwiseAnd(n node.Node) { + nn := n.(*binary.BitwiseAnd) + + p.Print(nn.Left) + io.WriteString(p.w, " & ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryBitwiseOr(n node.Node) { + nn := n.(*binary.BitwiseOr) + + p.Print(nn.Left) + io.WriteString(p.w, " | ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryBitwiseXor(n node.Node) { + nn := n.(*binary.BitwiseXor) + + p.Print(nn.Left) + io.WriteString(p.w, " ^ ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryBooleanAnd(n node.Node) { + nn := n.(*binary.BooleanAnd) + + p.Print(nn.Left) + io.WriteString(p.w, " && ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryBooleanOr(n node.Node) { + nn := n.(*binary.BooleanOr) + + p.Print(nn.Left) + io.WriteString(p.w, " || ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryCoalesce(n node.Node) { + nn := n.(*binary.Coalesce) + + p.Print(nn.Left) + io.WriteString(p.w, " ?? ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryConcat(n node.Node) { + nn := n.(*binary.Concat) + + p.Print(nn.Left) + io.WriteString(p.w, " . ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryDiv(n node.Node) { + nn := n.(*binary.Div) + + p.Print(nn.Left) + io.WriteString(p.w, " / ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryEqual(n node.Node) { + nn := n.(*binary.Equal) + + p.Print(nn.Left) + io.WriteString(p.w, " == ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryGreaterOrEqual(n node.Node) { + nn := n.(*binary.GreaterOrEqual) + + p.Print(nn.Left) + io.WriteString(p.w, " >= ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryGreater(n node.Node) { + nn := n.(*binary.Greater) + + p.Print(nn.Left) + io.WriteString(p.w, " > ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryIdentical(n node.Node) { + nn := n.(*binary.Identical) + + p.Print(nn.Left) + io.WriteString(p.w, " === ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryLogicalAnd(n node.Node) { + nn := n.(*binary.LogicalAnd) + + p.Print(nn.Left) + io.WriteString(p.w, " and ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryLogicalOr(n node.Node) { + nn := n.(*binary.LogicalOr) + + p.Print(nn.Left) + io.WriteString(p.w, " or ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryLogicalXor(n node.Node) { + nn := n.(*binary.LogicalXor) + + p.Print(nn.Left) + io.WriteString(p.w, " xor ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryMinus(n node.Node) { + nn := n.(*binary.Minus) + + p.Print(nn.Left) + io.WriteString(p.w, " - ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryMod(n node.Node) { + nn := n.(*binary.Mod) + + p.Print(nn.Left) + io.WriteString(p.w, " % ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryMul(n node.Node) { + nn := n.(*binary.Mul) + + p.Print(nn.Left) + io.WriteString(p.w, " * ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryNotEqual(n node.Node) { + nn := n.(*binary.NotEqual) + + p.Print(nn.Left) + io.WriteString(p.w, " != ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryNotIdentical(n node.Node) { + nn := n.(*binary.NotIdentical) + + p.Print(nn.Left) + io.WriteString(p.w, " !== ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryPlus(n node.Node) { + nn := n.(*binary.Plus) + + p.Print(nn.Left) + io.WriteString(p.w, " + ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryPow(n node.Node) { + nn := n.(*binary.Pow) + + p.Print(nn.Left) + io.WriteString(p.w, " ** ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryShiftLeft(n node.Node) { + nn := n.(*binary.ShiftLeft) + + p.Print(nn.Left) + io.WriteString(p.w, " << ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinaryShiftRight(n node.Node) { + nn := n.(*binary.ShiftRight) + + p.Print(nn.Left) + io.WriteString(p.w, " >> ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinarySmallerOrEqual(n node.Node) { + nn := n.(*binary.SmallerOrEqual) + + p.Print(nn.Left) + io.WriteString(p.w, " <= ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinarySmaller(n node.Node) { + nn := n.(*binary.Smaller) + + p.Print(nn.Left) + io.WriteString(p.w, " < ") + p.Print(nn.Right) +} + +func (p *PrettyPrinter) printBinarySpaceship(n node.Node) { + nn := n.(*binary.Spaceship) + + p.Print(nn.Left) + io.WriteString(p.w, " <=> ") + p.Print(nn.Right) +} + +// cast + +func (p *PrettyPrinter) printArray(n node.Node) { + nn := n.(*cast.Array) + + io.WriteString(p.w, "(array)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printBool(n node.Node) { + nn := n.(*cast.Bool) + + io.WriteString(p.w, "(bool)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printDouble(n node.Node) { + nn := n.(*cast.Double) + + io.WriteString(p.w, "(float)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printInt(n node.Node) { + nn := n.(*cast.Int) + + io.WriteString(p.w, "(int)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printObject(n node.Node) { + nn := n.(*cast.Object) + + io.WriteString(p.w, "(object)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printString(n node.Node) { + nn := n.(*cast.String) + + io.WriteString(p.w, "(string)") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printUnset(n node.Node) { + nn := n.(*cast.Unset) + + io.WriteString(p.w, "(unset)") + p.Print(nn.Expr) +} + +// expr + +func (p *PrettyPrinter) printExprArrayDimFetch(n node.Node) { + nn := n.(*expr.ArrayDimFetch) + p.Print(nn.Variable) + io.WriteString(p.w, "[") + p.Print(nn.Dim) + io.WriteString(p.w, "]") +} + +func (p *PrettyPrinter) printExprArrayItem(n node.Node) { + nn := n.(*expr.ArrayItem) + + if nn.Key != nil { + p.Print(nn.Key) + io.WriteString(p.w, " => ") + } + + p.Print(nn.Val) +} + +func (p *PrettyPrinter) printExprArray(n node.Node) { + nn := n.(*expr.Array) + + io.WriteString(p.w, "array(") + p.joinPrint(", ", nn.Items) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprBitwiseNot(n node.Node) { + nn := n.(*expr.BitwiseNot) + io.WriteString(p.w, "~") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprBooleanNot(n node.Node) { + nn := n.(*expr.BooleanNot) + io.WriteString(p.w, "!") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprClassConstFetch(n node.Node) { + nn := n.(*expr.ClassConstFetch) + + p.Print(nn.Class) + io.WriteString(p.w, "::") + io.WriteString(p.w, nn.ConstantName.(*node.Identifier).Value) +} + +func (p *PrettyPrinter) printExprClone(n node.Node) { + nn := n.(*expr.Clone) + + io.WriteString(p.w, "clone ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprClosureUse(n node.Node) { + nn := n.(*expr.ClosureUse) + + io.WriteString(p.w, "use (") + p.joinPrint(", ", nn.Uses) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprClosure(n node.Node) { + nn := n.(*expr.Closure) + + if nn.Static { + io.WriteString(p.w, "static ") + } + + io.WriteString(p.w, "function ") + + if nn.ReturnsRef { + io.WriteString(p.w, "&") + } + + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.Params) + io.WriteString(p.w, ")") + + if nn.ClosureUse != nil { + io.WriteString(p.w, " ") + p.Print(nn.ClosureUse) + } + + if nn.ReturnType != nil { + io.WriteString(p.w, ": ") + p.Print(nn.ReturnType) + } + + io.WriteString(p.w, " {\n") + p.printNodes(nn.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") +} + +func (p *PrettyPrinter) printExprConstFetch(n node.Node) { + nn := n.(*expr.ConstFetch) + + p.Print(nn.Constant) +} + +func (p *PrettyPrinter) printExprEmpty(n node.Node) { + nn := n.(*expr.Empty) + + io.WriteString(p.w, "empty(") + p.Print(nn.Expr) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprErrorSuppress(n node.Node) { + nn := n.(*expr.ErrorSuppress) + + io.WriteString(p.w, "@") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprEval(n node.Node) { + nn := n.(*expr.Eval) + + io.WriteString(p.w, "eval(") + p.Print(nn.Expr) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprExit(n node.Node) { + nn := n.(*expr.Exit) + + if nn.Die { + io.WriteString(p.w, "die(") + } else { + io.WriteString(p.w, "exit(") + } + p.Print(nn.Expr) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprFunctionCall(n node.Node) { + nn := n.(*expr.FunctionCall) + + p.Print(nn.Function) + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.ArgumentList.Arguments) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprInclude(n node.Node) { + nn := n.(*expr.Include) + + io.WriteString(p.w, "include ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprIncludeOnce(n node.Node) { + nn := n.(*expr.IncludeOnce) + + io.WriteString(p.w, "include_once ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprInstanceOf(n node.Node) { + nn := n.(*expr.InstanceOf) + + p.Print(nn.Expr) + io.WriteString(p.w, " instanceof ") + p.Print(nn.Class) +} + +func (p *PrettyPrinter) printExprIsset(n node.Node) { + nn := n.(*expr.Isset) + + io.WriteString(p.w, "isset(") + p.joinPrint(", ", nn.Variables) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprList(n node.Node) { + nn := n.(*expr.List) + + io.WriteString(p.w, "list(") + p.joinPrint(", ", nn.Items) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprMethodCall(n node.Node) { + nn := n.(*expr.MethodCall) + + p.Print(nn.Variable) + io.WriteString(p.w, "->") + p.Print(nn.Method) + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.ArgumentList.Arguments) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprNew(n node.Node) { + nn := n.(*expr.New) + + io.WriteString(p.w, "new ") + p.Print(nn.Class) + + if nn.ArgumentList != nil { + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.ArgumentList.Arguments) + io.WriteString(p.w, ")") + } +} + +func (p *PrettyPrinter) printExprPostDec(n node.Node) { + nn := n.(*expr.PostDec) + + p.Print(nn.Variable) + io.WriteString(p.w, "--") +} + +func (p *PrettyPrinter) printExprPostInc(n node.Node) { + nn := n.(*expr.PostInc) + + p.Print(nn.Variable) + io.WriteString(p.w, "++") +} + +func (p *PrettyPrinter) printExprPreDec(n node.Node) { + nn := n.(*expr.PreDec) + + io.WriteString(p.w, "--") + p.Print(nn.Variable) +} + +func (p *PrettyPrinter) printExprPreInc(n node.Node) { + nn := n.(*expr.PreInc) + + io.WriteString(p.w, "++") + p.Print(nn.Variable) +} + +func (p *PrettyPrinter) printExprPrint(n node.Node) { + nn := n.(*expr.Print) + + io.WriteString(p.w, "print(") + p.Print(nn.Expr) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprPropertyFetch(n node.Node) { + nn := n.(*expr.PropertyFetch) + + p.Print(nn.Variable) + io.WriteString(p.w, "->") + p.Print(nn.Property) +} + +func (p *PrettyPrinter) printExprReference(n node.Node) { + nn := n.(*expr.Reference) + + io.WriteString(p.w, "&") + p.Print(nn.Variable) +} + +func (p *PrettyPrinter) printExprRequire(n node.Node) { + nn := n.(*expr.Require) + + io.WriteString(p.w, "require ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprRequireOnce(n node.Node) { + nn := n.(*expr.RequireOnce) + + io.WriteString(p.w, "require_once ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprShellExec(n node.Node) { + nn := n.(*expr.ShellExec) + + io.WriteString(p.w, "`") + for _, part := range nn.Parts { + switch part.(type) { + case *scalar.EncapsedStringPart: + p.Print(part) + default: + io.WriteString(p.w, "{") + p.Print(part) + io.WriteString(p.w, "}") + } + } + io.WriteString(p.w, "`") +} + +func (p *PrettyPrinter) printExprShortArray(n node.Node) { + nn := n.(*expr.ShortArray) + + io.WriteString(p.w, "[") + p.joinPrint(", ", nn.Items) + io.WriteString(p.w, "]") +} + +func (p *PrettyPrinter) printExprShortList(n node.Node) { + nn := n.(*expr.ShortList) + + io.WriteString(p.w, "[") + p.joinPrint(", ", nn.Items) + io.WriteString(p.w, "]") +} + +func (p *PrettyPrinter) printExprStaticCall(n node.Node) { + nn := n.(*expr.StaticCall) + + p.Print(nn.Class) + io.WriteString(p.w, "::") + p.Print(nn.Call) + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.ArgumentList.Arguments) + io.WriteString(p.w, ")") +} + +func (p *PrettyPrinter) printExprStaticPropertyFetch(n node.Node) { + nn := n.(*expr.StaticPropertyFetch) + + p.Print(nn.Class) + io.WriteString(p.w, "::") + p.Print(nn.Property) +} + +func (p *PrettyPrinter) printExprTernary(n node.Node) { + nn := n.(*expr.Ternary) + + p.Print(nn.Condition) + io.WriteString(p.w, " ?") + + if nn.IfTrue != nil { + io.WriteString(p.w, " ") + p.Print(nn.IfTrue) + io.WriteString(p.w, " ") + } + + io.WriteString(p.w, ": ") + p.Print(nn.IfFalse) +} + +func (p *PrettyPrinter) printExprUnaryMinus(n node.Node) { + nn := n.(*expr.UnaryMinus) + + io.WriteString(p.w, "-") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprUnaryPlus(n node.Node) { + nn := n.(*expr.UnaryPlus) + + io.WriteString(p.w, "+") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprVariable(n node.Node) { + nn := n.(*expr.Variable) + io.WriteString(p.w, "$") + p.Print(nn.VarName) +} + +func (p *PrettyPrinter) printExprYieldFrom(n node.Node) { + nn := n.(*expr.YieldFrom) + + io.WriteString(p.w, "yield from ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printExprYield(n node.Node) { + nn := n.(*expr.Yield) + + io.WriteString(p.w, "yield ") + + if nn.Key != nil { + p.Print(nn.Key) + io.WriteString(p.w, " => ") + } + + p.Print(nn.Value) +} + +// smtm + +func (p *PrettyPrinter) printStmtAltElseIf(n node.Node) { + nn := n.(*stmt.AltElseIf) + + io.WriteString(p.w, "elseif (") + p.Print(nn.Cond) + io.WriteString(p.w, ") :") + + if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 { + io.WriteString(p.w, "\n") + p.printNodes(s) + } +} + +func (p *PrettyPrinter) printStmtAltElse(n node.Node) { + nn := n.(*stmt.AltElse) + + io.WriteString(p.w, "else :") + + if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 { + io.WriteString(p.w, "\n") + p.printNodes(s) + } +} + +func (p *PrettyPrinter) printStmtAltFor(n node.Node) { + nn := n.(*stmt.AltFor) + + io.WriteString(p.w, "for (") + p.joinPrint(", ", nn.Init) + io.WriteString(p.w, "; ") + p.joinPrint(", ", nn.Cond) + io.WriteString(p.w, "; ") + p.joinPrint(", ", nn.Loop) + io.WriteString(p.w, ") :\n") + + s := nn.Stmt.(*stmt.StmtList) + p.printNodes(s.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + + io.WriteString(p.w, "endfor;") +} + +func (p *PrettyPrinter) printStmtAltForeach(n node.Node) { + nn := n.(*stmt.AltForeach) + + io.WriteString(p.w, "foreach (") + p.Print(nn.Expr) + io.WriteString(p.w, " as ") + + if nn.Key != nil { + p.Print(nn.Key) + io.WriteString(p.w, " => ") + } + + p.Print(nn.Variable) + + io.WriteString(p.w, ") :\n") + + s := nn.Stmt.(*stmt.StmtList) + p.printNodes(s.Stmts) + + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "endforeach;") +} + +func (p *PrettyPrinter) printStmtAltIf(n node.Node) { + nn := n.(*stmt.AltIf) + + io.WriteString(p.w, "if (") + p.Print(nn.Cond) + io.WriteString(p.w, ") :\n") + + s := nn.Stmt.(*stmt.StmtList) + p.printNodes(s.Stmts) + + for _, elseif := range nn.ElseIf { + io.WriteString(p.w, "\n") + p.printIndent() + p.Print(elseif) + } + + if nn.Else != nil { + io.WriteString(p.w, "\n") + p.printIndent() + p.Print(nn.Else) + } + + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "endif;") +} + +func (p *PrettyPrinter) printStmtAltSwitch(n node.Node) { + nn := n.(*stmt.AltSwitch) + + io.WriteString(p.w, "switch (") + p.Print(nn.Cond) + io.WriteString(p.w, ") :\n") + + s := nn.CaseList.Cases + p.printNodes(s) + + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "endswitch;") +} + +func (p *PrettyPrinter) printStmtAltWhile(n node.Node) { + nn := n.(*stmt.AltWhile) + + io.WriteString(p.w, "while (") + p.Print(nn.Cond) + io.WriteString(p.w, ") :\n") + + s := nn.Stmt.(*stmt.StmtList) + p.printNodes(s.Stmts) + + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "endwhile;") +} + +func (p *PrettyPrinter) printStmtBreak(n node.Node) { + nn := n.(*stmt.Break) + + io.WriteString(p.w, "break") + if nn.Expr != nil { + io.WriteString(p.w, " ") + p.Print(nn.Expr) + } + + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtCase(n node.Node) { + nn := n.(*stmt.Case) + + io.WriteString(p.w, "case ") + p.Print(nn.Cond) + io.WriteString(p.w, ":") + + if len(nn.Stmts) > 0 { + io.WriteString(p.w, "\n") + p.printNodes(nn.Stmts) + } +} + +func (p *PrettyPrinter) printStmtCatch(n node.Node) { + nn := n.(*stmt.Catch) + + io.WriteString(p.w, "catch (") + p.joinPrint(" | ", nn.Types) + io.WriteString(p.w, " ") + p.Print(nn.Variable) + io.WriteString(p.w, ") {\n") + p.printNodes(nn.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") +} + +func (p *PrettyPrinter) printStmtClassMethod(n node.Node) { + nn := n.(*stmt.ClassMethod) + + if nn.Modifiers != nil { + p.joinPrint(" ", nn.Modifiers) + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "function ") + + if nn.ReturnsRef { + io.WriteString(p.w, "&") + } + + p.Print(nn.MethodName) + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.Params) + io.WriteString(p.w, ")") + + if nn.ReturnType != nil { + io.WriteString(p.w, ": ") + p.Print(nn.ReturnType) + } + + switch s := nn.Stmt.(type) { + case *stmt.StmtList: + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "{\n") + p.printNodes(s.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") + default: + p.Print(s) + } +} + +func (p *PrettyPrinter) printStmtClass(n node.Node) { + nn := n.(*stmt.Class) + + if nn.Modifiers != nil { + p.joinPrint(" ", nn.Modifiers) + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "class") + + if nn.ClassName != nil { + io.WriteString(p.w, " ") + p.Print(nn.ClassName) + } + + if nn.ArgumentList != nil { + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.ArgumentList.Arguments) + io.WriteString(p.w, ")") + } + + if nn.Extends != nil { + io.WriteString(p.w, " extends ") + p.Print(nn.Extends.ClassName) + } + + if nn.Implements != nil { + io.WriteString(p.w, " implements ") + p.joinPrint(", ", nn.Implements.InterfaceNames) + } + + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "{\n") + p.printNodes(nn.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") +} + +func (p *PrettyPrinter) printStmtClassConstList(n node.Node) { + nn := n.(*stmt.ClassConstList) + + if nn.Modifiers != nil { + p.joinPrint(" ", nn.Modifiers) + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "const ") + + p.joinPrint(", ", nn.Consts) + + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtConstant(n node.Node) { + nn := n.(*stmt.Constant) + + p.Print(nn.ConstantName) + io.WriteString(p.w, " = ") + p.Print(nn.Expr) +} + +func (p *PrettyPrinter) printStmtContinue(n node.Node) { + nn := n.(*stmt.Continue) + + io.WriteString(p.w, "continue") + if nn.Expr != nil { + io.WriteString(p.w, " ") + p.Print(nn.Expr) + } + + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtDeclare(n node.Node) { + nn := n.(*stmt.Declare) + + io.WriteString(p.w, "declare(") + p.joinPrint(", ", nn.Consts) + io.WriteString(p.w, ")") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } +} + +func (p *PrettyPrinter) printStmtDefault(n node.Node) { + nn := n.(*stmt.Default) + io.WriteString(p.w, "default:") + + if len(nn.Stmts) > 0 { + io.WriteString(p.w, "\n") + p.printNodes(nn.Stmts) + } +} + +func (p *PrettyPrinter) printStmtDo(n node.Node) { + nn := n.(*stmt.Do) + io.WriteString(p.w, "do") + + switch s := nn.Stmt.(type) { + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + io.WriteString(p.w, " ") + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + io.WriteString(p.w, "\n") + p.printIndent() + } + + io.WriteString(p.w, "while (") + p.Print(nn.Cond) + io.WriteString(p.w, ");") +} + +func (p *PrettyPrinter) printStmtEcho(n node.Node) { + nn := n.(*stmt.Echo) + io.WriteString(p.w, "echo ") + p.joinPrint(", ", nn.Exprs) + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtElseif(n node.Node) { + nn := n.(*stmt.ElseIf) + + io.WriteString(p.w, "elseif (") + p.Print(nn.Cond) + io.WriteString(p.w, ")") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } +} + +func (p *PrettyPrinter) printStmtElse(n node.Node) { + nn := n.(*stmt.Else) + + io.WriteString(p.w, "else") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } +} + +func (p *PrettyPrinter) printStmtExpression(n node.Node) { + nn := n.(*stmt.Expression) + + p.Print(nn.Expr) + + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtFinally(n node.Node) { + nn := n.(*stmt.Finally) + + io.WriteString(p.w, "finally {\n") + p.printNodes(nn.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") +} + +func (p *PrettyPrinter) printStmtFor(n node.Node) { + nn := n.(*stmt.For) + + io.WriteString(p.w, "for (") + p.joinPrint(", ", nn.Init) + io.WriteString(p.w, "; ") + p.joinPrint(", ", nn.Cond) + io.WriteString(p.w, "; ") + p.joinPrint(", ", nn.Loop) + io.WriteString(p.w, ")") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } +} + +func (p *PrettyPrinter) printStmtForeach(n node.Node) { + nn := n.(*stmt.Foreach) + + io.WriteString(p.w, "foreach (") + p.Print(nn.Expr) + io.WriteString(p.w, " as ") + + if nn.Key != nil { + p.Print(nn.Key) + io.WriteString(p.w, " => ") + } + + p.Print(nn.Variable) + io.WriteString(p.w, ")") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } +} + +func (p *PrettyPrinter) printStmtFunction(n node.Node) { + nn := n.(*stmt.Function) + + io.WriteString(p.w, "function ") + + if nn.ReturnsRef { + io.WriteString(p.w, "&") + } + + p.Print(nn.FunctionName) + + io.WriteString(p.w, "(") + p.joinPrint(", ", nn.Params) + io.WriteString(p.w, ")") + + if nn.ReturnType != nil { + io.WriteString(p.w, ": ") + p.Print(nn.ReturnType) + } + + io.WriteString(p.w, " {\n") + p.printNodes(nn.Stmts) + io.WriteString(p.w, "\n") + p.printIndent() + io.WriteString(p.w, "}") +} + +func (p *PrettyPrinter) printStmtGlobal(n node.Node) { + nn := n.(*stmt.Global) + + io.WriteString(p.w, "global ") + p.joinPrint(", ", nn.Vars) + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtGoto(n node.Node) { + nn := n.(*stmt.Goto) + + io.WriteString(p.w, "goto ") + p.Print(nn.Label) + io.WriteString(p.w, ";") +} + +func (p *PrettyPrinter) printStmtGroupUse(n node.Node) { + nn := n.(*stmt.GroupUse) + + io.WriteString(p.w, "use ") + + if nn.UseType != nil { + p.Print(nn.UseType) + io.WriteString(p.w, " ") + } + + p.Print(nn.Prefix) + io.WriteString(p.w, "\\{") + p.joinPrint(", ", nn.UseList) + io.WriteString(p.w, "};") +} + +func (p *PrettyPrinter) printStmtHaltCompiler(n node.Node) { + io.WriteString(p.w, "__halt_compiler();") +} + +func (p *PrettyPrinter) printStmtIf(n node.Node) { + nn := n.(*stmt.If) + + io.WriteString(p.w, "if (") + p.Print(nn.Cond) + io.WriteString(p.w, ")") + + switch s := nn.Stmt.(type) { + case *stmt.Nop: + p.Print(s) + break + case *stmt.StmtList: + io.WriteString(p.w, " ") + p.Print(s) + default: + io.WriteString(p.w, "\n") + p.indentDepth++ + p.printIndent() + p.Print(s) + p.indentDepth-- + } + + if nn.ElseIf != nil { + io.WriteString(p.w, "\n") + p.indentDepth-- + p.printNodes(nn.ElseIf) + p.indentDepth++ + } + + if nn.Else != nil { + io.WriteString(p.w, "\n") + p.printIndent() + p.Print(nn.Else) + } +} + +func (p *PrettyPrinter) printStmtInlineHTML(n node.Node) { + nn := n.(*stmt.InlineHtml) + + io.WriteString(p.w, "?>") + io.WriteString(p.w, nn.Value) + io.WriteString(p.w, "HTML"}, + &stmt.Expression{ + Expr: &scalar.Heredoc{ + Label: "\"LBL\"", + Parts: []node.Node{ + &scalar.EncapsedStringPart{Value: "hello world\n"}, + }, + }, + }, + }, + }) + + expected := `
HTML
>= $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// binary + +func TestPrintBinaryBitwiseAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.BitwiseAnd{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a & $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryBitwiseOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.BitwiseOr{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a | $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryBitwiseXor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.BitwiseXor{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a ^ $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryBooleanAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.BooleanAnd{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a && $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryBooleanOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.BooleanOr{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a || $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryCoalesce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Coalesce{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a ?? $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryConcat(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Concat{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a . $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryDiv(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Div{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a / $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Equal{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a == $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryGreaterOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.GreaterOrEqual{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a >= $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryGreater(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Greater{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a > $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Identical{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a === $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryLogicalAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.LogicalAnd{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a and $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryLogicalOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.LogicalOr{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a or $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryLogicalXor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.LogicalXor{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a xor $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Minus{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a - $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryMod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Mod{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a % $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryMul(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Mul{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a * $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryNotEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.NotEqual{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a != $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryNotIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.NotIdentical{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a !== $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Plus{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a + $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryPow(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Pow{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a ** $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryShiftLeft(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.ShiftLeft{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a << $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinaryShiftRight(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.ShiftRight{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a >> $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinarySmallerOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.SmallerOrEqual{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a <= $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinarySmaller(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Smaller{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a < $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBinarySpaceship(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&binary.Spaceship{ + Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a <=> $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// cast + +func TestPrintArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Array{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(array)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintBool(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Bool{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(bool)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintDouble(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Double{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(float)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintInt(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Int{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(int)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintObject(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Object{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(object)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintString(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.String{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(string)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintUnset(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&cast.Unset{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `(unset)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// expr + +func TestPrintExprArrayDimFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ArrayDimFetch{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Dim: &scalar.Lnumber{Value: "1"}, + }) + + expected := `$var[1]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprArrayItemWithKey(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ArrayItem{ + Key: &scalar.String{Value: "'Hello'"}, + Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + }) + + expected := `'Hello' => $world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprArrayItem(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ArrayItem{ + Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "world"}}}, + }) + + expected := `&$world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Array{ + Items: []node.Node{ + &expr.ArrayItem{ + Key: &scalar.String{Value: "'Hello'"}, + Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + }, + &expr.ArrayItem{ + Key: &scalar.Lnumber{Value: "2"}, + Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}, + }, + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }, + }, + }) + + expected := `array('Hello' => $world, 2 => &$var, $var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprBitwiseNot(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.BitwiseNot{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `~$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprBooleanNot(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.BooleanNot{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `!$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprClassConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ClassConstFetch{ + Class: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + ConstantName: &node.Identifier{Value: "CONST"}, + }) + + expected := `$var::CONST` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprClone(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Clone{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `clone $var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprClosureUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ClosureUse{ + Uses: []node.Node{ + &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}}, + &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, + }, + }) + + expected := `use (&$foo, $bar)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprClosure(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &expr.Closure{ + Static: true, + ReturnsRef: true, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + Variadic: false, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }, + }, + ClosureUse: &expr.ClosureUse{ + Uses: []node.Node{ + &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + ReturnType: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }, + }, + }) + + expected := `namespace { + static function &(&$var) use (&$a, $b): \Foo { + $a; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ConstFetch{ + Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}, + }) + + expected := "null" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Empty{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `empty($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrettyPrinterrorSuppress(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ErrorSuppress{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `@$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintEval(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Eval{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `eval($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExit(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Exit{Die: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `exit($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintDie(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Exit{Die: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `die($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintFunctionCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.FunctionCall{ + Function: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + IsReference: true, + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &node.Argument{ + Variadic: true, + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + }, + }, + }) + + expected := `$var(&$a, ...$b, $c)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintInclude(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Include{Expr: &scalar.String{Value: "'path'"}}) + + expected := `include 'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintIncludeOnce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.IncludeOnce{Expr: &scalar.String{Value: "'path'"}}) + + expected := `include_once 'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintInstanceOf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.InstanceOf{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + }) + + expected := `$var instanceof Foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintIsset(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Isset{ + Variables: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }) + + expected := `isset($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.List{ + Items: []node.Node{ + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &expr.ArrayItem{ + Val: &expr.List{ + Items: []node.Node{ + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + }, + }, + }, + }, + }) + + expected := `list($a, list($b, $c))` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintMethodCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.MethodCall{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Method: &node.Identifier{Value: "bar"}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + }, + }) + + expected := `$foo->bar($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintNew(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.New{ + Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + }, + }) + + expected := `new Foo($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPostDec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.PostDec{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `$var--` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPostInc(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.PostInc{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `$var++` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPreDec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.PreDec{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `--$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPreInc(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.PreInc{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `++$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPrint(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Print{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `print($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.PropertyFetch{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Property: &node.Identifier{Value: "bar"}, + }) + + expected := `$foo->bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprReference(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Reference{ + Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + }) + + expected := `&$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintRequire(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Require{Expr: &scalar.String{Value: "'path'"}}) + + expected := `require 'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintRequireOnce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.RequireOnce{Expr: &scalar.String{Value: "'path'"}}) + + expected := `require_once 'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintShellExec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ShellExec{ + Parts: []node.Node{ + &scalar.EncapsedStringPart{Value: "hello "}, + &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + &scalar.EncapsedStringPart{Value: "!"}, + }, + }) + + expected := "`hello {$world}!`" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExprShortArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ShortArray{ + Items: []node.Node{ + &expr.ArrayItem{ + Key: &scalar.String{Value: "'Hello'"}, + Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + }, + &expr.ArrayItem{ + Key: &scalar.Lnumber{Value: "2"}, + Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}, + }, + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }, + }, + }) + + expected := `['Hello' => $world, 2 => &$var, $var]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintShortList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.ShortList{ + Items: []node.Node{ + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &expr.ArrayItem{ + Val: &expr.List{ + Items: []node.Node{ + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + &expr.ArrayItem{ + Val: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + }, + }, + }, + }, + }) + + expected := `[$a, list($b, $c)]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStaticCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.StaticCall{ + Class: &node.Identifier{Value: "Foo"}, + Call: &node.Identifier{Value: "bar"}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + }, + }) + + expected := `Foo::bar($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStaticPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.StaticPropertyFetch{ + Class: &node.Identifier{Value: "Foo"}, + Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, + }) + + expected := `Foo::$bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintTernary(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Ternary{ + Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }) + + expected := `$a ?: $b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintTernaryFull(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Ternary{ + Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }) + + expected := `$a ? $b : $c` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintUnaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.UnaryMinus{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `-$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintUnaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.UnaryPlus{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `+$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintVariable(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + + expected := `$$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintYieldFrom(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.YieldFrom{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `yield from $var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintYield(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Yield{ + Value: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `yield $var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintYieldFull(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&expr.Yield{ + Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, + Value: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }) + + expected := `yield $k => $var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// stmt + +func TestPrintAltElseIf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.AltElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }) + + expected := `elseif ($a) : + $b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltElseIfEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.AltElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{}, + }) + + expected := `elseif ($a) :` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltElse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.AltElse{ + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }) + + expected := `else : + $b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltElseEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.AltElse{ + Stmt: &stmt.StmtList{}, + }) + + expected := `else :` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltFor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.AltFor{ + Init: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + Cond: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + Loop: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, + }, + }, + }, + }, + }) + + expected := `namespace { + for ($a; $b; $c) : + $d; + endfor; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltForeach(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.AltForeach{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Key: &expr.Variable{VarName: &node.Identifier{Value: "key"}}, + Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "val"}}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, + }, + }, + }, + }, + }) + + expected := `namespace { + foreach ($var as $key => &$val) : + $d; + endforeach; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltIf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.AltIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, + }, + }, + ElseIf: []node.Node{ + &stmt.AltElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }, + &stmt.AltElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Stmt: &stmt.StmtList{}, + }, + }, + Else: &stmt.AltElse{ + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }, + }, + }, + }) + + expected := `namespace { + if ($a) : + $d; + elseif ($b) : + $b; + elseif ($c) : + else : + $b; + endif; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtAltSwitch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.AltSwitch{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + CaseList: &stmt.CaseList{ + Cases: []node.Node{ + &stmt.Case{ + Cond: &scalar.String{Value: "'a'"}, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }, + &stmt.Case{ + Cond: &scalar.String{Value: "'b'"}, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }, + }, + }, + }, + }) + + expected := `namespace { + switch ($var) : + case 'a': + $a; + case 'b': + $b; + endswitch; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintAltWhile(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.AltWhile{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + }, + }, + }, + }, + }) + + expected := `namespace { + while ($a) : + $b; + endwhile; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtBreak(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Break{ + Expr: &scalar.Lnumber{Value: "1"}, + }) + + expected := "break 1;" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtCase(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Case{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }) + + expected := `case $a: + $a;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtCaseEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Case{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmts: []node.Node{}, + }) + + expected := "case $a:" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtCatch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Catch{ + Types: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Exception"}}}, + &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "RuntimeException"}}}, + }, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }, + }, + }) + + expected := `namespace { + catch (Exception | \RuntimeException $e) { + $a; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtClassMethod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ClassMethod{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + ReturnsRef: true, + MethodName: &node.Identifier{Value: "foo"}, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}}, + }, + &node.Parameter{ + Variadic: true, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + ReturnType: &name.Name{Parts: []node.Node{&name.NamePart{Value: "void"}}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }, + }) + + expected := `public function &foo(?int &$a = null, ...$b): void +{ + $a; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} +func TestPrintStmtAbstractClassMethod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ClassMethod{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + ReturnsRef: true, + MethodName: &node.Identifier{Value: "foo"}, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}}, + }, + &node.Parameter{ + Variadic: true, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + ReturnType: &name.Name{Parts: []node.Node{&name.NamePart{Value: "void"}}}, + Stmt: &stmt.Nop{}, + }) + + expected := `public function &foo(?int &$a = null, ...$b): void;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtClass(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Class{ + Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, + ClassName: &node.Identifier{Value: "Foo"}, + Extends: &stmt.ClassExtends{ + ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + }, + Implements: &stmt.ClassImplements{ + InterfaceNames: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, + }, + }, + Stmts: []node.Node{ + &stmt.ClassConstList{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + }, + }, + }, + }, + }) + + expected := `namespace { + abstract class Foo extends Bar implements Baz, Quuz + { + public const FOO = 'bar'; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtAnonymousClass(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Class{ + Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + &node.Argument{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + }, + Extends: &stmt.ClassExtends{ + ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + }, + Implements: &stmt.ClassImplements{ + InterfaceNames: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, + }, + }, + Stmts: []node.Node{ + &stmt.ClassConstList{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + }, + }, + }, + }, + }) + + expected := `namespace { + abstract class($a, $b) extends Bar implements Baz, Quuz + { + public const FOO = 'bar'; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtClassConstList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ClassConstList{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'a'"}, + }, + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "BAR"}, + Expr: &scalar.String{Value: "'b'"}, + }, + }, + }) + + expected := `public const FOO = 'a', BAR = 'b';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtConstant(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'BAR'"}, + }) + + expected := "FOO = 'BAR'" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtContinue(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Continue{ + Expr: &scalar.Lnumber{Value: "1"}, + }) + + expected := `continue 1;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDeclareStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Declare{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }, + }, + }) + + expected := `{ + declare(FOO = 'bar') { + ; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDeclareExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Declare{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + }, + }, + }) + + expected := `{ + declare(FOO = 'bar') + 'bar'; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDeclareNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Declare{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + Stmt: &stmt.Nop{}, + }) + + expected := `declare(FOO = 'bar');` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDefalut(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Default{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }) + + expected := `default: + $a;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDefalutEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Default{ + Stmts: []node.Node{}, + }) + + expected := `default:` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDo_Expression(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Do{ + Cond: &scalar.Lnumber{Value: "1"}, + Stmt: &stmt.Expression{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + }, + }, + }) + + expected := `namespace { + do + $a; + while (1); +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtDo_StmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Do{ + Cond: &scalar.Lnumber{Value: "1"}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + }, + }, + }, + }, + }) + + expected := `namespace { + do { + $a; + } while (1); +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtEcho(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Echo{ + Exprs: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }) + + expected := `echo $a, $b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseIfStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }) + + expected := `elseif ($a) { + ; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseIfExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + }) + + expected := `elseif ($a) + 'bar';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseIfNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.ElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.Nop{}, + }) + + expected := `elseif ($a);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Else{ + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }) + + expected := `else { + ; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Else{ + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + }) + + expected := `else + 'bar';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtElseNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Else{ + Stmt: &stmt.Nop{}, + }) + + expected := `else;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintExpression(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}) + + expected := `$a;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtFinally(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Finally{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }, + }) + + expected := `namespace { + finally { + ; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.For{ + Init: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + Cond: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + &expr.Variable{VarName: &node.Identifier{Value: "d"}}, + }, + Loop: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "e"}}, + &expr.Variable{VarName: &node.Identifier{Value: "f"}}, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }, + }, + }) + + expected := `namespace { + for ($a, $b; $c, $d; $e, $f) { + ; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.For{ + Init: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + Cond: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + Loop: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + }, + }, + }) + + expected := `namespace { + for ($a; $b; $c) + 'bar'; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.For{ + Init: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + }, + Cond: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + Loop: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + }, + Stmt: &stmt.Nop{}, + }) + + expected := `for ($a; $b; $c);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForeachStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Foreach{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }, + }, + }) + + expected := `namespace { + foreach ($a as $b) { + ; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForeachExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Foreach{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}, + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + }, + }, + }) + + expected := `namespace { + foreach ($a as $k => $v) + 'bar'; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtForeachNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Foreach{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, + Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}}, + Stmt: &stmt.Nop{}, + }) + + expected := `foreach ($a as $k => &$v);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtFunction(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.Function{ + ReturnsRef: true, + FunctionName: &node.Identifier{Value: "foo"}, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + Variadic: false, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + }, + }, + ReturnType: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }, + }, + }) + + expected := `namespace { + function &foo(&$var): \Foo { + ; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtGlobal(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Global{ + Vars: []node.Node{ + &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }) + + expected := `global $a, $b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtGoto(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Goto{ + Label: &node.Identifier{Value: "FOO"}, + }) + + expected := `goto FOO;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintStmtGroupUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.GroupUse{ + UseType: &node.Identifier{Value: "function"}, + Prefix: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + UseList: []node.Node{ + &stmt.Use{ + Use: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + Alias: &node.Identifier{Value: "Baz"}, + }, + &stmt.Use{ + Use: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, + }, + }, + }) + + expected := `use function Foo\{Bar as Baz, Quuz};` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintHaltCompiler(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.HaltCompiler{}) + + expected := `__halt_compiler();` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintIfExpression(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.If{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.Expression{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + ElseIf: []node.Node{ + &stmt.ElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, + }, + }, + }, + }, + &stmt.ElseIf{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, + Stmt: &stmt.Nop{}, + }, + }, + Else: &stmt.Else{ + Stmt: &stmt.Expression{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "f"}}, + }, + }, + }, + }, + }) + + expected := `namespace { + if ($a) + $b; + elseif ($c) { + $d; + } + elseif ($e); + else + $f; +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintIfStmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.Namespace{ + Stmts: []node.Node{ + &stmt.If{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{ + Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + }, + }, + }, + }, + }, + }) + + expected := `namespace { + if ($a) { + $b; + } +}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintIfNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.If{ + Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Stmt: &stmt.Nop{}, + }) + + expected := `if ($a);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrintInlineHtml(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrettyPrinter(o, " ") + p.Print(&stmt.InlineHtml{ + Value: "test", + }) + + expected := `?>test 0 { - firstStmt := v.Stmts[0] - v.Stmts = v.Stmts[1:] - - switch fs := firstStmt.(type) { - case *stmt.InlineHtml: - io.WriteString(p.w, fs.Value) - io.WriteString(p.w, " 0 { - io.WriteString(p.w, "\\") - } + p.joinPrint("\\", nn.Parts) - p.Print(part) - } + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printNameFullyQualified(n node.Node) { nn := n.(*name.FullyQualified) + p.printFreeFloating(nn, freefloating.Start) - for _, part := range nn.Parts { - io.WriteString(p.w, "\\") - p.Print(part) - } + io.WriteString(p.w, "\\") + p.joinPrint("\\", nn.Parts) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printNameRelative(n node.Node) { nn := n.(*name.Relative) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "namespace") + p.printFreeFloating(nn, freefloating.Namespace) + for _, part := range nn.Parts { io.WriteString(p.w, "\\") p.Print(part) } + + p.printFreeFloating(nn, freefloating.End) } // scalar func (p *Printer) printScalarLNumber(n node.Node) { - v := n.(*scalar.Lnumber).Value - io.WriteString(p.w, v) + nn := n.(*scalar.Lnumber) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, nn.Value) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarDNumber(n node.Node) { - v := n.(*scalar.Dnumber).Value - io.WriteString(p.w, v) + nn := n.(*scalar.Dnumber) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, nn.Value) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarString(n node.Node) { - v := n.(*scalar.String).Value - - io.WriteString(p.w, v) + nn := n.(*scalar.String) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, nn.Value) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarEncapsedStringPart(n node.Node) { - v := n.(*scalar.EncapsedStringPart).Value - io.WriteString(p.w, v) + nn := n.(*scalar.EncapsedStringPart) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, nn.Value) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarEncapsed(n node.Node) { - io.WriteString(p.w, "\"") + nn := n.(*scalar.Encapsed) + p.printFreeFloating(nn, freefloating.Start) - for _, part := range n.(*scalar.Encapsed).Parts { + io.WriteString(p.w, "\"") + for _, part := range nn.Parts { switch part.(type) { - case *scalar.EncapsedStringPart: - p.Print(part) + case *expr.ArrayDimFetch: + s := (*part.GetFreeFloating())[freefloating.Start] + if len(s) > 0 && s[0].Value == "${" { + p.printExprArrayDimFetchWithoutLeadingDollar(part) + } else { + p.Print(part) + } + case *expr.Variable: + s := (*part.GetFreeFloating())[freefloating.Start] + if len(s) > 0 && s[0].Value == "${" { + p.printExprVariableWithoutLeadingDollar(part) + } else { + p.Print(part) + } default: - io.WriteString(p.w, "{") p.Print(part) - io.WriteString(p.w, "}") } } - io.WriteString(p.w, "\"") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarHeredoc(n node.Node) { nn := n.(*scalar.Heredoc) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "<<<") io.WriteString(p.w, nn.Label) @@ -576,1628 +624,2592 @@ func (p *Printer) printScalarHeredoc(n node.Node) { for _, part := range nn.Parts { switch part.(type) { - case *scalar.EncapsedStringPart: - p.Print(part) + case *expr.ArrayDimFetch: + s := (*part.GetFreeFloating())[freefloating.Start] + if len(s) > 0 && s[0].Value == "${" { + p.printExprArrayDimFetchWithoutLeadingDollar(part) + } else { + p.Print(part) + } + case *expr.Variable: + s := (*part.GetFreeFloating())[freefloating.Start] + if len(s) > 0 && s[0].Value == "${" { + p.printExprVariableWithoutLeadingDollar(part) + } else { + p.Print(part) + } default: - io.WriteString(p.w, "{") p.Print(part) - io.WriteString(p.w, "}") } } + io.WriteString(p.w, "\n") io.WriteString(p.w, strings.Trim(nn.Label, "\"'")) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printScalarMagicConstant(n node.Node) { - v := n.(*scalar.MagicConstant).Value - io.WriteString(p.w, v) + nn := n.(*scalar.MagicConstant) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, nn.Value) + p.printFreeFloating(nn, freefloating.End) } // Assign func (p *Printer) printAssign(n node.Node) { nn := n.(*assign.Assign) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " = ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } -func (p *Printer) printReference(n node.Node) { +func (p *Printer) printAssignReference(n node.Node) { nn := n.(*assign.Reference) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " =& ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "=") + p.printFreeFloating(nn, freefloating.Equal) + io.WriteString(p.w, "&") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignBitwiseAnd(n node.Node) { nn := n.(*assign.BitwiseAnd) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " &= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "&") + io.WriteString(p.w, "=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignBitwiseOr(n node.Node) { nn := n.(*assign.BitwiseOr) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " |= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "|=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignBitwiseXor(n node.Node) { nn := n.(*assign.BitwiseXor) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " ^= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "^=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignConcat(n node.Node) { nn := n.(*assign.Concat) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " .= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, ".=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignDiv(n node.Node) { nn := n.(*assign.Div) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " /= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "/=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignMinus(n node.Node) { nn := n.(*assign.Minus) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " -= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "-=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignMod(n node.Node) { nn := n.(*assign.Mod) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " %= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "%=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignMul(n node.Node) { nn := n.(*assign.Mul) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " *= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "*=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignPlus(n node.Node) { nn := n.(*assign.Plus) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " += ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "+=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignPow(n node.Node) { nn := n.(*assign.Pow) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " **= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "**=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignShiftLeft(n node.Node) { nn := n.(*assign.ShiftLeft) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " <<= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "<<=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printAssignShiftRight(n node.Node) { nn := n.(*assign.ShiftRight) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, " >>= ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, ">>=") p.Print(nn.Expression) + + p.printFreeFloating(nn, freefloating.End) } // binary func (p *Printer) printBinaryBitwiseAnd(n node.Node) { nn := n.(*binary.BitwiseAnd) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " & ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "&") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryBitwiseOr(n node.Node) { nn := n.(*binary.BitwiseOr) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " | ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "|") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryBitwiseXor(n node.Node) { nn := n.(*binary.BitwiseXor) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " ^ ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "^") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryBooleanAnd(n node.Node) { nn := n.(*binary.BooleanAnd) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " && ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "&&") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryBooleanOr(n node.Node) { nn := n.(*binary.BooleanOr) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " || ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "||") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryCoalesce(n node.Node) { nn := n.(*binary.Coalesce) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " ?? ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "??") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryConcat(n node.Node) { nn := n.(*binary.Concat) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " . ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ".") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryDiv(n node.Node) { nn := n.(*binary.Div) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " / ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "/") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryEqual(n node.Node) { nn := n.(*binary.Equal) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " == ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "==") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryGreaterOrEqual(n node.Node) { nn := n.(*binary.GreaterOrEqual) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " >= ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ">=") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryGreater(n node.Node) { nn := n.(*binary.Greater) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " > ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ">") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryIdentical(n node.Node) { nn := n.(*binary.Identical) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " === ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "===") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryLogicalAnd(n node.Node) { nn := n.(*binary.LogicalAnd) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " and ") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "and") + if nn.Right.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryLogicalOr(n node.Node) { nn := n.(*binary.LogicalOr) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " or ") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "or") + if nn.Right.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryLogicalXor(n node.Node) { nn := n.(*binary.LogicalXor) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " xor ") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "xor") + if nn.Right.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryMinus(n node.Node) { nn := n.(*binary.Minus) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " - ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "-") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryMod(n node.Node) { nn := n.(*binary.Mod) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " % ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "%") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryMul(n node.Node) { nn := n.(*binary.Mul) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " * ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "*") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryNotEqual(n node.Node) { nn := n.(*binary.NotEqual) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " != ") + p.printFreeFloating(nn, freefloating.Expr) + p.printFreeFloating(nn, freefloating.Equal) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "!=") + } p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryNotIdentical(n node.Node) { nn := n.(*binary.NotIdentical) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " !== ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "!==") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryPlus(n node.Node) { nn := n.(*binary.Plus) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " + ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "+") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryPow(n node.Node) { nn := n.(*binary.Pow) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " ** ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "**") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryShiftLeft(n node.Node) { nn := n.(*binary.ShiftLeft) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " << ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "<<") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinaryShiftRight(n node.Node) { nn := n.(*binary.ShiftRight) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " >> ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ">>") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinarySmallerOrEqual(n node.Node) { nn := n.(*binary.SmallerOrEqual) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " <= ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "<=") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinarySmaller(n node.Node) { nn := n.(*binary.Smaller) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " < ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "<") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBinarySpaceship(n node.Node) { nn := n.(*binary.Spaceship) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Left) - io.WriteString(p.w, " <=> ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "<=>") p.Print(nn.Right) + + p.printFreeFloating(nn, freefloating.End) } // cast func (p *Printer) printArray(n node.Node) { nn := n.(*cast.Array) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(array)") + } - io.WriteString(p.w, "(array)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printBool(n node.Node) { nn := n.(*cast.Bool) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(boolean)") + } - io.WriteString(p.w, "(bool)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printDouble(n node.Node) { nn := n.(*cast.Double) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(float)") + } - io.WriteString(p.w, "(float)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printInt(n node.Node) { nn := n.(*cast.Int) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(integer)") + } - io.WriteString(p.w, "(int)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printObject(n node.Node) { nn := n.(*cast.Object) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(object)") + } - io.WriteString(p.w, "(object)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printString(n node.Node) { nn := n.(*cast.String) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(string)") + } - io.WriteString(p.w, "(string)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printUnset(n node.Node) { nn := n.(*cast.Unset) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Cast) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "(unset)") + } - io.WriteString(p.w, "(unset)") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } // expr func (p *Printer) printExprArrayDimFetch(n node.Node) { nn := n.(*expr.ArrayDimFetch) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) - io.WriteString(p.w, "[") + p.printFreeFloating(nn, freefloating.Var) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "[") + } p.Print(nn.Dim) - io.WriteString(p.w, "]") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "]") + } + p.printFreeFloating(nn, freefloating.End) +} + +func (p *Printer) printExprArrayDimFetchWithoutLeadingDollar(n node.Node) { + nn := n.(*expr.ArrayDimFetch) + p.printFreeFloating(nn, freefloating.Start) + p.printExprVariableWithoutLeadingDollar(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "[") + } + p.Print(nn.Dim) + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "]") + } + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprArrayItem(n node.Node) { nn := n.(*expr.ArrayItem) + p.printFreeFloating(nn, freefloating.Start) if nn.Key != nil { p.Print(nn.Key) - io.WriteString(p.w, " => ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "=>") } p.Print(nn.Val) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprArray(n node.Node) { nn := n.(*expr.Array) - - io.WriteString(p.w, "array(") - p.joinPrint(", ", nn.Items) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "array") + p.printFreeFloating(nn, freefloating.Array) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Items) + p.printFreeFloating(nn, freefloating.ArrayPairList) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprBitwiseNot(n node.Node) { nn := n.(*expr.BitwiseNot) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "~") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprBooleanNot(n node.Node) { nn := n.(*expr.BooleanNot) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "!") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprClassConstFetch(n node.Node) { nn := n.(*expr.ClassConstFetch) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Class) + p.printFreeFloating(nn, freefloating.Name) io.WriteString(p.w, "::") - io.WriteString(p.w, nn.ConstantName.(*node.Identifier).Value) + p.Print(nn.ConstantName) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprClone(n node.Node) { nn := n.(*expr.Clone) - - io.WriteString(p.w, "clone ") + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "clone") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprClosureUse(n node.Node) { nn := n.(*expr.ClosureUse) - - io.WriteString(p.w, "use (") - p.joinPrint(", ", nn.Uses) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "use") + p.printFreeFloating(nn, freefloating.Use) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Uses) + p.printFreeFloating(nn, freefloating.LexicalVarList) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprClosure(n node.Node) { nn := n.(*expr.Closure) + p.printFreeFloating(nn, freefloating.Start) if nn.Static { - io.WriteString(p.w, "static ") + io.WriteString(p.w, "static") + } + p.printFreeFloating(nn, freefloating.Static) + if nn.Static && n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") } - io.WriteString(p.w, "function ") + io.WriteString(p.w, "function") + p.printFreeFloating(nn, freefloating.Function) if nn.ReturnsRef { io.WriteString(p.w, "&") } + p.printFreeFloating(nn, freefloating.Ampersand) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.Params) + p.joinPrint(",", nn.Params) + p.printFreeFloating(nn, freefloating.ParameterList) io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Params) if nn.ClosureUse != nil { - io.WriteString(p.w, " ") p.Print(nn.ClosureUse) } + p.printFreeFloating(nn, freefloating.LexicalVars) if nn.ReturnType != nil { - io.WriteString(p.w, ": ") + io.WriteString(p.w, ":") p.Print(nn.ReturnType) } + p.printFreeFloating(nn, freefloating.ReturnType) - io.WriteString(p.w, " {\n") + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprConstFetch(n node.Node) { nn := n.(*expr.ConstFetch) - + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Constant) -} - -func (p *Printer) printExprDie(n node.Node) { - nn := n.(*expr.Die) - - io.WriteString(p.w, "die(") - p.Print(nn.Expr) - io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprEmpty(n node.Node) { nn := n.(*expr.Empty) - - io.WriteString(p.w, "empty(") + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "empty") + p.printFreeFloating(nn, freefloating.Empty) + io.WriteString(p.w, "(") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.Expr) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprErrorSuppress(n node.Node) { nn := n.(*expr.ErrorSuppress) - + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "@") p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprEval(n node.Node) { nn := n.(*expr.Eval) - - io.WriteString(p.w, "eval(") + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "eval") + p.printFreeFloating(nn, freefloating.Eval) + io.WriteString(p.w, "(") p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.Expr) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprExit(n node.Node) { nn := n.(*expr.Exit) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "exit(") + if nn.Die { + io.WriteString(p.w, "die") + } else { + io.WriteString(p.w, "exit") + } + p.printFreeFloating(nn, freefloating.Exit) + + if nn.Expr != nil && nn.Expr.GetFreeFloating().IsEmpty() && nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) - io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprFunctionCall(n node.Node) { nn := n.(*expr.FunctionCall) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Function) + + p.printFreeFloating(nn.ArgumentList, freefloating.Start) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.ArgumentList.Arguments) + p.joinPrint(",", nn.ArgumentList.Arguments) + p.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) io.WriteString(p.w, ")") + p.printFreeFloating(nn.ArgumentList, freefloating.End) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprInclude(n node.Node) { nn := n.(*expr.Include) - - io.WriteString(p.w, "include ") + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "include") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprIncludeOnce(n node.Node) { nn := n.(*expr.IncludeOnce) - - io.WriteString(p.w, "include_once ") + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "include_once") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprInstanceOf(n node.Node) { nn := n.(*expr.InstanceOf) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Expr) - io.WriteString(p.w, " instanceof ") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + + io.WriteString(p.w, "instanceof") + + if nn.Class.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Class) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprIsset(n node.Node) { nn := n.(*expr.Isset) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "isset(") - p.joinPrint(", ", nn.Variables) + io.WriteString(p.w, "isset") + p.printFreeFloating(nn, freefloating.Isset) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Variables) + p.printFreeFloating(nn, freefloating.VarList) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprList(n node.Node) { nn := n.(*expr.List) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "list(") - p.joinPrint(", ", nn.Items) + io.WriteString(p.w, "list") + p.printFreeFloating(nn, freefloating.List) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Items) + p.printFreeFloating(nn, freefloating.ArrayPairList) io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprMethodCall(n node.Node) { nn := n.(*expr.MethodCall) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) io.WriteString(p.w, "->") p.Print(nn.Method) + + p.printFreeFloating(nn.ArgumentList, freefloating.Start) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.ArgumentList.Arguments) + p.joinPrint(",", nn.ArgumentList.Arguments) + p.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) io.WriteString(p.w, ")") + p.printFreeFloating(nn.ArgumentList, freefloating.End) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprNew(n node.Node) { nn := n.(*expr.New) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "new ") + io.WriteString(p.w, "new") + if nn.Class.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Class) if nn.ArgumentList != nil { + p.printFreeFloating(nn.ArgumentList, freefloating.Start) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.ArgumentList.Arguments) + p.joinPrint(",", nn.ArgumentList.Arguments) + p.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) io.WriteString(p.w, ")") + p.printFreeFloating(nn.ArgumentList, freefloating.End) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPostDec(n node.Node) { nn := n.(*expr.PostDec) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) io.WriteString(p.w, "--") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPostInc(n node.Node) { nn := n.(*expr.PostInc) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) io.WriteString(p.w, "++") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPreDec(n node.Node) { nn := n.(*expr.PreDec) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "--") p.Print(nn.Variable) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPreInc(n node.Node) { nn := n.(*expr.PreInc) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "++") p.Print(nn.Variable) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPrint(n node.Node) { nn := n.(*expr.Print) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "print(") + io.WriteString(p.w, "print") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) - io.WriteString(p.w, ")") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprPropertyFetch(n node.Node) { nn := n.(*expr.PropertyFetch) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) io.WriteString(p.w, "->") p.Print(nn.Property) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprReference(n node.Node) { nn := n.(*expr.Reference) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "&") p.Print(nn.Variable) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprRequire(n node.Node) { nn := n.(*expr.Require) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "require ") + io.WriteString(p.w, "require") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprRequireOnce(n node.Node) { nn := n.(*expr.RequireOnce) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "require_once ") + io.WriteString(p.w, "require_once") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprShellExec(n node.Node) { nn := n.(*expr.ShellExec) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "`") - for _, part := range nn.Parts { - switch part.(type) { - case *scalar.EncapsedStringPart: - p.Print(part) - default: - io.WriteString(p.w, "{") - p.Print(part) - io.WriteString(p.w, "}") - } - } + p.joinPrint("", nn.Parts) io.WriteString(p.w, "`") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprShortArray(n node.Node) { nn := n.(*expr.ShortArray) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "[") - p.joinPrint(", ", nn.Items) + p.joinPrint(",", nn.Items) + p.printFreeFloating(nn, freefloating.ArrayPairList) io.WriteString(p.w, "]") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprShortList(n node.Node) { nn := n.(*expr.ShortList) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "[") - p.joinPrint(", ", nn.Items) + p.joinPrint(",", nn.Items) + p.printFreeFloating(nn, freefloating.ArrayPairList) io.WriteString(p.w, "]") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprStaticCall(n node.Node) { nn := n.(*expr.StaticCall) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Class) + p.printFreeFloating(nn, freefloating.Name) io.WriteString(p.w, "::") p.Print(nn.Call) + + p.printFreeFloating(nn.ArgumentList, freefloating.Start) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.ArgumentList.Arguments) + p.joinPrint(",", nn.ArgumentList.Arguments) + p.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) io.WriteString(p.w, ")") + p.printFreeFloating(nn.ArgumentList, freefloating.End) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprStaticPropertyFetch(n node.Node) { nn := n.(*expr.StaticPropertyFetch) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Class) + p.printFreeFloating(nn, freefloating.Name) io.WriteString(p.w, "::") p.Print(nn.Property) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprTernary(n node.Node) { nn := n.(*expr.Ternary) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Condition) - io.WriteString(p.w, " ?") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, "?") if nn.IfTrue != nil { - io.WriteString(p.w, " ") p.Print(nn.IfTrue) - io.WriteString(p.w, " ") } + p.printFreeFloating(nn, freefloating.True) - io.WriteString(p.w, ": ") + io.WriteString(p.w, ":") p.Print(nn.IfFalse) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprUnaryMinus(n node.Node) { nn := n.(*expr.UnaryMinus) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "-") p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprUnaryPlus(n node.Node) { nn := n.(*expr.UnaryPlus) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "+") p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprVariable(n node.Node) { - io.WriteString(p.w, "$") - p.Print(n.(*expr.Variable).VarName) + nn := n.(*expr.Variable) + p.printFreeFloating(nn, freefloating.Start) + + p.printFreeFloating(nn, freefloating.Dollar) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "$") + } + + p.Print(nn.VarName) + + p.printFreeFloating(nn, freefloating.End) +} + +func (p *Printer) printExprVariableWithoutLeadingDollar(n node.Node) { + nn := n.(*expr.Variable) + p.printFreeFloating(nn, freefloating.Start) + + p.Print(nn.VarName) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprYieldFrom(n node.Node) { nn := n.(*expr.YieldFrom) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "yield from ") + io.WriteString(p.w, "yield from") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printExprYield(n node.Node) { nn := n.(*expr.Yield) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "yield ") + io.WriteString(p.w, "yield") if nn.Key != nil { + if nn.Key.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Key) - io.WriteString(p.w, " => ") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, "=>") + } else { + if nn.Value.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } p.Print(nn.Value) + + p.printFreeFloating(nn, freefloating.End) } // smtm func (p *Printer) printStmtAltElseIf(n node.Node) { nn := n.(*stmt.AltElseIf) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "elseif (") + io.WriteString(p.w, "elseif") + p.printFreeFloating(nn, freefloating.ElseIf) + io.WriteString(p.w, "(") p.Print(nn.Cond) - io.WriteString(p.w, ") :") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 { - io.WriteString(p.w, "\n") p.printNodes(s) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltElse(n node.Node) { nn := n.(*stmt.AltElse) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "else :") + io.WriteString(p.w, "else") + p.printFreeFloating(nn, freefloating.Else) + io.WriteString(p.w, ":") if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 { - io.WriteString(p.w, "\n") p.printNodes(s) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltFor(n node.Node) { nn := n.(*stmt.AltFor) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "for (") - p.joinPrint(", ", nn.Init) - io.WriteString(p.w, "; ") - p.joinPrint(", ", nn.Cond) - io.WriteString(p.w, "; ") - p.joinPrint(", ", nn.Loop) - io.WriteString(p.w, ") :\n") + io.WriteString(p.w, "for") + p.printFreeFloating(nn, freefloating.For) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Init) + p.printFreeFloating(nn, freefloating.InitExpr) + io.WriteString(p.w, ";") + p.joinPrint(",", nn.Cond) + p.printFreeFloating(nn, freefloating.CondExpr) + io.WriteString(p.w, ";") + p.joinPrint(",", nn.Loop) + p.printFreeFloating(nn, freefloating.IncExpr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") s := nn.Stmt.(*stmt.StmtList) p.printNodes(s.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "endfor;") + io.WriteString(p.w, "endfor") + p.printFreeFloating(nn, freefloating.AltEnd) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltForeach(n node.Node) { nn := n.(*stmt.AltForeach) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "foreach (") + io.WriteString(p.w, "foreach") + p.printFreeFloating(nn, freefloating.Foreach) + io.WriteString(p.w, "(") p.Print(nn.Expr) - io.WriteString(p.w, " as ") + p.printFreeFloating(nn, freefloating.Expr) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "as") if nn.Key != nil { + if nn.Key.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Key) - io.WriteString(p.w, " => ") + p.printFreeFloating(nn, freefloating.Key) + io.WriteString(p.w, "=>") + } else { + if nn.Variable.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) - io.WriteString(p.w, ") :\n") + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") s := nn.Stmt.(*stmt.StmtList) p.printNodes(s.Stmts) + p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "endforeach;") + io.WriteString(p.w, "endforeach") + p.printFreeFloating(nn, freefloating.AltEnd) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltIf(n node.Node) { nn := n.(*stmt.AltIf) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "if (") + io.WriteString(p.w, "if") + p.printFreeFloating(nn, freefloating.If) + io.WriteString(p.w, "(") p.Print(nn.Cond) - io.WriteString(p.w, ") :\n") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") s := nn.Stmt.(*stmt.StmtList) p.printNodes(s.Stmts) for _, elseif := range nn.ElseIf { - io.WriteString(p.w, "\n") - p.printIndent() p.Print(elseif) } if nn.Else != nil { - io.WriteString(p.w, "\n") - p.printIndent() p.Print(nn.Else) } - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "endif;") + p.printFreeFloating(nn, freefloating.Stmts) + io.WriteString(p.w, "endif") + p.printFreeFloating(nn, freefloating.AltEnd) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltSwitch(n node.Node) { nn := n.(*stmt.AltSwitch) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "switch (") + io.WriteString(p.w, "switch") + p.printFreeFloating(nn, freefloating.Switch) + io.WriteString(p.w, "(") p.Print(nn.Cond) - io.WriteString(p.w, ") :\n") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") - s := nn.CaseList.Cases - p.printNodes(s) + p.printFreeFloating(nn.CaseList, freefloating.Start) + p.printFreeFloating(nn.CaseList, freefloating.CaseListStart) + p.printNodes(nn.CaseList.Cases) + p.printFreeFloating(nn.CaseList, freefloating.CaseListEnd) + p.printFreeFloating(nn.CaseList, freefloating.End) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "endswitch;") + io.WriteString(p.w, "endswitch") + p.printFreeFloating(nn, freefloating.AltEnd) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtAltWhile(n node.Node) { nn := n.(*stmt.AltWhile) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "while (") + io.WriteString(p.w, "while") + p.printFreeFloating(nn, freefloating.While) + io.WriteString(p.w, "(") p.Print(nn.Cond) - io.WriteString(p.w, ") :\n") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") s := nn.Stmt.(*stmt.StmtList) p.printNodes(s.Stmts) + p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "endwhile;") + io.WriteString(p.w, "endwhile") + p.printFreeFloating(nn, freefloating.AltEnd) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtBreak(n node.Node) { nn := n.(*stmt.Break) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "break") if nn.Expr != nil { - io.WriteString(p.w, " ") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) } + p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtCase(n node.Node) { nn := n.(*stmt.Case) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "case ") + io.WriteString(p.w, "case") + if nn.Cond.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Cond) - io.WriteString(p.w, ":") + p.printFreeFloating(nn, freefloating.Expr) + p.printFreeFloating(nn, freefloating.CaseSeparator) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ":") + } if len(nn.Stmts) > 0 { - io.WriteString(p.w, "\n") p.printNodes(nn.Stmts) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtCatch(n node.Node) { nn := n.(*stmt.Catch) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "catch (") - p.joinPrint(" | ", nn.Types) - io.WriteString(p.w, " ") + io.WriteString(p.w, "catch") + p.printFreeFloating(nn, freefloating.Catch) + io.WriteString(p.w, "(") + p.joinPrint("|", nn.Types) p.Print(nn.Variable) - io.WriteString(p.w, ") {\n") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtClassMethod(n node.Node) { nn := n.(*stmt.ClassMethod) + p.printFreeFloating(nn, freefloating.Start) if nn.Modifiers != nil { - p.joinPrint(" ", nn.Modifiers) - io.WriteString(p.w, " ") + for k, m := range nn.Modifiers { + if k > 0 && m.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.Print(m) + } + + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } - io.WriteString(p.w, "function ") + p.printFreeFloating(nn, freefloating.ModifierList) + io.WriteString(p.w, "function") + p.printFreeFloating(nn, freefloating.Function) if nn.ReturnsRef { + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } io.WriteString(p.w, "&") + p.printFreeFloating(nn, freefloating.Ampersand) + } else { + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } p.Print(nn.MethodName) + p.printFreeFloating(nn, freefloating.Name) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.Params) + p.joinPrint(",", nn.Params) + p.printFreeFloating(nn, freefloating.ParameterList) io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Params) if nn.ReturnType != nil { - io.WriteString(p.w, ": ") + io.WriteString(p.w, ":") p.Print(nn.ReturnType) } - switch s := nn.Stmt.(type) { - case *stmt.StmtList: - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "{\n") - p.printNodes(s.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "}") - default: - p.Print(s) - } + p.Print(nn.Stmt) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtClass(n node.Node) { nn := n.(*stmt.Class) + p.printFreeFloating(nn, freefloating.Start) if nn.Modifiers != nil { - p.joinPrint(" ", nn.Modifiers) - io.WriteString(p.w, " ") + for k, m := range nn.Modifiers { + if k > 0 && m.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.Print(m) + } + + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } + p.printFreeFloating(nn, freefloating.ModifierList) io.WriteString(p.w, "class") + p.printFreeFloating(nn, freefloating.Class) if nn.ClassName != nil { - io.WriteString(p.w, " ") + if nn.ClassName.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.ClassName) } if nn.ArgumentList != nil { + p.printFreeFloating(nn.ArgumentList, freefloating.Start) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.ArgumentList.Arguments) + p.joinPrint(",", nn.ArgumentList.Arguments) + p.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) io.WriteString(p.w, ")") + p.printFreeFloating(nn.ArgumentList, freefloating.End) } if nn.Extends != nil { - io.WriteString(p.w, " extends ") + p.printFreeFloating(nn.Extends, freefloating.Start) + if nn.Extends.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "extends") + if nn.Extends.ClassName.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Extends.ClassName) } if nn.Implements != nil { - io.WriteString(p.w, " implements ") - p.joinPrint(", ", nn.Implements.InterfaceNames) + p.printFreeFloating(nn.Implements, freefloating.Start) + if nn.Implements.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "implements") + if nn.Implements.InterfaceNames[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.joinPrint(",", nn.Implements.InterfaceNames) } - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "{\n") + p.printFreeFloating(nn, freefloating.Name) + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtClassConstList(n node.Node) { nn := n.(*stmt.ClassConstList) + p.printFreeFloating(nn, freefloating.Start) if nn.Modifiers != nil { - p.joinPrint(" ", nn.Modifiers) + for k, m := range nn.Modifiers { + if k > 0 && m.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.Print(m) + } + + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + } + p.printFreeFloating(nn, freefloating.ModifierList) + io.WriteString(p.w, "const") + + if nn.Consts[0].GetFreeFloating().IsEmpty() { io.WriteString(p.w, " ") } - io.WriteString(p.w, "const ") + p.joinPrint(",", nn.Consts) + p.printFreeFloating(nn, freefloating.ConstList) - p.joinPrint(", ", nn.Consts) + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.End) +} + +func (p *Printer) printStmtConstList(n node.Node) { + nn := n.(*stmt.ConstList) + p.printFreeFloating(nn, freefloating.Start) + + io.WriteString(p.w, "const") + + if nn.Consts[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.joinPrint(",", nn.Consts) + p.printFreeFloating(nn, freefloating.Stmts) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtConstant(n node.Node) { nn := n.(*stmt.Constant) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.ConstantName) - io.WriteString(p.w, " = ") + p.printFreeFloating(nn, freefloating.Name) + io.WriteString(p.w, "=") p.Print(nn.Expr) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtContinue(n node.Node) { nn := n.(*stmt.Continue) + p.printFreeFloating(nn, freefloating.Start) io.WriteString(p.w, "continue") + if nn.Expr != nil { - io.WriteString(p.w, " ") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) } + p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtDeclare(n node.Node) { nn := n.(*stmt.Declare) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "declare(") - p.joinPrint(", ", nn.Consts) + io.WriteString(p.w, "declare") + p.printFreeFloating(nn, freefloating.Declare) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Consts) + p.printFreeFloating(nn, freefloating.ConstList) io.WriteString(p.w, ")") - switch s := nn.Stmt.(type) { - case *stmt.Nop: - p.Print(s) - break - case *stmt.StmtList: - io.WriteString(p.w, " ") - p.Print(s) - default: - io.WriteString(p.w, "\n") - p.indentDepth++ - p.printIndent() - p.Print(s) - p.indentDepth-- + if nn.Alt { + p.printFreeFloating(nn, freefloating.Cond) + io.WriteString(p.w, ":") + + s := nn.Stmt.(*stmt.StmtList) + p.printNodes(s.Stmts) + p.printFreeFloating(nn, freefloating.Stmts) + + io.WriteString(p.w, "enddeclare") + p.printFreeFloating(nn, freefloating.AltEnd) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + } else { + p.Print(nn.Stmt) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtDefault(n node.Node) { nn := n.(*stmt.Default) - io.WriteString(p.w, "default:") + p.printFreeFloating(nn, freefloating.Start) + + io.WriteString(p.w, "default") + p.printFreeFloating(nn, freefloating.Default) + p.printFreeFloating(nn, freefloating.CaseSeparator) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ":") + } if len(nn.Stmts) > 0 { - io.WriteString(p.w, "\n") p.printNodes(nn.Stmts) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtDo(n node.Node) { nn := n.(*stmt.Do) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "do") - switch s := nn.Stmt.(type) { - case *stmt.StmtList: - io.WriteString(p.w, " ") - p.Print(s) - io.WriteString(p.w, " ") - default: - io.WriteString(p.w, "\n") - p.indentDepth++ - p.printIndent() - p.Print(s) - p.indentDepth-- - io.WriteString(p.w, "\n") - p.printIndent() + if _, ok := nn.Stmt.(*stmt.StmtList); !ok { + if nn.Stmt.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } - io.WriteString(p.w, "while (") + p.Print(nn.Stmt) + p.printFreeFloating(nn, freefloating.Stmts) + + io.WriteString(p.w, "while") + p.printFreeFloating(nn, freefloating.While) + io.WriteString(p.w, "(") p.Print(nn.Cond) - io.WriteString(p.w, ");") + p.printFreeFloating(nn, freefloating.Expr) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Cond) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtEcho(n node.Node) { nn := n.(*stmt.Echo) - io.WriteString(p.w, "echo ") - p.joinPrint(", ", nn.Exprs) - io.WriteString(p.w, ";") + + if p.s == HtmlState { + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + p.printFreeFloating(nn, freefloating.Key) + io.WriteString(p.w, "=>") + } else { + if nn.Variable.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } - p.Print(nn.Variable) + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, ")") - switch s := nn.Stmt.(type) { - case *stmt.Nop: - p.Print(s) - break - case *stmt.StmtList: - io.WriteString(p.w, " ") - p.Print(s) - default: - io.WriteString(p.w, "\n") - p.indentDepth++ - p.printIndent() - p.Print(s) - p.indentDepth-- - } + p.Print(nn.Stmt) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtFunction(n node.Node) { nn := n.(*stmt.Function) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "function ") + io.WriteString(p.w, "function") + p.printFreeFloating(nn, freefloating.Function) if nn.ReturnsRef { + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } io.WriteString(p.w, "&") + } else { + if nn.FunctionName.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } p.Print(nn.FunctionName) + p.printFreeFloating(nn, freefloating.Name) io.WriteString(p.w, "(") - p.joinPrint(", ", nn.Params) + p.joinPrint(",", nn.Params) + p.printFreeFloating(nn, freefloating.ParamList) io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.Params) if nn.ReturnType != nil { - io.WriteString(p.w, ": ") + io.WriteString(p.w, ":") p.Print(nn.ReturnType) } + p.printFreeFloating(nn, freefloating.ReturnType) - io.WriteString(p.w, " {\n") + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtGlobal(n node.Node) { nn := n.(*stmt.Global) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "global ") - p.joinPrint(", ", nn.Vars) - io.WriteString(p.w, ";") + io.WriteString(p.w, "global") + p.joinPrint(",", nn.Vars) + p.printFreeFloating(nn, freefloating.VarList) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtGoto(n node.Node) { nn := n.(*stmt.Goto) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "goto ") + io.WriteString(p.w, "goto") + if nn.Label.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Label) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.Label) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtGroupUse(n node.Node) { nn := n.(*stmt.GroupUse) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "use ") + io.WriteString(p.w, "use") + p.printFreeFloating(nn, freefloating.Use) if nn.UseType != nil { + if nn.UseType.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.UseType) - io.WriteString(p.w, " ") } + if nn.Prefix.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Prefix) - io.WriteString(p.w, "\\{") - p.joinPrint(", ", nn.UseList) - io.WriteString(p.w, "};") + io.WriteString(p.w, "\\") + p.printFreeFloating(nn, freefloating.Slash) + + io.WriteString(p.w, "{") + p.joinPrint(",", nn.UseList) + p.printFreeFloating(nn, freefloating.Stmts) + io.WriteString(p.w, "}") + p.printFreeFloating(nn, freefloating.UseDeclarationList) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtHaltCompiler(n node.Node) { - io.WriteString(p.w, "__halt_compiler();") + nn := n.(*stmt.HaltCompiler) + p.printFreeFloating(nn, freefloating.Start) + + io.WriteString(p.w, "__halt_compiler") + p.printFreeFloating(nn, freefloating.HaltCompiller) + io.WriteString(p.w, "(") + p.printFreeFloating(nn, freefloating.OpenParenthesisToken) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.CloseParenthesisToken) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtIf(n node.Node) { nn := n.(*stmt.If) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "if (") + io.WriteString(p.w, "if") + p.printFreeFloating(n, freefloating.If) + io.WriteString(p.w, "(") p.Print(nn.Cond) + p.printFreeFloating(n, freefloating.Expr) io.WriteString(p.w, ")") - switch s := nn.Stmt.(type) { - case *stmt.Nop: - p.Print(s) - break - case *stmt.StmtList: - io.WriteString(p.w, " ") - p.Print(s) - default: - io.WriteString(p.w, "\n") - p.indentDepth++ - p.printIndent() - p.Print(s) - p.indentDepth-- - } + p.Print(nn.Stmt) if nn.ElseIf != nil { - io.WriteString(p.w, "\n") - p.indentDepth-- p.printNodes(nn.ElseIf) - p.indentDepth++ } if nn.Else != nil { - io.WriteString(p.w, "\n") - p.printIndent() p.Print(nn.Else) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtInlineHTML(n node.Node) { nn := n.(*stmt.InlineHtml) + p.printFreeFloating(nn, freefloating.Start) + + if p.s == PhpState && nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, "?>") + } + p.SetState(HtmlState) - io.WriteString(p.w, "?>") io.WriteString(p.w, nn.Value) - io.WriteString(p.w, " 0 && m.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.Print(m) + } + + if nn.Properties[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + + p.joinPrint(",", nn.Properties) + p.printFreeFloating(n, freefloating.PropertyList) + + p.printFreeFloating(n, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtProperty(n node.Node) { nn := n.(*stmt.Property) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Variable) if nn.Expr != nil { - io.WriteString(p.w, " = ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "=") p.Print(nn.Expr) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtReturn(n node.Node) { nn := n.(*stmt.Return) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "return ") + io.WriteString(p.w, "return") + if nn.Expr != nil && nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.Expr) + + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtStaticVar(n node.Node) { nn := n.(*stmt.StaticVar) + p.printFreeFloating(nn, freefloating.Start) + p.Print(nn.Variable) if nn.Expr != nil { - io.WriteString(p.w, " = ") + p.printFreeFloating(nn, freefloating.Var) + io.WriteString(p.w, "=") p.Print(nn.Expr) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtStatic(n node.Node) { nn := n.(*stmt.Static) + p.printFreeFloating(nn, freefloating.Start) + io.WriteString(p.w, "static") - io.WriteString(p.w, "static ") - p.joinPrint(", ", nn.Vars) - io.WriteString(p.w, ";") + p.joinPrint(",", nn.Vars) + p.printFreeFloating(nn, freefloating.VarList) + + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtStmtList(n node.Node) { nn := n.(*stmt.StmtList) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "{\n") + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtSwitch(n node.Node) { nn := n.(*stmt.Switch) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "switch (") + io.WriteString(p.w, "switch") + p.printFreeFloating(nn, freefloating.Switch) + io.WriteString(p.w, "(") p.Print(nn.Cond) + p.printFreeFloating(nn, freefloating.Expr) io.WriteString(p.w, ")") - io.WriteString(p.w, " {\n") + p.printFreeFloating(nn.CaseList, freefloating.Start) + io.WriteString(p.w, "{") + p.printFreeFloating(nn.CaseList, freefloating.CaseListStart) p.printNodes(nn.CaseList.Cases) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn.CaseList, freefloating.CaseListEnd) io.WriteString(p.w, "}") + p.printFreeFloating(nn.CaseList, freefloating.End) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtThrow(n node.Node) { nn := n.(*stmt.Throw) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "throw ") + io.WriteString(p.w, "throw") + if nn.Expr.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Expr) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.Expr) + + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) +} + +func (p *Printer) printStmtTraitAdaptationList(n node.Node) { + nn := n.(*stmt.TraitAdaptationList) + p.printFreeFloating(nn, freefloating.Start) + + io.WriteString(p.w, "{") + p.printNodes(nn.Adaptations) + p.printFreeFloating(nn, freefloating.AdaptationList) + io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTraitMethodRef(n node.Node) { nn := n.(*stmt.TraitMethodRef) + p.printFreeFloating(nn, freefloating.Start) + + if nn.Trait != nil { + p.Print(nn.Trait) + p.printFreeFloating(nn, freefloating.Name) + io.WriteString(p.w, "::") + } - p.Print(nn.Trait) - io.WriteString(p.w, "::") p.Print(nn.Method) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTraitUseAlias(n node.Node) { nn := n.(*stmt.TraitUseAlias) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Ref) - io.WriteString(p.w, " as") + p.printFreeFloating(nn, freefloating.Ref) + + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "as") if nn.Modifier != nil { - io.WriteString(p.w, " ") + if nn.Modifier.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Modifier) } if nn.Alias != nil { - io.WriteString(p.w, " ") + if nn.Alias.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Alias) } + p.printFreeFloating(nn, freefloating.Alias) - io.WriteString(p.w, ";") + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTraitUsePrecedence(n node.Node) { nn := n.(*stmt.TraitUsePrecedence) + p.printFreeFloating(nn, freefloating.Start) p.Print(nn.Ref) - io.WriteString(p.w, " insteadof ") - p.joinPrint(", ", nn.Insteadof) + p.printFreeFloating(nn, freefloating.Ref) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } - io.WriteString(p.w, ";") + io.WriteString(p.w, "insteadof") + if nn.Insteadof[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.joinPrint(",", nn.Insteadof) + p.printFreeFloating(nn, freefloating.NameList) + + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTraitUse(n node.Node) { nn := n.(*stmt.TraitUse) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "use ") - p.joinPrint(", ", nn.Traits) - - if nn.TraitAdaptationList != nil { - adaptations := nn.TraitAdaptationList.Adaptations - io.WriteString(p.w, " {\n") - p.printNodes(adaptations) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "}") - } else { - io.WriteString(p.w, ";") + io.WriteString(p.w, "use") + if nn.Traits[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") } + p.joinPrint(",", nn.Traits) + + p.Print(nn.TraitAdaptationList) + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTrait(n node.Node) { nn := n.(*stmt.Trait) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "trait ") + io.WriteString(p.w, "trait") + if nn.TraitName.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.TraitName) - io.WriteString(p.w, "\n") - p.printIndent() - io.WriteString(p.w, "{\n") + p.printFreeFloating(nn, freefloating.Name) + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtTry(n node.Node) { nn := n.(*stmt.Try) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "try {\n") + io.WriteString(p.w, "try") + p.printFreeFloating(nn, freefloating.Try) + io.WriteString(p.w, "{") p.printNodes(nn.Stmts) - io.WriteString(p.w, "\n") - p.printIndent() + p.printFreeFloating(nn, freefloating.Stmts) io.WriteString(p.w, "}") if nn.Catches != nil { - io.WriteString(p.w, "\n") - p.indentDepth-- p.printNodes(nn.Catches) - p.indentDepth++ } if nn.Finally != nil { - io.WriteString(p.w, "\n") - p.printIndent() p.Print(nn.Finally) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtUnset(n node.Node) { nn := n.(*stmt.Unset) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "unset(") - p.joinPrint(", ", nn.Vars) - io.WriteString(p.w, ");") + io.WriteString(p.w, "unset") + p.printFreeFloating(nn, freefloating.Unset) + io.WriteString(p.w, "(") + p.joinPrint(",", nn.Vars) + p.printFreeFloating(nn, freefloating.VarList) + io.WriteString(p.w, ")") + p.printFreeFloating(nn, freefloating.CloseParenthesisToken) + + p.printFreeFloating(nn, freefloating.SemiColon) + if n.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtUseList(n node.Node) { nn := n.(*stmt.UseList) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "use ") + io.WriteString(p.w, "use") if nn.UseType != nil { + if nn.UseType.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.UseType) - io.WriteString(p.w, " ") } - p.joinPrint(", ", nn.Uses) - io.WriteString(p.w, ";") + if nn.Uses[0].GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + p.joinPrint(",", nn.Uses) + p.printFreeFloating(nn, freefloating.UseDeclarationList) + + p.printFreeFloating(nn, freefloating.SemiColon) + if nn.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, ";") + } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtUse(n node.Node) { nn := n.(*stmt.Use) + p.printFreeFloating(nn, freefloating.Start) if nn.UseType != nil { p.Print(nn.UseType) - io.WriteString(p.w, " ") + if nn.UseType.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } } + p.printFreeFloating(nn, freefloating.Slash) + p.Print(nn.Use) if nn.Alias != nil { - io.WriteString(p.w, " as ") + if nn.Alias.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } + io.WriteString(p.w, "as") + if nn.Alias.GetFreeFloating().IsEmpty() { + io.WriteString(p.w, " ") + } p.Print(nn.Alias) } + + p.printFreeFloating(nn, freefloating.End) } func (p *Printer) printStmtWhile(n node.Node) { nn := n.(*stmt.While) + p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "while (") + io.WriteString(p.w, "while") + p.printFreeFloating(nn, freefloating.While) + io.WriteString(p.w, "(") p.Print(nn.Cond) + p.printFreeFloating(nn, freefloating.Expr) io.WriteString(p.w, ")") - switch s := nn.Stmt.(type) { - case *stmt.Nop: - p.Print(s) - break - case *stmt.StmtList: - io.WriteString(p.w, " ") - p.Print(s) - default: - io.WriteString(p.w, "\n") - p.indentDepth++ - p.printIndent() - p.Print(s) - p.indentDepth-- - } + p.Print(nn.Stmt) + + p.printFreeFloating(nn, freefloating.End) } diff --git a/printer/printer_parsed_php5_test.go b/printer/printer_parsed_php5_test.go new file mode 100644 index 0000000..a860ee2 --- /dev/null +++ b/printer/printer_parsed_php5_test.go @@ -0,0 +1,1419 @@ +package printer_test + +import ( + "bytes" + "testing" + + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/php5" + "github.com/z7zmey/php-parser/printer" +) + +func parsePhp5(src string) node.Node { + php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") + php5parser.WithFreeFloating() + php5parser.Parse() + + return php5parser.GetRootNode() +} + +func printPhp5(n node.Node) string { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) + p.Print(n) + + return o.String() +} + +// test node + +func TestParseAndPrintPhp5Root(t *testing.T) { + + src := `
Hello
+ >= $b ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test binary + +func TestParseAndPrintPhp5Binary(t *testing.T) { + src := `= $b ; + $a > $b ; + $a === $b ; + $a and $b ; + $a or $b ; + $a xor $b ; + $a - $b ; + $a % $b ; + $a * $b ; + $a != $b ; + $a <> $b ; + $a !== $b ; + $a + $b ; + $a ** $b ; + $a << $b ; + $a >> $b ; + $a <= $b ; + $a < $b ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test cast + +func TestParseAndPrintPhp5Cast(t *testing.T) { + src := ` $world , + ] ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5Array(t *testing.T) { + src := ` 2 ) ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5BitwiseNot(t *testing.T) { + src := ` bar ( $arg ) ;` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5New(t *testing.T) { + src := ` b ;` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5Reference(t *testing.T) { + src := ` & $c ] ; + + $a = function ( ) use ( & $b ) { + // do nothing + } ; + + foreach ( $a as & $b ) { + // do nothing + }` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5Require(t *testing.T) { + + src := ` & $b , // one + $c , /* two */ + ] ; + $a = [0, 1, 2] ;` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5StaticCall(t *testing.T) { + src := ` $v ;` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test stmt + +func TestParseAndPrintPhp5AltIf(t *testing.T) { + src := ` & $v ) : + echo $v ; + endforeach ;` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5AltSwitch(t *testing.T) { + src := ` + + + & $v ) { + ; + }` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5Function(t *testing.T) { + + src := `test call ( ) ; + $a -> { $b . 'b' } ; + $a -> $b ( ) -> { $c . 'c' } ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5ComplexString1(t *testing.T) { + src := `bar" ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5ComplexString2(t *testing.T) { + src := ` bar }" ; + "test ${ $foo -> bar ( ) }" ; + "test ${ $a . '' }" ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5ComplexString3(t *testing.T) { + src := ` bar }" ; + "test ${$foo -> bar ( ) }" ; + "test ${$a . '' }" ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintPhp5ComplexString4(t *testing.T) { + src := ` bar }" ; + "test {$foo -> bar ( ) }" ; + ` + + actual := printPhp5(parsePhp5(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} diff --git a/printer/printer_parsed_php7_test.go b/printer/printer_parsed_php7_test.go new file mode 100644 index 0000000..7585e2c --- /dev/null +++ b/printer/printer_parsed_php7_test.go @@ -0,0 +1,1535 @@ +package printer_test + +import ( + "bytes" + "os" + "testing" + + "github.com/z7zmey/php-parser/node" + "github.com/z7zmey/php-parser/node/name" + "github.com/z7zmey/php-parser/node/stmt" + "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/printer" +) + +func ExamplePrinter() { + src := `Hello + >= $b ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test binary + +func TestParseAndPrintBinary(t *testing.T) { + src := `= $b ; + $a > $b ; + $a === $b ; + $a and $b ; + $a or $b ; + $a xor $b ; + $a - $b ; + $a % $b ; + $a * $b ; + $a != $b ; + $a <> $b ; + $a !== $b ; + $a + $b ; + $a ** $b ; + $a << $b ; + $a >> $b ; + $a <= $b ; + $a < $b ; + $a <=> $b ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test cast + +func TestParseAndPrintCast(t *testing.T) { + src := ` $world , + ] ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintArray(t *testing.T) { + src := ` 2 ) ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintBitwiseNot(t *testing.T) { + src := ` bar ( $arg , ) ;` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintNew(t *testing.T) { + src := ` b ;` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintReference(t *testing.T) { + src := ` & $c ] ; + + $a = function ( ) use ( & $b ) { + // do nothing + } ; + + foreach ( $a as & $b ) { + // do nothing + }` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintRequire(t *testing.T) { + + src := ` & $b , // one + $c , /* two */ + ] ; + $a = [0, 1, 2] ;` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintShortList(t *testing.T) { + src := ` $v ; + yield from $a ;` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +// test stmt + +func TestParseAndPrintAltIf(t *testing.T) { + src := ` & $v ) : + echo $v ; + endforeach ;` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintAltSwitch(t *testing.T) { + src := ` + + + & $v ) { + ; + }` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintFunction(t *testing.T) { + + src := `test call ( ) ; + $a -> { $b . 'b' } ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintComplexString1(t *testing.T) { + src := `bar" ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintComplexString2(t *testing.T) { + src := ` bar }" ; + "test ${ $foo -> bar ( ) }" ; + "test ${ $a . '' }" ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintComplexString3(t *testing.T) { + src := ` bar }" ; + "test ${$foo -> bar ( ) }" ; + "test ${$a . '' }" ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} + +func TestParseAndPrintComplexString4(t *testing.T) { + src := ` bar }" ; + "test {$foo -> bar ( ) }" ; + ` + + actual := print(parse(src)) + + if src != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", src, actual) + } +} diff --git a/printer/printer_test.go b/printer/printer_test.go index 900dadb..3d45894 100644 --- a/printer/printer_test.go +++ b/printer/printer_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/assign" @@ -15,10 +16,10 @@ import ( "github.com/z7zmey/php-parser/printer" ) -func TestPrintFile(t *testing.T) { +func TestPrinterPrintFile(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, "\t") + p := printer.NewPrinter(o) p.Print(&node.Root{ Stmts: []node.Node{ &stmt.Namespace{ @@ -61,16 +62,7 @@ func TestPrintFile(t *testing.T) { }, }) - expected := `HTML"}, &stmt.Expression{ - Expr: &scalar.Heredoc{ - Label: "\"LBL\"", - Parts: []node.Node{ - &scalar.EncapsedStringPart{Value: "hello world\n"}, + Expr: &expr.Variable{ + FreeFloating: freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.TokenType, + Value: "$", + }, + }, + }, + VarName: &node.Identifier{ + Value: "a", + }, + }, + }, + &stmt.InlineHtml{Value: "
HTML
"}, + &stmt.Expression{ + Expr: &expr.Variable{ + FreeFloating: freefloating.Collection{ + freefloating.Start: []freefloating.String{ + { + StringType: freefloating.TokenType, + Value: "$", + }, + }, + }, + VarName: &node.Identifier{ + Value: "a", }, }, }, }, }) - expected := `
HTML
HTML
HTML
>= $b` + expected := `$a>>=$b` actual := o.String() if expected != actual { @@ -648,16 +777,20 @@ func TestPrintAssignShiftRight(t *testing.T) { // binary -func TestPrintBinaryBitwiseAnd(t *testing.T) { +func TestPrinterPrintBinaryBitwiseAnd(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.BitwiseAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a & $b` + expected := `$a&$b` actual := o.String() if expected != actual { @@ -665,16 +798,20 @@ func TestPrintBinaryBitwiseAnd(t *testing.T) { } } -func TestPrintBinaryBitwiseOr(t *testing.T) { +func TestPrinterPrintBinaryBitwiseOr(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.BitwiseOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a | $b` + expected := `$a|$b` actual := o.String() if expected != actual { @@ -682,16 +819,20 @@ func TestPrintBinaryBitwiseOr(t *testing.T) { } } -func TestPrintBinaryBitwiseXor(t *testing.T) { +func TestPrinterPrintBinaryBitwiseXor(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.BitwiseXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a ^ $b` + expected := `$a^$b` actual := o.String() if expected != actual { @@ -699,16 +840,20 @@ func TestPrintBinaryBitwiseXor(t *testing.T) { } } -func TestPrintBinaryBooleanAnd(t *testing.T) { +func TestPrinterPrintBinaryBooleanAnd(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.BooleanAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a && $b` + expected := `$a&&$b` actual := o.String() if expected != actual { @@ -716,16 +861,20 @@ func TestPrintBinaryBooleanAnd(t *testing.T) { } } -func TestPrintBinaryBooleanOr(t *testing.T) { +func TestPrinterPrintBinaryBooleanOr(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.BooleanOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a || $b` + expected := `$a||$b` actual := o.String() if expected != actual { @@ -733,16 +882,20 @@ func TestPrintBinaryBooleanOr(t *testing.T) { } } -func TestPrintBinaryCoalesce(t *testing.T) { +func TestPrinterPrintBinaryCoalesce(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Coalesce{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a ?? $b` + expected := `$a??$b` actual := o.String() if expected != actual { @@ -750,16 +903,20 @@ func TestPrintBinaryCoalesce(t *testing.T) { } } -func TestPrintBinaryConcat(t *testing.T) { +func TestPrinterPrintBinaryConcat(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Concat{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a . $b` + expected := `$a.$b` actual := o.String() if expected != actual { @@ -767,16 +924,20 @@ func TestPrintBinaryConcat(t *testing.T) { } } -func TestPrintBinaryDiv(t *testing.T) { +func TestPrinterPrintBinaryDiv(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Div{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a / $b` + expected := `$a/$b` actual := o.String() if expected != actual { @@ -784,16 +945,20 @@ func TestPrintBinaryDiv(t *testing.T) { } } -func TestPrintBinaryEqual(t *testing.T) { +func TestPrinterPrintBinaryEqual(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Equal{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a == $b` + expected := `$a==$b` actual := o.String() if expected != actual { @@ -801,16 +966,20 @@ func TestPrintBinaryEqual(t *testing.T) { } } -func TestPrintBinaryGreaterOrEqual(t *testing.T) { +func TestPrinterPrintBinaryGreaterOrEqual(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.GreaterOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a >= $b` + expected := `$a>=$b` actual := o.String() if expected != actual { @@ -818,16 +987,20 @@ func TestPrintBinaryGreaterOrEqual(t *testing.T) { } } -func TestPrintBinaryGreater(t *testing.T) { +func TestPrinterPrintBinaryGreater(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Greater{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a > $b` + expected := `$a>$b` actual := o.String() if expected != actual { @@ -835,16 +1008,20 @@ func TestPrintBinaryGreater(t *testing.T) { } } -func TestPrintBinaryIdentical(t *testing.T) { +func TestPrinterPrintBinaryIdentical(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Identical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a === $b` + expected := `$a===$b` actual := o.String() if expected != actual { @@ -852,13 +1029,17 @@ func TestPrintBinaryIdentical(t *testing.T) { } } -func TestPrintBinaryLogicalAnd(t *testing.T) { +func TestPrinterPrintBinaryLogicalAnd(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.LogicalAnd{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) expected := `$a and $b` @@ -869,13 +1050,17 @@ func TestPrintBinaryLogicalAnd(t *testing.T) { } } -func TestPrintBinaryLogicalOr(t *testing.T) { +func TestPrinterPrintBinaryLogicalOr(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.LogicalOr{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) expected := `$a or $b` @@ -886,13 +1071,17 @@ func TestPrintBinaryLogicalOr(t *testing.T) { } } -func TestPrintBinaryLogicalXor(t *testing.T) { +func TestPrinterPrintBinaryLogicalXor(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.LogicalXor{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) expected := `$a xor $b` @@ -903,16 +1092,20 @@ func TestPrintBinaryLogicalXor(t *testing.T) { } } -func TestPrintBinaryMinus(t *testing.T) { +func TestPrinterPrintBinaryMinus(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Minus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a - $b` + expected := `$a-$b` actual := o.String() if expected != actual { @@ -920,16 +1113,20 @@ func TestPrintBinaryMinus(t *testing.T) { } } -func TestPrintBinaryMod(t *testing.T) { +func TestPrinterPrintBinaryMod(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Mod{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a % $b` + expected := `$a%$b` actual := o.String() if expected != actual { @@ -937,16 +1134,20 @@ func TestPrintBinaryMod(t *testing.T) { } } -func TestPrintBinaryMul(t *testing.T) { +func TestPrinterPrintBinaryMul(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Mul{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a * $b` + expected := `$a*$b` actual := o.String() if expected != actual { @@ -954,16 +1155,20 @@ func TestPrintBinaryMul(t *testing.T) { } } -func TestPrintBinaryNotEqual(t *testing.T) { +func TestPrinterPrintBinaryNotEqual(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.NotEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a != $b` + expected := `$a!=$b` actual := o.String() if expected != actual { @@ -971,16 +1176,20 @@ func TestPrintBinaryNotEqual(t *testing.T) { } } -func TestPrintBinaryNotIdentical(t *testing.T) { +func TestPrinterPrintBinaryNotIdentical(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.NotIdentical{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a !== $b` + expected := `$a!==$b` actual := o.String() if expected != actual { @@ -988,16 +1197,20 @@ func TestPrintBinaryNotIdentical(t *testing.T) { } } -func TestPrintBinaryPlus(t *testing.T) { +func TestPrinterPrintBinaryPlus(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Plus{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a + $b` + expected := `$a+$b` actual := o.String() if expected != actual { @@ -1005,16 +1218,20 @@ func TestPrintBinaryPlus(t *testing.T) { } } -func TestPrintBinaryPow(t *testing.T) { +func TestPrinterPrintBinaryPow(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Pow{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a ** $b` + expected := `$a**$b` actual := o.String() if expected != actual { @@ -1022,16 +1239,20 @@ func TestPrintBinaryPow(t *testing.T) { } } -func TestPrintBinaryShiftLeft(t *testing.T) { +func TestPrinterPrintBinaryShiftLeft(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.ShiftLeft{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a << $b` + expected := `$a<<$b` actual := o.String() if expected != actual { @@ -1039,16 +1260,20 @@ func TestPrintBinaryShiftLeft(t *testing.T) { } } -func TestPrintBinaryShiftRight(t *testing.T) { +func TestPrinterPrintBinaryShiftRight(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.ShiftRight{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a >> $b` + expected := `$a>>$b` actual := o.String() if expected != actual { @@ -1056,16 +1281,20 @@ func TestPrintBinaryShiftRight(t *testing.T) { } } -func TestPrintBinarySmallerOrEqual(t *testing.T) { +func TestPrinterPrintBinarySmallerOrEqual(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.SmallerOrEqual{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a <= $b` + expected := `$a<=$b` actual := o.String() if expected != actual { @@ -1073,16 +1302,20 @@ func TestPrintBinarySmallerOrEqual(t *testing.T) { } } -func TestPrintBinarySmaller(t *testing.T) { +func TestPrinterPrintBinarySmaller(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Smaller{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a < $b` + expected := `$a<$b` actual := o.String() if expected != actual { @@ -1090,16 +1323,20 @@ func TestPrintBinarySmaller(t *testing.T) { } } -func TestPrintBinarySpaceship(t *testing.T) { +func TestPrinterPrintBinarySpaceship(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&binary.Spaceship{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Left: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Right: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a <=> $b` + expected := `$a<=>$b` actual := o.String() if expected != actual { @@ -1109,12 +1346,14 @@ func TestPrintBinarySpaceship(t *testing.T) { // cast -func TestPrintArray(t *testing.T) { +func TestPrinterPrintArray(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Array{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `(array)$var` @@ -1125,15 +1364,17 @@ func TestPrintArray(t *testing.T) { } } -func TestPrintBool(t *testing.T) { +func TestPrinterPrintBool(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Bool{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) - expected := `(bool)$var` + expected := `(boolean)$var` actual := o.String() if expected != actual { @@ -1141,12 +1382,14 @@ func TestPrintBool(t *testing.T) { } } -func TestPrintDouble(t *testing.T) { +func TestPrinterPrintDouble(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Double{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `(float)$var` @@ -1157,15 +1400,17 @@ func TestPrintDouble(t *testing.T) { } } -func TestPrintInt(t *testing.T) { +func TestPrinterPrintInt(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Int{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) - expected := `(int)$var` + expected := `(integer)$var` actual := o.String() if expected != actual { @@ -1173,12 +1418,14 @@ func TestPrintInt(t *testing.T) { } } -func TestPrintObject(t *testing.T) { +func TestPrinterPrintObject(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Object{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `(object)$var` @@ -1189,12 +1436,14 @@ func TestPrintObject(t *testing.T) { } } -func TestPrintString(t *testing.T) { +func TestPrinterPrintString(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.String{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `(string)$var` @@ -1205,12 +1454,14 @@ func TestPrintString(t *testing.T) { } } -func TestPrintUnset(t *testing.T) { +func TestPrinterPrintUnset(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&cast.Unset{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `(unset)$var` @@ -1223,13 +1474,15 @@ func TestPrintUnset(t *testing.T) { // expr -func TestPrintExprArrayDimFetch(t *testing.T) { +func TestPrinterPrintExprArrayDimFetch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ArrayDimFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - Dim: &scalar.Lnumber{Value: "1"}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + Dim: &scalar.Lnumber{Value: "1"}, }) expected := `$var[1]` @@ -1240,16 +1493,18 @@ func TestPrintExprArrayDimFetch(t *testing.T) { } } -func TestPrintExprArrayItemWithKey(t *testing.T) { +func TestPrinterPrintExprArrayItemWithKey(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ArrayItem{ Key: &scalar.String{Value: "'Hello'"}, - Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "world"}, + }, }) - expected := `'Hello' => $world` + expected := `'Hello'=>$world` actual := o.String() if expected != actual { @@ -1257,12 +1512,14 @@ func TestPrintExprArrayItemWithKey(t *testing.T) { } } -func TestPrintExprArrayItem(t *testing.T) { +func TestPrinterPrintExprArrayItem(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ArrayItem{ - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "world"}}}, + Val: &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "world"}, + }}, }) expected := `&$world` @@ -1273,27 +1530,33 @@ func TestPrintExprArrayItem(t *testing.T) { } } -func TestPrintExprArray(t *testing.T) { +func TestPrinterPrintExprArray(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Array{ Items: []node.Node{ &expr.ArrayItem{ Key: &scalar.String{Value: "'Hello'"}, - Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "world"}, + }, }, &expr.ArrayItem{ Key: &scalar.Lnumber{Value: "2"}, - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}, + Val: &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }}, }, &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }, }, }) - expected := `array('Hello' => $world, 2 => &$var, $var)` + expected := `array('Hello'=>$world,2=>&$var,$var)` actual := o.String() if expected != actual { @@ -1301,12 +1564,14 @@ func TestPrintExprArray(t *testing.T) { } } -func TestPrintExprBitwiseNot(t *testing.T) { +func TestPrinterPrintExprBitwiseNot(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.BitwiseNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `~$var` @@ -1317,12 +1582,14 @@ func TestPrintExprBitwiseNot(t *testing.T) { } } -func TestPrintExprBooleanNot(t *testing.T) { +func TestPrinterPrintExprBooleanNot(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.BooleanNot{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `!$var` @@ -1333,13 +1600,17 @@ func TestPrintExprBooleanNot(t *testing.T) { } } -func TestPrintExprClassConstFetch(t *testing.T) { +func TestPrinterPrintExprClassConstFetch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ClassConstFetch{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - ConstantName: &node.Identifier{Value: "CONST"}, + Class: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + ConstantName: &node.Identifier{ + Value: "CONST", + }, }) expected := `$var::CONST` @@ -1350,12 +1621,14 @@ func TestPrintExprClassConstFetch(t *testing.T) { } } -func TestPrintExprClone(t *testing.T) { +func TestPrinterPrintExprClone(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Clone{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `clone $var` @@ -1366,60 +1639,22 @@ func TestPrintExprClone(t *testing.T) { } } -func TestPrintExprClosureUse(t *testing.T) { +func TestPrinterPrintExprClosureUse(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ClosureUse{ Uses: []node.Node{ - &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}}, - &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, - }, - }) - - expected := `use (&$foo, $bar)` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintExprClosure(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &expr.Closure{ - Static: true, - ReturnsRef: true, - Params: []node.Node{ - &node.Parameter{ - ByRef: true, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - }, - }, - ClosureUse: &expr.ClosureUse{ - Uses: []node.Node{ - &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - ReturnType: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - }, + &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "foo"}, + }}, + &expr.Variable{ + VarName: &node.Identifier{Value: "bar"}, }, }, }) - expected := `namespace { - static function &(&$var) use (&$a, $b): \Foo { - $a; - } -}` + expected := `use(&$foo,$bar)` actual := o.String() if expected != actual { @@ -1427,10 +1662,54 @@ func TestPrintExprClosure(t *testing.T) { } } -func TestPrintExprConstFetch(t *testing.T) { +func TestPrinterPrintExprClosure(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) + p.Print(&expr.Closure{ + Static: true, + ReturnsRef: true, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + Variadic: false, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }, + }, + ClosureUse: &expr.ClosureUse{ + Uses: []node.Node{ + &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, + &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, + }, + }, + ReturnType: &name.FullyQualified{ + Parts: []node.Node{&name.NamePart{Value: "Foo"}}, + }, + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, + }, + }) + + expected := `static function&(&$var)use(&$a,$b):\Foo{$a;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) p.Print(&expr.ConstFetch{ Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}, }) @@ -1443,25 +1722,15 @@ func TestPrintExprConstFetch(t *testing.T) { } } -func TestPrintDie(t *testing.T) { +func TestPrinterPrintEmpty(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Die{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) - - expected := `die($var)` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&expr.Empty{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.Empty{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) expected := `empty($var)` actual := o.String() @@ -1471,11 +1740,15 @@ func TestPrintEmpty(t *testing.T) { } } -func TestPrintErrorSuppress(t *testing.T) { +func TestPrinterPrettyPrinterrorSuppress(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.ErrorSuppress{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.ErrorSuppress{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) expected := `@$var` actual := o.String() @@ -1485,11 +1758,15 @@ func TestPrintErrorSuppress(t *testing.T) { } } -func TestPrintEval(t *testing.T) { +func TestPrinterPrintEval(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Eval{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.Eval{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) expected := `eval($var)` actual := o.String() @@ -1499,13 +1776,18 @@ func TestPrintEval(t *testing.T) { } } -func TestPrintExit(t *testing.T) { +func TestPrinterPrintExit(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Exit{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.Exit{ + Die: false, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) - expected := `exit($var)` + expected := `exit $var` actual := o.String() if expected != actual { @@ -1513,30 +1795,57 @@ func TestPrintExit(t *testing.T) { } } -func TestPrintFunctionCall(t *testing.T) { +func TestPrinterPrintDie(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) + p.Print(&expr.Exit{ + Die: true, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) + + expected := `die $var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintFunctionCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) p.Print(&expr.FunctionCall{ - Function: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Function: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, ArgumentList: &node.ArgumentList{ Arguments: []node.Node{ &node.Argument{ IsReference: true, - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &node.Argument{ Variadic: true, - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, }, }, }, }) - expected := `$var(&$a, ...$b, $c)` + expected := `$var(&$a,...$b,$c)` actual := o.String() if expected != actual { @@ -1544,11 +1853,13 @@ func TestPrintFunctionCall(t *testing.T) { } } -func TestPrintInclude(t *testing.T) { +func TestPrinterPrintInclude(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Include{Expr: &scalar.String{Value: "'path'"}}) + p := printer.NewPrinter(o) + p.Print(&expr.Include{ + Expr: &scalar.String{Value: "'path'"}, + }) expected := `include 'path'` actual := o.String() @@ -1558,11 +1869,13 @@ func TestPrintInclude(t *testing.T) { } } -func TestPrintIncludeOnce(t *testing.T) { +func TestPrinterPrintIncludeOnce(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.IncludeOnce{Expr: &scalar.String{Value: "'path'"}}) + p := printer.NewPrinter(o) + p.Print(&expr.IncludeOnce{ + Expr: &scalar.String{Value: "'path'"}, + }) expected := `include_once 'path'` actual := o.String() @@ -1572,12 +1885,14 @@ func TestPrintIncludeOnce(t *testing.T) { } } -func TestPrintInstanceOf(t *testing.T) { +func TestPrinterPrintInstanceOf(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, }) @@ -1589,18 +1904,22 @@ func TestPrintInstanceOf(t *testing.T) { } } -func TestPrintIsset(t *testing.T) { +func TestPrinterPrintIsset(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Isset{ Variables: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }) - expected := `isset($a, $b)` + expected := `isset($a,$b)` actual := o.String() if expected != actual { @@ -1608,23 +1927,29 @@ func TestPrintIsset(t *testing.T) { } } -func TestPrintList(t *testing.T) { +func TestPrinterPrintList(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.List{ Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &expr.ArrayItem{ Val: &expr.List{ Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, }, }, }, @@ -1632,7 +1957,7 @@ func TestPrintList(t *testing.T) { }, }) - expected := `list($a, list($b, $c))` + expected := `list($a,list($b,$c))` actual := o.String() if expected != actual { @@ -1640,26 +1965,32 @@ func TestPrintList(t *testing.T) { } } -func TestPrintMethodCall(t *testing.T) { +func TestPrinterPrintMethodCall(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Method: &node.Identifier{Value: "bar"}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "foo"}, + }, + Method: &node.Identifier{Value: "bar"}, ArgumentList: &node.ArgumentList{ Arguments: []node.Node{ &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }, }, }) - expected := `$foo->bar($a, $b)` + expected := `$foo->bar($a,$b)` actual := o.String() if expected != actual { @@ -1667,25 +1998,35 @@ func TestPrintMethodCall(t *testing.T) { } } -func TestPrintNew(t *testing.T) { +func TestPrinterPrintNew(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.New{ - Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, + Class: &name.Name{ + Parts: []node.Node{ + &name.NamePart{ + Value: "Foo", + }, + }, + }, ArgumentList: &node.ArgumentList{ Arguments: []node.Node{ &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }, }, }) - expected := `new Foo($a, $b)` + expected := `new Foo($a,$b)` actual := o.String() if expected != actual { @@ -1693,12 +2034,14 @@ func TestPrintNew(t *testing.T) { } } -func TestPrintPostDec(t *testing.T) { +func TestPrinterPrintPostDec(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.PostDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `$var--` @@ -1709,12 +2052,14 @@ func TestPrintPostDec(t *testing.T) { } } -func TestPrintPostInc(t *testing.T) { +func TestPrinterPrintPostInc(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.PostInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `$var++` @@ -1725,12 +2070,14 @@ func TestPrintPostInc(t *testing.T) { } } -func TestPrintPreDec(t *testing.T) { +func TestPrinterPrintPreDec(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.PreDec{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `--$var` @@ -1741,12 +2088,14 @@ func TestPrintPreDec(t *testing.T) { } } -func TestPrintPreInc(t *testing.T) { +func TestPrinterPrintPreInc(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.PreInc{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `++$var` @@ -1757,13 +2106,17 @@ func TestPrintPreInc(t *testing.T) { } } -func TestPrintPrint(t *testing.T) { +func TestPrinterPrintPrint(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Print{Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.Print{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) - expected := `print($var)` + expected := `print $var` actual := o.String() if expected != actual { @@ -1771,12 +2124,14 @@ func TestPrintPrint(t *testing.T) { } } -func TestPrintPropertyFetch(t *testing.T) { +func TestPrinterPrintPropertyFetch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.PropertyFetch{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "foo"}, + }, Property: &node.Identifier{Value: "bar"}, }) @@ -1788,12 +2143,14 @@ func TestPrintPropertyFetch(t *testing.T) { } } -func TestPrintExprReference(t *testing.T) { +func TestPrinterPrintExprReference(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Reference{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "foo"}, + }, }) expected := `&$foo` @@ -1804,11 +2161,13 @@ func TestPrintExprReference(t *testing.T) { } } -func TestPrintRequire(t *testing.T) { +func TestPrinterPrintRequire(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Require{Expr: &scalar.String{Value: "'path'"}}) + p := printer.NewPrinter(o) + p.Print(&expr.Require{ + Expr: &scalar.String{Value: "'path'"}, + }) expected := `require 'path'` actual := o.String() @@ -1818,11 +2177,13 @@ func TestPrintRequire(t *testing.T) { } } -func TestPrintRequireOnce(t *testing.T) { +func TestPrinterPrintRequireOnce(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.RequireOnce{Expr: &scalar.String{Value: "'path'"}}) + p := printer.NewPrinter(o) + p.Print(&expr.RequireOnce{ + Expr: &scalar.String{Value: "'path'"}, + }) expected := `require_once 'path'` actual := o.String() @@ -1832,19 +2193,21 @@ func TestPrintRequireOnce(t *testing.T) { } } -func TestPrintShellExec(t *testing.T) { +func TestPrinterPrintShellExec(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ShellExec{ Parts: []node.Node{ &scalar.EncapsedStringPart{Value: "hello "}, - &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + &expr.Variable{ + VarName: &node.Identifier{Value: "world"}, + }, &scalar.EncapsedStringPart{Value: "!"}, }, }) - expected := "`hello {$world}!`" + expected := "`hello $world!`" actual := o.String() if expected != actual { @@ -1852,27 +2215,33 @@ func TestPrintShellExec(t *testing.T) { } } -func TestPrintExprShortArray(t *testing.T) { +func TestPrinterPrintExprShortArray(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ShortArray{ Items: []node.Node{ &expr.ArrayItem{ Key: &scalar.String{Value: "'Hello'"}, - Val: &expr.Variable{VarName: &node.Identifier{Value: "world"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "world"}, + }, }, &expr.ArrayItem{ Key: &scalar.Lnumber{Value: "2"}, - Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}, + Val: &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }}, }, &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }, }, }) - expected := `['Hello' => $world, 2 => &$var, $var]` + expected := `['Hello'=>$world,2=>&$var,$var]` actual := o.String() if expected != actual { @@ -1880,23 +2249,29 @@ func TestPrintExprShortArray(t *testing.T) { } } -func TestPrintShortList(t *testing.T) { +func TestPrinterPrintShortList(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.ShortList{ Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &expr.ArrayItem{ Val: &expr.List{ Items: []node.Node{ &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, &expr.ArrayItem{ - Val: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Val: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, }, }, }, @@ -1904,7 +2279,7 @@ func TestPrintShortList(t *testing.T) { }, }) - expected := `[$a, list($b, $c)]` + expected := `[$a,list($b,$c)]` actual := o.String() if expected != actual { @@ -1912,26 +2287,30 @@ func TestPrintShortList(t *testing.T) { } } -func TestPrintStaticCall(t *testing.T) { +func TestPrinterPrintStaticCall(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.StaticCall{ Class: &node.Identifier{Value: "Foo"}, Call: &node.Identifier{Value: "bar"}, ArgumentList: &node.ArgumentList{ Arguments: []node.Node{ &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, }, &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }, }, }) - expected := `Foo::bar($a, $b)` + expected := `Foo::bar($a,$b)` actual := o.String() if expected != actual { @@ -1939,13 +2318,15 @@ func TestPrintStaticCall(t *testing.T) { } } -func TestPrintStaticPropertyFetch(t *testing.T) { +func TestPrinterPrintStaticPropertyFetch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.StaticPropertyFetch{ - Class: &node.Identifier{Value: "Foo"}, - Property: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, + Class: &node.Identifier{Value: "Foo"}, + Property: &expr.Variable{ + VarName: &node.Identifier{Value: "bar"}, + }, }) expected := `Foo::$bar` @@ -1956,16 +2337,20 @@ func TestPrintStaticPropertyFetch(t *testing.T) { } } -func TestPrintTernary(t *testing.T) { +func TestPrinterPrintTernary(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Condition: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + IfFalse: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }) - expected := `$a ?: $b` + expected := `$a?:$b` actual := o.String() if expected != actual { @@ -1973,17 +2358,23 @@ func TestPrintTernary(t *testing.T) { } } -func TestPrintTernaryFull(t *testing.T) { +func TestPrinterPrintTernaryFull(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Ternary{ - Condition: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - IfTrue: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - IfFalse: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + Condition: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + IfTrue: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, + IfFalse: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, }) - expected := `$a ? $b : $c` + expected := `$a?$b:$c` actual := o.String() if expected != actual { @@ -1991,12 +2382,14 @@ func TestPrintTernaryFull(t *testing.T) { } } -func TestPrintUnaryMinus(t *testing.T) { +func TestPrinterPrintUnaryMinus(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.UnaryMinus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `-$var` @@ -2007,12 +2400,14 @@ func TestPrintUnaryMinus(t *testing.T) { } } -func TestPrintUnaryPlus(t *testing.T) { +func TestPrinterPrintUnaryPlus(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.UnaryPlus{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `+$var` @@ -2023,11 +2418,15 @@ func TestPrintUnaryPlus(t *testing.T) { } } -func TestPrintVariable(t *testing.T) { +func TestPrinterPrintVariable(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "var"}}}) + p := printer.NewPrinter(o) + p.Print(&expr.Variable{ + VarName: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }) expected := `$$var` actual := o.String() @@ -2037,12 +2436,14 @@ func TestPrintVariable(t *testing.T) { } } -func TestPrintYieldFrom(t *testing.T) { +func TestPrinterPrintYieldFrom(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.YieldFrom{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `yield from $var` @@ -2053,12 +2454,14 @@ func TestPrintYieldFrom(t *testing.T) { } } -func TestPrintYield(t *testing.T) { +func TestPrinterPrintYield(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Yield{ - Value: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Value: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) expected := `yield $var` @@ -2069,16 +2472,20 @@ func TestPrintYield(t *testing.T) { } } -func TestPrintYieldFull(t *testing.T) { +func TestPrinterPrintYieldFull(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&expr.Yield{ - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Value: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, + Key: &expr.Variable{ + VarName: &node.Identifier{Value: "k"}, + }, + Value: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, }) - expected := `yield $k => $var` + expected := `yield $k=>$var` actual := o.String() if expected != actual { @@ -2088,21 +2495,24 @@ func TestPrintYieldFull(t *testing.T) { // stmt -func TestPrintAltElseIf(t *testing.T) { +func TestPrinterPrintAltElseIf(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.AltElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, Stmt: &stmt.StmtList{ Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, }, }, }) - expected := `elseif ($a) : - $b;` + expected := `elseif($a):$b;` actual := o.String() if expected != actual { @@ -2110,16 +2520,18 @@ func TestPrintAltElseIf(t *testing.T) { } } -func TestPrintAltElseIfEmpty(t *testing.T) { +func TestPrinterPrintAltElseIfEmpty(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.AltElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, Stmt: &stmt.StmtList{}, }) - expected := `elseif ($a) :` + expected := `elseif($a):` actual := o.String() if expected != actual { @@ -2127,20 +2539,21 @@ func TestPrintAltElseIfEmpty(t *testing.T) { } } -func TestPrintAltElse(t *testing.T) { +func TestPrinterPrintAltElse(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.AltElse{ Stmt: &stmt.StmtList{ Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, }, }, }) - expected := `else : - $b;` + expected := `else:$b;` actual := o.String() if expected != actual { @@ -2148,15 +2561,15 @@ func TestPrintAltElse(t *testing.T) { } } -func TestPrintAltElseEmpty(t *testing.T) { +func TestPrinterPrintAltElseEmpty(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.AltElse{ Stmt: &stmt.StmtList{}, }) - expected := `else :` + expected := `else:` actual := o.String() if expected != actual { @@ -2164,36 +2577,121 @@ func TestPrintAltElseEmpty(t *testing.T) { } } -func TestPrintAltFor(t *testing.T) { +func TestPrinterPrintAltFor(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.AltFor{ - Init: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - Cond: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - Loop: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "c"}}, + p := printer.NewPrinter(o) + p.Print(&stmt.AltFor{ + Init: []node.Node{ + &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + }, + Cond: []node.Node{ + &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, + }, + Loop: []node.Node{ + &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "d"}, + }}, + }, + }, + }) + + expected := `for($a;$b;$c):$d;endfor;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltForeach(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) + p.Print(&stmt.AltForeach{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + Key: &expr.Variable{ + VarName: &node.Identifier{Value: "key"}, + }, + Variable: &expr.Reference{Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "val"}, + }}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "d"}, + }}, + }, + }, + }) + + expected := `foreach($var as $key=>&$val):$d;endforeach;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltIf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) + p.Print(&stmt.AltIf{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "d"}, + }}, + }, + }, + ElseIf: []node.Node{ + &stmt.AltElseIf{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, }, Stmt: &stmt.StmtList{ Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, }, }, }, + &stmt.AltElseIf{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, + Stmt: &stmt.StmtList{}, + }, + }, + Else: &stmt.AltElse{ + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, + }, + }, }, }) - expected := `namespace { - for ($a; $b; $c) : - $d; - endfor; -}` + expected := `if($a):$d;elseif($b):$b;elseif($c):else:$b;endif;` actual := o.String() if expected != actual { @@ -2201,85 +2699,37 @@ func TestPrintAltFor(t *testing.T) { } } -func TestPrintAltForeach(t *testing.T) { +func TestPrinterPrintStmtAltSwitch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.AltForeach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "key"}}, - Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "val"}}}, - Stmt: &stmt.StmtList{ + p := printer.NewPrinter(o) + p.Print(&stmt.AltSwitch{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + CaseList: &stmt.CaseList{ + Cases: []node.Node{ + &stmt.Case{ + Cond: &scalar.String{Value: "'a'"}, Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, }, }, - }, - }, - }) - - expected := `namespace { - foreach ($var as $key => &$val) : - $d; - endforeach; -}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintAltIf(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.AltIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Stmt: &stmt.StmtList{ + &stmt.Case{ + Cond: &scalar.String{Value: "'b'"}, Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}}, - }, - }, - ElseIf: []node.Node{ - &stmt.AltElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - }, - }, - &stmt.AltElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - Stmt: &stmt.StmtList{}, - }, - }, - Else: &stmt.AltElse{ - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, }, }, }, }, }) - expected := `namespace { - if ($a) : - $d; - elseif ($b) : - $b; - elseif ($c) : - else : - $b; - endif; -}` + expected := `switch($var):case 'a':$a;case 'b':$b;endswitch;` actual := o.String() if expected != actual { @@ -2287,42 +2737,24 @@ func TestPrintAltIf(t *testing.T) { } } -func TestPrintStmtAltSwitch(t *testing.T) { +func TestPrinterPrintAltWhile(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.AltSwitch{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - CaseList: &stmt.CaseList{ - Cases: []node.Node{ - &stmt.Case{ - Cond: &scalar.String{Value: "'a'"}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - }, - }, - &stmt.Case{ - Cond: &scalar.String{Value: "'b'"}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - }, - }, - }, + p := printer.NewPrinter(o) + p.Print(&stmt.AltWhile{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }}, }, }, }) - expected := `namespace { - switch ($var) : - case 'a': - $a; - case 'b': - $b; - endswitch; -}` + expected := `while($a):$b;endwhile;` actual := o.String() if expected != actual { @@ -2330,41 +2762,14 @@ func TestPrintStmtAltSwitch(t *testing.T) { } } -func TestPrintAltWhile(t *testing.T) { +func TestPrinterPrintStmtBreak(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.AltWhile{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, - }, - }, - }, - }, - }) - - expected := `namespace { - while ($a) : - $b; - endwhile; -}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintStmtBreak(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Break{ - Expr: &scalar.Lnumber{Value: "1"}, + Expr: &scalar.Lnumber{ + Value: "1", + }, }) expected := "break 1;" @@ -2375,19 +2780,22 @@ func TestPrintStmtBreak(t *testing.T) { } } -func TestPrintStmtCase(t *testing.T) { +func TestPrinterPrintStmtCase(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Case{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, }, }) - expected := `case $a: - $a;` + expected := `case $a:$a;` actual := o.String() if expected != actual { @@ -2395,12 +2803,14 @@ func TestPrintStmtCase(t *testing.T) { } } -func TestPrintStmtCaseEmpty(t *testing.T) { +func TestPrinterPrintStmtCaseEmpty(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Case{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, Stmts: []node.Node{}, }) @@ -2412,30 +2822,26 @@ func TestPrintStmtCaseEmpty(t *testing.T) { } } -func TestPrintStmtCatch(t *testing.T) { +func TestPrinterPrintStmtCatch(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ + p := printer.NewPrinter(o) + p.Print(&stmt.Catch{ + Types: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Exception"}}}, + &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "RuntimeException"}}}, + }, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "e"}, + }, Stmts: []node.Node{ - &stmt.Catch{ - Types: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Exception"}}}, - &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "RuntimeException"}}}, - }, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, - }, - }, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, }, }) - expected := `namespace { - catch (Exception | \RuntimeException $e) { - $a; - } -}` + expected := `catch(Exception|\RuntimeException$e){$a;}` actual := o.String() if expected != actual { @@ -2443,10 +2849,10 @@ func TestPrintStmtCatch(t *testing.T) { } } -func TestPrintStmtClassMethod(t *testing.T) { +func TestPrinterPrintStmtClassMethod(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.ClassMethod{ Modifiers: []node.Node{&node.Identifier{Value: "public"}}, ReturnsRef: true, @@ -2455,26 +2861,31 @@ func TestPrintStmtClassMethod(t *testing.T) { &node.Parameter{ ByRef: true, VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}}, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}}, }, &node.Parameter{ Variadic: true, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }, - ReturnType: &name.Name{Parts: []node.Node{&name.NamePart{Value: "void"}}}, + ReturnType: &name.Name{ + Parts: []node.Node{&name.NamePart{Value: "void"}}, + }, Stmt: &stmt.StmtList{ Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, }, }, }) - expected := `public function &foo(?int &$a = null, ...$b): void -{ - $a; -}` + expected := `public function &foo(?int&$a=null,...$b):void{$a;}` actual := o.String() if expected != actual { @@ -2482,45 +2893,80 @@ func TestPrintStmtClassMethod(t *testing.T) { } } -func TestPrintStmtClass(t *testing.T) { +func TestPrinterPrintStmtAbstractClassMethod(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ + p := printer.NewPrinter(o) + p.Print(&stmt.ClassMethod{ + Modifiers: []node.Node{ + &node.Identifier{Value: "public"}, + &node.Identifier{Value: "static"}, + }, + ReturnsRef: true, + MethodName: &node.Identifier{Value: "foo"}, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}}, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}}, + }, + &node.Parameter{ + Variadic: true, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, + }, + }, + ReturnType: &name.Name{ + Parts: []node.Node{&name.NamePart{Value: "void"}}, + }, + Stmt: &stmt.Nop{}, + }) + + expected := `public static function &foo(?int&$a=null,...$b):void;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtClass(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) + p.Print(&stmt.Class{ + Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, + ClassName: &node.Identifier{Value: "Foo"}, + Extends: &stmt.ClassExtends{ + ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + }, + Implements: &stmt.ClassImplements{ + InterfaceNames: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, + }, + }, Stmts: []node.Node{ - &stmt.Class{ - Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, - ClassName: &node.Identifier{Value: "Foo"}, - Extends: &stmt.ClassExtends{ - ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + &stmt.ClassConstList{ + Modifiers: []node.Node{ + &node.Identifier{Value: "public"}, + &node.Identifier{Value: "static"}, }, - Implements: &stmt.ClassImplements{ - InterfaceNames: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, - }, - }, - Stmts: []node.Node{ - &stmt.ClassConstList{ - Modifiers: []node.Node{&node.Identifier{Value: "public"}}, - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, }, }, }, }, }) - expected := `namespace { - abstract class Foo extends Bar implements Baz, Quuz - { - public const FOO = 'bar'; - } -}` + expected := `abstract class Foo extends Bar implements Baz,Quuz{public static const FOO='bar';}` actual := o.String() if expected != actual { @@ -2528,54 +2974,49 @@ func TestPrintStmtClass(t *testing.T) { } } -func TestPrintStmtAnonymousClass(t *testing.T) { +func TestPrinterPrintStmtAnonymousClass(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ + p := printer.NewPrinter(o) + p.Print(&stmt.Class{ + Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, + ArgumentList: &node.ArgumentList{ + Arguments: []node.Node{ + &node.Argument{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + }, + &node.Argument{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, + }, + }, + }, + Extends: &stmt.ClassExtends{ + ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, + }, + Implements: &stmt.ClassImplements{ + InterfaceNames: []node.Node{ + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, + &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, + }, + }, Stmts: []node.Node{ - &stmt.Class{ - Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, - ArgumentList: &node.ArgumentList{ - Arguments: []node.Node{ - &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, - &node.Argument{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - }, - Extends: &stmt.ClassExtends{ - ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, - }, - Implements: &stmt.ClassImplements{ - InterfaceNames: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}}, - }, - }, - Stmts: []node.Node{ - &stmt.ClassConstList{ - Modifiers: []node.Node{&node.Identifier{Value: "public"}}, - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, + &stmt.ClassConstList{ + Modifiers: []node.Node{&node.Identifier{Value: "public"}}, + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, }, }, }, }, }) - expected := `namespace { - abstract class($a, $b) extends Bar implements Baz, Quuz - { - public const FOO = 'bar'; - } -}` + expected := `abstract class($a,$b) extends Bar implements Baz,Quuz{public const FOO='bar';}` actual := o.String() if expected != actual { @@ -2583,10 +3024,10 @@ func TestPrintStmtAnonymousClass(t *testing.T) { } } -func TestPrintStmtClassConstList(t *testing.T) { +func TestPrinterPrintStmtClassConstList(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.ClassConstList{ Modifiers: []node.Node{&node.Identifier{Value: "public"}}, Consts: []node.Node{ @@ -2601,7 +3042,7 @@ func TestPrintStmtClassConstList(t *testing.T) { }, }) - expected := `public const FOO = 'a', BAR = 'b';` + expected := `public const FOO='a',BAR='b';` actual := o.String() if expected != actual { @@ -2609,16 +3050,41 @@ func TestPrintStmtClassConstList(t *testing.T) { } } -func TestPrintStmtConstant(t *testing.T) { +func TestPrinterPrintStmtConstList(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) + p.Print(&stmt.ConstList{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'a'"}, + }, + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "BAR"}, + Expr: &scalar.String{Value: "'b'"}, + }, + }, + }) + + expected := `const FOO='a',BAR='b';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtConstant(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) p.Print(&stmt.Constant{ ConstantName: &node.Identifier{Value: "FOO"}, Expr: &scalar.String{Value: "'BAR'"}, }) - expected := "FOO = 'BAR'" + expected := "FOO='BAR'" actual := o.String() if expected != actual { @@ -2626,12 +3092,14 @@ func TestPrintStmtConstant(t *testing.T) { } } -func TestPrintStmtContinue(t *testing.T) { +func TestPrinterPrintStmtContinue(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Continue{ - Expr: &scalar.Lnumber{Value: "1"}, + Expr: &scalar.Lnumber{ + Value: "1", + }, }) expected := `continue 1;` @@ -2642,33 +3110,25 @@ func TestPrintStmtContinue(t *testing.T) { } } -func TestPrintStmtDeclareStmts(t *testing.T) { +func TestPrinterPrintStmtDeclareStmts(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Declare{ - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Nop{}, - }, - }, + p := printer.NewPrinter(o) + p.Print(&stmt.Declare{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, + }, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, }, }, }) - expected := `{ - declare(FOO = 'bar') { - ; - } -}` + expected := `declare(FOO='bar'){;}` actual := o.String() if expected != actual { @@ -2676,28 +3136,21 @@ func TestPrintStmtDeclareStmts(t *testing.T) { } } -func TestPrintStmtDeclareExpr(t *testing.T) { +func TestPrinterPrintStmtDeclareExpr(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Declare{ - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, - Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, + p := printer.NewPrinter(o) + p.Print(&stmt.Declare{ + Consts: []node.Node{ + &stmt.Constant{ + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.String{Value: "'bar'"}, }, }, + Stmt: &stmt.Expression{Expr: &scalar.String{Value: "'bar'"}}, }) - expected := `{ - declare(FOO = 'bar') - 'bar'; -}` + expected := `declare(FOO='bar')'bar';` actual := o.String() if expected != actual { @@ -2705,10 +3158,10 @@ func TestPrintStmtDeclareExpr(t *testing.T) { } } -func TestPrintStmtDeclareNop(t *testing.T) { +func TestPrinterPrintStmtDeclareNop(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Declare{ Consts: []node.Node{ &stmt.Constant{ @@ -2719,7 +3172,7 @@ func TestPrintStmtDeclareNop(t *testing.T) { Stmt: &stmt.Nop{}, }) - expected := `declare(FOO = 'bar');` + expected := `declare(FOO='bar');` actual := o.String() if expected != actual { @@ -2727,18 +3180,19 @@ func TestPrintStmtDeclareNop(t *testing.T) { } } -func TestPrintStmtDefalut(t *testing.T) { +func TestPrinterPrintStmtDefalut(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Default{ Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, }, }) - expected := `default: - $a;` + expected := `default:$a;` actual := o.String() if expected != actual { @@ -2746,10 +3200,10 @@ func TestPrintStmtDefalut(t *testing.T) { } } -func TestPrintStmtDefalutEmpty(t *testing.T) { +func TestPrinterPrintStmtDefalutEmpty(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Default{ Stmts: []node.Node{}, }) @@ -2762,26 +3216,20 @@ func TestPrintStmtDefalutEmpty(t *testing.T) { } } -func TestPrintStmtDo_Expression(t *testing.T) { +func TestPrinterPrintStmtDo_Expression(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.Do{ - Cond: &scalar.Lnumber{Value: "1"}, - Stmt: &stmt.Expression{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - }, + p := printer.NewPrinter(o) + p.Print(&stmt.Do{ + Cond: &scalar.Lnumber{Value: "1"}, + Stmt: &stmt.Expression{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, }, }, }) - expected := `namespace { - do - $a; - while (1); -}` + expected := `do $a;while(1);` actual := o.String() if expected != actual { @@ -2789,28 +3237,49 @@ func TestPrintStmtDo_Expression(t *testing.T) { } } -func TestPrintStmtDo_StmtList(t *testing.T) { +func TestPrinterPrintStmtDo_StmtList(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ + p := printer.NewPrinter(o) + p.Print(&stmt.Do{ + Cond: &scalar.Lnumber{Value: "1"}, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Expression{Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }}, + }, + }, + }) + + expected := `do{$a;}while(1);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtEchoHtmlState(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) + p.Print(&node.Root{ Stmts: []node.Node{ - &stmt.Do{ - Cond: &scalar.Lnumber{Value: "1"}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, + &stmt.Echo{ + Exprs: []node.Node{ + &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, }, }, }, }, }) - expected := `namespace { - do { - $a; - } while (1); -}` + expected := ` $v) - 'bar'; -}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintStmtForeachNop(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Foreach{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Key: &expr.Variable{VarName: &node.Identifier{Value: "k"}}, - Variable: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "v"}}}, - Stmt: &stmt.Nop{}, - }) - - expected := `foreach ($a as $k => &$v);` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintStmtFunction(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.Function{ - ReturnsRef: true, - FunctionName: &node.Identifier{Value: "foo"}, - Params: []node.Node{ - &node.Parameter{ - ByRef: true, - Variadic: false, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, - }, - }, - ReturnType: &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Stmts: []node.Node{ - &stmt.Nop{}, - }, + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Key: &expr.Variable{ + VarName: &node.Identifier{Value: "k"}, + }, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "v"}, + }, + Stmt: &stmt.StmtList{ + Stmts: []node.Node{ + &stmt.Nop{}, }, }, }) - expected := `namespace { - function &foo(&$var): \Foo { - ; - } -}` + expected := `foreach($a as $k=>$v){;}` actual := o.String() if expected != actual { @@ -3198,18 +3532,54 @@ func TestPrintStmtFunction(t *testing.T) { } } -func TestPrintStmtGlobal(t *testing.T) { +func TestPrinterPrintStmtFunction(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) + p.Print(&stmt.Function{ + ReturnsRef: true, + FunctionName: &node.Identifier{Value: "foo"}, + Params: []node.Node{ + &node.Parameter{ + ByRef: true, + Variadic: false, + Variable: &expr.Variable{ + VarName: &node.Identifier{Value: "var"}, + }, + }, + }, + ReturnType: &name.FullyQualified{ + Parts: []node.Node{&name.NamePart{Value: "Foo"}}, + }, + Stmts: []node.Node{ + &stmt.Nop{}, + }, + }) + + expected := `function &foo(&$var):\Foo{;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtGlobal(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o) p.Print(&stmt.Global{ Vars: []node.Node{ - &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - &expr.Variable{VarName: &node.Identifier{Value: "b"}}, + &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, + }, }, }) - expected := `global $a, $b;` + expected := `global$a,$b;` actual := o.String() if expected != actual { @@ -3217,10 +3587,10 @@ func TestPrintStmtGlobal(t *testing.T) { } } -func TestPrintStmtGoto(t *testing.T) { +func TestPrinterPrintStmtGoto(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.Goto{ Label: &node.Identifier{Value: "FOO"}, }) @@ -3233,10 +3603,10 @@ func TestPrintStmtGoto(t *testing.T) { } } -func TestPrintStmtGroupUse(t *testing.T) { +func TestPrinterPrintStmtGroupUse(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.GroupUse{ UseType: &node.Identifier{Value: "function"}, Prefix: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, @@ -3251,7 +3621,7 @@ func TestPrintStmtGroupUse(t *testing.T) { }, }) - expected := `use function Foo\{Bar as Baz, Quuz};` + expected := `use function Foo\{Bar as Baz,Quuz};` actual := o.String() if expected != actual { @@ -3259,10 +3629,10 @@ func TestPrintStmtGroupUse(t *testing.T) { } } -func TestPrintHaltCompiler(t *testing.T) { +func TestPrinterPrintHaltCompiler(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") + p := printer.NewPrinter(o) p.Print(&stmt.HaltCompiler{}) expected := `__halt_compiler();` @@ -3273,162 +3643,51 @@ func TestPrintHaltCompiler(t *testing.T) { } } -func TestPrintIfExpression(t *testing.T) { +func TestPrinterPrintIfExpression(t *testing.T) { o := bytes.NewBufferString("") - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.If{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Stmt: &stmt.Expression{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "d"}}, - }, - }, - }, - }, - &stmt.ElseIf{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, - Stmt: &stmt.Nop{}, - }, - }, - Else: &stmt.Else{ - Stmt: &stmt.Expression{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "f"}}, - }, - }, + p := printer.NewPrinter(o) + p.Print(&stmt.If{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "a"}, + }, + Stmt: &stmt.Expression{ + Expr: &expr.Variable{ + VarName: &node.Identifier{Value: "b"}, }, }, - }) - - expected := `namespace { - if ($a) - $b; - elseif ($c) { - $d; - } - elseif ($e); - else - $f; -}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintIfStmtList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.Namespace{ - Stmts: []node.Node{ - &stmt.If{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, + ElseIf: []node.Node{ + &stmt.ElseIf{ + Cond: &expr.Variable{ + VarName: &node.Identifier{Value: "c"}, + }, Stmt: &stmt.StmtList{ Stmts: []node.Node{ &stmt.Expression{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, - }, - }, - }, - }, - }, - }) - - expected := `namespace { - if ($a) { - $b; - } -}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintIfNop(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.If{ - Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, - Stmt: &stmt.Nop{}, - }) - - expected := `if ($a);` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrintInlineHtml(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o, " ") - p.Print(&stmt.InlineHtml{ - Value: "test", - }) - - expected := `?>test= LexerToken(len(_LexerToken_index)-1) { + return "LexerToken(" + strconv.FormatInt(int64(i+57346), 10) + ")" + } + return _LexerToken_name[_LexerToken_index[i]:_LexerToken_index[i+1]] +} diff --git a/scanner/scanner.go b/scanner/scanner.go index 03e323e..b9a5ae4 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -11,6 +11,7 @@ package scanner import ( "fmt" "github.com/cznic/golex/lex" + "github.com/z7zmey/php-parser/freefloating" ) const ( @@ -33,7 +34,7 @@ func isValidFirstVarNameRune(r rune) bool { } func (l *Lexer) Lex(lval Lval) int { - l.Comments = nil + l.FreeFloating = nil c := l.Enter() yystate0: @@ -49,25 +50,25 @@ yystate0: case 1: // start condition: PHP goto yystart13 case 2: // start condition: STRING - goto yystart549 + goto yystart548 case 3: // start condition: STRING_VAR - goto yystart557 + goto yystart556 case 4: // start condition: STRING_VAR_INDEX - goto yystart567 + goto yystart566 case 5: // start condition: STRING_VAR_NAME - goto yystart584 + goto yystart583 case 6: // start condition: PROPERTY - goto yystart589 + goto yystart588 case 7: // start condition: HEREDOC_END - goto yystart597 + goto yystart596 case 8: // start condition: NOWDOC - goto yystart600 + goto yystart599 case 9: // start condition: HEREDOC - goto yystart602 + goto yystart601 case 10: // start condition: BACKQUOTE - goto yystart606 + goto yystart605 case 11: // start condition: HALT_COMPILER - goto yystart611 + goto yystart610 } goto yystate0 // silence unused label error @@ -626,25 +627,25 @@ yystart13: case c == '\'': goto yystate29 case c == '\\': - goto yystate462 + goto yystate461 case c == '\n': goto yystate16 case c == '\t' || c == '\r' || c == ' ': goto yystate15 case c == '^': - goto yystate463 + goto yystate462 case c == '_': - goto yystate465 + goto yystate464 case c == '`': - goto yystate539 + goto yystate538 case c == 'b': - goto yystate540 + goto yystate539 case c == '{': - goto yystate544 + goto yystate543 case c == '|': - goto yystate545 + goto yystate544 case c == '}': - goto yystate548 + goto yystate547 case c >= '1' && c <= '9': goto yystate127 case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f': @@ -5900,27 +5901,18 @@ yystate459: } yystate460: - c = l.Next() - switch { - default: - goto yyabort - case c >= '\x01' && c <= '/' || c >= ':' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '\u007f': - goto yystate461 - } - -yystate461: c = l.Next() yyrule = 69 l.Mark() goto yyrule69 -yystate462: +yystate461: c = l.Next() yyrule = 95 l.Mark() goto yyrule95 -yystate463: +yystate462: c = l.Next() yyrule = 129 l.Mark() @@ -5928,15 +5920,28 @@ yystate463: default: goto yyrule129 case c == '=': - goto yystate464 + goto yystate463 } -yystate464: +yystate463: c = l.Next() yyrule = 108 l.Mark() goto yyrule108 +yystate464: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == '_': + goto yystate465 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate465: c = l.Next() yyrule = 133 @@ -5944,9 +5949,23 @@ yystate465: switch { default: goto yyrule133 - case c == '_': + case c == 'C' || c == 'c': goto yystate466 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c == 'D' || c == 'd': + goto yystate473 + case c == 'F' || c == 'f': + goto yystate478 + case c == 'H' || c == 'h': + goto yystate493 + case c == 'L' || c == 'l': + goto yystate506 + case c == 'M' || c == 'm': + goto yystate512 + case c == 'N' || c == 'n': + goto yystate520 + case c == 'T' || c == 't': + goto yystate531 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c == 'E' || c == 'G' || c >= 'I' && c <= 'K' || c >= 'O' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c == 'e' || c == 'g' || c >= 'i' && c <= 'k' || c >= 'o' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -5957,23 +5976,9 @@ yystate466: switch { default: goto yyrule133 - case c == 'C' || c == 'c': - goto yystate467 - case c == 'D' || c == 'd': - goto yystate474 - case c == 'F' || c == 'f': - goto yystate479 - case c == 'H' || c == 'h': - goto yystate494 case c == 'L' || c == 'l': - goto yystate507 - case c == 'M' || c == 'm': - goto yystate513 - case c == 'N' || c == 'n': - goto yystate521 - case c == 'T' || c == 't': - goto yystate532 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c == 'E' || c == 'G' || c >= 'I' && c <= 'K' || c >= 'O' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c == 'e' || c == 'g' || c >= 'i' && c <= 'k' || c >= 'o' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate467 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -5984,9 +5989,9 @@ yystate467: switch { default: goto yyrule133 - case c == 'L' || c == 'l': + case c == 'A' || c == 'a': goto yystate468 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -5997,9 +6002,9 @@ yystate468: switch { default: goto yyrule133 - case c == 'A' || c == 'a': + case c == 'S' || c == 's': goto yystate469 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6023,9 +6028,9 @@ yystate470: switch { default: goto yyrule133 - case c == 'S' || c == 's': + case c == '_': goto yystate471 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6043,19 +6048,6 @@ yystate471: } yystate472: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate473 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate473: c = l.Next() yyrule = 75 l.Mark() @@ -6066,6 +6058,19 @@ yystate473: goto yystate165 } +yystate473: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'I' || c == 'i': + goto yystate474 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate474: c = l.Next() yyrule = 133 @@ -6073,9 +6078,9 @@ yystate474: switch { default: goto yyrule133 - case c == 'I' || c == 'i': + case c == 'R' || c == 'r': goto yystate475 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6086,9 +6091,9 @@ yystate475: switch { default: goto yyrule133 - case c == 'R' || c == 'r': + case c == '_': goto yystate476 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6106,19 +6111,6 @@ yystate476: } yystate477: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate478 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate478: c = l.Next() yyrule = 76 l.Mark() @@ -6129,6 +6121,21 @@ yystate478: goto yystate165 } +yystate478: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'I' || c == 'i': + goto yystate479 + case c == 'U' || c == 'u': + goto yystate484 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 't' || c >= 'v' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate479: c = l.Next() yyrule = 133 @@ -6136,11 +6143,9 @@ yystate479: switch { default: goto yyrule133 - case c == 'I' || c == 'i': + case c == 'L' || c == 'l': goto yystate480 - case c == 'U' || c == 'u': - goto yystate485 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 't' || c >= 'v' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6151,9 +6156,9 @@ yystate480: switch { default: goto yyrule133 - case c == 'L' || c == 'l': + case c == 'E' || c == 'e': goto yystate481 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6164,9 +6169,9 @@ yystate481: switch { default: goto yyrule133 - case c == 'E' || c == 'e': + case c == '_': goto yystate482 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6184,19 +6189,6 @@ yystate482: } yystate483: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate484 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate484: c = l.Next() yyrule = 77 l.Mark() @@ -6207,6 +6199,19 @@ yystate484: goto yystate165 } +yystate484: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'N' || c == 'n': + goto yystate485 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate485: c = l.Next() yyrule = 133 @@ -6214,9 +6219,9 @@ yystate485: switch { default: goto yyrule133 - case c == 'N' || c == 'n': + case c == 'C' || c == 'c': goto yystate486 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6227,9 +6232,9 @@ yystate486: switch { default: goto yyrule133 - case c == 'C' || c == 'c': + case c == 'T' || c == 't': goto yystate487 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6240,9 +6245,9 @@ yystate487: switch { default: goto yyrule133 - case c == 'T' || c == 't': + case c == 'I' || c == 'i': goto yystate488 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6253,9 +6258,9 @@ yystate488: switch { default: goto yyrule133 - case c == 'I' || c == 'i': + case c == 'O' || c == 'o': goto yystate489 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6266,9 +6271,9 @@ yystate489: switch { default: goto yyrule133 - case c == 'O' || c == 'o': + case c == 'N' || c == 'n': goto yystate490 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6279,9 +6284,9 @@ yystate490: switch { default: goto yyrule133 - case c == 'N' || c == 'n': + case c == '_': goto yystate491 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6299,19 +6304,6 @@ yystate491: } yystate492: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate493 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate493: c = l.Next() yyrule = 78 l.Mark() @@ -6322,6 +6314,19 @@ yystate493: goto yystate165 } +yystate493: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'A' || c == 'a': + goto yystate494 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate494: c = l.Next() yyrule = 133 @@ -6329,9 +6334,9 @@ yystate494: switch { default: goto yyrule133 - case c == 'A' || c == 'a': + case c == 'L' || c == 'l': goto yystate495 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6342,9 +6347,9 @@ yystate495: switch { default: goto yyrule133 - case c == 'L' || c == 'l': + case c == 'T' || c == 't': goto yystate496 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6355,9 +6360,9 @@ yystate496: switch { default: goto yyrule133 - case c == 'T' || c == 't': + case c == '_': goto yystate497 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6368,9 +6373,9 @@ yystate497: switch { default: goto yyrule133 - case c == '_': + case c == 'C' || c == 'c': goto yystate498 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6381,9 +6386,9 @@ yystate498: switch { default: goto yyrule133 - case c == 'C' || c == 'c': + case c == 'O' || c == 'o': goto yystate499 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6394,9 +6399,9 @@ yystate499: switch { default: goto yyrule133 - case c == 'O' || c == 'o': + case c == 'M' || c == 'm': goto yystate500 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6407,9 +6412,9 @@ yystate500: switch { default: goto yyrule133 - case c == 'M' || c == 'm': + case c == 'P' || c == 'p': goto yystate501 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6420,9 +6425,9 @@ yystate501: switch { default: goto yyrule133 - case c == 'P' || c == 'p': + case c == 'I' || c == 'i': goto yystate502 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6433,9 +6438,9 @@ yystate502: switch { default: goto yyrule133 - case c == 'I' || c == 'i': + case c == 'L' || c == 'l': goto yystate503 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6446,26 +6451,13 @@ yystate503: switch { default: goto yyrule133 - case c == 'L' || c == 'l': + case c == 'E' || c == 'e': goto yystate504 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } yystate504: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == 'E' || c == 'e': - goto yystate505 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate505: c = l.Next() yyrule = 133 l.Mark() @@ -6473,12 +6465,12 @@ yystate505: default: goto yyrule133 case c == 'R' || c == 'r': - goto yystate506 + goto yystate505 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } -yystate506: +yystate505: c = l.Next() yyrule = 83 l.Mark() @@ -6489,7 +6481,7 @@ yystate506: goto yystate165 } -yystate507: +yystate506: c = l.Next() yyrule = 133 l.Mark() @@ -6497,11 +6489,24 @@ yystate507: default: goto yyrule133 case c == 'I' || c == 'i': - goto yystate508 + goto yystate507 case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } +yystate507: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'N' || c == 'n': + goto yystate508 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate508: c = l.Next() yyrule = 133 @@ -6509,9 +6514,9 @@ yystate508: switch { default: goto yyrule133 - case c == 'N' || c == 'n': + case c == 'E' || c == 'e': goto yystate509 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6522,9 +6527,9 @@ yystate509: switch { default: goto yyrule133 - case c == 'E' || c == 'e': + case c == '_': goto yystate510 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6542,19 +6547,6 @@ yystate510: } yystate511: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate512 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate512: c = l.Next() yyrule = 79 l.Mark() @@ -6565,6 +6557,19 @@ yystate512: goto yystate165 } +yystate512: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'E' || c == 'e': + goto yystate513 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate513: c = l.Next() yyrule = 133 @@ -6572,9 +6577,9 @@ yystate513: switch { default: goto yyrule133 - case c == 'E' || c == 'e': + case c == 'T' || c == 't': goto yystate514 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6585,9 +6590,9 @@ yystate514: switch { default: goto yyrule133 - case c == 'T' || c == 't': + case c == 'H' || c == 'h': goto yystate515 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6598,9 +6603,9 @@ yystate515: switch { default: goto yyrule133 - case c == 'H' || c == 'h': + case c == 'O' || c == 'o': goto yystate516 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6611,9 +6616,9 @@ yystate516: switch { default: goto yyrule133 - case c == 'O' || c == 'o': + case c == 'D' || c == 'd': goto yystate517 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6624,9 +6629,9 @@ yystate517: switch { default: goto yyrule133 - case c == 'D' || c == 'd': + case c == '_': goto yystate518 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6644,19 +6649,6 @@ yystate518: } yystate519: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate520 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate520: c = l.Next() yyrule = 81 l.Mark() @@ -6667,6 +6659,19 @@ yystate520: goto yystate165 } +yystate520: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'A' || c == 'a': + goto yystate521 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate521: c = l.Next() yyrule = 133 @@ -6674,9 +6679,9 @@ yystate521: switch { default: goto yyrule133 - case c == 'A' || c == 'a': + case c == 'M' || c == 'm': goto yystate522 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6687,9 +6692,9 @@ yystate522: switch { default: goto yyrule133 - case c == 'M' || c == 'm': + case c == 'E' || c == 'e': goto yystate523 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6700,9 +6705,9 @@ yystate523: switch { default: goto yyrule133 - case c == 'E' || c == 'e': + case c == 'S' || c == 's': goto yystate524 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6713,9 +6718,9 @@ yystate524: switch { default: goto yyrule133 - case c == 'S' || c == 's': + case c == 'P' || c == 'p': goto yystate525 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6726,9 +6731,9 @@ yystate525: switch { default: goto yyrule133 - case c == 'P' || c == 'p': + case c == 'A' || c == 'a': goto yystate526 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6739,9 +6744,9 @@ yystate526: switch { default: goto yyrule133 - case c == 'A' || c == 'a': + case c == 'C' || c == 'c': goto yystate527 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6752,9 +6757,9 @@ yystate527: switch { default: goto yyrule133 - case c == 'C' || c == 'c': + case c == 'E' || c == 'e': goto yystate528 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6765,9 +6770,9 @@ yystate528: switch { default: goto yyrule133 - case c == 'E' || c == 'e': + case c == '_': goto yystate529 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6785,19 +6790,6 @@ yystate529: } yystate530: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate531 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate531: c = l.Next() yyrule = 80 l.Mark() @@ -6808,6 +6800,19 @@ yystate531: goto yystate165 } +yystate531: + c = l.Next() + yyrule = 133 + l.Mark() + switch { + default: + goto yyrule133 + case c == 'R' || c == 'r': + goto yystate532 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate165 + } + yystate532: c = l.Next() yyrule = 133 @@ -6815,9 +6820,9 @@ yystate532: switch { default: goto yyrule133 - case c == 'R' || c == 'r': + case c == 'A' || c == 'a': goto yystate533 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6828,9 +6833,9 @@ yystate533: switch { default: goto yyrule133 - case c == 'A' || c == 'a': + case c == 'I' || c == 'i': goto yystate534 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6841,9 +6846,9 @@ yystate534: switch { default: goto yyrule133 - case c == 'I' || c == 'i': + case c == 'T' || c == 't': goto yystate535 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6854,9 +6859,9 @@ yystate535: switch { default: goto yyrule133 - case c == 'T' || c == 't': + case c == '_': goto yystate536 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } @@ -6874,19 +6879,6 @@ yystate536: } yystate537: - c = l.Next() - yyrule = 133 - l.Mark() - switch { - default: - goto yyrule133 - case c == '_': - goto yystate538 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate165 - } - -yystate538: c = l.Next() yyrule = 82 l.Mark() @@ -6897,13 +6889,13 @@ yystate538: goto yystate165 } -yystate539: +yystate538: c = l.Next() yyrule = 140 l.Mark() goto yyrule140 -yystate540: +yystate539: c = l.Next() yyrule = 133 l.Mark() @@ -6911,31 +6903,31 @@ yystate540: default: goto yyrule133 case c == '"': - goto yystate541 + goto yystate540 case c == '<': - goto yystate542 + goto yystate541 case c == 'R' || c == 'r': goto yystate181 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate165 } -yystate541: +yystate540: c = l.Next() yyrule = 146 l.Mark() goto yyrule146 -yystate542: +yystate541: c = l.Next() switch { default: goto yyabort case c == '<': - goto yystate543 + goto yystate542 } -yystate543: +yystate542: c = l.Next() switch { default: @@ -6944,13 +6936,13 @@ yystate543: goto yystate138 } -yystate544: +yystate543: c = l.Next() yyrule = 130 l.Mark() goto yyrule130 -yystate545: +yystate544: c = l.Next() yyrule = 129 l.Mark() @@ -6958,59 +6950,59 @@ yystate545: default: goto yyrule129 case c == '=': - goto yystate546 + goto yystate545 case c == '|': - goto yystate547 + goto yystate546 } -yystate546: +yystate545: c = l.Next() yyrule = 101 l.Mark() goto yyrule101 -yystate547: +yystate546: c = l.Next() yyrule = 99 l.Mark() goto yyrule99 -yystate548: +yystate547: c = l.Next() yyrule = 131 l.Mark() goto yyrule131 - goto yystate549 // silence unused label error -yystate549: + goto yystate548 // silence unused label error +yystate548: c = l.Next() -yystart549: +yystart548: switch { default: goto yyabort case c == '"': - goto yystate551 - case c == '$': - goto yystate552 - case c == '{': - goto yystate555 - case c >= '\x01' && c <= '!' || c == '#' || c >= '%' && c <= 'z' || c >= '|' && c <= 'ÿ': goto yystate550 + case c == '$': + goto yystate551 + case c == '{': + goto yystate554 + case c >= '\x01' && c <= '!' || c == '#' || c >= '%' && c <= 'z' || c >= '|' && c <= 'ÿ': + goto yystate549 } -yystate550: +yystate549: c = l.Next() yyrule = 151 l.Mark() goto yyrule151 -yystate551: +yystate550: c = l.Next() yyrule = 147 l.Mark() goto yyrule147 -yystate552: +yystate551: c = l.Next() yyrule = 151 l.Mark() @@ -7018,12 +7010,12 @@ yystate552: default: goto yyrule151 case c == '{': - goto yystate554 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate553 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate552 } -yystate553: +yystate552: c = l.Next() yyrule = 150 l.Mark() @@ -7031,16 +7023,16 @@ yystate553: default: goto yyrule150 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate553 + goto yystate552 } -yystate554: +yystate553: c = l.Next() yyrule = 149 l.Mark() goto yyrule149 -yystate555: +yystate554: c = l.Next() yyrule = 151 l.Mark() @@ -7048,41 +7040,41 @@ yystate555: default: goto yyrule151 case c == '$': - goto yystate556 + goto yystate555 } -yystate556: +yystate555: c = l.Next() yyrule = 148 l.Mark() goto yyrule148 - goto yystate557 // silence unused label error -yystate557: + goto yystate556 // silence unused label error +yystate556: c = l.Next() -yystart557: +yystart556: switch { default: goto yyabort case c == '$': - goto yystate559 - case c == '-': - goto yystate561 - case c == '[': - goto yystate566 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate564 - case c >= '\x01' && c <= '#' || c >= '%' && c <= ',' || c >= '.' && c <= '@' || c >= '\\' && c <= '^' || c == '`' || c >= '{' && c <= '~': goto yystate558 + case c == '-': + goto yystate560 + case c == '[': + goto yystate565 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate563 + case c >= '\x01' && c <= '#' || c >= '%' && c <= ',' || c >= '.' && c <= '@' || c >= '\\' && c <= '^' || c == '`' || c >= '{' && c <= '~': + goto yystate557 } -yystate558: +yystate557: c = l.Next() yyrule = 158 l.Mark() goto yyrule158 -yystate559: +yystate558: c = l.Next() yyrule = 158 l.Mark() @@ -7090,10 +7082,10 @@ yystate559: default: goto yyrule158 case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate560 + goto yystate559 } -yystate560: +yystate559: c = l.Next() yyrule = 154 l.Mark() @@ -7101,10 +7093,10 @@ yystate560: default: goto yyrule154 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate560 + goto yystate559 } -yystate561: +yystate560: c = l.Next() yyrule = 158 l.Mark() @@ -7112,19 +7104,19 @@ yystate561: default: goto yyrule158 case c == '>': - goto yystate562 + goto yystate561 } -yystate562: +yystate561: c = l.Next() switch { default: goto yyabort case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate563 + goto yystate562 } -yystate563: +yystate562: c = l.Next() yyrule = 155 l.Mark() @@ -7132,7 +7124,18 @@ yystate563: default: goto yyrule155 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate563 + goto yystate562 + } + +yystate563: + c = l.Next() + yyrule = 156 + l.Mark() + switch { + default: + goto yyrule156 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate564 } yystate564: @@ -7143,59 +7146,54 @@ yystate564: default: goto yyrule156 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate565 + goto yystate564 } yystate565: - c = l.Next() - yyrule = 156 - l.Mark() - switch { - default: - goto yyrule156 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate565 - } - -yystate566: c = l.Next() yyrule = 157 l.Mark() goto yyrule157 - goto yystate567 // silence unused label error -yystate567: + goto yystate566 // silence unused label error +yystate566: c = l.Next() -yystart567: +yystart566: switch { default: goto yyabort case c == '!' || c == '%' || c == '&' || c >= '(' && c <= '/' || c >= ':' && c <= '@' || c == '[' || c == '^' || c == '|' || c == '~': - goto yystate571 - case c == '$': - goto yystate572 - case c == '0': - goto yystate574 - case c == '\n': goto yystate570 - case c == '\t' || c == '\r' || c == ' ' || c == '#' || c == '\'' || c == '\\': + case c == '$': + goto yystate571 + case c == '0': + goto yystate573 + case c == '\n': goto yystate569 - case c == ']': - goto yystate583 - case c >= '1' && c <= '9': - goto yystate580 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate581 - case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c == '"' || c == '`' || c == '{' || c == '}': + case c == '\t' || c == '\r' || c == ' ' || c == '#' || c == '\'' || c == '\\': goto yystate568 + case c == ']': + goto yystate582 + case c >= '1' && c <= '9': + goto yystate579 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate580 + case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c == '"' || c == '`' || c == '{' || c == '}': + goto yystate567 } -yystate568: +yystate567: c = l.Next() yyrule = 165 l.Mark() goto yyrule165 +yystate568: + c = l.Next() + yyrule = 163 + l.Mark() + goto yyrule163 + yystate569: c = l.Next() yyrule = 163 @@ -7203,18 +7201,12 @@ yystate569: goto yyrule163 yystate570: - c = l.Next() - yyrule = 163 - l.Mark() - goto yyrule163 - -yystate571: c = l.Next() yyrule = 164 l.Mark() goto yyrule164 -yystate572: +yystate571: c = l.Next() yyrule = 164 l.Mark() @@ -7222,10 +7214,10 @@ yystate572: default: goto yyrule164 case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate573 + goto yystate572 } -yystate573: +yystate572: c = l.Next() yyrule = 160 l.Mark() @@ -7233,7 +7225,22 @@ yystate573: default: goto yyrule160 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate573 + goto yystate572 + } + +yystate573: + c = l.Next() + yyrule = 159 + l.Mark() + switch { + default: + goto yyrule159 + case c == 'B' || c == 'b': + goto yystate575 + case c == 'X' || c == 'x': + goto yystate577 + case c >= '0' && c <= '9': + goto yystate574 } yystate574: @@ -7243,35 +7250,20 @@ yystate574: switch { default: goto yyrule159 - case c == 'B' || c == 'b': - goto yystate576 - case c == 'X' || c == 'x': - goto yystate578 case c >= '0' && c <= '9': - goto yystate575 + goto yystate574 } yystate575: - c = l.Next() - yyrule = 159 - l.Mark() - switch { - default: - goto yyrule159 - case c >= '0' && c <= '9': - goto yystate575 - } - -yystate576: c = l.Next() switch { default: goto yyabort case c == '0' || c == '1': - goto yystate577 + goto yystate576 } -yystate577: +yystate576: c = l.Next() yyrule = 159 l.Mark() @@ -7279,16 +7271,27 @@ yystate577: default: goto yyrule159 case c == '0' || c == '1': - goto yystate577 + goto yystate576 } -yystate578: +yystate577: c = l.Next() switch { default: goto yyabort case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': - goto yystate579 + goto yystate578 + } + +yystate578: + c = l.Next() + yyrule = 159 + l.Mark() + switch { + default: + goto yyrule159 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': + goto yystate578 } yystate579: @@ -7298,19 +7301,19 @@ yystate579: switch { default: goto yyrule159 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': - goto yystate579 + case c >= '0' && c <= '9': + goto yystate574 } yystate580: c = l.Next() - yyrule = 159 + yyrule = 161 l.Mark() switch { default: - goto yyrule159 - case c >= '0' && c <= '9': - goto yystate575 + goto yyrule161 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate581 } yystate581: @@ -7321,46 +7324,35 @@ yystate581: default: goto yyrule161 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate582 + goto yystate581 } yystate582: - c = l.Next() - yyrule = 161 - l.Mark() - switch { - default: - goto yyrule161 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate582 - } - -yystate583: c = l.Next() yyrule = 162 l.Mark() goto yyrule162 - goto yystate584 // silence unused label error -yystate584: + goto yystate583 // silence unused label error +yystate583: c = l.Next() -yystart584: +yystart583: switch { default: goto yyabort case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate586 - case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '~': goto yystate585 + case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '~': + goto yystate584 } -yystate585: +yystate584: c = l.Next() yyrule = 167 l.Mark() goto yyrule167 -yystate586: +yystate585: c = l.Next() yyrule = 167 l.Mark() @@ -7368,53 +7360,64 @@ yystate586: default: goto yyrule167 case c == '[' || c == '}': - goto yystate588 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate587 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate586 } -yystate587: +yystate586: c = l.Next() switch { default: goto yyabort case c == '[' || c == '}': - goto yystate588 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate587 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate586 } -yystate588: +yystate587: c = l.Next() yyrule = 166 l.Mark() goto yyrule166 - goto yystate589 // silence unused label error -yystate589: + goto yystate588 // silence unused label error +yystate588: c = l.Next() -yystart589: +yystart588: switch { default: goto yyabort case c == '-': - goto yystate593 - case c == '\n': goto yystate592 - case c == '\t' || c == '\r' || c == ' ': + case c == '\n': goto yystate591 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate595 - case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= ',' || c >= '.' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '~': + case c == '\t' || c == '\r' || c == ' ': goto yystate590 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate594 + case c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c >= '!' && c <= ',' || c >= '.' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '~': + goto yystate589 } -yystate590: +yystate589: c = l.Next() yyrule = 138 l.Mark() goto yyrule138 +yystate590: + c = l.Next() + yyrule = 135 + l.Mark() + switch { + default: + goto yyrule135 + case c == '\t' || c == '\n' || c == '\r' || c == ' ': + goto yystate591 + } + yystate591: c = l.Next() yyrule = 135 @@ -7423,21 +7426,10 @@ yystate591: default: goto yyrule135 case c == '\t' || c == '\n' || c == '\r' || c == ' ': - goto yystate592 + goto yystate591 } yystate592: - c = l.Next() - yyrule = 135 - l.Mark() - switch { - default: - goto yyrule135 - case c == '\t' || c == '\n' || c == '\r' || c == ' ': - goto yystate592 - } - -yystate593: c = l.Next() yyrule = 138 l.Mark() @@ -7445,15 +7437,26 @@ yystate593: default: goto yyrule138 case c == '>': - goto yystate594 + goto yystate593 } -yystate594: +yystate593: c = l.Next() yyrule = 136 l.Mark() goto yyrule136 +yystate594: + c = l.Next() + yyrule = 137 + l.Mark() + switch { + default: + goto yyrule137 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate595 + } + yystate595: c = l.Next() yyrule = 137 @@ -7462,32 +7465,21 @@ yystate595: default: goto yyrule137 case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate596 + goto yystate595 } + goto yystate596 // silence unused label error yystate596: c = l.Next() - yyrule = 137 - l.Mark() - switch { - default: - goto yyrule137 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate596 - } - - goto yystate597 // silence unused label error -yystate597: - c = l.Next() -yystart597: +yystart596: switch { default: goto yyabort case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate598 + goto yystate597 } -yystate598: +yystate597: c = l.Next() yyrule = 145 l.Mark() @@ -7495,54 +7487,67 @@ yystate598: default: goto yyrule145 case c == ';': - goto yystate599 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate598 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate597 } -yystate599: +yystate598: c = l.Next() yyrule = 144 l.Mark() goto yyrule144 - goto yystate600 // silence unused label error -yystate600: + goto yystate599 // silence unused label error +yystate599: c = l.Next() -yystart600: +yystart599: switch { default: goto yyabort case c >= '\x01' && c <= 'ÿ': - goto yystate601 + goto yystate600 } -yystate601: +yystate600: c = l.Next() yyrule = 143 l.Mark() goto yyrule143 - goto yystate602 // silence unused label error -yystate602: + goto yystate601 // silence unused label error +yystate601: c = l.Next() -yystart602: +yystart601: switch { default: goto yyabort case c == '$': - goto yystate604 - case c == '{': - goto yystate605 - case c >= '\x01' && c <= '#' || c >= '%' && c <= 'z' || c >= '|' && c <= 'ÿ': goto yystate603 + case c == '{': + goto yystate604 + case c >= '\x01' && c <= '#' || c >= '%' && c <= 'z' || c >= '|' && c <= 'ÿ': + goto yystate602 } +yystate602: + c = l.Next() + yyrule = 153 + l.Mark() + goto yyrule153 + yystate603: c = l.Next() yyrule = 153 l.Mark() - goto yyrule153 + switch { + default: + goto yyrule153 + case c == '{': + goto yystate553 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate552 + } yystate604: c = l.Next() @@ -7551,47 +7556,34 @@ yystate604: switch { default: goto yyrule153 - case c == '{': - goto yystate554 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': - goto yystate553 + case c == '$': + goto yystate555 } + goto yystate605 // silence unused label error yystate605: c = l.Next() - yyrule = 153 - l.Mark() - switch { - default: - goto yyrule153 - case c == '$': - goto yystate556 - } - - goto yystate606 // silence unused label error -yystate606: - c = l.Next() -yystart606: +yystart605: switch { default: goto yyabort case c == '$': - goto yystate608 - case c == '`': - goto yystate609 - case c == '{': - goto yystate610 - case c >= '\x01' && c <= '#' || c >= '%' && c <= '_' || c >= 'a' && c <= 'z' || c >= '|' && c <= 'ÿ': goto yystate607 + case c == '`': + goto yystate608 + case c == '{': + goto yystate609 + case c >= '\x01' && c <= '#' || c >= '%' && c <= '_' || c >= 'a' && c <= 'z' || c >= '|' && c <= 'ÿ': + goto yystate606 } -yystate607: +yystate606: c = l.Next() yyrule = 152 l.Mark() goto yyrule152 -yystate608: +yystate607: c = l.Next() yyrule = 152 l.Mark() @@ -7599,18 +7591,18 @@ yystate608: default: goto yyrule152 case c == '{': - goto yystate554 - case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': goto yystate553 + case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': + goto yystate552 } -yystate609: +yystate608: c = l.Next() yyrule = 141 l.Mark() goto yyrule141 -yystate610: +yystate609: c = l.Next() yyrule = 152 l.Mark() @@ -7618,29 +7610,31 @@ yystate610: default: goto yyrule152 case c == '$': - goto yystate556 + goto yystate555 } - goto yystate611 // silence unused label error -yystate611: + goto yystate610 // silence unused label error +yystate610: c = l.Next() -yystart611: +yystart610: switch { default: goto yyabort case c >= '\x01' && c <= 'ÿ': - goto yystate612 + goto yystate611 } -yystate612: +yystate611: c = l.Next() yyrule = 168 l.Mark() goto yyrule168 yyrule1: // [ \t\n\r]+ - - goto yystate0 + { + l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) + goto yystate0 + } yyrule2: // . { @@ -7662,15 +7656,18 @@ yyrule2: // . c = l.Next() } lval.Token(l.createToken(tb)) - return T_INLINE_HTML + return int(T_INLINE_HTML) } yyrule3: // \<\?php([ \t]|{NEW_LINE}) { + l.addFreeFloating(freefloating.TokenType, l.Token()[:5]) l.Begin(PHP) + l.ungetChars(len(l.Token()) - 5) goto yystate0 } yyrule4: // \<\? { + l.addFreeFloating(freefloating.TokenType, l.Token()) l.Begin(PHP) goto yystate0 } @@ -7678,12 +7675,14 @@ yyrule5: // \<\?= { l.Begin(PHP) lval.Token(l.createToken(l.Token())) - return T_ECHO + return int(T_ECHO) goto yystate0 } yyrule6: // [ \t\n\r]+ - - goto yystate0 + { + l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) + goto yystate0 + } yyrule7: // [;][ \t\n\r]*\?\>{NEW_LINE}? { l.Begin(INITIAL) @@ -7701,7 +7700,7 @@ yyrule8: // \?\>{NEW_LINE}? yyrule9: // {DNUM}|{EXPONENT_DNUM} { lval.Token(l.createToken(l.Token())) - return T_DNUMBER + return int(T_DNUMBER) goto yystate0 } yyrule10: // {BNUM} @@ -7723,10 +7722,10 @@ yyrule10: // {BNUM} } if len(tb)-i < 64 { lval.Token(l.createToken(l.Token())) - return T_LNUMBER + return int(T_LNUMBER) } else { lval.Token(l.createToken(l.Token())) - return T_DNUMBER + return int(T_DNUMBER) } goto yystate0 } @@ -7735,10 +7734,10 @@ yyrule11: // {LNUM} if len(l.Token()) < 20 { lval.Token(l.createToken(l.Token())) - return T_LNUMBER + return int(T_LNUMBER) } else { lval.Token(l.createToken(l.Token())) - return T_DNUMBER + return int(T_DNUMBER) } goto yystate0 } @@ -7762,689 +7761,689 @@ yyrule12: // {HNUM} length := len(tb) - i if length < 16 || (length == 16 && tb[i].Rune <= '7') { lval.Token(l.createToken(l.Token())) - return T_LNUMBER + return int(T_LNUMBER) } else { lval.Token(l.createToken(l.Token())) - return T_DNUMBER + return int(T_DNUMBER) } goto yystate0 } yyrule13: // abstract { lval.Token(l.createToken(l.Token())) - return T_ABSTRACT + return int(T_ABSTRACT) goto yystate0 } yyrule14: // array { lval.Token(l.createToken(l.Token())) - return T_ARRAY + return int(T_ARRAY) goto yystate0 } yyrule15: // as { lval.Token(l.createToken(l.Token())) - return T_AS + return int(T_AS) goto yystate0 } yyrule16: // break { lval.Token(l.createToken(l.Token())) - return T_BREAK + return int(T_BREAK) goto yystate0 } yyrule17: // callable { lval.Token(l.createToken(l.Token())) - return T_CALLABLE + return int(T_CALLABLE) goto yystate0 } yyrule18: // case { lval.Token(l.createToken(l.Token())) - return T_CASE + return int(T_CASE) goto yystate0 } yyrule19: // catch { lval.Token(l.createToken(l.Token())) - return T_CATCH + return int(T_CATCH) goto yystate0 } yyrule20: // class { lval.Token(l.createToken(l.Token())) - return T_CLASS + return int(T_CLASS) goto yystate0 } yyrule21: // clone { lval.Token(l.createToken(l.Token())) - return T_CLONE + return int(T_CLONE) goto yystate0 } yyrule22: // const { lval.Token(l.createToken(l.Token())) - return T_CONST + return int(T_CONST) goto yystate0 } yyrule23: // continue { lval.Token(l.createToken(l.Token())) - return T_CONTINUE + return int(T_CONTINUE) goto yystate0 } yyrule24: // declare { lval.Token(l.createToken(l.Token())) - return T_DECLARE + return int(T_DECLARE) goto yystate0 } yyrule25: // default { lval.Token(l.createToken(l.Token())) - return T_DEFAULT + return int(T_DEFAULT) goto yystate0 } yyrule26: // do { lval.Token(l.createToken(l.Token())) - return T_DO + return int(T_DO) goto yystate0 } yyrule27: // echo { lval.Token(l.createToken(l.Token())) - return T_ECHO + return int(T_ECHO) goto yystate0 } yyrule28: // else { lval.Token(l.createToken(l.Token())) - return T_ELSE + return int(T_ELSE) goto yystate0 } yyrule29: // elseif { lval.Token(l.createToken(l.Token())) - return T_ELSEIF + return int(T_ELSEIF) goto yystate0 } yyrule30: // empty { lval.Token(l.createToken(l.Token())) - return T_EMPTY + return int(T_EMPTY) goto yystate0 } yyrule31: // enddeclare { lval.Token(l.createToken(l.Token())) - return T_ENDDECLARE + return int(T_ENDDECLARE) goto yystate0 } yyrule32: // endfor { lval.Token(l.createToken(l.Token())) - return T_ENDFOR + return int(T_ENDFOR) goto yystate0 } yyrule33: // endforeach { lval.Token(l.createToken(l.Token())) - return T_ENDFOREACH + return int(T_ENDFOREACH) goto yystate0 } yyrule34: // endif { lval.Token(l.createToken(l.Token())) - return T_ENDIF + return int(T_ENDIF) goto yystate0 } yyrule35: // endswitch { lval.Token(l.createToken(l.Token())) - return T_ENDSWITCH + return int(T_ENDSWITCH) goto yystate0 } yyrule36: // endwhile { lval.Token(l.createToken(l.Token())) - return T_ENDWHILE + return int(T_ENDWHILE) goto yystate0 } yyrule37: // eval { lval.Token(l.createToken(l.Token())) - return T_EVAL + return int(T_EVAL) goto yystate0 } yyrule38: // exit|die { lval.Token(l.createToken(l.Token())) - return T_EXIT + return int(T_EXIT) goto yystate0 } yyrule39: // extends { lval.Token(l.createToken(l.Token())) - return T_EXTENDS + return int(T_EXTENDS) goto yystate0 } yyrule40: // final { lval.Token(l.createToken(l.Token())) - return T_FINAL + return int(T_FINAL) goto yystate0 } yyrule41: // finally { lval.Token(l.createToken(l.Token())) - return T_FINALLY + return int(T_FINALLY) goto yystate0 } yyrule42: // for { lval.Token(l.createToken(l.Token())) - return T_FOR + return int(T_FOR) goto yystate0 } yyrule43: // foreach { lval.Token(l.createToken(l.Token())) - return T_FOREACH + return int(T_FOREACH) goto yystate0 } yyrule44: // function|cfunction { lval.Token(l.createToken(l.Token())) - return T_FUNCTION + return int(T_FUNCTION) goto yystate0 } yyrule45: // global { lval.Token(l.createToken(l.Token())) - return T_GLOBAL + return int(T_GLOBAL) goto yystate0 } yyrule46: // goto { lval.Token(l.createToken(l.Token())) - return T_GOTO + return int(T_GOTO) goto yystate0 } yyrule47: // if { lval.Token(l.createToken(l.Token())) - return T_IF + return int(T_IF) goto yystate0 } yyrule48: // isset { lval.Token(l.createToken(l.Token())) - return T_ISSET + return int(T_ISSET) goto yystate0 } yyrule49: // implements { lval.Token(l.createToken(l.Token())) - return T_IMPLEMENTS + return int(T_IMPLEMENTS) goto yystate0 } yyrule50: // instanceof { lval.Token(l.createToken(l.Token())) - return T_INSTANCEOF + return int(T_INSTANCEOF) goto yystate0 } yyrule51: // insteadof { lval.Token(l.createToken(l.Token())) - return T_INSTEADOF + return int(T_INSTEADOF) goto yystate0 } yyrule52: // interface { lval.Token(l.createToken(l.Token())) - return T_INTERFACE + return int(T_INTERFACE) goto yystate0 } yyrule53: // list { lval.Token(l.createToken(l.Token())) - return T_LIST + return int(T_LIST) goto yystate0 } yyrule54: // namespace { lval.Token(l.createToken(l.Token())) - return T_NAMESPACE + return int(T_NAMESPACE) goto yystate0 } yyrule55: // private { lval.Token(l.createToken(l.Token())) - return T_PRIVATE + return int(T_PRIVATE) goto yystate0 } yyrule56: // public { lval.Token(l.createToken(l.Token())) - return T_PUBLIC + return int(T_PUBLIC) goto yystate0 } yyrule57: // print { lval.Token(l.createToken(l.Token())) - return T_PRINT + return int(T_PRINT) goto yystate0 } yyrule58: // protected { lval.Token(l.createToken(l.Token())) - return T_PROTECTED + return int(T_PROTECTED) goto yystate0 } yyrule59: // return { lval.Token(l.createToken(l.Token())) - return T_RETURN + return int(T_RETURN) goto yystate0 } yyrule60: // static { lval.Token(l.createToken(l.Token())) - return T_STATIC + return int(T_STATIC) goto yystate0 } yyrule61: // switch { lval.Token(l.createToken(l.Token())) - return T_SWITCH + return int(T_SWITCH) goto yystate0 } yyrule62: // throw { lval.Token(l.createToken(l.Token())) - return T_THROW + return int(T_THROW) goto yystate0 } yyrule63: // trait { lval.Token(l.createToken(l.Token())) - return T_TRAIT + return int(T_TRAIT) goto yystate0 } yyrule64: // try { lval.Token(l.createToken(l.Token())) - return T_TRY + return int(T_TRY) goto yystate0 } yyrule65: // unset { lval.Token(l.createToken(l.Token())) - return T_UNSET + return int(T_UNSET) goto yystate0 } yyrule66: // use { lval.Token(l.createToken(l.Token())) - return T_USE + return int(T_USE) goto yystate0 } yyrule67: // var { lval.Token(l.createToken(l.Token())) - return T_VAR + return int(T_VAR) goto yystate0 } yyrule68: // while { lval.Token(l.createToken(l.Token())) - return T_WHILE + return int(T_WHILE) goto yystate0 } -yyrule69: // yield[ \t\n\r]+from[^a-zA-Z0-9_\x80-\xff] +yyrule69: // yield[ \t\n\r]+from { lval.Token(l.createToken(l.Token())) - return T_YIELD_FROM + return int(T_YIELD_FROM) goto yystate0 } yyrule70: // yield { lval.Token(l.createToken(l.Token())) - return T_YIELD + return int(T_YIELD) goto yystate0 } yyrule71: // include { lval.Token(l.createToken(l.Token())) - return T_INCLUDE + return int(T_INCLUDE) goto yystate0 } yyrule72: // include_once { lval.Token(l.createToken(l.Token())) - return T_INCLUDE_ONCE + return int(T_INCLUDE_ONCE) goto yystate0 } yyrule73: // require { lval.Token(l.createToken(l.Token())) - return T_REQUIRE + return int(T_REQUIRE) goto yystate0 } yyrule74: // require_once { lval.Token(l.createToken(l.Token())) - return T_REQUIRE_ONCE + return int(T_REQUIRE_ONCE) goto yystate0 } yyrule75: // __CLASS__ { lval.Token(l.createToken(l.Token())) - return T_CLASS_C + return int(T_CLASS_C) goto yystate0 } yyrule76: // __DIR__ { lval.Token(l.createToken(l.Token())) - return T_DIR + return int(T_DIR) goto yystate0 } yyrule77: // __FILE__ { lval.Token(l.createToken(l.Token())) - return T_FILE + return int(T_FILE) goto yystate0 } yyrule78: // __FUNCTION__ { lval.Token(l.createToken(l.Token())) - return T_FUNC_C + return int(T_FUNC_C) goto yystate0 } yyrule79: // __LINE__ { lval.Token(l.createToken(l.Token())) - return T_LINE + return int(T_LINE) goto yystate0 } yyrule80: // __NAMESPACE__ { lval.Token(l.createToken(l.Token())) - return T_NS_C + return int(T_NS_C) goto yystate0 } yyrule81: // __METHOD__ { lval.Token(l.createToken(l.Token())) - return T_METHOD_C + return int(T_METHOD_C) goto yystate0 } yyrule82: // __TRAIT__ { lval.Token(l.createToken(l.Token())) - return T_TRAIT_C + return int(T_TRAIT_C) goto yystate0 } yyrule83: // __halt_compiler { lval.Token(l.createToken(l.Token())) - return T_HALT_COMPILER + return int(T_HALT_COMPILER) goto yystate0 } yyrule84: // \([ \t]*array[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_ARRAY_CAST + return int(T_ARRAY_CAST) goto yystate0 } yyrule85: // \([ \t]*(bool|boolean)[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_BOOL_CAST + return int(T_BOOL_CAST) goto yystate0 } yyrule86: // \([ \t]*(real|double|float)[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_DOUBLE_CAST + return int(T_DOUBLE_CAST) goto yystate0 } yyrule87: // \([ \t]*(int|integer)[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_INT_CAST + return int(T_INT_CAST) goto yystate0 } yyrule88: // \([ \t]*object[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_OBJECT_CAST + return int(T_OBJECT_CAST) goto yystate0 } yyrule89: // \([ \t]*(string|binary)[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_STRING_CAST + return int(T_STRING_CAST) goto yystate0 } yyrule90: // \([ \t]*unset[ \t]*\) { lval.Token(l.createToken(l.Token())) - return T_UNSET_CAST + return int(T_UNSET_CAST) goto yystate0 } yyrule91: // new { lval.Token(l.createToken(l.Token())) - return T_NEW + return int(T_NEW) goto yystate0 } yyrule92: // and { lval.Token(l.createToken(l.Token())) - return T_LOGICAL_AND + return int(T_LOGICAL_AND) goto yystate0 } yyrule93: // or { lval.Token(l.createToken(l.Token())) - return T_LOGICAL_OR + return int(T_LOGICAL_OR) goto yystate0 } yyrule94: // xor { lval.Token(l.createToken(l.Token())) - return T_LOGICAL_XOR + return int(T_LOGICAL_XOR) goto yystate0 } yyrule95: // \\ { lval.Token(l.createToken(l.Token())) - return T_NS_SEPARATOR + return int(T_NS_SEPARATOR) goto yystate0 } yyrule96: // \.\.\. { lval.Token(l.createToken(l.Token())) - return T_ELLIPSIS + return int(T_ELLIPSIS) goto yystate0 } yyrule97: // :: { lval.Token(l.createToken(l.Token())) - return T_PAAMAYIM_NEKUDOTAYIM // T_DOUBLE_COLON + return int(T_PAAMAYIM_NEKUDOTAYIM) // T_DOUBLE_COLON goto yystate0 } yyrule98: // && { lval.Token(l.createToken(l.Token())) - return T_BOOLEAN_AND + return int(T_BOOLEAN_AND) goto yystate0 } yyrule99: // \|\| { lval.Token(l.createToken(l.Token())) - return T_BOOLEAN_OR + return int(T_BOOLEAN_OR) goto yystate0 } yyrule100: // &= { lval.Token(l.createToken(l.Token())) - return T_AND_EQUAL + return int(T_AND_EQUAL) goto yystate0 } yyrule101: // \|= { lval.Token(l.createToken(l.Token())) - return T_OR_EQUAL + return int(T_OR_EQUAL) goto yystate0 } yyrule102: // \.= { lval.Token(l.createToken(l.Token())) - return T_CONCAT_EQUAL + return int(T_CONCAT_EQUAL) goto yystate0 } yyrule103: // \*= { lval.Token(l.createToken(l.Token())) - return T_MUL_EQUAL + return int(T_MUL_EQUAL) goto yystate0 } yyrule104: // \*\*= { lval.Token(l.createToken(l.Token())) - return T_POW_EQUAL + return int(T_POW_EQUAL) goto yystate0 } yyrule105: // [/]= { lval.Token(l.createToken(l.Token())) - return T_DIV_EQUAL + return int(T_DIV_EQUAL) goto yystate0 } yyrule106: // \+= { lval.Token(l.createToken(l.Token())) - return T_PLUS_EQUAL + return int(T_PLUS_EQUAL) goto yystate0 } yyrule107: // -= { lval.Token(l.createToken(l.Token())) - return T_MINUS_EQUAL + return int(T_MINUS_EQUAL) goto yystate0 } yyrule108: // \^= { lval.Token(l.createToken(l.Token())) - return T_XOR_EQUAL + return int(T_XOR_EQUAL) goto yystate0 } yyrule109: // %= { lval.Token(l.createToken(l.Token())) - return T_MOD_EQUAL + return int(T_MOD_EQUAL) goto yystate0 } yyrule110: // -- { lval.Token(l.createToken(l.Token())) - return T_DEC + return int(T_DEC) goto yystate0 } yyrule111: // \+\+ { lval.Token(l.createToken(l.Token())) - return T_INC + return int(T_INC) goto yystate0 } yyrule112: // => { lval.Token(l.createToken(l.Token())) - return T_DOUBLE_ARROW + return int(T_DOUBLE_ARROW) goto yystate0 } yyrule113: // \<=\> { lval.Token(l.createToken(l.Token())) - return T_SPACESHIP + return int(T_SPACESHIP) goto yystate0 } yyrule114: // \!=|\<\> { lval.Token(l.createToken(l.Token())) - return T_IS_NOT_EQUAL + return int(T_IS_NOT_EQUAL) goto yystate0 } yyrule115: // \!== { lval.Token(l.createToken(l.Token())) - return T_IS_NOT_IDENTICAL + return int(T_IS_NOT_IDENTICAL) goto yystate0 } yyrule116: // == { lval.Token(l.createToken(l.Token())) - return T_IS_EQUAL + return int(T_IS_EQUAL) goto yystate0 } yyrule117: // === { lval.Token(l.createToken(l.Token())) - return T_IS_IDENTICAL + return int(T_IS_IDENTICAL) goto yystate0 } yyrule118: // \<\<= { lval.Token(l.createToken(l.Token())) - return T_SL_EQUAL + return int(T_SL_EQUAL) goto yystate0 } yyrule119: // \>\>= { lval.Token(l.createToken(l.Token())) - return T_SR_EQUAL + return int(T_SR_EQUAL) goto yystate0 } yyrule120: // \>= { lval.Token(l.createToken(l.Token())) - return T_IS_GREATER_OR_EQUAL + return int(T_IS_GREATER_OR_EQUAL) goto yystate0 } yyrule121: // \<= { lval.Token(l.createToken(l.Token())) - return T_IS_SMALLER_OR_EQUAL + return int(T_IS_SMALLER_OR_EQUAL) goto yystate0 } yyrule122: // \*\* { lval.Token(l.createToken(l.Token())) - return T_POW + return int(T_POW) goto yystate0 } yyrule123: // \<\< { lval.Token(l.createToken(l.Token())) - return T_SL + return int(T_SL) goto yystate0 } yyrule124: // \>\> { lval.Token(l.createToken(l.Token())) - return T_SR + return int(T_SR) goto yystate0 } yyrule125: // \?\? { lval.Token(l.createToken(l.Token())) - return T_COALESCE + return int(T_COALESCE) goto yystate0 } yyrule126: // (#|[/][/]) @@ -8464,6 +8463,7 @@ yyrule126: // (#|[/][/]) } case '\n': + c = l.Next() case '?': c = l.Next() if c == '>' { @@ -8478,13 +8478,13 @@ yyrule126: // (#|[/][/]) } break } - l.addComment(tb) + l.addFreeFloating(freefloating.CommentType, tb) goto yystate0 } yyrule127: // [/][*][*][/] { - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) goto yystate0 } yyrule128: // ([/][*])|([/][*][*]) @@ -8509,9 +8509,9 @@ yyrule128: // ([/][*])|([/][*][*]) } if is_doc_comment { l.PhpDocComment = string(l.TokenBytes(nil)) - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) } else { - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) } goto yystate0 } @@ -8539,36 +8539,38 @@ yyrule131: // \} yyrule132: // \${VAR_NAME} { lval.Token(l.createToken(l.Token())) - return T_VARIABLE + return int(T_VARIABLE) goto yystate0 } yyrule133: // {VAR_NAME} { lval.Token(l.createToken(l.Token())) - return T_STRING + return int(T_STRING) goto yystate0 } yyrule134: // -> { l.Begin(PROPERTY) lval.Token(l.createToken(l.Token())) - return T_OBJECT_OPERATOR + return int(T_OBJECT_OPERATOR) goto yystate0 } yyrule135: // [ \t\n\r]+ - - goto yystate0 + { + l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) + goto yystate0 + } yyrule136: // -> { lval.Token(l.createToken(l.Token())) - return T_OBJECT_OPERATOR + return int(T_OBJECT_OPERATOR) goto yystate0 } yyrule137: // {VAR_NAME} { l.Begin(PHP) lval.Token(l.createToken(l.Token())) - return T_STRING + return int(T_STRING) goto yystate0 } yyrule138: // . @@ -8580,7 +8582,7 @@ yyrule138: // . yyrule139: // [\']([^\\\']*(\\(.|\n))*)*[\'] { lval.Token(l.createToken(l.Token())) - return T_CONSTANT_ENCAPSED_STRING + return int(T_CONSTANT_ENCAPSED_STRING) goto yystate0 } yyrule140: // ` @@ -8652,7 +8654,7 @@ yyrule142: // [b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["])) } l.ungetChars(ungetCnt) lval.Token(l.createToken(heredocToken)) - return T_START_HEREDOC + return int(T_START_HEREDOC) } yyrule143: // .|[ \t\n\r] { @@ -8668,11 +8670,13 @@ yyrule143: // .|[ \t\n\r] if l.heredocLabel+";" == string(searchLabel) { l.Begin(HEREDOC_END) tb = l.ungetChars(len(l.heredocLabel) + 1) + tb = tb[:len(tb)-1] break } if l.heredocLabel == string(searchLabel) { l.Begin(HEREDOC_END) tb = l.ungetChars(len(l.heredocLabel)) + tb = tb[:len(tb)-1] break } @@ -8683,20 +8687,20 @@ yyrule143: // .|[ \t\n\r] c = l.Next() } lval.Token(l.createToken(tb)) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } yyrule144: // {VAR_NAME}\; { l.Begin(PHP) lval.Token(l.createToken(l.ungetChars(1))) - return T_END_HEREDOC + return int(T_END_HEREDOC) goto yystate0 } yyrule145: // {VAR_NAME} { l.Begin(PHP) lval.Token(l.createToken(l.Token())) - return T_END_HEREDOC + return int(T_END_HEREDOC) goto yystate0 } yyrule146: // [b]?[\"] @@ -8724,7 +8728,7 @@ yyrule146: // [b]?[\"] case '"': c = l.Next() lval.Token(l.createToken(l.Token())) - return T_CONSTANT_ENCAPSED_STRING + return int(T_CONSTANT_ENCAPSED_STRING) break F case '$': @@ -8760,14 +8764,14 @@ yyrule148: // \{\$ { lval.Token(l.createToken(l.ungetChars(1))) l.pushState(PHP) - return T_CURLY_OPEN + return int(T_CURLY_OPEN) goto yystate0 } yyrule149: // \$\{ { l.pushState(STRING_VAR_NAME) lval.Token(l.createToken(l.Token())) - return T_DOLLAR_OPEN_CURLY_BRACES + return int(T_DOLLAR_OPEN_CURLY_BRACES) goto yystate0 } yyrule150: // \${VAR_NAME} @@ -8787,13 +8791,13 @@ yyrule151: // .|[ \t\n\r] if c == '{' || isValidFirstVarNameRune(rune(c)) { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '{': if rune(c) == '$' { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '\\': currentChar := l.Last @@ -8802,7 +8806,7 @@ yyrule151: // .|[ \t\n\r] } if rune(c) == '"' { lval.Token(l.createToken(l.Token())) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } currentChar = l.Last tb = append(tb, currentChar) @@ -8824,13 +8828,13 @@ yyrule152: // .|[ \t\n\r] if c == '{' || isValidFirstVarNameRune(rune(c)) { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '{': if rune(c) == '$' { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '\\': currentChar := l.Last @@ -8839,7 +8843,7 @@ yyrule152: // .|[ \t\n\r] } if rune(c) == '`' { lval.Token(l.createToken(l.Token())) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } currentChar = l.Last tb = append(tb, currentChar) @@ -8854,64 +8858,73 @@ yyrule153: // .|[ \t\n\r] { searchLabel := []byte{} - tb := []lex.Char{} + currentChar := l.Prev + tb := []lex.Char{currentChar} + HEREDOC_FOR: for { - if c == -1 { - break - } nls := 0 - switch c { + switch currentChar.Rune { case '\r': - nls = 1 - c := l.Next() - if c != '\n' { - nls = 0 - l.ungetChars(0) + if c == '\n' { + nls = 1 + currentChar := l.Last + tb = append(tb, currentChar) + c = l.Next() } fallthrough case '\n': if l.heredocLabel+";" == string(searchLabel) { l.Begin(HEREDOC_END) - tb = l.ungetChars(len(l.heredocLabel) + 1 + nls) + l.ungetChars(len(l.heredocLabel) + 1 + nls) + i := len(tb) - len(l.heredocLabel) - 3 - nls + if i < 1 { + break HEREDOC_FOR + } + tb = tb[:i] lval.Token(l.createToken(tb)) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } if l.heredocLabel == string(searchLabel) { l.Begin(HEREDOC_END) - tb = l.ungetChars(len(l.heredocLabel) + nls) + l.ungetChars(len(l.heredocLabel) + nls) + i := len(tb) - len(l.heredocLabel) - 2 - nls + if i < 1 { + break HEREDOC_FOR + } + tb = tb[:i] lval.Token(l.createToken(tb)) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } searchLabel = []byte{} - case '$': - c = l.Next() - if rune(c) == '{' || isValidFirstVarNameRune(rune(c)) { - tb = l.ungetChars(1) - lval.Token(l.createToken(tb)) - return T_ENCAPSED_AND_WHITESPACE + if c == '{' || isValidFirstVarNameRune(rune(c)) { + l.ungetChars(1) + lval.Token(l.createToken(tb[:len(tb)-1])) + return int(T_ENCAPSED_AND_WHITESPACE) } - l.ungetChars(0) - case '{': - c = l.Next() if rune(c) == '$' { - tb = l.ungetChars(1) - lval.Token(l.createToken(tb)) - return T_ENCAPSED_AND_WHITESPACE + l.ungetChars(1) + lval.Token(l.createToken(tb[:len(tb)-1])) + return int(T_ENCAPSED_AND_WHITESPACE) } - l.ungetChars(0) case '\\': - c = l.Next() - if c == '\n' || c == '\r' { - l.ungetChars(0) + if c != '\n' && c != '\r' { + currentChar := l.Last + tb = append(tb, currentChar) + c = l.Next() } default: - searchLabel = append(searchLabel, byte(rune(c))) + searchLabel = append(searchLabel, byte(rune(currentChar.Rune))) } + if c == -1 { + break + } + currentChar = l.Last + tb = append(tb, currentChar) c = l.Next() } goto yystate0 @@ -8919,20 +8932,20 @@ yyrule153: // .|[ \t\n\r] yyrule154: // \${VAR_NAME} { lval.Token(l.createToken(l.Token())) - return T_VARIABLE + return int(T_VARIABLE) goto yystate0 } yyrule155: // ->{VAR_NAME} { lval.Token(l.createToken(l.ungetChars(len(l.Token()) - 2))) - return T_OBJECT_OPERATOR + return int(T_OBJECT_OPERATOR) goto yystate0 } yyrule156: // {VAR_NAME} { l.popState() lval.Token(l.createToken(l.Token())) - return T_STRING + return int(T_STRING) goto yystate0 } yyrule157: // \[ @@ -8951,19 +8964,19 @@ yyrule158: // .|[ \t\n\r] yyrule159: // {LNUM}|{HNUM}|{BNUM} { lval.Token(l.createToken(l.Token())) - return T_NUM_STRING + return int(T_NUM_STRING) goto yystate0 } yyrule160: // \${VAR_NAME} { lval.Token(l.createToken(l.Token())) - return T_VARIABLE + return int(T_VARIABLE) goto yystate0 } yyrule161: // {VAR_NAME} { lval.Token(l.createToken(l.Token())) - return T_STRING + return int(T_STRING) goto yystate0 } yyrule162: // \] @@ -8979,7 +8992,7 @@ yyrule163: // [ \n\r\t\\'#] l.popState() l.popState() lval.Token(l.createToken(l.Token())) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) goto yystate0 } yyrule164: // {OPERATORS} @@ -8999,7 +9012,7 @@ yyrule166: // {VAR_NAME}[\[\}] l.popState() l.pushState(PHP) lval.Token(l.createToken(l.ungetChars(1))) - return T_STRING_VARNAME + return int(T_STRING_VARNAME) goto yystate0 } yyrule167: // . @@ -9011,7 +9024,7 @@ yyrule167: // . } yyrule168: // .|[ \t\n\r] { - // do nothing + l.addFreeFloating(freefloating.TokenType, l.Token()) goto yystate0 } yyrule169: // {ANY_CHAR} @@ -9025,8 +9038,13 @@ yyrule169: // {ANY_CHAR} goto yyabort // silence unused label error yyabort: // no lexem recognized - if c, ok := l.Abort(); ok { - return int(c) + if _, ok := l.Abort(); ok { + // always return same $end token + if l.lastToken == nil { + l.lastToken = l.createToken(l.Token()) + } + lval.Token(l.lastToken) + return -1 } goto yyAction } diff --git a/scanner/scanner.l b/scanner/scanner.l index abcf2d3..3986e50 100644 --- a/scanner/scanner.l +++ b/scanner/scanner.l @@ -9,6 +9,7 @@ package scanner import ( "fmt" + "github.com/z7zmey/php-parser/freefloating" "github.com/cznic/golex/lex" ) @@ -32,9 +33,8 @@ func isValidFirstVarNameRune(r rune) bool { } func (l *Lexer) Lex(lval Lval) int { - l.Comments = nil + l.FreeFloating = nil c := l.Enter() - %} %s PHP STRING STRING_VAR STRING_VAR_INDEX STRING_VAR_NAME PROPERTY HEREDOC_END NOWDOC HEREDOC BACKQUOTE HALT_COMPILER @@ -59,7 +59,7 @@ ANY_CHAR . %% c = l.Rule0() -[ \t\n\r]+ +[ \t\n\r]+ l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) . tb := []lex.Char{} @@ -84,17 +84,18 @@ ANY_CHAR . } lval.Token(l.createToken(tb)) - return T_INLINE_HTML + return int(T_INLINE_HTML) -\<\?php([ \t]|{NEW_LINE}) l.Begin(PHP); -\<\? l.Begin(PHP); -\<\?= l.Begin(PHP);lval.Token(l.createToken(l.Token())); return T_ECHO; +\<\?php([ \t]|{NEW_LINE}) l.addFreeFloating(freefloating.TokenType, l.Token()[:5]);l.Begin(PHP);l.ungetChars(len(l.Token())-5) +\<\? l.addFreeFloating(freefloating.TokenType, l.Token());l.Begin(PHP); +\<\?= l.Begin(PHP);lval.Token(l.createToken(l.Token())); return int(T_ECHO); -[ \t\n\r]+ + +[ \t\n\r]+ l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) [;][ \t\n\r]*\?\>{NEW_LINE}? l.Begin(INITIAL);lval.Token(l.createToken(l.Token())); return Rune2Class(';'); \?\>{NEW_LINE}? l.Begin(INITIAL);lval.Token(l.createToken(l.Token())); return Rune2Class(';'); -{DNUM}|{EXPONENT_DNUM} lval.Token(l.createToken(l.Token())); return T_DNUMBER +{DNUM}|{EXPONENT_DNUM} lval.Token(l.createToken(l.Token())); return int(T_DNUMBER) {BNUM} tb := l.Token() i:=2 @@ -108,15 +109,15 @@ ANY_CHAR . } } if len(tb) - i < 64 { - lval.Token(l.createToken(l.Token())); return T_LNUMBER + lval.Token(l.createToken(l.Token())); return int(T_LNUMBER) } else { - lval.Token(l.createToken(l.Token())); return T_DNUMBER + lval.Token(l.createToken(l.Token())); return int(T_DNUMBER) } {LNUM} if len(l.Token()) < 20 { - lval.Token(l.createToken(l.Token())); return T_LNUMBER + lval.Token(l.createToken(l.Token())); return int(T_LNUMBER) } else { - lval.Token(l.createToken(l.Token())); return T_DNUMBER + lval.Token(l.createToken(l.Token())); return int(T_DNUMBER) } {HNUM} tb := l.Token() @@ -132,124 +133,124 @@ ANY_CHAR . } length := len(tb) - i if length < 16 || (length == 16 && tb[i].Rune <= '7') { - lval.Token(l.createToken(l.Token())); return T_LNUMBER + lval.Token(l.createToken(l.Token())); return int(T_LNUMBER) } else { - lval.Token(l.createToken(l.Token())); return T_DNUMBER + lval.Token(l.createToken(l.Token())); return int(T_DNUMBER) } -abstract lval.Token(l.createToken(l.Token())); return T_ABSTRACT -array lval.Token(l.createToken(l.Token())); return T_ARRAY -as lval.Token(l.createToken(l.Token())); return T_AS -break lval.Token(l.createToken(l.Token())); return T_BREAK -callable lval.Token(l.createToken(l.Token())); return T_CALLABLE -case lval.Token(l.createToken(l.Token())); return T_CASE -catch lval.Token(l.createToken(l.Token())); return T_CATCH -class lval.Token(l.createToken(l.Token())); return T_CLASS -clone lval.Token(l.createToken(l.Token())); return T_CLONE -const lval.Token(l.createToken(l.Token())); return T_CONST -continue lval.Token(l.createToken(l.Token())); return T_CONTINUE -declare lval.Token(l.createToken(l.Token())); return T_DECLARE -default lval.Token(l.createToken(l.Token())); return T_DEFAULT -do lval.Token(l.createToken(l.Token())); return T_DO -echo lval.Token(l.createToken(l.Token())); return T_ECHO -else lval.Token(l.createToken(l.Token())); return T_ELSE -elseif lval.Token(l.createToken(l.Token())); return T_ELSEIF -empty lval.Token(l.createToken(l.Token())); return T_EMPTY -enddeclare lval.Token(l.createToken(l.Token())); return T_ENDDECLARE -endfor lval.Token(l.createToken(l.Token())); return T_ENDFOR -endforeach lval.Token(l.createToken(l.Token())); return T_ENDFOREACH -endif lval.Token(l.createToken(l.Token())); return T_ENDIF -endswitch lval.Token(l.createToken(l.Token())); return T_ENDSWITCH -endwhile lval.Token(l.createToken(l.Token())); return T_ENDWHILE -eval lval.Token(l.createToken(l.Token())); return T_EVAL -exit|die lval.Token(l.createToken(l.Token())); return T_EXIT -extends lval.Token(l.createToken(l.Token())); return T_EXTENDS -final lval.Token(l.createToken(l.Token())); return T_FINAL -finally lval.Token(l.createToken(l.Token())); return T_FINALLY -for lval.Token(l.createToken(l.Token())); return T_FOR -foreach lval.Token(l.createToken(l.Token())); return T_FOREACH -function|cfunction lval.Token(l.createToken(l.Token())); return T_FUNCTION -global lval.Token(l.createToken(l.Token())); return T_GLOBAL -goto lval.Token(l.createToken(l.Token())); return T_GOTO -if lval.Token(l.createToken(l.Token())); return T_IF -isset lval.Token(l.createToken(l.Token())); return T_ISSET -implements lval.Token(l.createToken(l.Token())); return T_IMPLEMENTS -instanceof lval.Token(l.createToken(l.Token())); return T_INSTANCEOF -insteadof lval.Token(l.createToken(l.Token())); return T_INSTEADOF -interface lval.Token(l.createToken(l.Token())); return T_INTERFACE -list lval.Token(l.createToken(l.Token())); return T_LIST -namespace lval.Token(l.createToken(l.Token())); return T_NAMESPACE -private lval.Token(l.createToken(l.Token())); return T_PRIVATE -public lval.Token(l.createToken(l.Token())); return T_PUBLIC -print lval.Token(l.createToken(l.Token())); return T_PRINT -protected lval.Token(l.createToken(l.Token())); return T_PROTECTED -return lval.Token(l.createToken(l.Token())); return T_RETURN -static lval.Token(l.createToken(l.Token())); return T_STATIC -switch lval.Token(l.createToken(l.Token())); return T_SWITCH -throw lval.Token(l.createToken(l.Token())); return T_THROW -trait lval.Token(l.createToken(l.Token())); return T_TRAIT -try lval.Token(l.createToken(l.Token())); return T_TRY -unset lval.Token(l.createToken(l.Token())); return T_UNSET -use lval.Token(l.createToken(l.Token())); return T_USE -var lval.Token(l.createToken(l.Token())); return T_VAR -while lval.Token(l.createToken(l.Token())); return T_WHILE -yield[ \t\n\r]+from[^a-zA-Z0-9_\x80-\xff] lval.Token(l.createToken(l.Token())); return T_YIELD_FROM -yield lval.Token(l.createToken(l.Token())); return T_YIELD -include lval.Token(l.createToken(l.Token())); return T_INCLUDE -include_once lval.Token(l.createToken(l.Token())); return T_INCLUDE_ONCE -require lval.Token(l.createToken(l.Token())); return T_REQUIRE -require_once lval.Token(l.createToken(l.Token())); return T_REQUIRE_ONCE -__CLASS__ lval.Token(l.createToken(l.Token())); return T_CLASS_C -__DIR__ lval.Token(l.createToken(l.Token())); return T_DIR -__FILE__ lval.Token(l.createToken(l.Token())); return T_FILE -__FUNCTION__ lval.Token(l.createToken(l.Token())); return T_FUNC_C -__LINE__ lval.Token(l.createToken(l.Token())); return T_LINE -__NAMESPACE__ lval.Token(l.createToken(l.Token())); return T_NS_C -__METHOD__ lval.Token(l.createToken(l.Token())); return T_METHOD_C -__TRAIT__ lval.Token(l.createToken(l.Token())); return T_TRAIT_C -__halt_compiler lval.Token(l.createToken(l.Token())); return T_HALT_COMPILER -\([ \t]*array[ \t]*\) lval.Token(l.createToken(l.Token())); return T_ARRAY_CAST -\([ \t]*(bool|boolean)[ \t]*\) lval.Token(l.createToken(l.Token())); return T_BOOL_CAST -\([ \t]*(real|double|float)[ \t]*\) lval.Token(l.createToken(l.Token())); return T_DOUBLE_CAST -\([ \t]*(int|integer)[ \t]*\) lval.Token(l.createToken(l.Token())); return T_INT_CAST -\([ \t]*object[ \t]*\) lval.Token(l.createToken(l.Token())); return T_OBJECT_CAST -\([ \t]*(string|binary)[ \t]*\) lval.Token(l.createToken(l.Token())); return T_STRING_CAST -\([ \t]*unset[ \t]*\) lval.Token(l.createToken(l.Token())); return T_UNSET_CAST -new lval.Token(l.createToken(l.Token())); return T_NEW -and lval.Token(l.createToken(l.Token())); return T_LOGICAL_AND -or lval.Token(l.createToken(l.Token())); return T_LOGICAL_OR -xor lval.Token(l.createToken(l.Token())); return T_LOGICAL_XOR -\\ lval.Token(l.createToken(l.Token())); return T_NS_SEPARATOR -\.\.\. lval.Token(l.createToken(l.Token())); return T_ELLIPSIS -:: lval.Token(l.createToken(l.Token())); return T_PAAMAYIM_NEKUDOTAYIM // T_DOUBLE_COLON -&& lval.Token(l.createToken(l.Token())); return T_BOOLEAN_AND -\|\| lval.Token(l.createToken(l.Token())); return T_BOOLEAN_OR -&= lval.Token(l.createToken(l.Token())); return T_AND_EQUAL -\|= lval.Token(l.createToken(l.Token())); return T_OR_EQUAL -\.= lval.Token(l.createToken(l.Token())); return T_CONCAT_EQUAL -\*= lval.Token(l.createToken(l.Token())); return T_MUL_EQUAL -\*\*= lval.Token(l.createToken(l.Token())); return T_POW_EQUAL -[/]= lval.Token(l.createToken(l.Token())); return T_DIV_EQUAL -\+= lval.Token(l.createToken(l.Token())); return T_PLUS_EQUAL --= lval.Token(l.createToken(l.Token())); return T_MINUS_EQUAL -\^= lval.Token(l.createToken(l.Token())); return T_XOR_EQUAL -%= lval.Token(l.createToken(l.Token())); return T_MOD_EQUAL --- lval.Token(l.createToken(l.Token())); return T_DEC -\+\+ lval.Token(l.createToken(l.Token())); return T_INC -=> lval.Token(l.createToken(l.Token())); return T_DOUBLE_ARROW -\<=\> lval.Token(l.createToken(l.Token())); return T_SPACESHIP -\!=|\<\> lval.Token(l.createToken(l.Token())); return T_IS_NOT_EQUAL -\!== lval.Token(l.createToken(l.Token())); return T_IS_NOT_IDENTICAL -== lval.Token(l.createToken(l.Token())); return T_IS_EQUAL -=== lval.Token(l.createToken(l.Token())); return T_IS_IDENTICAL -\<\<= lval.Token(l.createToken(l.Token())); return T_SL_EQUAL -\>\>= lval.Token(l.createToken(l.Token())); return T_SR_EQUAL -\>= lval.Token(l.createToken(l.Token())); return T_IS_GREATER_OR_EQUAL -\<= lval.Token(l.createToken(l.Token())); return T_IS_SMALLER_OR_EQUAL -\*\* lval.Token(l.createToken(l.Token())); return T_POW -\<\< lval.Token(l.createToken(l.Token())); return T_SL -\>\> lval.Token(l.createToken(l.Token())); return T_SR -\?\? lval.Token(l.createToken(l.Token())); return T_COALESCE +abstract lval.Token(l.createToken(l.Token())); return int(T_ABSTRACT) +array lval.Token(l.createToken(l.Token())); return int(T_ARRAY) +as lval.Token(l.createToken(l.Token())); return int(T_AS) +break lval.Token(l.createToken(l.Token())); return int(T_BREAK) +callable lval.Token(l.createToken(l.Token())); return int(T_CALLABLE) +case lval.Token(l.createToken(l.Token())); return int(T_CASE) +catch lval.Token(l.createToken(l.Token())); return int(T_CATCH) +class lval.Token(l.createToken(l.Token())); return int(T_CLASS) +clone lval.Token(l.createToken(l.Token())); return int(T_CLONE) +const lval.Token(l.createToken(l.Token())); return int(T_CONST) +continue lval.Token(l.createToken(l.Token())); return int(T_CONTINUE) +declare lval.Token(l.createToken(l.Token())); return int(T_DECLARE) +default lval.Token(l.createToken(l.Token())); return int(T_DEFAULT) +do lval.Token(l.createToken(l.Token())); return int(T_DO) +echo lval.Token(l.createToken(l.Token())); return int(T_ECHO) +else lval.Token(l.createToken(l.Token())); return int(T_ELSE) +elseif lval.Token(l.createToken(l.Token())); return int(T_ELSEIF) +empty lval.Token(l.createToken(l.Token())); return int(T_EMPTY) +enddeclare lval.Token(l.createToken(l.Token())); return int(T_ENDDECLARE) +endfor lval.Token(l.createToken(l.Token())); return int(T_ENDFOR) +endforeach lval.Token(l.createToken(l.Token())); return int(T_ENDFOREACH) +endif lval.Token(l.createToken(l.Token())); return int(T_ENDIF) +endswitch lval.Token(l.createToken(l.Token())); return int(T_ENDSWITCH) +endwhile lval.Token(l.createToken(l.Token())); return int(T_ENDWHILE) +eval lval.Token(l.createToken(l.Token())); return int(T_EVAL) +exit|die lval.Token(l.createToken(l.Token())); return int(T_EXIT) +extends lval.Token(l.createToken(l.Token())); return int(T_EXTENDS) +final lval.Token(l.createToken(l.Token())); return int(T_FINAL) +finally lval.Token(l.createToken(l.Token())); return int(T_FINALLY) +for lval.Token(l.createToken(l.Token())); return int(T_FOR) +foreach lval.Token(l.createToken(l.Token())); return int(T_FOREACH) +function|cfunction lval.Token(l.createToken(l.Token())); return int(T_FUNCTION) +global lval.Token(l.createToken(l.Token())); return int(T_GLOBAL) +goto lval.Token(l.createToken(l.Token())); return int(T_GOTO) +if lval.Token(l.createToken(l.Token())); return int(T_IF) +isset lval.Token(l.createToken(l.Token())); return int(T_ISSET) +implements lval.Token(l.createToken(l.Token())); return int(T_IMPLEMENTS) +instanceof lval.Token(l.createToken(l.Token())); return int(T_INSTANCEOF) +insteadof lval.Token(l.createToken(l.Token())); return int(T_INSTEADOF) +interface lval.Token(l.createToken(l.Token())); return int(T_INTERFACE) +list lval.Token(l.createToken(l.Token())); return int(T_LIST) +namespace lval.Token(l.createToken(l.Token())); return int(T_NAMESPACE) +private lval.Token(l.createToken(l.Token())); return int(T_PRIVATE) +public lval.Token(l.createToken(l.Token())); return int(T_PUBLIC) +print lval.Token(l.createToken(l.Token())); return int(T_PRINT) +protected lval.Token(l.createToken(l.Token())); return int(T_PROTECTED) +return lval.Token(l.createToken(l.Token())); return int(T_RETURN) +static lval.Token(l.createToken(l.Token())); return int(T_STATIC) +switch lval.Token(l.createToken(l.Token())); return int(T_SWITCH) +throw lval.Token(l.createToken(l.Token())); return int(T_THROW) +trait lval.Token(l.createToken(l.Token())); return int(T_TRAIT) +try lval.Token(l.createToken(l.Token())); return int(T_TRY) +unset lval.Token(l.createToken(l.Token())); return int(T_UNSET) +use lval.Token(l.createToken(l.Token())); return int(T_USE) +var lval.Token(l.createToken(l.Token())); return int(T_VAR) +while lval.Token(l.createToken(l.Token())); return int(T_WHILE) +yield[ \t\n\r]+from lval.Token(l.createToken(l.Token())); return int(T_YIELD_FROM) +yield lval.Token(l.createToken(l.Token())); return int(T_YIELD) +include lval.Token(l.createToken(l.Token())); return int(T_INCLUDE) +include_once lval.Token(l.createToken(l.Token())); return int(T_INCLUDE_ONCE) +require lval.Token(l.createToken(l.Token())); return int(T_REQUIRE) +require_once lval.Token(l.createToken(l.Token())); return int(T_REQUIRE_ONCE) +__CLASS__ lval.Token(l.createToken(l.Token())); return int(T_CLASS_C) +__DIR__ lval.Token(l.createToken(l.Token())); return int(T_DIR) +__FILE__ lval.Token(l.createToken(l.Token())); return int(T_FILE) +__FUNCTION__ lval.Token(l.createToken(l.Token())); return int(T_FUNC_C) +__LINE__ lval.Token(l.createToken(l.Token())); return int(T_LINE) +__NAMESPACE__ lval.Token(l.createToken(l.Token())); return int(T_NS_C) +__METHOD__ lval.Token(l.createToken(l.Token())); return int(T_METHOD_C) +__TRAIT__ lval.Token(l.createToken(l.Token())); return int(T_TRAIT_C) +__halt_compiler lval.Token(l.createToken(l.Token())); return int(T_HALT_COMPILER) +\([ \t]*array[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_ARRAY_CAST) +\([ \t]*(bool|boolean)[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_BOOL_CAST) +\([ \t]*(real|double|float)[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_DOUBLE_CAST) +\([ \t]*(int|integer)[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_INT_CAST) +\([ \t]*object[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_OBJECT_CAST) +\([ \t]*(string|binary)[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_STRING_CAST) +\([ \t]*unset[ \t]*\) lval.Token(l.createToken(l.Token())); return int(T_UNSET_CAST) +new lval.Token(l.createToken(l.Token())); return int(T_NEW) +and lval.Token(l.createToken(l.Token())); return int(T_LOGICAL_AND) +or lval.Token(l.createToken(l.Token())); return int(T_LOGICAL_OR) +xor lval.Token(l.createToken(l.Token())); return int(T_LOGICAL_XOR) +\\ lval.Token(l.createToken(l.Token())); return int(T_NS_SEPARATOR) +\.\.\. lval.Token(l.createToken(l.Token())); return int(T_ELLIPSIS) +:: lval.Token(l.createToken(l.Token())); return int(T_PAAMAYIM_NEKUDOTAYIM) // T_DOUBLE_COLON +&& lval.Token(l.createToken(l.Token())); return int(T_BOOLEAN_AND) +\|\| lval.Token(l.createToken(l.Token())); return int(T_BOOLEAN_OR) +&= lval.Token(l.createToken(l.Token())); return int(T_AND_EQUAL) +\|= lval.Token(l.createToken(l.Token())); return int(T_OR_EQUAL) +\.= lval.Token(l.createToken(l.Token())); return int(T_CONCAT_EQUAL) +\*= lval.Token(l.createToken(l.Token())); return int(T_MUL_EQUAL) +\*\*= lval.Token(l.createToken(l.Token())); return int(T_POW_EQUAL) +[/]= lval.Token(l.createToken(l.Token())); return int(T_DIV_EQUAL) +\+= lval.Token(l.createToken(l.Token())); return int(T_PLUS_EQUAL) +-= lval.Token(l.createToken(l.Token())); return int(T_MINUS_EQUAL) +\^= lval.Token(l.createToken(l.Token())); return int(T_XOR_EQUAL) +%= lval.Token(l.createToken(l.Token())); return int(T_MOD_EQUAL) +-- lval.Token(l.createToken(l.Token())); return int(T_DEC) +\+\+ lval.Token(l.createToken(l.Token())); return int(T_INC) +=> lval.Token(l.createToken(l.Token())); return int(T_DOUBLE_ARROW) +\<=\> lval.Token(l.createToken(l.Token())); return int(T_SPACESHIP) +\!=|\<\> lval.Token(l.createToken(l.Token())); return int(T_IS_NOT_EQUAL) +\!== lval.Token(l.createToken(l.Token())); return int(T_IS_NOT_IDENTICAL) +== lval.Token(l.createToken(l.Token())); return int(T_IS_EQUAL) +=== lval.Token(l.createToken(l.Token())); return int(T_IS_IDENTICAL) +\<\<= lval.Token(l.createToken(l.Token())); return int(T_SL_EQUAL) +\>\>= lval.Token(l.createToken(l.Token())); return int(T_SR_EQUAL) +\>= lval.Token(l.createToken(l.Token())); return int(T_IS_GREATER_OR_EQUAL) +\<= lval.Token(l.createToken(l.Token())); return int(T_IS_SMALLER_OR_EQUAL) +\*\* lval.Token(l.createToken(l.Token())); return int(T_POW) +\<\< lval.Token(l.createToken(l.Token())); return int(T_SL) +\>\> lval.Token(l.createToken(l.Token())); return int(T_SR) +\?\? lval.Token(l.createToken(l.Token())); return int(T_COALESCE) (#|[/][/]) tb := l.Token() @@ -268,6 +269,7 @@ ANY_CHAR . } case '\n': + c = l.Next() case '?': c = l.Next() @@ -286,10 +288,10 @@ ANY_CHAR . break; } - l.addComment(tb) + l.addFreeFloating(freefloating.CommentType, tb) [/][*][*][/] - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) ([/][*])|([/][*][*]) tb := l.Token() is_doc_comment := false @@ -314,25 +316,25 @@ ANY_CHAR . if is_doc_comment { l.PhpDocComment = string(l.TokenBytes(nil)) - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) } else { - l.addComment(l.Token()) + l.addFreeFloating(freefloating.CommentType, l.Token()) } {OPERATORS} lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) \{ l.pushState(PHP); lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) \} l.popState(); lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])); l.PhpDocComment = "" -\${VAR_NAME} lval.Token(l.createToken(l.Token())); return T_VARIABLE -{VAR_NAME} lval.Token(l.createToken(l.Token())); return T_STRING +\${VAR_NAME} lval.Token(l.createToken(l.Token())); return int(T_VARIABLE) +{VAR_NAME} lval.Token(l.createToken(l.Token())); return int(T_STRING) --> l.Begin(PROPERTY);lval.Token(l.createToken(l.Token())); return T_OBJECT_OPERATOR; -[ \t\n\r]+ --> lval.Token(l.createToken(l.Token())); return T_OBJECT_OPERATOR; -{VAR_NAME} l.Begin(PHP);lval.Token(l.createToken(l.Token())); return T_STRING; +-> l.Begin(PROPERTY);lval.Token(l.createToken(l.Token())); return int(T_OBJECT_OPERATOR); +[ \t\n\r]+ l.addFreeFloating(freefloating.WhiteSpaceType, l.Token()) +-> lval.Token(l.createToken(l.Token())); return int(T_OBJECT_OPERATOR); +{VAR_NAME} l.Begin(PHP);lval.Token(l.createToken(l.Token())); return int(T_STRING); . l.ungetChars(1);l.Begin(PHP) -[\']([^\\\']*(\\(.|\n))*)*[\'] lval.Token(l.createToken(l.Token())); return T_CONSTANT_ENCAPSED_STRING; +[\']([^\\\']*(\\(.|\n))*)*[\'] lval.Token(l.createToken(l.Token())); return int(T_CONSTANT_ENCAPSED_STRING); ` l.Begin(BACKQUOTE); lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) ` l.Begin(PHP); lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) @@ -398,7 +400,7 @@ ANY_CHAR . l.ungetChars(ungetCnt) lval.Token(l.createToken(heredocToken)); - return T_START_HEREDOC + return int(T_START_HEREDOC) .|[ \t\n\r] searchLabel := []byte{} @@ -413,12 +415,14 @@ ANY_CHAR . if l.heredocLabel + ";" == string(searchLabel) { l.Begin(HEREDOC_END) tb = l.ungetChars(len(l.heredocLabel)+1) + tb = tb[:len(tb)-1] break; } if l.heredocLabel == string(searchLabel) { l.Begin(HEREDOC_END) tb = l.ungetChars(len(l.heredocLabel)) + tb = tb[:len(tb)-1] break; } @@ -431,10 +435,10 @@ ANY_CHAR . } lval.Token(l.createToken(tb) ) - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) -{VAR_NAME}\; l.Begin(PHP);lval.Token(l.createToken(l.ungetChars(1))); return T_END_HEREDOC -{VAR_NAME} l.Begin(PHP);lval.Token(l.createToken(l.Token())); return T_END_HEREDOC +{VAR_NAME}\; l.Begin(PHP);lval.Token(l.createToken(l.ungetChars(1))); return int(T_END_HEREDOC) +{VAR_NAME} l.Begin(PHP);lval.Token(l.createToken(l.Token())); return int(T_END_HEREDOC) [b]?[\"] binPrefix := l.Token()[0].Rune == 'b' @@ -457,7 +461,7 @@ ANY_CHAR . switch c { case '"' : c = l.Next(); - lval.Token(l.createToken(l.Token())); return T_CONSTANT_ENCAPSED_STRING + lval.Token(l.createToken(l.Token())); return int(T_CONSTANT_ENCAPSED_STRING) break F; case '$': @@ -484,8 +488,8 @@ ANY_CHAR . } \" l.popState(); lval.Token(l.createToken(l.Token())); return Rune2Class(l.Token()[0].Rune) -\{\$ lval.Token(l.createToken(l.ungetChars(1))); l.pushState(PHP); return T_CURLY_OPEN -\$\{ l.pushState(STRING_VAR_NAME); lval.Token(l.createToken(l.Token())); return T_DOLLAR_OPEN_CURLY_BRACES +\{\$ lval.Token(l.createToken(l.ungetChars(1))); l.pushState(PHP); return int(T_CURLY_OPEN) +\$\{ l.pushState(STRING_VAR_NAME); lval.Token(l.createToken(l.Token())); return int(T_DOLLAR_OPEN_CURLY_BRACES) \${VAR_NAME} l.ungetChars(len(l.Token()));l.pushState(STRING_VAR) .|[ \t\n\r] currentChar := l.Prev @@ -496,14 +500,14 @@ ANY_CHAR . if c == '{' || isValidFirstVarNameRune(rune(c)) { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '{': if rune(c) == '$' { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '\\': @@ -514,7 +518,7 @@ ANY_CHAR . if rune(c) == '"' { lval.Token(l.createToken(l.Token())); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } currentChar = l.Last @@ -536,14 +540,14 @@ ANY_CHAR . if c == '{' || isValidFirstVarNameRune(rune(c)) { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '{': if rune(c) == '$' { l.ungetChars(1) lval.Token(l.createToken(tb[:len(tb)-1])); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } case '\\': @@ -554,7 +558,7 @@ ANY_CHAR . if rune(c) == '`' { lval.Token(l.createToken(l.Token())); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } currentChar = l.Last @@ -568,97 +572,119 @@ ANY_CHAR . .|[ \t\n\r] searchLabel := []byte{} - tb := []lex.Char{} + currentChar := l.Prev + tb := []lex.Char{currentChar} - for { - if c == -1 { - break; - } - + HEREDOC_FOR:for { nls := 0 - switch c { + switch currentChar.Rune { case '\r': - nls = 1 - c := l.Next() - if c != '\n' { - nls = 0 - l.ungetChars(0) + if c == '\n' { + nls = 1 + currentChar := l.Last + tb = append(tb, currentChar) + c = l.Next(); } fallthrough case '\n': - if l.heredocLabel + ";" == string(searchLabel) { + if l.heredocLabel + ";" == string(searchLabel) { l.Begin(HEREDOC_END) - tb = l.ungetChars(len(l.heredocLabel)+1+nls) + l.ungetChars(len(l.heredocLabel)+1+nls) + + i := len(tb) - len(l.heredocLabel) - 3 - nls + if i < 1 { + break HEREDOC_FOR; + } + tb = tb[:i] + lval.Token(l.createToken(tb)); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } if l.heredocLabel == string(searchLabel) { l.Begin(HEREDOC_END) - tb = l.ungetChars(len(l.heredocLabel)+nls) + l.ungetChars(len(l.heredocLabel)+nls) + + i := len(tb) - len(l.heredocLabel) - 2 - nls + if i < 1 { + break HEREDOC_FOR; + } + tb = tb[:i] + lval.Token(l.createToken(tb)); - return T_ENCAPSED_AND_WHITESPACE + return int(T_ENCAPSED_AND_WHITESPACE) } searchLabel = []byte{} - + case '$': - c = l.Next(); - if rune(c) == '{' || isValidFirstVarNameRune(rune(c)) { - tb = l.ungetChars(1) - lval.Token(l.createToken(tb)); - return T_ENCAPSED_AND_WHITESPACE - } - l.ungetChars(0) - + if c == '{' || isValidFirstVarNameRune(rune(c)) { + l.ungetChars(1) + lval.Token(l.createToken(tb[:len(tb)-1])); + return int(T_ENCAPSED_AND_WHITESPACE) + } + case '{': - c = l.Next(); if rune(c) == '$' { - tb = l.ungetChars(1) - lval.Token(l.createToken(tb)); - return T_ENCAPSED_AND_WHITESPACE - } - l.ungetChars(0) + l.ungetChars(1) + lval.Token(l.createToken(tb[:len(tb)-1])); + return int(T_ENCAPSED_AND_WHITESPACE) + } case '\\': - c = l.Next(); - if c == '\n' || c == '\r' { - l.ungetChars(0) + if c != '\n' && c != '\r' { + currentChar := l.Last + tb = append(tb, currentChar) + c = l.Next(); } default: - searchLabel = append(searchLabel, byte(rune(c))) + searchLabel = append(searchLabel, byte(rune(currentChar.Rune))) } + if c == -1 { + break; + } + + currentChar = l.Last + tb = append(tb, currentChar) c = l.Next() + } -\${VAR_NAME} lval.Token(l.createToken(l.Token())); return T_VARIABLE -->{VAR_NAME} lval.Token(l.createToken(l.ungetChars(len(l.Token())-2))); return T_OBJECT_OPERATOR -{VAR_NAME} l.popState();lval.Token(l.createToken(l.Token())); return T_STRING +\${VAR_NAME} lval.Token(l.createToken(l.Token())); return int(T_VARIABLE) +->{VAR_NAME} lval.Token(l.createToken(l.ungetChars(len(l.Token())-2))); return int(T_OBJECT_OPERATOR) +{VAR_NAME} l.popState();lval.Token(l.createToken(l.Token())); return int(T_STRING) \[ l.pushState(STRING_VAR_INDEX);lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) .|[ \t\n\r] l.ungetChars(1);l.popState() -{LNUM}|{HNUM}|{BNUM} lval.Token(l.createToken(l.Token())); return T_NUM_STRING -\${VAR_NAME} lval.Token(l.createToken(l.Token())); return T_VARIABLE -{VAR_NAME} lval.Token(l.createToken(l.Token())); return T_STRING +{LNUM}|{HNUM}|{BNUM} lval.Token(l.createToken(l.Token())); return int(T_NUM_STRING) +\${VAR_NAME} lval.Token(l.createToken(l.Token())); return int(T_VARIABLE) +{VAR_NAME} lval.Token(l.createToken(l.Token())); return int(T_STRING) \] l.popState(); l.popState();lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) -[ \n\r\t\\'#] l.popState(); l.popState();lval.Token(l.createToken(l.Token())); return T_ENCAPSED_AND_WHITESPACE +[ \n\r\t\\'#] l.popState(); l.popState();lval.Token(l.createToken(l.Token())); return int(T_ENCAPSED_AND_WHITESPACE) {OPERATORS} lval.Token(l.createToken(l.Token())); return Rune2Class(rune(l.TokenBytes(nil)[0])) {ANY_CHAR} l.Error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", l.TokenBytes(nil)[0], l.TokenBytes(nil)[0]));l.Abort(); -{VAR_NAME}[\[\}] l.popState();l.pushState(PHP);lval.Token(l.createToken(l.ungetChars(1))); return T_STRING_VARNAME +{VAR_NAME}[\[\}] l.popState();l.pushState(PHP);lval.Token(l.createToken(l.ungetChars(1))); return int(T_STRING_VARNAME) . l.ungetChars(1);l.popState();l.pushState(PHP) -.|[ \t\n\r] // do nothing +.|[ \t\n\r] l.addFreeFloating(freefloating.TokenType, l.Token()) {ANY_CHAR} l.Error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", l.TokenBytes(nil)[0], l.TokenBytes(nil)[0]));l.Abort(); %% - if c, ok := l.Abort(); ok { return int(c) } + if _, ok := l.Abort(); ok { + // always return same $end token + if l.lastToken == nil { + l.lastToken = l.createToken(l.Token()) + } + lval.Token(l.lastToken); + return -1 + } goto yyAction } diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go index 53e0418..68127d1 100644 --- a/scanner/scanner_test.go +++ b/scanner/scanner_test.go @@ -2,31 +2,14 @@ package scanner_test import ( "bytes" - "reflect" "testing" + "github.com/z7zmey/php-parser/freefloating" "github.com/z7zmey/php-parser/position" - - "github.com/z7zmey/php-parser/comment" - "github.com/z7zmey/php-parser/scanner" - - "github.com/kylelemons/godebug/pretty" + "gotest.tools/assert" ) -func assertEqual(t *testing.T, expected interface{}, actual interface{}) { - if !reflect.DeepEqual(expected, actual) { - diff := pretty.Compare(expected, actual) - - if diff != "" { - t.Errorf("diff: (-expected +actual)\n%s", diff) - } else { - t.Errorf("expected and actual are not equal\n") - } - - } -} - type lval struct { Tkn *scanner.Token } @@ -230,193 +213,194 @@ func TestTokens(t *testing.T) { ` - expected := []int{ - scanner.T_INLINE_HTML, - scanner.Rune2Class(';'), - scanner.T_ECHO, - scanner.Rune2Class(';'), + expected := []string{ + scanner.T_INLINE_HTML.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), + scanner.T_ECHO.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_DNUMBER, - scanner.T_DNUMBER, - scanner.T_DNUMBER, - scanner.T_DNUMBER, + scanner.T_DNUMBER.String(), + scanner.T_DNUMBER.String(), + scanner.T_DNUMBER.String(), + scanner.T_DNUMBER.String(), - scanner.T_LNUMBER, - scanner.T_DNUMBER, + scanner.T_LNUMBER.String(), + scanner.T_DNUMBER.String(), - scanner.T_LNUMBER, - scanner.T_DNUMBER, + scanner.T_LNUMBER.String(), + scanner.T_DNUMBER.String(), - scanner.T_LNUMBER, - scanner.T_DNUMBER, + scanner.T_LNUMBER.String(), + scanner.T_DNUMBER.String(), - scanner.T_ABSTRACT, - scanner.T_ARRAY, - scanner.T_AS, - scanner.T_BREAK, - scanner.T_CALLABLE, - scanner.T_CASE, - scanner.T_CATCH, - scanner.T_CLASS, - scanner.T_CLONE, - scanner.T_CONST, - scanner.T_CONTINUE, - scanner.T_DECLARE, - scanner.T_DEFAULT, - scanner.T_DO, - scanner.T_ECHO, - scanner.T_ELSE, - scanner.T_ELSEIF, - scanner.T_EMPTY, - scanner.T_ENDDECLARE, - scanner.T_ENDFOR, - scanner.T_ENDFOREACH, - scanner.T_ENDIF, - scanner.T_ENDSWITCH, - scanner.T_ENDWHILE, - scanner.T_EVAL, - scanner.T_EXIT, - scanner.T_EXTENDS, - scanner.T_FINAL, - scanner.T_FINALLY, - scanner.T_FOR, - scanner.T_FOREACH, - scanner.T_FUNCTION, - scanner.T_FUNCTION, - scanner.T_GLOBAL, - scanner.T_GOTO, - scanner.T_IF, - scanner.T_ISSET, - scanner.T_IMPLEMENTS, - scanner.T_INSTANCEOF, - scanner.T_INSTEADOF, - scanner.T_INTERFACE, - scanner.T_LIST, - scanner.T_NAMESPACE, - scanner.T_PRIVATE, - scanner.T_PUBLIC, - scanner.T_PRINT, - scanner.T_PROTECTED, - scanner.T_RETURN, - scanner.T_STATIC, - scanner.T_SWITCH, - scanner.T_THROW, - scanner.T_TRAIT, - scanner.T_TRY, - scanner.T_UNSET, - scanner.T_USE, - scanner.T_VAR, - scanner.T_WHILE, - scanner.T_YIELD_FROM, - scanner.T_YIELD, - scanner.T_INCLUDE, - scanner.T_INCLUDE_ONCE, - scanner.T_REQUIRE, - scanner.T_REQUIRE_ONCE, + scanner.T_ABSTRACT.String(), + scanner.T_ARRAY.String(), + scanner.T_AS.String(), + scanner.T_BREAK.String(), + scanner.T_CALLABLE.String(), + scanner.T_CASE.String(), + scanner.T_CATCH.String(), + scanner.T_CLASS.String(), + scanner.T_CLONE.String(), + scanner.T_CONST.String(), + scanner.T_CONTINUE.String(), + scanner.T_DECLARE.String(), + scanner.T_DEFAULT.String(), + scanner.T_DO.String(), + scanner.T_ECHO.String(), + scanner.T_ELSE.String(), + scanner.T_ELSEIF.String(), + scanner.T_EMPTY.String(), + scanner.T_ENDDECLARE.String(), + scanner.T_ENDFOR.String(), + scanner.T_ENDFOREACH.String(), + scanner.T_ENDIF.String(), + scanner.T_ENDSWITCH.String(), + scanner.T_ENDWHILE.String(), + scanner.T_EVAL.String(), + scanner.T_EXIT.String(), + scanner.T_EXTENDS.String(), + scanner.T_FINAL.String(), + scanner.T_FINALLY.String(), + scanner.T_FOR.String(), + scanner.T_FOREACH.String(), + scanner.T_FUNCTION.String(), + scanner.T_FUNCTION.String(), + scanner.T_GLOBAL.String(), + scanner.T_GOTO.String(), + scanner.T_IF.String(), + scanner.T_ISSET.String(), + scanner.T_IMPLEMENTS.String(), + scanner.T_INSTANCEOF.String(), + scanner.T_INSTEADOF.String(), + scanner.T_INTERFACE.String(), + scanner.T_LIST.String(), + scanner.T_NAMESPACE.String(), + scanner.T_PRIVATE.String(), + scanner.T_PUBLIC.String(), + scanner.T_PRINT.String(), + scanner.T_PROTECTED.String(), + scanner.T_RETURN.String(), + scanner.T_STATIC.String(), + scanner.T_SWITCH.String(), + scanner.T_THROW.String(), + scanner.T_TRAIT.String(), + scanner.T_TRY.String(), + scanner.T_UNSET.String(), + scanner.T_USE.String(), + scanner.T_VAR.String(), + scanner.T_WHILE.String(), + scanner.T_YIELD_FROM.String(), + scanner.T_YIELD.String(), + scanner.T_INCLUDE.String(), + scanner.T_INCLUDE_ONCE.String(), + scanner.T_REQUIRE.String(), + scanner.T_REQUIRE_ONCE.String(), - scanner.T_CLASS_C, - scanner.T_DIR, - scanner.T_FILE, - scanner.T_FUNC_C, - scanner.T_LINE, - scanner.T_NS_C, - scanner.T_METHOD_C, - scanner.T_TRAIT_C, - scanner.T_HALT_COMPILER, + scanner.T_CLASS_C.String(), + scanner.T_DIR.String(), + scanner.T_FILE.String(), + scanner.T_FUNC_C.String(), + scanner.T_LINE.String(), + scanner.T_NS_C.String(), + scanner.T_METHOD_C.String(), + scanner.T_TRAIT_C.String(), + scanner.T_HALT_COMPILER.String(), - scanner.T_NEW, - scanner.T_LOGICAL_AND, - scanner.T_LOGICAL_OR, - scanner.T_LOGICAL_XOR, + scanner.T_NEW.String(), + scanner.T_LOGICAL_AND.String(), + scanner.T_LOGICAL_OR.String(), + scanner.T_LOGICAL_XOR.String(), - scanner.T_NS_SEPARATOR, - scanner.T_ELLIPSIS, - scanner.T_PAAMAYIM_NEKUDOTAYIM, - scanner.T_BOOLEAN_AND, - scanner.T_BOOLEAN_OR, - scanner.T_AND_EQUAL, - scanner.T_OR_EQUAL, - scanner.T_CONCAT_EQUAL, - scanner.T_MUL_EQUAL, - scanner.T_POW_EQUAL, - scanner.T_DIV_EQUAL, - scanner.T_PLUS_EQUAL, - scanner.T_MINUS_EQUAL, - scanner.T_XOR_EQUAL, - scanner.T_MOD_EQUAL, - scanner.T_DEC, - scanner.T_INC, - scanner.T_DOUBLE_ARROW, - scanner.T_SPACESHIP, - scanner.T_IS_NOT_EQUAL, - scanner.T_IS_NOT_EQUAL, - scanner.T_IS_NOT_IDENTICAL, - scanner.T_IS_EQUAL, - scanner.T_IS_IDENTICAL, - scanner.T_SL_EQUAL, - scanner.T_SR_EQUAL, - scanner.T_IS_GREATER_OR_EQUAL, - scanner.T_IS_SMALLER_OR_EQUAL, - scanner.T_POW, - scanner.T_SL, - scanner.T_SR, - scanner.T_COALESCE, + scanner.T_NS_SEPARATOR.String(), + scanner.T_ELLIPSIS.String(), + scanner.T_PAAMAYIM_NEKUDOTAYIM.String(), + scanner.T_BOOLEAN_AND.String(), + scanner.T_BOOLEAN_OR.String(), + scanner.T_AND_EQUAL.String(), + scanner.T_OR_EQUAL.String(), + scanner.T_CONCAT_EQUAL.String(), + scanner.T_MUL_EQUAL.String(), + scanner.T_POW_EQUAL.String(), + scanner.T_DIV_EQUAL.String(), + scanner.T_PLUS_EQUAL.String(), + scanner.T_MINUS_EQUAL.String(), + scanner.T_XOR_EQUAL.String(), + scanner.T_MOD_EQUAL.String(), + scanner.T_DEC.String(), + scanner.T_INC.String(), + scanner.T_DOUBLE_ARROW.String(), + scanner.T_SPACESHIP.String(), + scanner.T_IS_NOT_EQUAL.String(), + scanner.T_IS_NOT_EQUAL.String(), + scanner.T_IS_NOT_IDENTICAL.String(), + scanner.T_IS_EQUAL.String(), + scanner.T_IS_IDENTICAL.String(), + scanner.T_SL_EQUAL.String(), + scanner.T_SR_EQUAL.String(), + scanner.T_IS_GREATER_OR_EQUAL.String(), + scanner.T_IS_SMALLER_OR_EQUAL.String(), + scanner.T_POW.String(), + scanner.T_SL.String(), + scanner.T_SR.String(), + scanner.T_COALESCE.String(), - scanner.Rune2Class(';'), - scanner.Rune2Class(':'), - scanner.Rune2Class(','), - scanner.Rune2Class('.'), - scanner.Rune2Class('['), - scanner.Rune2Class(']'), - scanner.Rune2Class('('), - scanner.Rune2Class(')'), - scanner.Rune2Class('|'), - scanner.Rune2Class('/'), - scanner.Rune2Class('^'), - scanner.Rune2Class('&'), - scanner.Rune2Class('+'), - scanner.Rune2Class('-'), - scanner.Rune2Class('*'), - scanner.Rune2Class('='), - scanner.Rune2Class('%'), - scanner.Rune2Class('!'), - scanner.Rune2Class('~'), - scanner.Rune2Class('$'), - scanner.Rune2Class('<'), - scanner.Rune2Class('>'), - scanner.Rune2Class('?'), - scanner.Rune2Class('@'), - scanner.Rune2Class('{'), - scanner.Rune2Class('}'), + scanner.LexerToken(scanner.Rune2Class(';')).String(), + scanner.LexerToken(scanner.Rune2Class(':')).String(), + scanner.LexerToken(scanner.Rune2Class(',')).String(), + scanner.LexerToken(scanner.Rune2Class('.')).String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.LexerToken(scanner.Rune2Class('(')).String(), + scanner.LexerToken(scanner.Rune2Class(')')).String(), + scanner.LexerToken(scanner.Rune2Class('|')).String(), + scanner.LexerToken(scanner.Rune2Class('/')).String(), + scanner.LexerToken(scanner.Rune2Class('^')).String(), + scanner.LexerToken(scanner.Rune2Class('&')).String(), + scanner.LexerToken(scanner.Rune2Class('+')).String(), + scanner.LexerToken(scanner.Rune2Class('-')).String(), + scanner.LexerToken(scanner.Rune2Class('*')).String(), + scanner.LexerToken(scanner.Rune2Class('=')).String(), + scanner.LexerToken(scanner.Rune2Class('%')).String(), + scanner.LexerToken(scanner.Rune2Class('!')).String(), + scanner.LexerToken(scanner.Rune2Class('~')).String(), + scanner.LexerToken(scanner.Rune2Class('$')).String(), + scanner.LexerToken(scanner.Rune2Class('<')).String(), + scanner.LexerToken(scanner.Rune2Class('>')).String(), + scanner.LexerToken(scanner.Rune2Class('?')).String(), + scanner.LexerToken(scanner.Rune2Class('@')).String(), + scanner.LexerToken(scanner.Rune2Class('{')).String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), - scanner.T_VARIABLE, - scanner.T_STRING, + scanner.T_VARIABLE.String(), + scanner.T_STRING.String(), - scanner.T_OBJECT_OPERATOR, - scanner.T_OBJECT_OPERATOR, - scanner.T_STRING, + scanner.T_OBJECT_OPERATOR.String(), + scanner.T_OBJECT_OPERATOR.String(), + scanner.T_STRING.String(), - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), - scanner.T_ARRAY_CAST, - scanner.T_BOOL_CAST, - scanner.T_BOOL_CAST, - scanner.T_DOUBLE_CAST, - scanner.T_DOUBLE_CAST, - scanner.T_DOUBLE_CAST, - scanner.T_INT_CAST, - scanner.T_INT_CAST, - scanner.T_OBJECT_CAST, - scanner.T_STRING_CAST, - scanner.T_STRING_CAST, - scanner.T_UNSET_CAST, + scanner.T_ARRAY_CAST.String(), + scanner.T_BOOL_CAST.String(), + scanner.T_BOOL_CAST.String(), + scanner.T_DOUBLE_CAST.String(), + scanner.T_DOUBLE_CAST.String(), + scanner.T_DOUBLE_CAST.String(), + scanner.T_INT_CAST.String(), + scanner.T_INT_CAST.String(), + scanner.T_OBJECT_CAST.String(), + scanner.T_STRING_CAST.String(), + scanner.T_STRING_CAST.String(), + scanner.T_UNSET_CAST.String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -424,10 +408,10 @@ func TestTokens(t *testing.T) { break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestSingleQuoteStringTokens(t *testing.T) { @@ -451,19 +435,19 @@ func TestSingleQuoteStringTokens(t *testing.T) { \'' ` - expected := []int{ - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, - scanner.T_CONSTANT_ENCAPSED_STRING, + expected := []string{ + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), + scanner.T_CONSTANT_ENCAPSED_STRING.String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -471,10 +455,10 @@ func TestSingleQuoteStringTokens(t *testing.T) { break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestTeplateStringTokens(t *testing.T) { @@ -494,64 +478,65 @@ func TestTeplateStringTokens(t *testing.T) { "$0$foo" ` - expected := []int{ - scanner.Rune2Class('"'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('"'), + expected := []string{ + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_DOLLAR_OPEN_CURLY_BRACES, - scanner.T_STRING_VARNAME, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_DOLLAR_OPEN_CURLY_BRACES.String(), + scanner.T_STRING_VARNAME.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), - scanner.Rune2Class('"'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('"'), + scanner.LexerToken(scanner.Rune2Class('"')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('"')).String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -559,10 +544,10 @@ func TestTeplateStringTokens(t *testing.T) { break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestBackquoteStringTokens(t *testing.T) { @@ -579,64 +564,65 @@ func TestBackquoteStringTokens(t *testing.T) { ` + "`$0$foo`" + ` ` - expected := []int{ - scanner.Rune2Class('`'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('`'), + expected := []string{ + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_DOLLAR_OPEN_CURLY_BRACES, - scanner.T_STRING_VARNAME, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_DOLLAR_OPEN_CURLY_BRACES.String(), + scanner.T_STRING_VARNAME.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), - scanner.Rune2Class('`'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('`'), + scanner.LexerToken(scanner.Rune2Class('`')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('`')).String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -644,10 +630,10 @@ func TestBackquoteStringTokens(t *testing.T) { break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestHereDocTokens(t *testing.T) { @@ -674,62 +660,64 @@ CAT; CAT; ` - expected := []int{ - scanner.T_START_HEREDOC, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + expected := []string{ + scanner.T_START_HEREDOC.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + scanner.T_START_HEREDOC.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_OBJECT_OPERATOR, - scanner.T_STRING, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('['), - scanner.T_NUM_STRING, - scanner.Rune2Class(']'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('['), - scanner.T_NUM_STRING, - scanner.Rune2Class(']'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('['), - scanner.T_NUM_STRING, - scanner.Rune2Class(']'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('['), - scanner.T_STRING, - scanner.Rune2Class(']'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.Rune2Class('['), - scanner.T_VARIABLE, - scanner.Rune2Class(']'), - scanner.T_ENCAPSED_AND_WHITESPACE, scanner.T_CURLY_OPEN, - scanner.T_VARIABLE, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_DOLLAR_OPEN_CURLY_BRACES, - scanner.T_STRING_VARNAME, - scanner.Rune2Class('}'), - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + scanner.T_START_HEREDOC.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_OBJECT_OPERATOR.String(), + scanner.T_STRING.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.T_NUM_STRING.String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.T_NUM_STRING.String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.T_NUM_STRING.String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.T_STRING.String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('[')).String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class(']')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_CURLY_OPEN.String(), + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_DOLLAR_OPEN_CURLY_BRACES.String(), + scanner.T_STRING_VARNAME.String(), + scanner.LexerToken(scanner.Rune2Class('}')).String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -737,10 +725,10 @@ CAT; break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestHereDocTokens2(t *testing.T) { @@ -766,43 +754,42 @@ $foo$bar\ CAT ` - expected := []int{ - scanner.T_START_HEREDOC, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + expected := []string{ + scanner.T_START_HEREDOC.String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + scanner.T_START_HEREDOC.String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + scanner.T_START_HEREDOC.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, - scanner.Rune2Class(';'), + scanner.T_START_HEREDOC.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_VARIABLE.String(), + scanner.T_END_HEREDOC.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), - scanner.T_START_HEREDOC, - scanner.T_VARIABLE, - scanner.T_VARIABLE, - scanner.T_ENCAPSED_AND_WHITESPACE, - scanner.T_END_HEREDOC, + scanner.T_START_HEREDOC.String(), + scanner.T_VARIABLE.String(), + scanner.T_VARIABLE.String(), + scanner.T_ENCAPSED_AND_WHITESPACE.String(), + scanner.T_END_HEREDOC.String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -810,10 +797,49 @@ CAT break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) +} + +func TestHereDocTokens3(t *testing.T) { + src := ` test ` - expected := []int{ - scanner.T_VARIABLE, - scanner.Rune2Class(';'), - scanner.T_INLINE_HTML, + expected := []string{ + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), + scanner.T_INLINE_HTML.String(), - scanner.T_VARIABLE, - scanner.Rune2Class(';'), - scanner.T_INLINE_HTML, + scanner.T_VARIABLE.String(), + scanner.LexerToken(scanner.Rune2Class(';')).String(), + scanner.T_INLINE_HTML.String(), } lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true lv := &lval{} - actual := []int{} + actual := []string{} for { token := lexer.Lex(lv) @@ -842,21 +869,21 @@ func TestInlineHtmlNopTokens(t *testing.T) { break } - actual = append(actual, token) + actual = append(actual, scanner.LexerToken(token).String()) } - assertEqual(t, expected, actual) + assert.DeepEqual(t, expected, actual) } func TestStringTokensAfterVariable(t *testing.T) { src := ` test` - expected := []*comment.Comment{ - comment.NewComment("//test", position.NewPosition(2, 2, 8, 13)), + expected := []freefloating.String{ + { + Value: " bar ( '' ) ;` + + lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php") + lexer.WithFreeFloating = true + lv := &lval{} + + expected := []freefloating.String{ + { + Value: " 0 { - fmt.Fprintf(d.Writer, "%v\"Comments\":\n", d.Indent+" ") - for _, cc := range c { - fmt.Fprintf(d.Writer, "%v%q before %q\n", d.Indent+" ", cc, comment.TokenNames[cc.TokenName()]) + if !n.GetFreeFloating().IsEmpty() { + fmt.Fprintf(d.Writer, "%v\"freefloating\":\n", d.Indent+" ") + for key, freeFloatingStrings := range *n.GetFreeFloating() { + for _, freeFloatingString := range freeFloatingStrings { + fmt.Fprintf(d.Writer, "%v%q: %q\n", d.Indent+" ", key.String(), freeFloatingString.Value) } } } if a := n.Attributes(); len(a) > 0 { for key, attr := range a { - fmt.Fprintf(d.Writer, "%v\"%v\": %v;\n", d.Indent+" ", key, attr) + switch attr.(type) { + case string: + fmt.Fprintf(d.Writer, "%v\"%v\": %q\n", d.Indent+" ", key, attr) + default: + fmt.Fprintf(d.Writer, "%v\"%v\": %v\n", d.Indent+" ", key, attr) + } } } return true } -// GetChildrenVisitor is invoked at every node parameter that contains children nodes -func (d Dumper) GetChildrenVisitor(key string) walker.Visitor { - fmt.Fprintf(d.Writer, "%v%q:\n", d.Indent+" ", key) - return Dumper{d.Writer, d.Indent + " ", d.Comments, d.Positions, d.NsResolver} -} - // LeaveNode is invoked after node process -func (d Dumper) LeaveNode(n walker.Walkable) { +func (d *Dumper) LeaveNode(n walker.Walkable) { // do nothing } + +// GetChildrenVisitor is invoked at every node parameter that contains children nodes +func (d *Dumper) EnterChildNode(key string, w walker.Walkable) { + fmt.Fprintf(d.Writer, "%v%q:\n", d.Indent+" ", key) + d.Indent = d.Indent + " " +} + +func (d *Dumper) LeaveChildNode(key string, w walker.Walkable) { + d.Indent = strings.TrimSuffix(d.Indent, " ") +} + +func (d *Dumper) EnterChildList(key string, w walker.Walkable) { + fmt.Fprintf(d.Writer, "%v%q:\n", d.Indent+" ", key) + d.Indent = d.Indent + " " +} + +func (d *Dumper) LeaveChildList(key string, w walker.Walkable) { + d.Indent = strings.TrimSuffix(d.Indent, " ") +} diff --git a/visitor/dumper_test.go b/visitor/dumper_test.go index c0d3bed..c5dc4d4 100644 --- a/visitor/dumper_test.go +++ b/visitor/dumper_test.go @@ -1,4 +1,3 @@ -// Package visitor contains walker.visitor implementations package visitor_test import ( @@ -13,7 +12,7 @@ func ExampleDumper() { src := ` 0 { + for key, attr := range a { + printIndent(d.Writer, d.depth) + switch attr.(type) { + case string: + fmt.Fprintf(d.Writer, "%s: %q,\n", key, attr) + default: + fmt.Fprintf(d.Writer, "%s: %v,\n", key, attr) + } + } + } + + return true +} + +// LeaveNode is invoked after node process +func (d *GoDumper) LeaveNode(n walker.Walkable) { + d.depth-- + printIndent(d.Writer, d.depth) + if d.depth != 0 { + io.WriteString(d.Writer, "},\n") + } else { + io.WriteString(d.Writer, "}\n") + } +} + +func (d *GoDumper) EnterChildNode(key string, w walker.Walkable) { + printIndent(d.Writer, d.depth) + io.WriteString(d.Writer, key+": ") + d.isChildNode = true +} + +func (d *GoDumper) LeaveChildNode(key string, w walker.Walkable) { + // do nothing +} + +func (d *GoDumper) EnterChildList(key string, w walker.Walkable) { + printIndent(d.Writer, d.depth) + io.WriteString(d.Writer, key+": []node.Node{\n") + d.depth++ +} + +func (d *GoDumper) LeaveChildList(key string, w walker.Walkable) { + d.depth-- + printIndent(d.Writer, d.depth) + if d.depth != 0 { + io.WriteString(d.Writer, "},\n") + } +} diff --git a/visitor/go_dumper_test.go b/visitor/go_dumper_test.go new file mode 100644 index 0000000..d7cf0ef --- /dev/null +++ b/visitor/go_dumper_test.go @@ -0,0 +1,529 @@ +package visitor_test + +import ( + "bytes" + "os" + + "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/visitor" +) + +func ExampleGoDumper() { + src := ` 0 { + var attributes []string + for key := range n.Attributes() { + attributes = append(attributes, key) + } + + sort.Strings(attributes) + + for _, attributeName := range attributes { + attr := a[attributeName] + switch attr.(type) { + case string: + fmt.Fprintf(d.Writer, ",\"%s\":%q", attributeName, attr) + default: + fmt.Fprintf(d.Writer, ",\"%s\":%v", attributeName, attr) + } + } + } + + return true +} + +// LeaveNode is invoked after node process +func (d *JsonDumper) LeaveNode(n walker.Walkable) { + fmt.Fprint(d.Writer, "}") +} + +func (d *JsonDumper) EnterChildNode(key string, w walker.Walkable) { + fmt.Fprintf(d.Writer, ",%q:", key) +} + +func (d *JsonDumper) LeaveChildNode(key string, w walker.Walkable) { + // do nothing +} + +func (d *JsonDumper) EnterChildList(key string, w walker.Walkable) { + fmt.Fprintf(d.Writer, ",%q:[", key) + +} + +func (d *JsonDumper) LeaveChildList(key string, w walker.Walkable) { + fmt.Fprint(d.Writer, "]") +} diff --git a/visitor/json_dumper_test.go b/visitor/json_dumper_test.go new file mode 100644 index 0000000..13243c2 --- /dev/null +++ b/visitor/json_dumper_test.go @@ -0,0 +1,41 @@ +package visitor_test + +import ( + "bytes" + "os" + + "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/visitor" +) + +func ExampleJsonDumper() { + src := ` 0 { + for key, attr := range a { + fmt.Fprint(d.Writer, ",\n") + d.printIndent(d.Writer) + switch attr.(type) { + case string: + fmt.Fprintf(d.Writer, "\"%s\": %q", key, attr) + default: + fmt.Fprintf(d.Writer, "\"%s\": %v", key, attr) + } + } + } + + return true +} + +// LeaveNode is invoked after node process +func (d *PrettyJsonDumper) LeaveNode(n walker.Walkable) { + d.depth-- + fmt.Fprint(d.Writer, "\n") + d.printIndent(d.Writer) + fmt.Fprint(d.Writer, "}") +} + +func (d *PrettyJsonDumper) EnterChildNode(key string, w walker.Walkable) { + fmt.Fprint(d.Writer, ",\n") + d.printIndent(d.Writer) + fmt.Fprintf(d.Writer, "%q: ", key) + d.isChildNode = true +} + +func (d *PrettyJsonDumper) LeaveChildNode(key string, w walker.Walkable) { + // do nothing +} + +func (d *PrettyJsonDumper) EnterChildList(key string, w walker.Walkable) { + fmt.Fprint(d.Writer, ",\n") + d.printIndent(d.Writer) + fmt.Fprintf(d.Writer, "%q: [\n", key) + d.depth++ + + d.isNotFirstNode = false +} + +func (d *PrettyJsonDumper) LeaveChildList(key string, w walker.Walkable) { + d.depth-- + fmt.Fprint(d.Writer, "\n") + d.printIndent(d.Writer) + fmt.Fprint(d.Writer, "]") +} diff --git a/visitor/pretty_json_dumper_test.go b/visitor/pretty_json_dumper_test.go new file mode 100644 index 0000000..180efff --- /dev/null +++ b/visitor/pretty_json_dumper_test.go @@ -0,0 +1,535 @@ +package visitor_test + +import ( + "bytes" + "os" + + "github.com/z7zmey/php-parser/php7" + "github.com/z7zmey/php-parser/visitor" +) + +func ExamplePrettyJsonDumper() { + src := `