diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..26bd28c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +internal/php5/php5.go -diff -merge +internal/php5/php5.go linguist-generated=true +internal/php7/php7.go -diff -merge +internal/php7/php7.go linguist-generated=true +internal/scanner/scanner.go -diff -merge +internal/scanner/scanner.go linguist-generated=true \ No newline at end of file diff --git a/Makefile b/Makefile index 9540674..5309a04 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,13 @@ PHPFILE=example.php -all: compile fmt build run +all: compile fmt build fmt: find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' + build: go generate ./... - go build - -run: - ./php-parser -d go $(PHPFILE) + go build ./cmd/... test: go test ./... @@ -19,38 +16,38 @@ cover: go test ./... --cover bench: - go test -benchmem -bench=. ./php5 - go test -benchmem -bench=. ./php7 + go test -benchmem -bench=. ./internal/php5 + go test -benchmem -bench=. ./internal/php7 -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 - sed -i '' -e 's/\/\/line/\/\/ line/g' ./php5/php5.go - sed -i '' -e 's/\/\/line/\/\/ line/g' ./php7/php7.go - sed -i '' -e 's/\/\/line/\/\/ line/g' ./scanner/scanner.go +compile: ./internal/php5/php5.go ./internal/php7/php7.go ./internal/scanner/scanner.go + sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./internal/php7/php7.go + sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./internal/php5/php5.go + sed -i '' -e 's/\/\/line/\/\/ line/g' ./internal/php5/php5.go + sed -i '' -e 's/\/\/line/\/\/ line/g' ./internal/php7/php7.go + sed -i '' -e 's/\/\/line/\/\/ line/g' ./internal/scanner/scanner.go rm -f y.output -./scanner/scanner.go: ./scanner/scanner.rl +./internal/scanner/scanner.go: ./internal/scanner/scanner.rl ragel -Z -G2 -o $@ $< -./php5/php5.go: ./php5/php5.y +./internal/php5/php5.go: ./internal/php5/php5.y goyacc -o $@ $< -./php7/php7.go: ./php7/php7.y +./internal/php7/php7.go: ./internal/php7/php7.y goyacc -o $@ $< cpu_pprof: - go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./php7 + go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./internal/php7 go tool pprof ./php7.test cpu.pprof mem_pprof: - go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./php7 + go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./internal/php7 go tool pprof -alloc_objects ./php7.test mem.pprof cpu_pprof_php5: - go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php5 + go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./internal/php5 go tool pprof ./php5.test cpu.prof mem_pprof_php5: - go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php5 + go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./internal/php5 go tool pprof -alloc_objects ./php5.test mem.prof diff --git a/main.go b/cmd/php-parser/main.go similarity index 56% rename from main.go rename to cmd/php-parser/main.go index a1ad92c..796e87e 100644 --- a/main.go +++ b/cmd/php-parser/main.go @@ -4,28 +4,39 @@ import ( "bytes" "flag" "fmt" + "io" "io/ioutil" "log" "os" "path/filepath" "runtime" + "strconv" "sync" + "time" "github.com/pkg/profile" "github.com/yookoala/realpath" - "github.com/z7zmey/php-parser/parser" - "github.com/z7zmey/php-parser/printer" - "github.com/z7zmey/php-parser/visitor" + + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/parser" + "github.com/z7zmey/php-parser/pkg/version" + "github.com/z7zmey/php-parser/pkg/visitor/dumper" + "github.com/z7zmey/php-parser/pkg/visitor/nsresolver" + "github.com/z7zmey/php-parser/pkg/visitor/printer" + "github.com/z7zmey/php-parser/pkg/visitor/traverser" ) var wg sync.WaitGroup -var phpVersion string -var dumpType string +var phpVersion *version.Version var profiler string -var withFreeFloating *bool +var dump *bool var showResolvedNs *bool var printBack *bool var printPath *bool +var printErrors *bool +var printExecTime *bool type file struct { path string @@ -33,21 +44,33 @@ type file struct { } type result struct { - path string - parser parser.Parser + path string + rootNode ast.Vertex + errors []*errors.Error } func main() { - withFreeFloating = flag.Bool("ff", false, "parse and show free floating strings") + start := time.Now() + var phpVer string + + printExecTime = flag.Bool("time", false, "print execution time") showResolvedNs = flag.Bool("r", false, "resolve names") printBack = flag.Bool("pb", false, "print AST back into the parsed file") printPath = flag.Bool("p", false, "print filepath") - flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]") + printErrors = flag.Bool("e", false, "print errors") + dump = flag.Bool("d", false, "dump") flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]") - flag.StringVar(&phpVersion, "phpver", "7.4", "php version") + flag.StringVar(&phpVer, "phpver", "7.4", "php version") flag.Parse() + var err error + phpVersion, err = version.New(phpVer) + if err != nil { + fmt.Println("Error: " + err.Error()) + os.Exit(1) + } + if len(flag.Args()) == 0 { flag.Usage() return @@ -82,6 +105,11 @@ func main() { wg.Wait() close(fileCh) close(resultCh) + + elapsed := time.Since(start) + if *printExecTime { + log.Printf("took: %s", elapsed) + } } func processPath(pathList []string, fileCh chan<- *file) { @@ -109,18 +137,19 @@ func parserWorker(fileCh <-chan *file, r chan<- result) { return } - parserWorker, err := parser.NewParser(f.content, phpVersion) + var parserErrors []*errors.Error + rootNode, err := parser.Parse(f.content, cfg.Config{ + Version: phpVersion, + ErrorHandlerFunc: func(e *errors.Error) { + parserErrors = append(parserErrors, e) + }, + }) if err != nil { - panic(err.Error()) + fmt.Println("Error:" + err.Error()) + os.Exit(1) } - if *withFreeFloating { - parserWorker.WithFreeFloating() - } - - parserWorker.Parse() - - r <- result{path: f.path, parser: parserWorker} + r <- result{path: f.path, rootNode: rootNode, errors: parserErrors} } } @@ -136,51 +165,34 @@ func printerWorker(r <-chan result) { counter++ if *printPath { - fmt.Fprintf(os.Stdout, "==> [%d] %s\n", counter, res.path) + _, _ = io.WriteString(os.Stderr, "==> ["+strconv.Itoa(counter)+"] "+res.path+"\n") } - for _, e := range res.parser.GetErrors() { - fmt.Fprintf(os.Stdout, "==> %s\n", e) + if *printErrors { + for _, e := range res.errors { + _, _ = io.WriteString(os.Stderr, "==> "+e.String()+"\n") + } } if *printBack { o := bytes.NewBuffer([]byte{}) p := printer.NewPrinter(o) - p.Print(res.parser.GetRootNode()) + res.rootNode.Accept(p) err := ioutil.WriteFile(res.path, o.Bytes(), 0644) checkErr(err) } - var nsResolver *visitor.NamespaceResolver if *showResolvedNs { - nsResolver = visitor.NewNamespaceResolver() - res.parser.GetRootNode().Walk(nsResolver) + v := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(v).Traverse(res.rootNode) + for _, n := range v.ResolvedNames { + _, _ = io.WriteString(os.Stderr, "===> "+n+"\n") + } } - switch dumpType { - case "custom": - dumper := &visitor.Dumper{ - Writer: os.Stdout, - Indent: "| ", - NsResolver: nsResolver, - } - res.parser.GetRootNode().Walk(dumper) - case "json": - dumper := &visitor.JsonDumper{ - Writer: os.Stdout, - NsResolver: nsResolver, - } - res.parser.GetRootNode().Walk(dumper) - case "pretty_json": - dumper := &visitor.PrettyJsonDumper{ - Writer: os.Stdout, - NsResolver: nsResolver, - } - res.parser.GetRootNode().Walk(dumper) - case "go": - dumper := &visitor.GoDumper{Writer: os.Stdout} - res.parser.GetRootNode().Walk(dumper) + if *dump == true { + dumper.NewDumper(os.Stdout).WithPositions().WithTokens().Dump(res.rootNode) } wg.Done() diff --git a/freefloating/position_string.go b/freefloating/position_string.go deleted file mode 100644 index 2428f22..0000000 --- a/freefloating/position_string.go +++ /dev/null @@ -1,98 +0,0 @@ -// Code generated by "stringer -type=Position -output ./position_string.go"; DO NOT EDIT. - -package freefloating - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[Start-0] - _ = x[End-1] - _ = x[Slash-2] - _ = x[Colon-3] - _ = x[SemiColon-4] - _ = x[AltEnd-5] - _ = x[Dollar-6] - _ = x[Ampersand-7] - _ = x[Name-8] - _ = x[Prefix-9] - _ = x[Key-10] - _ = x[Var-11] - _ = x[UseType-12] - _ = x[ReturnType-13] - _ = x[OptionalType-14] - _ = x[CaseSeparator-15] - _ = x[LexicalVars-16] - _ = x[Params-17] - _ = x[Ref-18] - _ = x[Cast-19] - _ = x[Expr-20] - _ = x[InitExpr-21] - _ = x[CondExpr-22] - _ = x[IncExpr-23] - _ = x[True-24] - _ = x[Cond-25] - _ = x[HaltCompiller-26] - _ = x[Namespace-27] - _ = x[Static-28] - _ = x[Class-29] - _ = x[Use-30] - _ = x[While-31] - _ = x[For-32] - _ = x[Switch-33] - _ = x[Break-34] - _ = x[Foreach-35] - _ = x[Declare-36] - _ = x[Label-37] - _ = x[Finally-38] - _ = x[List-39] - _ = x[Default-40] - _ = x[If-41] - _ = x[ElseIf-42] - _ = x[Else-43] - _ = x[Variadic-44] - _ = x[Function-45] - _ = x[DoubleArrow-46] - _ = x[Alias-47] - _ = x[As-48] - _ = x[Equal-49] - _ = x[Exit-50] - _ = x[Array-51] - _ = x[Isset-52] - _ = x[Empty-53] - _ = x[Eval-54] - _ = x[Echo-55] - _ = x[Try-56] - _ = x[Catch-57] - _ = x[Unset-58] - _ = x[Stmts-59] - _ = x[VarList-60] - _ = x[ConstList-61] - _ = x[NameList-62] - _ = x[ParamList-63] - _ = x[ModifierList-64] - _ = x[ArrayPairList-65] - _ = x[CaseListStart-66] - _ = x[CaseListEnd-67] - _ = x[ArgumentList-68] - _ = x[PropertyList-69] - _ = x[ParameterList-70] - _ = x[AdaptationList-71] - _ = x[LexicalVarList-72] - _ = x[UseDeclarationList-73] - _ = x[OpenParenthesisToken-74] - _ = x[CloseParenthesisToken-75] -} - -const _Position_name = "StartEndSlashColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" - -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, 296, 301, 303, 308, 312, 317, 322, 327, 331, 335, 338, 343, 348, 353, 360, 369, 377, 386, 398, 411, 424, 435, 447, 459, 472, 486, 500, 518, 538, 559} - -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 deleted file mode 100644 index ee05c36..0000000 --- a/freefloating/string.go +++ /dev/null @@ -1,113 +0,0 @@ -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 - DoubleArrow - 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/go.mod b/go.mod index 6b90c8b..79bd6f0 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,5 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pkg/profile v1.4.0 github.com/yookoala/realpath v1.0.0 - golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 // indirect gotest.tools v2.2.0+incompatible ) diff --git a/go.sum b/go.sum index 6f9717a..082e37f 100644 --- a/go.sum +++ b/go.sum @@ -6,22 +6,6 @@ github.com/pkg/profile v1.4.0 h1:uCmaf4vVbWAOZz36k1hrQD7ijGRzLwaME8Am/7a4jZI= github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE= github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ= github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 h1:9Di9iYgOt9ThCipBxChBVhgNipDoE5mxO84rQV7D0FE= -golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff --git a/internal/php5/node.go b/internal/php5/node.go new file mode 100644 index 0000000..6a612ac --- /dev/null +++ b/internal/php5/node.go @@ -0,0 +1,85 @@ +package php5 + +import ( + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" +) + +type ParserBrackets struct { + Position *position.Position + OpenBracketTkn *token.Token + Child ast.Vertex + CloseBracketTkn *token.Token +} + +func (n *ParserBrackets) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ParserBrackets) GetPosition() *position.Position { + return n.Position +} + +type ParserSeparatedList struct { + Position *position.Position + Items []ast.Vertex + SeparatorTkns []*token.Token +} + +func (n *ParserSeparatedList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ParserSeparatedList) GetPosition() *position.Position { + return n.Position +} + +// TraitAdaptationList node +type TraitAdaptationList struct { + Position *position.Position + OpenCurlyBracketTkn *token.Token + Adaptations []ast.Vertex + CloseCurlyBracketTkn *token.Token +} + +func (n *TraitAdaptationList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *TraitAdaptationList) GetPosition() *position.Position { + return n.Position +} + +// ArgumentList node +type ArgumentList struct { + Position *position.Position + OpenParenthesisTkn *token.Token + Arguments []ast.Vertex + SeparatorTkns []*token.Token + CloseParenthesisTkn *token.Token +} + +func (n *ArgumentList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ArgumentList) GetPosition() *position.Position { + return n.Position +} + +// TraitMethodRef node +type TraitMethodRef struct { + Position *position.Position + Trait ast.Vertex + DoubleColonTkn *token.Token + Method ast.Vertex +} + +func (n *TraitMethodRef) Accept(v ast.Visitor) { + // do nothing +} + +func (n *TraitMethodRef) GetPosition() *position.Position { + return n.Position +} diff --git a/internal/php5/parser.go b/internal/php5/parser.go new file mode 100644 index 0000000..a8c8dcf --- /dev/null +++ b/internal/php5/parser.go @@ -0,0 +1,66 @@ +package php5 + +import ( + "github.com/z7zmey/php-parser/internal/position" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/token" +) + +// Parser structure +type Parser struct { + Lexer *scanner.Lexer + currentToken *token.Token + rootNode ast.Vertex + errHandlerFunc func(*errors.Error) + builder *position.Builder +} + +// NewParser creates and returns new Parser +func NewParser(lexer *scanner.Lexer, config cfg.Config) *Parser { + return &Parser{ + Lexer: lexer, + errHandlerFunc: config.ErrorHandlerFunc, + builder: position.NewBuilder(), + } +} + +// Lex proxy to scanner Lex +func (p *Parser) Lex(lval *yySymType) int { + t := p.Lexer.Lex() + + p.currentToken = t + lval.token = t + + return int(t.ID) +} + +func (p *Parser) Error(msg string) { + if p.errHandlerFunc == nil { + return + } + + p.errHandlerFunc(errors.NewError(msg, p.currentToken.Position)) +} + +// Parse the php7 Parser entrypoint +func (p *Parser) Parse() int { + p.rootNode = nil + return yyParse(p) +} + +// GetRootNode returns root node +func (p *Parser) GetRootNode() ast.Vertex { + return p.rootNode +} + +// helpers + +func lastNode(nn []ast.Vertex) ast.Vertex { + if len(nn) == 0 { + return nil + } + return nn[len(nn)-1] +} diff --git a/internal/php5/parser_test.go b/internal/php5/parser_test.go new file mode 100644 index 0000000..a8a9bd5 --- /dev/null +++ b/internal/php5/parser_test.go @@ -0,0 +1,50781 @@ +package php5_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/internal/php5" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "github.com/z7zmey/php-parser/pkg/version" +) + +func TestIdentifier(t *testing.T) { + src := `bar($a, ...$b); + foo::bar($a, ...$b); + $foo::bar($a, ...$b); + new foo($a, ...$b);` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 7, + StartPos: 5, + EndPos: 132, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 20, + }, + Expr: &ast.ExprFunctionCall{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 19, + }, + Function: &ast.Name{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 46, + EndPos: 48, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 48, + EndPos: 51, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 48, + EndPos: 51, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 51, + EndPos: 52, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 56, + EndPos: 61, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 56, + EndPos: 59, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 55, + EndPos: 56, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 54, + EndPos: 55, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 61, + EndPos: 62, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 62, + EndPos: 63, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 86, + }, + Expr: &ast.ExprStaticCall{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 85, + }, + Class: &ast.Name{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 4, + EndLine: 5, + StartPos: 63, + EndPos: 66, + }, + }, + }, + }, + Value: []byte("foo"), + }, + }, + }, + DoubleColonTkn: &token.Token{ + ID: token.T_PAAMAYIM_NEKUDOTAYIM, + Value: []byte("::"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 69, + EndPos: 71, + }, + }, + Call: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 71, + EndPos: 74, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 71, + EndPos: 74, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 74, + EndPos: 75, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 79, + EndPos: 84, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 79, + EndPos: 82, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 78, + EndPos: 79, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 77, + EndPos: 78, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 84, + EndPos: 85, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 85, + EndPos: 86, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 110, + }, + Expr: &ast.ExprStaticCall{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 109, + }, + Class: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$foo"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 5, + EndLine: 6, + StartPos: 86, + EndPos: 89, + }, + }, + }, + }, + Value: []byte("$foo"), + }, + }, + DoubleColonTkn: &token.Token{ + ID: token.T_PAAMAYIM_NEKUDOTAYIM, + Value: []byte("::"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 93, + EndPos: 95, + }, + }, + Call: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 95, + EndPos: 98, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 95, + EndPos: 98, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 98, + EndPos: 99, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 103, + EndPos: 108, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 103, + EndPos: 106, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 102, + EndPos: 103, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 101, + EndPos: 102, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 108, + EndPos: 109, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 109, + EndPos: 110, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 132, + }, + Expr: &ast.ExprNew{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 131, + }, + NewTkn: &token.Token{ + ID: token.T_NEW, + Value: []byte("new"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 116, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 6, + EndLine: 7, + StartPos: 110, + EndPos: 113, + }, + }, + }, + }, + Class: &ast.Name{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 116, + EndPos: 117, + }, + }, + }, + }, + Value: []byte("foo"), + }, + }, + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 120, + EndPos: 121, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 125, + EndPos: 130, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 125, + EndPos: 128, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 124, + EndPos: 125, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 123, + EndPos: 124, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 130, + EndPos: 131, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 131, + EndPos: 132, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestPhp5ParameterNode(t *testing.T) { + src := `bar()";` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 22, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 22, + }, + Expr: &ast.ScalarEncapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + OpenQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 15, + }, + }, + Prop: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + }, + Value: []byte("bar"), + }, + }, + &ast.ScalarEncapsedStringPart{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 20, + }, + EncapsedStrTkn: &token.Token{ + ID: token.T_ENCAPSED_AND_WHITESPACE, + Value: []byte("()"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 20, + }, + }, + Value: []byte("()"), + }, + }, + CloseQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 22, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestScalarEncapsed_DollarOpenCurlyBraces(t *testing.T) { + src := `bar()}";` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 24, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 24, + }, + Expr: &ast.ScalarEncapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 23, + }, + OpenQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 16, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 19, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 19, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 22, + }, + }, + }, + }, + CloseQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 22, + EndPos: 23, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestScalarHeredoc_HeredocSimpleLabel(t *testing.T) { + src := ` $v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 30, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_ExprWithKey(t *testing.T) { + src := ` $v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 30, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_WithRef(t *testing.T) { + src := ` &$v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 31, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 31, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 25, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_WithList(t *testing.T) { + src := ` list($v)) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 36, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 36, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 32, + }, + ListTkn: &token.Token{ + ID: token.T_LIST, + Value: []byte("list"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 28, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + OpenBracketTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + }, + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + }, + Value: []byte("$v"), + }, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 31, + EndPos: 32, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 32, + EndPos: 33, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 34, + EndPos: 36, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 34, + EndPos: 35, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 33, + EndPos: 34, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 35, + EndPos: 36, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtFunction(t *testing.T) { + src := `
` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte("?>"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 17, + }, + }, + Value: []byte("
"), + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtInterface(t *testing.T) { + src := `1, &$b,);` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + Expr: &ast.ExprArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 20, + }, + ArrayTkn: &token.Token{ + ID: token.T_ARRAY, + Value: []byte("array"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 12, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + }, + Value: []byte("1"), + }, + }, + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + }, + Value: []byte("$b"), + }, + }, + }, + &ast.ExprArrayItem{}, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + }, + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 19, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprBitwiseNot(t *testing.T) { + src := `foo();` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 13, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 13, + }, + Expr: &ast.ExprMethodCall{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 12, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + }, + Value: []byte("foo"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprNew(t *testing.T) { + src := `b["c"]()->d["e"]();` + +func TestExprPropertyFetch(t *testing.T) { + src := `foo;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 11, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 11, + }, + Expr: &ast.ExprPropertyFetch{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Prop: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + }, + Value: []byte("foo"), + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprShellExec(t *testing.T) { + src := "1, &$b,];` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + Expr: &ast.ExprArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 15, + }, + OpenBracketTkn: &token.Token{ + ID: token.ID(91), + Value: []byte("["), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 8, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 8, + }, + }, + Value: []byte("1"), + }, + }, + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 13, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 9, + EndPos: 10, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + }, + Value: []byte("$b"), + }, + }, + }, + &ast.ExprArrayItem{}, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 9, + }, + }, + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(93), + Value: []byte("]"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprStaticCall(t *testing.T) { + src := ` $b;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 18, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 18, + }, + Expr: &ast.ExprYield{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + YieldTkn: &token.Token{ + ID: token.T_YIELD, + Value: []byte("yield"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 14, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 18, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprYield_Expr(t *testing.T) { + src := ` 1;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Expr: &ast.ExprYield{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + YieldTkn: &token.Token{ + ID: token.T_YIELD, + Value: []byte("yield"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 14, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Value: []byte("1"), + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 17, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +// expr assign + +func TestExprAssign(t *testing.T) { + src := `>= $b;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 17, + StartPos: 5, + EndPos: 210, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 13, + }, + Expr: &ast.ExprAssign{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 12, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(">="), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 203, + EndPos: 206, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 202, + EndPos: 203, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 206, + EndPos: 207, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 209, + EndPos: 210, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +// expr binary + +func TestExprBinary_BitwiseAnd(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;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 26, + StartPos: 5, + EndPos: 295, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 13, + }, + Expr: &ast.ExprBinaryBitwiseAnd{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 12, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte("="), + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 99, + EndPos: 101, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 98, + EndPos: 99, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 102, + EndPos: 104, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 102, + EndPos: 104, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 102, + EndPos: 104, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 101, + EndPos: 102, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 10, + EndLine: 10, + StartPos: 104, + EndPos: 105, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 108, + EndPos: 116, + }, + Expr: &ast.ExprBinaryGreater{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 108, + EndPos: 115, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 108, + EndPos: 110, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 108, + EndPos: 110, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 108, + EndPos: 110, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 10, + EndLine: 11, + StartPos: 105, + EndPos: 108, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(62), + Value: []byte(">"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 111, + EndPos: 112, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 110, + EndPos: 111, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 113, + EndPos: 115, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 113, + EndPos: 115, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 113, + EndPos: 115, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 112, + EndPos: 113, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 115, + EndPos: 116, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 119, + EndPos: 129, + }, + Expr: &ast.ExprBinaryIdentical{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 119, + EndPos: 128, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 119, + EndPos: 121, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 119, + EndPos: 121, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 119, + EndPos: 121, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 11, + EndLine: 12, + StartPos: 116, + EndPos: 119, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_IDENTICAL, + Value: []byte("==="), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 122, + EndPos: 125, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 121, + EndPos: 122, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 126, + EndPos: 128, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 126, + EndPos: 128, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 126, + EndPos: 128, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 125, + EndPos: 126, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 128, + EndPos: 129, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 132, + EndPos: 142, + }, + Expr: &ast.ExprBinaryLogicalAnd{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 132, + EndPos: 141, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 132, + EndPos: 134, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 132, + EndPos: 134, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 132, + EndPos: 134, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 12, + EndLine: 13, + StartPos: 129, + EndPos: 132, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_AND, + Value: []byte("and"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 135, + EndPos: 138, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 134, + EndPos: 135, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 139, + EndPos: 141, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 139, + EndPos: 141, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 139, + EndPos: 141, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 138, + EndPos: 139, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 141, + EndPos: 142, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 145, + EndPos: 154, + }, + Expr: &ast.ExprBinaryLogicalOr{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 145, + EndPos: 153, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 145, + EndPos: 147, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 145, + EndPos: 147, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 145, + EndPos: 147, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 13, + EndLine: 14, + StartPos: 142, + EndPos: 145, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_OR, + Value: []byte("or"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 148, + EndPos: 150, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 147, + EndPos: 148, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 150, + EndPos: 151, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 153, + EndPos: 154, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 167, + }, + Expr: &ast.ExprBinaryLogicalXor{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 166, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 14, + EndLine: 15, + StartPos: 154, + EndPos: 157, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_XOR, + Value: []byte("xor"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 160, + EndPos: 163, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 159, + EndPos: 160, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 164, + EndPos: 166, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 164, + EndPos: 166, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 164, + EndPos: 166, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 163, + EndPos: 164, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 166, + EndPos: 167, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 170, + EndPos: 178, + }, + Expr: &ast.ExprBinaryMinus{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 170, + EndPos: 177, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 170, + EndPos: 172, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 170, + EndPos: 172, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 170, + EndPos: 172, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 15, + EndLine: 16, + StartPos: 167, + EndPos: 170, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(45), + Value: []byte("-"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 173, + EndPos: 174, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 172, + EndPos: 173, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 175, + EndPos: 177, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 175, + EndPos: 177, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 175, + EndPos: 177, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 174, + EndPos: 175, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 177, + EndPos: 178, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 181, + EndPos: 189, + }, + Expr: &ast.ExprBinaryMod{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 181, + EndPos: 188, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 181, + EndPos: 183, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 181, + EndPos: 183, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 181, + EndPos: 183, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 16, + EndLine: 17, + StartPos: 178, + EndPos: 181, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(37), + Value: []byte("%"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 184, + EndPos: 185, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 183, + EndPos: 184, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 186, + EndPos: 188, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 186, + EndPos: 188, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 186, + EndPos: 188, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 185, + EndPos: 186, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 188, + EndPos: 189, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 192, + EndPos: 200, + }, + Expr: &ast.ExprBinaryMul{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 192, + EndPos: 199, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 192, + EndPos: 194, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 192, + EndPos: 194, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 192, + EndPos: 194, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 17, + EndLine: 18, + StartPos: 189, + EndPos: 192, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(42), + Value: []byte("*"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 195, + EndPos: 196, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 194, + EndPos: 195, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 197, + EndPos: 199, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 197, + EndPos: 199, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 197, + EndPos: 199, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 196, + EndPos: 197, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 199, + EndPos: 200, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 203, + EndPos: 212, + }, + Expr: &ast.ExprBinaryNotEqual{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 203, + EndPos: 211, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 203, + EndPos: 205, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 203, + EndPos: 205, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 203, + EndPos: 205, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 18, + EndLine: 19, + StartPos: 200, + EndPos: 203, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_NOT_EQUAL, + Value: []byte("!="), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 206, + EndPos: 208, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 205, + EndPos: 206, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 208, + EndPos: 209, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 211, + EndPos: 212, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 225, + }, + Expr: &ast.ExprBinaryNotIdentical{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 224, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 19, + EndLine: 20, + StartPos: 212, + EndPos: 215, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_NOT_IDENTICAL, + Value: []byte("!=="), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 218, + EndPos: 221, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 217, + EndPos: 218, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 222, + EndPos: 224, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 222, + EndPos: 224, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 222, + EndPos: 224, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 221, + EndPos: 222, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 224, + EndPos: 225, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 228, + EndPos: 236, + }, + Expr: &ast.ExprBinaryPlus{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 228, + EndPos: 235, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 228, + EndPos: 230, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 228, + EndPos: 230, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 228, + EndPos: 230, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 20, + EndLine: 21, + StartPos: 225, + EndPos: 228, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(43), + Value: []byte("+"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 231, + EndPos: 232, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 230, + EndPos: 231, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 233, + EndPos: 235, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 233, + EndPos: 235, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 233, + EndPos: 235, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 232, + EndPos: 233, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 235, + EndPos: 236, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 239, + EndPos: 248, + }, + Expr: &ast.ExprBinaryPow{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 239, + EndPos: 247, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 239, + EndPos: 241, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 239, + EndPos: 241, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 239, + EndPos: 241, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 21, + EndLine: 22, + StartPos: 236, + EndPos: 239, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_POW, + Value: []byte("**"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 242, + EndPos: 244, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 241, + EndPos: 242, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 244, + EndPos: 245, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 247, + EndPos: 248, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 260, + }, + Expr: &ast.ExprBinaryShiftLeft{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 259, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 22, + EndLine: 23, + StartPos: 248, + EndPos: 251, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_SL, + Value: []byte("<<"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 254, + EndPos: 256, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 253, + EndPos: 254, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 256, + EndPos: 257, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 259, + EndPos: 260, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 272, + }, + Expr: &ast.ExprBinaryShiftRight{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 271, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 23, + EndLine: 24, + StartPos: 260, + EndPos: 263, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_SR, + Value: []byte(">>"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 266, + EndPos: 268, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 265, + EndPos: 266, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 268, + EndPos: 269, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 271, + EndPos: 272, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 284, + }, + Expr: &ast.ExprBinarySmallerOrEqual{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 283, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 24, + EndLine: 25, + StartPos: 272, + EndPos: 275, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_SMALLER_OR_EQUAL, + Value: []byte("<="), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 278, + EndPos: 280, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 277, + EndPos: 278, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 280, + EndPos: 281, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 283, + EndPos: 284, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 295, + }, + Expr: &ast.ExprBinarySmaller{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 294, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 25, + EndLine: 26, + StartPos: 284, + EndPos: 287, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(60), + Value: []byte("<"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 290, + EndPos: 291, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 289, + EndPos: 290, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 292, + EndPos: 294, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 292, + EndPos: 294, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 292, + EndPos: 294, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 291, + EndPos: 292, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 294, + EndPos: 295, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + actual := php5parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +// expr cast + +func TestExprCast_Array(t *testing.T) { + src := ` T_INCLUDE +%token T_INCLUDE_ONCE +%token T_EXIT +%token T_IF +%token T_LNUMBER +%token T_DNUMBER +%token T_STRING +%token T_STRING_VARNAME +%token T_VARIABLE +%token T_NUM_STRING +%token T_INLINE_HTML +%token T_CHARACTER +%token T_BAD_CHARACTER +%token T_ENCAPSED_AND_WHITESPACE +%token T_CONSTANT_ENCAPSED_STRING +%token T_ECHO +%token T_DO +%token T_WHILE +%token T_ENDWHILE +%token T_FOR +%token T_ENDFOR +%token T_FOREACH +%token T_ENDFOREACH +%token T_DECLARE +%token T_ENDDECLARE +%token T_AS +%token T_SWITCH +%token T_ENDSWITCH +%token T_CASE +%token T_DEFAULT +%token T_BREAK +%token T_CONTINUE +%token T_GOTO +%token T_FUNCTION +%token T_FN +%token T_CONST +%token T_RETURN +%token T_TRY +%token T_CATCH +%token T_FINALLY +%token T_THROW +%token T_USE +%token T_INSTEADOF +%token T_GLOBAL +%token T_VAR +%token T_UNSET +%token T_ISSET +%token T_EMPTY +%token T_HALT_COMPILER +%token T_CLASS +%token T_TRAIT +%token T_INTERFACE +%token T_EXTENDS +%token T_IMPLEMENTS +%token T_OBJECT_OPERATOR +%token T_DOUBLE_ARROW +%token T_LIST +%token T_ARRAY +%token T_CALLABLE +%token T_CLASS_C +%token T_TRAIT_C +%token T_METHOD_C +%token T_FUNC_C +%token T_LINE +%token T_FILE +%token T_COMMENT +%token T_DOC_COMMENT +%token T_OPEN_TAG +%token T_OPEN_TAG_WITH_ECHO +%token T_CLOSE_TAG +%token T_WHITESPACE +%token T_START_HEREDOC +%token T_END_HEREDOC +%token T_DOLLAR_OPEN_CURLY_BRACES +%token T_CURLY_OPEN +%token T_PAAMAYIM_NEKUDOTAYIM +%token T_NAMESPACE +%token T_NS_C +%token T_DIR +%token T_NS_SEPARATOR +%token T_ELLIPSIS +%token T_EVAL +%token T_REQUIRE +%token T_REQUIRE_ONCE +%token T_LOGICAL_OR +%token T_LOGICAL_XOR +%token T_LOGICAL_AND +%token T_INSTANCEOF +%token T_NEW +%token T_CLONE +%token T_ELSEIF +%token T_ELSE +%token T_ENDIF +%token T_PRINT +%token T_YIELD +%token T_STATIC +%token T_ABSTRACT +%token T_FINAL +%token T_PRIVATE +%token T_PROTECTED +%token T_PUBLIC +%token T_INC +%token T_DEC +%token T_YIELD_FROM +%token T_INT_CAST +%token T_DOUBLE_CAST +%token T_STRING_CAST +%token T_ARRAY_CAST +%token T_OBJECT_CAST +%token T_BOOL_CAST +%token T_UNSET_CAST +%token T_COALESCE +%token T_SPACESHIP +%token T_NOELSE +%token T_PLUS_EQUAL +%token T_MINUS_EQUAL +%token T_MUL_EQUAL +%token T_POW_EQUAL +%token T_DIV_EQUAL +%token T_CONCAT_EQUAL +%token T_MOD_EQUAL +%token T_AND_EQUAL +%token T_OR_EQUAL +%token T_XOR_EQUAL +%token T_SL_EQUAL +%token T_SR_EQUAL +%token T_COALESCE_EQUAL +%token T_BOOLEAN_OR +%token T_BOOLEAN_AND +%token T_POW +%token T_SL +%token T_SR +%token T_IS_IDENTICAL +%token T_IS_NOT_IDENTICAL +%token T_IS_EQUAL +%token T_IS_NOT_EQUAL +%token T_IS_SMALLER_OR_EQUAL +%token T_IS_GREATER_OR_EQUAL +%token '"' +%token '`' +%token '{' +%token '}' +%token ';' +%token ':' +%token '(' +%token ')' +%token '[' +%token ']' +%token '?' +%token '&' +%token '-' +%token '+' +%token '!' +%token '~' +%token '@' +%token '$' +%token ',' +%token '|' +%token '=' +%token '^' +%token '*' +%token '/' +%token '%' +%token '<' +%token '>' +%token '.' + +%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE +%left ',' +%left T_LOGICAL_OR +%left T_LOGICAL_XOR +%left T_LOGICAL_AND +%right T_PRINT +%right T_YIELD +%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL +%left '?' ':' +%left T_BOOLEAN_OR +%left T_BOOLEAN_AND +%left '|' +%left '^' +%left '&' +%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL +%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL +%left T_SL T_SR +%left '+' '-' '.' +%left '*' '/' '%' +%right '!' +%nonassoc T_INSTANCEOF +%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' +%right T_POW +%right '[' +%nonassoc T_NEW T_CLONE +%left T_ELSEIF +%left T_ELSE +%left T_ENDIF +%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC + +%type function interface_entry +%type possible_comma +%type case_separator +%type is_reference is_variadic + +%type top_statement use_declaration use_function_declaration use_const_declaration common_scalar +%type static_class_constant compound_variable reference_variable class_name variable_class_name +%type dim_offset expr expr_without_variable r_variable w_variable rw_variable variable base_variable_with_function_calls +%type base_variable array_function_dereference function_call inner_statement statement unticked_statement +%type statement global_var static_scalar scalar class_constant static_class_name_scalar class_name_scalar +%type encaps_var encaps_var encaps_var_offset general_constant isset_variable internal_functions_in_yacc assignment_list_element +%type variable_name variable_without_objects dynamic_class_name_reference new_expr class_name_reference static_member +%type function_call fully_qualified_class_name combined_scalar combined_scalar_offset general_constant parenthesis_expr +%type exit_expr yield_expr function_declaration_statement class_declaration_statement constant_declaration +%type else_single new_else_single unset_variable declare_statement parameter_list non_empty_parameter_list +%type finally_statement additional_catch unticked_function_declaration_statement unticked_class_declaration_statement +%type optional_class_type parameter class_entry_type class_statement class_constant_declaration +%type trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias +%type trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method +%type static_scalar_value static_operation static_var_list global_var_list +%type ctor_arguments function_call_parameter_list echo_expr_list class_variable_declaration +%type trait_adaptations unset_variables declare_list non_empty_array_pair_list array_pair_list +%type switch_case_list non_empty_function_call_parameter_list assignment_list lexical_var_list +%type method_body trait_reference_list static_array_pair_list non_empty_static_array_pair_list +%type foreach_statement for_statement while_statement isset_variables +%type foreach_variable foreach_optional_arg for_expr non_empty_for_expr +%type extends_from interface_list trait_list namespace_name +%type implements_list use_declarations use_function_declarations use_const_declarations +%type interface_extends_list +%type lexical_vars + +%type top_statement_list +%type inner_statement_list encaps_list +%type elseif_list new_elseif_list +%type case_list catch_statement additional_catches +%type non_empty_additional_catches class_statement_list +%type class_statement_list variable_modifiers method_modifiers +%type trait_adaptation_list non_empty_trait_adaptation_list +%type non_empty_member_modifiers backticks_expr + +%type chaining_dereference chaining_instance_call chaining_method_or_property instance_call variable_property +%type method_or_not array_method_dereference object_property object_dim_list dynamic_class_name_variable_property +%type dynamic_class_name_variable_properties variable_properties + +%type simple_indirect_reference + +%% + +start: + top_statement_list + { + yylex.(*Parser).currentToken.Value = nil + + yylex.(*Parser).rootNode = &ast.Root{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1), + Stmts: $1, + EndTkn: yylex.(*Parser).currentToken, + } + } +; + +top_statement_list: + top_statement_list top_statement + { + if $2 != nil { + $$ = append($1, $2) + } + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + +namespace_name: + T_STRING + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.NamePart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + }, + }, + } + } + | namespace_name T_NS_SEPARATOR T_STRING + { + part := &ast.NamePart{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + StringTkn: $3, + Value: $3.Value, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, part) + + $$ = $1 + } +; + +top_statement: + error + { + // error + $$ = nil + } + | statement + { + $$ = $1 + } + | function_declaration_statement + { + $$ = $1 + } + | class_declaration_statement + { + $$ = $1 + } + | T_HALT_COMPILER '(' ')' ';' + { + $$ = &ast.StmtHaltCompiler{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + HaltCompilerTkn: $1, + OpenParenthesisTkn: $2, + CloseParenthesisTkn: $3, + SemiColonTkn: $4, + } + } + | T_NAMESPACE namespace_name ';' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + NsTkn: $1, + Name: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + SemiColonTkn: $3, + } + } + | T_NAMESPACE namespace_name '{' top_statement_list '}' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + NsTkn: $1, + Name: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + OpenCurlyBracketTkn: $3, + Stmts: $4, + CloseCurlyBracketTkn: $5, + } + } + | T_NAMESPACE '{' top_statement_list '}' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + NsTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + } + } + | T_USE use_declarations ';' + { + $$ = &ast.StmtUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + UseTkn: $1, + Uses: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $3, + } + } + | T_USE T_FUNCTION use_function_declarations ';' + { + $$ = &ast.StmtUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + UseTkn: $1, + Type: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + Uses: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $4, + } + } + | T_USE T_CONST use_const_declarations ';' + { + $$ = &ast.StmtUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + UseTkn: $1, + Type: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + Uses: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $4, + } + } + | constant_declaration ';' + { + $1.(*ast.StmtConstList).SemiColonTkn = $2 + $1.(*ast.StmtConstList).Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $2) + $$ = $1 + } +; + +use_declarations: + use_declarations ',' use_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | use_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +use_declaration: + namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $3), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NS_SEPARATOR namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $3, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + } + } +; + +use_function_declarations: + use_function_declarations ',' use_function_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | use_function_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +use_function_declaration: + namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $3), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NS_SEPARATOR namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $3, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + } + } +; + +use_const_declarations: + use_const_declarations ',' use_const_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | use_const_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +use_const_declaration: + namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $3), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NS_SEPARATOR namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + NsSeparatorTkn: $1, + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $3, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + } + } +; + +constant_declaration: + constant_declaration ',' T_STRING '=' static_scalar + { + constList := $1.(*ast.StmtConstList) + constList.Position = yylex.(*Parser).builder.NewNodesPosition($1, $5) + constList.SeparatorTkns = append(constList.SeparatorTkns, $2) + constList.Consts = append(constList.Consts, &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $5), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + EqualTkn: $4, + Expr: $5, + }) + + $$ = $1 + } + | T_CONST T_STRING '=' static_scalar + { + $$ = &ast.StmtConstList{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + ConstTkn: $1, + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + EqualTkn: $3, + Expr: $4, + }, + }, + } + } +; + +inner_statement_list: + inner_statement_list inner_statement + { + if $2 != nil { + $$ = append($1, $2) + } + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + + +inner_statement: + error + { + // error + $$ = nil + } + | statement + { + $$ = $1 + } + | function_declaration_statement + { + $$ = $1 + } + | class_declaration_statement + { + $$ = $1 + } + | T_HALT_COMPILER '(' ')' ';' + { + $$ = &ast.StmtHaltCompiler{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + HaltCompilerTkn: $1, + OpenParenthesisTkn: $2, + CloseParenthesisTkn: $3, + SemiColonTkn: $4, + } + } +; + + +statement: + unticked_statement + { + $$ = $1 + } + | T_STRING ':' + { + $$ = &ast.StmtLabel{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + ColonTkn: $2, + } + } +; + +unticked_statement: + '{' inner_statement_list '}' + { + $$ = &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Stmts: $2, + CloseCurlyBracketTkn: $3, + } + } + | T_IF parenthesis_expr statement elseif_list else_single + { + pos := yylex.(*Parser).builder.NewTokenNodePosition($1, $3) + if $5 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($1, $5) + } else if len($4) > 0 { + pos = yylex.(*Parser).builder.NewTokenNodeListPosition($1, $4) + } + + $$ = &ast.StmtIf{ + Position: pos, + IfTkn: $1, + OpenParenthesisTkn: $2.(*ast.ExprBrackets).OpenParenthesisTkn, + Cond: $2.(*ast.ExprBrackets).Expr, + CloseParenthesisTkn: $2.(*ast.ExprBrackets).CloseParenthesisTkn, + Stmt: $3, + ElseIf: $4, + Else: $5, + } + } + | T_IF parenthesis_expr ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';' + { + $$ = &ast.StmtIf{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $8), + IfTkn: $1, + OpenParenthesisTkn: $2.(*ast.ExprBrackets).OpenParenthesisTkn, + Cond: $2.(*ast.ExprBrackets).Expr, + CloseParenthesisTkn: $2.(*ast.ExprBrackets).CloseParenthesisTkn, + ColonTkn: $3, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($4), + Stmts: $4, + }, + ElseIf: $5, + Else: $6, + EndIfTkn: $7, + SemiColonTkn: $8, + } + } + | T_WHILE parenthesis_expr while_statement + { + $3.(*ast.StmtWhile).WhileTkn = $1 + $3.(*ast.StmtWhile).OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn + $3.(*ast.StmtWhile).Cond = $2.(*ast.ExprBrackets).Expr + $3.(*ast.StmtWhile).CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn + $3.(*ast.StmtWhile).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $3) + + $$ = $3 + } + | T_DO statement T_WHILE parenthesis_expr ';' + { + $$ = &ast.StmtDo{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + DoTkn: $1, + Stmt: $2, + WhileTkn: $3, + OpenParenthesisTkn: $4.(*ast.ExprBrackets).OpenParenthesisTkn, + Cond: $4.(*ast.ExprBrackets).Expr, + CloseParenthesisTkn: $4.(*ast.ExprBrackets).CloseParenthesisTkn, + SemiColonTkn: $5, + } + } + | T_FOR '(' for_expr ';' for_expr ';' for_expr ')' for_statement + { + $9.(*ast.StmtFor).ForTkn = $1 + $9.(*ast.StmtFor).OpenParenthesisTkn = $2 + $9.(*ast.StmtFor).Init = $3.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).InitSeparatorTkns = $3.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).InitSemiColonTkn = $4 + $9.(*ast.StmtFor).Cond = $5.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).CondSeparatorTkns = $5.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).CondSemiColonTkn = $6 + $9.(*ast.StmtFor).Loop = $7.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).LoopSeparatorTkns = $7.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).CloseParenthesisTkn = $8 + $9.(*ast.StmtFor).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $9) + + $$ = $9 + } + | T_SWITCH parenthesis_expr switch_case_list + { + $3.(*ast.StmtSwitch).SwitchTkn = $1 + $3.(*ast.StmtSwitch).OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn + $3.(*ast.StmtSwitch).Cond = $2.(*ast.ExprBrackets).Expr + $3.(*ast.StmtSwitch).CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn + $3.(*ast.StmtSwitch).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $3) + + $$ = $3 + } + | T_BREAK ';' + { + $$ = &ast.StmtBreak{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + BreakTkn: $1, + SemiColonTkn: $2, + } + } + | T_BREAK expr ';' + { + $$ = &ast.StmtBreak{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + BreakTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_CONTINUE ';' + { + $$ = &ast.StmtContinue{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + ContinueTkn: $1, + SemiColonTkn: $2, + } + } + | T_CONTINUE expr ';' + { + $$ = &ast.StmtContinue{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ContinueTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_RETURN ';' + { + $$ = &ast.StmtReturn{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + ReturnTkn: $1, + SemiColonTkn: $2, + } + } + | T_RETURN expr_without_variable ';' + { + $$ = &ast.StmtReturn{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ReturnTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_RETURN variable ';' + { + $$ = &ast.StmtReturn{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ReturnTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | yield_expr ';' + { + $$ = &ast.StmtExpression{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Expr: $1, + SemiColonTkn: $2, + } + } + | T_GLOBAL global_var_list ';' + { + $2.(*ast.StmtGlobal).GlobalTkn = $1 + $2.(*ast.StmtGlobal).SemiColonTkn = $3 + $2.(*ast.StmtGlobal).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_STATIC static_var_list ';' + { + $2.(*ast.StmtStatic).StaticTkn = $1 + $2.(*ast.StmtStatic).SemiColonTkn = $3 + $2.(*ast.StmtStatic).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_ECHO echo_expr_list ';' + { + $2.(*ast.StmtEcho).EchoTkn = $1 + $2.(*ast.StmtEcho).SemiColonTkn = $3 + $2.(*ast.StmtEcho).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_INLINE_HTML + { + $$ = &ast.StmtInlineHtml{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + InlineHtmlTkn: $1, + Value: $1.Value, + } + } + | expr ';' + { + $$ = &ast.StmtExpression{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Expr: $1, + SemiColonTkn: $2, + } + } + | T_UNSET '(' unset_variables ')' ';' + { + $3.(*ast.StmtUnset).UnsetTkn = $1 + $3.(*ast.StmtUnset).OpenParenthesisTkn = $2 + $3.(*ast.StmtUnset).CloseParenthesisTkn = $4 + $3.(*ast.StmtUnset).SemiColonTkn = $5 + $3.(*ast.StmtUnset).Position = yylex.(*Parser).builder.NewTokensPosition($1, $5) + + $$ = $3 + } + | T_FOREACH '(' variable T_AS foreach_variable foreach_optional_arg ')' foreach_statement + { + foreach := $8.(*ast.StmtForeach) + + foreach.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $8) + foreach.ForeachTkn = $1 + foreach.OpenParenthesisTkn = $2 + foreach.Expr = $3 + foreach.AsTkn = $4 + foreach.Var = $5 + foreach.CloseParenthesisTkn = $7 + + if $6 != nil { + foreach.Key = foreach.Var + foreach.DoubleArrowTkn = $6.(*ast.StmtForeach).DoubleArrowTkn + foreach.Var = $6.(*ast.StmtForeach).Var + } + + if val, ok := foreach.Key.(*ast.StmtForeach); ok { + yylex.(*Parser).errHandlerFunc(errors.NewError("Key element cannot be a reference", val.AmpersandTkn.Position)) + foreach.Key = val.Var + } + + if val, ok := foreach.Var.(*ast.StmtForeach); ok { + foreach.AmpersandTkn = val.AmpersandTkn + foreach.Var = val.Var + } + + $$ = foreach + } + | T_FOREACH '(' expr_without_variable T_AS foreach_variable foreach_optional_arg ')' foreach_statement + { + foreach := $8.(*ast.StmtForeach) + + foreach.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $8) + foreach.ForeachTkn = $1 + foreach.OpenParenthesisTkn = $2 + foreach.Expr = $3 + foreach.AsTkn = $4 + foreach.Var = $5 + foreach.CloseParenthesisTkn = $7 + + if $6 != nil { + foreach.Key = foreach.Var + foreach.DoubleArrowTkn = $6.(*ast.StmtForeach).DoubleArrowTkn + foreach.Var = $6.(*ast.StmtForeach).Var + } + + if val, ok := foreach.Key.(*ast.StmtForeach); ok { + yylex.(*Parser).errHandlerFunc(errors.NewError("Key element cannot be a reference", val.AmpersandTkn.Position)) + foreach.Key = val.Var + } + + if val, ok := foreach.Var.(*ast.StmtForeach); ok { + foreach.AmpersandTkn = val.AmpersandTkn + foreach.Var = val.Var + } + + $$ = foreach + } + | T_DECLARE '(' declare_list ')' declare_statement + { + $5.(*ast.StmtDeclare).DeclareTkn = $1 + $5.(*ast.StmtDeclare).OpenParenthesisTkn = $2 + $5.(*ast.StmtDeclare).Consts = $3.(*ParserSeparatedList).Items + $5.(*ast.StmtDeclare).SeparatorTkns = $3.(*ParserSeparatedList).SeparatorTkns + $5.(*ast.StmtDeclare).CloseParenthesisTkn = $4 + $5.(*ast.StmtDeclare).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $5) + + $$ = $5 + } + | ';' + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | T_TRY '{' inner_statement_list '}' catch_statement finally_statement + { + pos := yylex.(*Parser).builder.NewTokenNodeListPosition($1, $5) + if $6 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($1, $6) + } + + $$ = &ast.StmtTry{ + Position: pos, + TryTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + Catches: $5, + Finally: $6, + } + } + | T_THROW expr ';' + { + $$ = &ast.StmtThrow{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ThrowTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_GOTO T_STRING ';' + { + $$ = &ast.StmtGoto{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + GotoTkn: $1, + Label: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $2, + Value: $2.Value, + }, + SemiColonTkn: $3, + } + } +; + +catch_statement: + /* empty */ + { + $$ = []ast.Vertex{} + } + | T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' additional_catches + { + catch := &ast.StmtCatch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $8), + CatchTkn: $1, + OpenParenthesisTkn: $2, + Types: []ast.Vertex{$3}, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + CloseParenthesisTkn: $5, + OpenCurlyBracketTkn: $6, + Stmts: $7, + CloseCurlyBracketTkn: $8, + } + $$ = append([]ast.Vertex{catch}, $9...) + } +; + +finally_statement: + /* empty */ + { + $$ = nil + } + | T_FINALLY '{' inner_statement_list '}' + { + $$ = &ast.StmtFinally{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + FinallyTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + } + } +; + +additional_catches: + non_empty_additional_catches + { + $$ = $1 + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + +non_empty_additional_catches: + additional_catch + { + $$ = []ast.Vertex{$1} + } + | non_empty_additional_catches additional_catch + { + $$ = append($1, $2) + } +; + +additional_catch: + T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' + { + $$ = &ast.StmtCatch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $8), + CatchTkn: $1, + OpenParenthesisTkn: $2, + Types: []ast.Vertex{$3}, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + CloseParenthesisTkn: $5, + OpenCurlyBracketTkn: $6, + Stmts: $7, + CloseCurlyBracketTkn: $8, + } + } +; + +unset_variables: + unset_variable + { + $$ = &ast.StmtUnset{ + Vars: []ast.Vertex{$1}, + } + } + | unset_variables ',' unset_variable + { + $1.(*ast.StmtUnset).Vars = append($1.(*ast.StmtUnset).Vars, $3) + $1.(*ast.StmtUnset).SeparatorTkns = append($1.(*ast.StmtUnset).SeparatorTkns, $2) + + $$ = $1 + } +; + +unset_variable: + variable + { + $$ = $1 + } +; + +function_declaration_statement: + unticked_function_declaration_statement + { + $$ = $1 + } +; + +class_declaration_statement: + unticked_class_declaration_statement + { + $$ = $1 + } +; + +is_reference: + /* empty */ + { + $$ = nil + } + | '&' + { + $$ = $1 + } +; + +is_variadic: + /* empty */ + { + $$ = nil + } + | T_ELLIPSIS + { + $$ = $1 + } +; + +unticked_function_declaration_statement: + function is_reference T_STRING '(' parameter_list ')' '{' inner_statement_list '}' + { + $$ = &ast.StmtFunction{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $9), + FunctionTkn: $1, + AmpersandTkn: $2, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + OpenParenthesisTkn: $4, + Params: $5.(*ParserSeparatedList).Items, + SeparatorTkns: $5.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $6, + OpenCurlyBracketTkn: $7, + Stmts: $8, + CloseCurlyBracketTkn: $9, + } + } +; + +unticked_class_declaration_statement: + class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}' + { + switch n := $1.(type) { + case *ast.StmtClass : + className := &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + } + + n.Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $7) + n.Name = className + n.OpenCurlyBracketTkn = $5 + n.Stmts = $6 + n.CloseCurlyBracketTkn = $7 + + if $3 != nil { + n.ExtendsTkn = $3.(*ast.StmtClass).ExtendsTkn + n.Extends = $3.(*ast.StmtClass).Extends + } + + if $4 != nil { + n.ImplementsTkn = $4.(*ast.StmtClass).ImplementsTkn + n.Implements = $4.(*ast.StmtClass).Implements + n.ImplementsSeparatorTkns = $4.(*ast.StmtClass).ImplementsSeparatorTkns + } + case *ast.StmtTrait : + traitName := &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + } + + n.Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $7) + n.Name = traitName + n.OpenCurlyBracketTkn = $5 + n.Stmts = $6 + n.CloseCurlyBracketTkn = $7 + + if $3 != nil { + yylex.(*Parser).errHandlerFunc(errors.NewError("A trait cannot extend a class. Traits can only be composed from other traits with the 'use' keyword", $3.(*ast.StmtClass).Position)) + } + + if $4 != nil { + yylex.(*Parser).errHandlerFunc(errors.NewError("A trait cannot implement an interface", $4.(*ast.StmtClass).Position)) + } + } + + $$ = $1 + } + | interface_entry T_STRING interface_extends_list '{' class_statement_list '}' + { + iface := &ast.StmtInterface{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $6), + InterfaceTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenCurlyBracketTkn: $4, + Stmts: $5, + CloseCurlyBracketTkn: $6, + } + + if $3 != nil { + iface.ExtendsTkn = $3.(*ast.StmtInterface).ExtendsTkn + iface.Extends = $3.(*ast.StmtInterface).Extends + iface.ExtendsSeparatorTkns = $3.(*ast.StmtInterface).ExtendsSeparatorTkns + } + + $$ = iface + } +; + + +class_entry_type: + T_CLASS + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + ClassTkn: $1, + } + } + | T_ABSTRACT T_CLASS + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + Modifiers: []ast.Vertex{ + &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + ClassTkn: $2, + } + } + | T_TRAIT + { + $$ = &ast.StmtTrait{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + TraitTkn: $1, + } + } + | T_FINAL T_CLASS + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + Modifiers: []ast.Vertex{ + &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + ClassTkn: $2, + } + } +; + +extends_from: + /* empty */ + { + $$ = nil + } + | T_EXTENDS fully_qualified_class_name + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ExtendsTkn: $1, + Extends: $2, + } + } +; + +interface_entry: + T_INTERFACE + { + $$ = $1 + } +; + +interface_extends_list: + /* empty */ + { + $$ = nil + } + | T_EXTENDS interface_list + { + $$ = &ast.StmtInterface{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + ExtendsTkn: $1, + Extends: $2.(*ParserSeparatedList).Items, + ExtendsSeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }; + } +; + +implements_list: + /* empty */ + { + $$ = nil + } + | T_IMPLEMENTS interface_list + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + ImplementsTkn: $1, + Implements: $2.(*ParserSeparatedList).Items, + ImplementsSeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }; + } +; + +interface_list: + fully_qualified_class_name + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | interface_list ',' fully_qualified_class_name + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +foreach_optional_arg: + /* empty */ + { + $$ = nil + } + | T_DOUBLE_ARROW foreach_variable + { + $$ = &ast.StmtForeach{ + DoubleArrowTkn: $1, + Var: $2, + } + } +; + +foreach_variable: + variable + { + $$ = $1 + } + | '&' variable + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AmpersandTkn: $1, + Var: $2, + } + } + | T_LIST '(' assignment_list ')' + { + pairList := $3.(*ParserSeparatedList) + fistPair := pairList.Items[0].(*ast.ExprArrayItem) + + if fistPair.Key == nil && fistPair.Val == nil && len(pairList.Items) == 1 { + pairList.Items = nil + } + + $$ = &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + } + } +; + +for_statement: + statement + { + $$ = &ast.StmtFor{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDFOR ';' + { + $$ = &ast.StmtFor{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndForTkn: $3, + SemiColonTkn: $4, + } + } +; + +foreach_statement: + statement + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDFOREACH ';' + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndForeachTkn: $3, + SemiColonTkn: $4, + } + } +; + + +declare_statement: + statement + { + $$ = &ast.StmtDeclare{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDDECLARE ';' + { + $$ = &ast.StmtDeclare{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndDeclareTkn: $3, + SemiColonTkn: $4, + } + } +; + + +declare_list: + T_STRING '=' static_scalar + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + EqualTkn: $2, + Expr: $3, + }, + }, + } + } + | declare_list ',' T_STRING '=' static_scalar + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append( + $1.(*ParserSeparatedList).Items, + &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $5), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + EqualTkn: $4, + Expr: $5, + }, + ) + + $$ = $1 + } +; + + +switch_case_list: + '{' case_list '}' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Cases: $2, + CloseCurlyBracketTkn: $3, + } + } + | '{' ';' case_list '}' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + OpenCurlyBracketTkn: $1, + CaseSeparatorTkn: $2, + Cases: $3, + CloseCurlyBracketTkn: $4, + } + } + | ':' case_list T_ENDSWITCH ';' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Cases: $2, + EndSwitchTkn: $3, + SemiColonTkn: $4, + } + } + | ':' ';' case_list T_ENDSWITCH ';' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + ColonTkn: $1, + CaseSeparatorTkn: $2, + Cases: $3, + EndSwitchTkn: $4, + SemiColonTkn: $5, + } + } +; + + +case_list: + /* empty */ + { + $$ = nil + } + | case_list T_CASE expr case_separator inner_statement_list + { + $$ = append($1, &ast.StmtCase{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $5), + CaseTkn: $2, + Cond: $3, + CaseSeparatorTkn: $4, + Stmts: $5, + }) + } + | case_list T_DEFAULT case_separator inner_statement_list + { + $$ = append($1, &ast.StmtDefault{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $4), + DefaultTkn: $2, + CaseSeparatorTkn: $3, + Stmts: $4, + }) + } +; + + +case_separator: + ':' + { + $$ = $1 + } + | ';' + { + $$ = $1 + } +; + + +while_statement: + statement + { + $$ = &ast.StmtWhile{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDWHILE ';' + { + $$ = &ast.StmtWhile{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndWhileTkn: $3, + SemiColonTkn: $4, + } + } +; + + + +elseif_list: + /* empty */ + { + $$ = nil + } + | elseif_list T_ELSEIF parenthesis_expr statement + { + $$ = append($1, &ast.StmtElseIf{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $4), + ElseIfTkn: $2, + OpenParenthesisTkn: $3.(*ast.ExprBrackets).OpenParenthesisTkn, + Cond: $3.(*ast.ExprBrackets).Expr, + CloseParenthesisTkn: $3.(*ast.ExprBrackets).CloseParenthesisTkn, + Stmt: $4, + }) + } +; + + +new_elseif_list: + /* empty */ + { + $$ = nil + } + | new_elseif_list T_ELSEIF parenthesis_expr ':' inner_statement_list + { + $$ = append($1, &ast.StmtElseIf{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $5), + ElseIfTkn: $2, + OpenParenthesisTkn: $3.(*ast.ExprBrackets).OpenParenthesisTkn, + Cond: $3.(*ast.ExprBrackets).Expr, + CloseParenthesisTkn: $3.(*ast.ExprBrackets).CloseParenthesisTkn, + ColonTkn: $4, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($5), + Stmts: $5, + }, + }) + } +; + + +else_single: + /* empty */ + { + $$ = nil + } + | T_ELSE statement + { + $$ = &ast.StmtElse{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ElseTkn: $1, + Stmt: $2, + } + } +; + + +new_else_single: + /* empty */ + { + $$ = nil + } + | T_ELSE ':' inner_statement_list + { + $$ = &ast.StmtElse{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3), + ElseTkn: $1, + ColonTkn: $2, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($3), + Stmts: $3, + }, + } + } +; + + +parameter_list: + non_empty_parameter_list + { + $$ = $1 + } + | /* empty */ + { + $$ = &ParserSeparatedList{} + } +; + +non_empty_parameter_list: + parameter + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | non_empty_parameter_list ',' parameter + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +parameter: + optional_class_type is_reference is_variadic T_VARIABLE + { + pos := yylex.(*Parser).builder.NewTokenPosition($4) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodeTokenPosition($1, $4) + } else if $2 != nil { + pos = yylex.(*Parser).builder.NewTokensPosition($2, $4) + } else if $3 != nil { + pos = yylex.(*Parser).builder.NewTokensPosition($3, $4) + } + + $$ = &ast.Parameter{ + Position: pos, + Type: $1, + AmpersandTkn: $2, + VariadicTkn: $3, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + } + } + | optional_class_type is_reference is_variadic T_VARIABLE '=' expr + { + pos := yylex.(*Parser).builder.NewTokenNodePosition($4, $6) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodesPosition($1, $6) + } else if $2 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($2, $6) + } else if $3 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($3, $6) + } + + $$ = &ast.Parameter{ + Position: pos, + Type: $1, + AmpersandTkn: $2, + VariadicTkn: $3, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + EqualTkn: $5, + DefaultValue: $6, + } + } +; + + +optional_class_type: + /* empty */ + { + $$ = nil + } + | T_ARRAY + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_CALLABLE + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | fully_qualified_class_name + { + $$ = $1 + } +; + + +function_call_parameter_list: + '(' ')' + { + $$ = &ArgumentList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenParenthesisTkn: $1, + CloseParenthesisTkn: $2, + } + } + | '(' non_empty_function_call_parameter_list ')' + { + argumentList := $2.(*ArgumentList) + argumentList.Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + argumentList.OpenParenthesisTkn = $1 + argumentList.CloseParenthesisTkn = $3 + + $$ = argumentList + } + | '(' yield_expr ')' + { + $$ = &ArgumentList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Arguments: []ast.Vertex{ + &ast.Argument{ + Position: yylex.(*Parser).builder.NewNodePosition($2), + Expr: $2, + }, + }, + CloseParenthesisTkn: $3, + } + } +; + + +non_empty_function_call_parameter_list: + function_call_parameter + { + $$ = &ArgumentList{ + Arguments: []ast.Vertex{$1}, + } + } + | non_empty_function_call_parameter_list ',' function_call_parameter + { + $1.(*ArgumentList).SeparatorTkns = append($1.(*ArgumentList).SeparatorTkns, $2) + $1.(*ArgumentList).Arguments = append($1.(*ArgumentList).Arguments, $3) + + $$ = $1 + } +; + +function_call_parameter: + expr_without_variable + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Expr: $1, + } + } + | variable + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Expr: $1, + } + } + | '&' w_variable + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AmpersandTkn: $1, + Expr: $2, + } + } + | T_ELLIPSIS expr + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + VariadicTkn: $1, + Expr: $2, + } + } +; + +global_var_list: + global_var_list ',' global_var + { + $1.(*ast.StmtGlobal).Vars = append($1.(*ast.StmtGlobal).Vars, $3) + $1.(*ast.StmtGlobal).SeparatorTkns = append($1.(*ast.StmtGlobal).SeparatorTkns, $2) + + $$ = $1 + } + | global_var + { + $$ = &ast.StmtGlobal{ + Vars: []ast.Vertex{$1}, + } + } +; + + +global_var: + T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | '$' r_variable + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + DollarTkn: $1, + Name: $2, + } + } + | '$' '{' expr '}' + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + DollarTkn: $1, + OpenCurlyBracketTkn: $2, + Name: $3, + CloseCurlyBracketTkn: $4, + } + } +; + + +static_var_list: + static_var_list ',' T_VARIABLE + { + $1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + }, + }) + $1.(*ast.StmtStatic).SeparatorTkns = append($1.(*ast.StmtStatic).SeparatorTkns, $2) + + $$ = $1 + } + | static_var_list ',' T_VARIABLE '=' static_scalar + { + $1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $5), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + }, + EqualTkn: $4, + Expr: $5, + }) + $1.(*ast.StmtStatic).SeparatorTkns = append($1.(*ast.StmtStatic).SeparatorTkns, $2) + + $$ = $1 + } + | T_VARIABLE + { + $$ = &ast.StmtStatic{ + Vars: []ast.Vertex{ + &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + }, + }, + } + } + | T_VARIABLE '=' static_scalar + { + $$ = &ast.StmtStatic{ + Vars: []ast.Vertex{ + &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + EqualTkn: $2, + Expr: $3, + }, + }, + } + } +; + + +class_statement_list: + class_statement_list class_statement + { + $$ = append($1, $2) + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + + +class_statement: + variable_modifiers class_variable_declaration ';' + { + $$ = &ast.StmtPropertyList{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1, $3), + Modifiers: $1, + Props: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $3, + } + } + | class_constant_declaration ';' + { + $1.(*ast.StmtClassConstList).SemiColonTkn = $2 + $1.(*ast.StmtClassConstList).Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $2) + $$ = $1 + } + | trait_use_statement + { + $$ = $1 + } + | method_modifiers function is_reference T_STRING '(' parameter_list ')' method_body + { + pos := yylex.(*Parser).builder.NewTokenNodePosition($2, $8) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodeListNodePosition($1, $8) + } + + $$ = &ast.StmtClassMethod{ + Position: pos, + Modifiers: $1, + FunctionTkn: $2, + AmpersandTkn: $3, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + OpenParenthesisTkn: $5, + Params: $6.(*ParserSeparatedList).Items, + SeparatorTkns: $6.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $7, + Stmt: $8, + } + } +; + +trait_use_statement: + T_USE trait_list trait_adaptations + { + traitUse := &ast.StmtTraitUse{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + UseTkn: $1, + Traits: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + } + + switch n := $3.(type) { + case *TraitAdaptationList : + traitUse.OpenCurlyBracketTkn = n.OpenCurlyBracketTkn + traitUse.Adaptations = n.Adaptations + traitUse.CloseCurlyBracketTkn = n.CloseCurlyBracketTkn + case *ast.StmtNop : + traitUse.SemiColonTkn = n.SemiColonTkn + }; + + $$ = traitUse + } +; + +trait_list: + fully_qualified_class_name + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | trait_list ',' fully_qualified_class_name + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +trait_adaptations: + ';' + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | '{' trait_adaptation_list '}' + { + $$ = &TraitAdaptationList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Adaptations: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +trait_adaptation_list: + /* empty */ + { + $$ = nil + } + | non_empty_trait_adaptation_list + { + $$ = $1 + } +; + +non_empty_trait_adaptation_list: + trait_adaptation_statement + { + $$ = []ast.Vertex{$1} + } + | non_empty_trait_adaptation_list trait_adaptation_statement + { + $$ = append($1, $2) + } +; + +trait_adaptation_statement: + trait_precedence ';' + { + $1.(*ast.StmtTraitUsePrecedence).SemiColonTkn = $2 + + $$ = $1; + } + | trait_alias ';' + { + $1.(*ast.StmtTraitUseAlias).SemiColonTkn = $2 + + $$ = $1; + } +; + +trait_precedence: + trait_method_reference_fully_qualified T_INSTEADOF trait_reference_list + { + $$ = &ast.StmtTraitUsePrecedence{ + Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ParserSeparatedList).Items), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + InsteadofTkn: $2, + Insteadof: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + } + } +; + +trait_reference_list: + fully_qualified_class_name + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | trait_reference_list ',' fully_qualified_class_name + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +trait_method_reference: + T_STRING + { + $$ = &TraitMethodRef{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Method: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | trait_method_reference_fully_qualified + { + $$ = $1 + } +; + +trait_method_reference_fully_qualified: + fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING + { + $$ = &TraitMethodRef{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Trait: $1, + DoubleColonTkn: $2, + Method: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +trait_alias: + trait_method_reference T_AS trait_modifiers T_STRING + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Modifier: $3, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + } + } + | trait_method_reference T_AS member_modifier + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Modifier: $3, + } + } +; + +trait_modifiers: + /* empty */ + { + $$ = nil + } + | member_modifier + { + $$ = $1 + } +; + +method_body: + ';' /* abstract method */ + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | '{' inner_statement_list '}' + { + $$ = &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Stmts: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +variable_modifiers: + non_empty_member_modifiers + { + $$ = $1; + } + | T_VAR + { + $$ = []ast.Vertex{ + &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } +; + +method_modifiers: + /* empty */ + { + $$ = nil + } + | non_empty_member_modifiers + { + $$ = $1 + } +; + +non_empty_member_modifiers: + member_modifier + { + $$ = []ast.Vertex{$1} + } + | non_empty_member_modifiers member_modifier + { + $$ = append($1, $2) + } +; + +member_modifier: + T_PUBLIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_PROTECTED + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_PRIVATE + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_STATIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_ABSTRACT + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_FINAL + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } +; + +class_variable_declaration: + class_variable_declaration ',' T_VARIABLE + { + item := &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + }, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, item) + + $$ = $1 + } + | class_variable_declaration ',' T_VARIABLE '=' static_scalar + { + item := &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $5), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + }, + EqualTkn: $4, + Expr: $5, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, item) + + $$ = $1 + } + | T_VARIABLE + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + Expr: nil, + }, + }, + } + } + | T_VARIABLE '=' static_scalar + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + EqualTkn: $2, + Expr: $3, + }, + }, + } + } +; + +class_constant_declaration: + class_constant_declaration ',' T_STRING '=' static_scalar + { + constList := $1.(*ast.StmtClassConstList) + constList.Position = yylex.(*Parser).builder.NewNodesPosition($1, $5) + constList.SeparatorTkns = append(constList.SeparatorTkns, $2) + constList.Consts = append(constList.Consts, &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $5), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + EqualTkn: $4, + Expr: $5, + }) + + $$ = $1 + } + | T_CONST T_STRING '=' static_scalar + { + $$ = &ast.StmtClassConstList{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + ConstTkn: $1, + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + EqualTkn: $3, + Expr: $4, + }, + }, + } + } +; + +echo_expr_list: + echo_expr_list ',' expr + { + $1.(*ast.StmtEcho).Exprs = append($1.(*ast.StmtEcho).Exprs, $3) + $1.(*ast.StmtEcho).SeparatorTkns = append($1.(*ast.StmtEcho).SeparatorTkns, $2) + + $$ = $1 + } + | expr + { + $$ = &ast.StmtEcho{ + Exprs: []ast.Vertex{$1}, + } + } +; + + +for_expr: + /* empty */ + { + $$ = &ParserSeparatedList{} + } + | non_empty_for_expr + { + $$ = $1 + } +; + +non_empty_for_expr: + non_empty_for_expr ',' expr + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | expr + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +chaining_method_or_property: + chaining_method_or_property variable_property + { + $$ = append($1, $2...) + } + | variable_property + { + $$ = $1 + } +; + +chaining_dereference: + chaining_dereference '[' dim_offset ']' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($2, $4), + Var: nil, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + + $$ = append($1, fetch) + } + | '[' dim_offset ']' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + Var: nil, + OpenBracketTkn: $1, + Dim: $2, + CloseBracketTkn: $3, + } + + $$ = []ast.Vertex{fetch} + } +; + +chaining_instance_call: + chaining_dereference chaining_method_or_property + { + $$ = append($1, $2...) + } + | chaining_dereference + { + $$ = $1 + } + | chaining_method_or_property + { + $$ = $1 + } +; + +instance_call: + /* empty */ + { + $$ = nil + } + | chaining_instance_call + { + $$ = $1 + } +; + +new_expr: + T_NEW class_name_reference ctor_arguments + { + if $3 != nil { + $$ = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + NewTkn: $1, + Class: $2, + OpenParenthesisTkn: $3.(*ArgumentList).OpenParenthesisTkn, + Args: $3.(*ArgumentList).Arguments, + SeparatorTkns: $3.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $3.(*ArgumentList).CloseParenthesisTkn, + } + } else { + $$ = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + Class: $2, + } + } + } +; + +expr_without_variable: + T_LIST '(' assignment_list ')' '=' expr + { + $$ = &ast.ExprAssign{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $6), + Var: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + }, + EqualTkn: $5, + Expr: $6, + } + } + | variable '=' expr + { + $$ = &ast.ExprAssign{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable '=' '&' variable + { + $$ = &ast.ExprAssignReference{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Var: $1, + EqualTkn: $2, + AmpersandTkn: $3, + Expr: $4, + } + } + | variable '=' '&' T_NEW class_name_reference ctor_arguments + { + var _new *ast.ExprNew + if $3 != nil { + _new = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($4, $6), + NewTkn: $4, + Class: $5, + OpenParenthesisTkn: $6.(*ArgumentList).OpenParenthesisTkn, + Args: $6.(*ArgumentList).Arguments, + SeparatorTkns: $6.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $6.(*ArgumentList).CloseParenthesisTkn, + } + } else { + _new = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($4, $5), + NewTkn: $4, + Class: $5, + } + } + + $$ = &ast.ExprAssignReference{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, _new), + Var: $1, + EqualTkn: $2, + AmpersandTkn: $3, + Expr: _new, + } + } + | T_CLONE expr + { + $$ = &ast.ExprClone{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CloneTkn: $1, + Expr: $2, + } + } + | variable T_PLUS_EQUAL expr + { + $$ = &ast.ExprAssignPlus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MINUS_EQUAL expr + { + $$ = &ast.ExprAssignMinus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MUL_EQUAL expr + { + $$ = &ast.ExprAssignMul{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_POW_EQUAL expr + { + $$ = &ast.ExprAssignPow{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_DIV_EQUAL expr + { + $$ = &ast.ExprAssignDiv{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_CONCAT_EQUAL expr + { + $$ = &ast.ExprAssignConcat{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MOD_EQUAL expr + { + $$ = &ast.ExprAssignMod{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_AND_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_OR_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_XOR_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_SL_EQUAL expr + { + $$ = &ast.ExprAssignShiftLeft{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_SR_EQUAL expr + { + $$ = &ast.ExprAssignShiftRight{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | rw_variable T_INC + { + $$ = &ast.ExprPostInc{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Var: $1, + IncTkn: $2, + } + } + | T_INC rw_variable + { + $$ = &ast.ExprPreInc{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncTkn: $1, + Var: $2, + } + } + | rw_variable T_DEC + { + $$ = &ast.ExprPostDec{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Var: $1, + DecTkn: $2, + } + } + | T_DEC rw_variable + { + $$ = &ast.ExprPreDec{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + DecTkn: $1, + Var: $2, + } + } + | expr T_BOOLEAN_OR expr + { + $$ = &ast.ExprBinaryBooleanOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_BOOLEAN_AND expr + { + $$ = &ast.ExprBinaryBooleanAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_OR expr + { + $$ = &ast.ExprBinaryLogicalOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_AND expr + { + $$ = &ast.ExprBinaryLogicalAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_XOR expr + { + $$ = &ast.ExprBinaryLogicalXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '|' expr + { + $$ = &ast.ExprBinaryBitwiseOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '&' expr + { + $$ = &ast.ExprBinaryBitwiseAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '^' expr + { + $$ = &ast.ExprBinaryBitwiseXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '.' expr + { + $$ = &ast.ExprBinaryConcat{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '+' expr + { + $$ = &ast.ExprBinaryPlus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '-' expr + { + $$ = &ast.ExprBinaryMinus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '*' expr + { + $$ = &ast.ExprBinaryMul{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_POW expr + { + $$ = &ast.ExprBinaryPow{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '/' expr + { + $$ = &ast.ExprBinaryDiv{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '%' expr + { + $$ = &ast.ExprBinaryMod{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_SL expr + { + $$ = &ast.ExprBinaryShiftLeft{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_SR expr + { + $$ = &ast.ExprBinaryShiftRight{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | '+' expr %prec T_INC + { + $$ = &ast.ExprUnaryPlus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + PlusTkn: $1, + Expr: $2, + } + } + | '-' expr %prec T_INC + { + $$ = &ast.ExprUnaryMinus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + MinusTkn: $1, + Expr: $2, + } + } + | '!' expr + { + $$ = &ast.ExprBooleanNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ExclamationTkn: $1, + Expr: $2, + } + } + | '~' expr + { + $$ = &ast.ExprBitwiseNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + TildaTkn: $1, + Expr: $2, + } + } + | expr T_IS_IDENTICAL expr + { + $$ = &ast.ExprBinaryIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_NOT_IDENTICAL expr + { + $$ = &ast.ExprBinaryNotIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_EQUAL expr + { + $$ = &ast.ExprBinaryEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_NOT_EQUAL expr + { + $$ = &ast.ExprBinaryNotEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '<' expr + { + $$ = &ast.ExprBinarySmaller{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_SMALLER_OR_EQUAL expr + { + $$ = &ast.ExprBinarySmallerOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '>' expr + { + $$ = &ast.ExprBinaryGreater{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_GREATER_OR_EQUAL expr + { + $$ = &ast.ExprBinaryGreaterOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_INSTANCEOF class_name_reference + { + $$ = &ast.ExprInstanceOf{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Expr: $1, + InstanceOfTkn: $2, + Class: $3, + } + } + | parenthesis_expr + { + $$ = $1 + } + | new_expr + { + $$ = $1 + } + | '(' new_expr ')' instance_call + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + + for _, n := range($4) { + switch nn := n.(type) { + case *ast.ExprFunctionCall: + nn.Function = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprArrayDimFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprPropertyFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprMethodCall: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + } + } + } + | expr '?' expr ':' expr + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $5), + Cond: $1, + QuestionTkn: $2, + IfTrue: $3, + ColonTkn: $4, + IfFalse: $5, + } + } + | expr '?' ':' expr + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Cond: $1, + QuestionTkn: $2, + ColonTkn: $3, + IfFalse: $4, + } + } + | internal_functions_in_yacc + { + $$ = $1 + } + | T_INT_CAST expr + { + $$ = &ast.ExprCastInt{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_DOUBLE_CAST expr + { + $$ = &ast.ExprCastDouble{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_STRING_CAST expr + { + $$ = &ast.ExprCastString{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_ARRAY_CAST expr + { + $$ = &ast.ExprCastArray{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_OBJECT_CAST expr + { + $$ = &ast.ExprCastObject{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_BOOL_CAST expr + { + $$ = &ast.ExprCastBool{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_UNSET_CAST expr + { + $$ = &ast.ExprCastUnset{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_EXIT exit_expr + { + exit := &ast.ExprExit{ + ExitTkn: $1, + } + + if $2 == nil { + exit.Position = yylex.(*Parser).builder.NewTokenPosition($1) + } else { + exit.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2) + exit.OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn + exit.Expr = $2.(*ast.ExprBrackets).Expr + exit.CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn + } + + $$ = exit + } + | '@' expr + { + $$ = &ast.ExprErrorSuppress{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AtTkn: $1, + Expr: $2, + } + } + | scalar + { + $$ = $1 + } + | combined_scalar_offset + { + $$ = $1 + } + | combined_scalar + { + $$ = $1 + } + | '`' backticks_expr '`' + { + $$ = &ast.ExprShellExec{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBacktickTkn: $1, + Parts: $2, + CloseBacktickTkn: $3, + } + } + | T_PRINT expr + { + $$ = &ast.ExprPrint{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + PrintTkn: $1, + Expr: $2, + } + } + | T_YIELD + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + YieldTkn: $1, + } + } + | function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' + { + closure := $6.(*ast.ExprClosure) + + closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $9) + closure.FunctionTkn = $1 + closure.AmpersandTkn = $2 + closure.OpenParenthesisTkn = $3 + closure.Params = $4.(*ParserSeparatedList).Items + closure.SeparatorTkns = $4.(*ParserSeparatedList).SeparatorTkns + closure.CloseParenthesisTkn = $5 + closure.OpenCurlyBracketTkn = $7 + closure.Stmts = $8 + closure.CloseCurlyBracketTkn = $9 + + $$ = closure + } + | T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' + { + closure := $7.(*ast.ExprClosure) + + closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $10) + closure.StaticTkn = $1 + closure.FunctionTkn = $2 + closure.AmpersandTkn = $3 + closure.OpenParenthesisTkn = $4 + closure.Params = $5.(*ParserSeparatedList).Items + closure.SeparatorTkns = $5.(*ParserSeparatedList).SeparatorTkns + closure.CloseParenthesisTkn = $6 + closure.OpenCurlyBracketTkn = $8 + closure.Stmts = $9 + closure.CloseCurlyBracketTkn = $10 + + $$ = closure + } +; + +yield_expr: + T_YIELD expr_without_variable + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + YieldTkn: $1, + Val: $2, + } + } + | T_YIELD variable + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + YieldTkn: $1, + Val: $2, + } + } + | T_YIELD expr T_DOUBLE_ARROW expr_without_variable + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + YieldTkn: $1, + Key: $2, + DoubleArrowTkn: $3, + Val: $4, + } + } + | T_YIELD expr T_DOUBLE_ARROW variable + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + YieldTkn: $1, + Key: $2, + DoubleArrowTkn: $3, + Val: $4, + } + } +; + +combined_scalar_offset: + combined_scalar '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | combined_scalar_offset '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + Var: &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + }, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | general_constant '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } +; + +combined_scalar: + T_ARRAY '(' array_pair_list ')' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ArrayTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + } + } + | '[' array_pair_list ']' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Items: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $3, + } + } +; + +function: + T_FUNCTION + { + $$ = $1 + } +; + +lexical_vars: + /* empty */ + { + $$ = &ast.ExprClosure{} + } + | T_USE '(' lexical_var_list ')' + { + $$ = &ast.ExprClosure{ + UseTkn: $1, + UseOpenParenthesisTkn: $2, + Uses: $3.(*ParserSeparatedList).Items, + UseSeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + UseCloseParenthesisTkn: $4, + } + } +; + +lexical_var_list: + lexical_var_list ',' T_VARIABLE + { + variable := &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + }, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, variable) + + $$ = $1 + } + | lexical_var_list ',' '&' T_VARIABLE + { + variable := &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($3, $4), + AmpersandTkn: $3, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, variable) + + $$ = $1 + } + | T_VARIABLE + { + variable := &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + } + + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ variable }, + } + } + | '&' T_VARIABLE + { + variable := &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + AmpersandTkn: $1, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + }, + } + + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ variable }, + } + } +; + +function_call: + namespace_name function_call_parameter_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodeListNodePosition($1.(*ParserSeparatedList).Items, $2), + Function: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + OpenParenthesisTkn: $2.(*ArgumentList).OpenParenthesisTkn, + Args: $2.(*ArgumentList).Arguments, + SeparatorTkns: $2.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $2.(*ArgumentList).CloseParenthesisTkn, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + Function: &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + }, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + } + | T_NS_SEPARATOR namespace_name function_call_parameter_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Function: &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + OpenParenthesisTkn: $3.(*ArgumentList).OpenParenthesisTkn, + Args: $3.(*ArgumentList).Arguments, + SeparatorTkns: $3.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $3.(*ArgumentList).CloseParenthesisTkn, + } + } + | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list + { + staticCall := &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + staticCall.OpenCurlyBracketTkn = brackets.OpenBracketTkn + staticCall.Call = brackets.Child + staticCall.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = staticCall + } + | class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list + { + $$ = &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list + { + staticCall := &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + staticCall.OpenCurlyBracketTkn = brackets.OpenBracketTkn + staticCall.Call = brackets.Child + staticCall.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = staticCall + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list + { + $$ = &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + } + | variable_without_objects function_call_parameter_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $2), + Function: $1, + OpenParenthesisTkn: $2.(*ArgumentList).OpenParenthesisTkn, + Args: $2.(*ArgumentList).Arguments, + SeparatorTkns: $2.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $2.(*ArgumentList).CloseParenthesisTkn, + } + } +; + +class_name: + T_STATIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | namespace_name + { + $$ = &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + } + } +; + +fully_qualified_class_name: + namespace_name + { + $$ = &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + } + } +; + +class_name_reference: + class_name + { + $$ = $1 + } + | dynamic_class_name_reference + { + $$ = $1 + } +; + +dynamic_class_name_reference: + base_variable T_OBJECT_OPERATOR object_property dynamic_class_name_variable_properties + { + $$ = $1 + + $3[0].(*ast.ExprPropertyFetch).ObjectOperatorTkn = $2 + + for _, n := range($3) { + switch nn := n.(type) { + case *ast.ExprArrayDimFetch: + nn.Var = $$ + *$$.GetPosition() = *yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprPropertyFetch: + nn.Var = $$ + *$$.GetPosition() = *yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + } + } + + for _, n := range($4) { + switch nn := n.(type) { + case *ast.ExprArrayDimFetch: + nn.Var = $$ + *$$.GetPosition() = *yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprPropertyFetch: + nn.Var = $$ + *$$.GetPosition() = *yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + } + } + } + | base_variable + { + $$ = $1 + } +; + + +dynamic_class_name_variable_properties: + dynamic_class_name_variable_properties dynamic_class_name_variable_property + { + $$ = append($1, $2...) + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + + +dynamic_class_name_variable_property: + T_OBJECT_OPERATOR object_property + { + $2[0].(*ast.ExprPropertyFetch).ObjectOperatorTkn = $1 + + $$ = $2 + } +; + +exit_expr: + /* empty */ + { + $$ = nil + } + | '(' ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenParenthesisTkn: $1, + CloseParenthesisTkn: $2, + } + } + | parenthesis_expr + { + $$ = $1 + } +; + +backticks_expr: + /* empty */ + { + $$ = []ast.Vertex{} + } + | T_ENCAPSED_AND_WHITESPACE + { + $$ = []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + EncapsedStrTkn: $1, + Value: $1.Value, + }, + } + } + | encaps_list + { + $$ = $1; + } +; + +ctor_arguments: + /* empty */ + { + $$ = &ArgumentList{} + } + | function_call_parameter_list + { + $$ = $1 + } +; + +common_scalar: + T_LNUMBER + { + $$ = &ast.ScalarLnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } + | T_DNUMBER + { + $$ = &ast.ScalarDnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } + | T_CONSTANT_ENCAPSED_STRING + { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } + | T_LINE + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_FILE + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_DIR + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_TRAIT_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_METHOD_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_FUNC_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_NS_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenHeredocTkn: $1, + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + EncapsedStrTkn: $2, + Value: $2.Value, + }, + }, + CloseHeredocTkn: $3, + } + } + | T_START_HEREDOC T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenHeredocTkn: $1, + CloseHeredocTkn: $2, + } + } +; + +static_class_constant: + class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +static_scalar: + static_scalar_value + { + $$ = $1 + } +; + +static_scalar_value: + common_scalar + { + $$ = $1 + } + | static_class_name_scalar + { + $$ = $1 + } + | namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Const: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + Const: &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + Const: &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_ARRAY '(' static_array_pair_list ')' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ArrayTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + } + } + | '[' static_array_pair_list ']' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Items: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $3, + } + } + | static_class_constant + { + $$ = $1 + } + | T_CLASS_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | static_operation + { + $$ = $1 + } +; + +static_operation: + static_scalar_value '[' static_scalar_value ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | static_scalar_value '+' static_scalar_value + { + $$ = &ast.ExprBinaryPlus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '-' static_scalar_value + { + $$ = &ast.ExprBinaryMinus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '*' static_scalar_value + { + $$ = &ast.ExprBinaryMul{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_POW static_scalar_value + { + $$ = &ast.ExprBinaryPow{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '/' static_scalar_value + { + $$ = &ast.ExprBinaryDiv{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '%' static_scalar_value + { + $$ = &ast.ExprBinaryMod{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | '!' static_scalar_value + { + $$ = &ast.ExprBooleanNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ExclamationTkn: $1, + Expr: $2, + } + } + | '~' static_scalar_value + { + $$ = &ast.ExprBitwiseNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + TildaTkn: $1, + Expr: $2, + } + } + | static_scalar_value '|' static_scalar_value + { + $$ = &ast.ExprBinaryBitwiseOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '&' static_scalar_value + { + $$ = &ast.ExprBinaryBitwiseAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '^' static_scalar_value + { + $$ = &ast.ExprBinaryBitwiseXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_SL static_scalar_value + { + $$ = &ast.ExprBinaryShiftLeft{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_SR static_scalar_value + { + $$ = &ast.ExprBinaryShiftRight{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '.' static_scalar_value + { + $$ = &ast.ExprBinaryConcat{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_LOGICAL_XOR static_scalar_value + { + $$ = &ast.ExprBinaryLogicalXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_LOGICAL_AND static_scalar_value + { + $$ = &ast.ExprBinaryLogicalAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_LOGICAL_OR static_scalar_value + { + $$ = &ast.ExprBinaryLogicalOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_BOOLEAN_AND static_scalar_value + { + $$ = &ast.ExprBinaryBooleanAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_BOOLEAN_OR static_scalar_value + { + $$ = &ast.ExprBinaryBooleanOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_IDENTICAL static_scalar_value + { + $$ = &ast.ExprBinaryIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_NOT_IDENTICAL static_scalar_value + { + $$ = &ast.ExprBinaryNotIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_EQUAL static_scalar_value + { + $$ = &ast.ExprBinaryEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_NOT_EQUAL static_scalar_value + { + $$ = &ast.ExprBinaryNotEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '<' static_scalar_value + { + $$ = &ast.ExprBinarySmaller{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '>' static_scalar_value + { + $$ = &ast.ExprBinaryGreater{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_SMALLER_OR_EQUAL static_scalar_value + { + $$ = &ast.ExprBinarySmallerOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value T_IS_GREATER_OR_EQUAL static_scalar_value + { + $$ = &ast.ExprBinaryGreaterOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | static_scalar_value '?' ':' static_scalar_value + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Cond: $1, + QuestionTkn: $2, + ColonTkn: $3, + IfFalse: $4, + } + } + | static_scalar_value '?' static_scalar_value ':' static_scalar_value + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $5), + Cond: $1, + QuestionTkn: $2, + IfTrue: $3, + ColonTkn: $4, + IfFalse: $5, + } + } + | '+' static_scalar_value + { + $$ = &ast.ExprUnaryPlus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + PlusTkn: $1, + Expr: $2, + } + } + | '-' static_scalar_value + { + $$ = &ast.ExprUnaryMinus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + MinusTkn: $1, + Expr: $2, + } + } + | '(' static_scalar_value ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } +; + +general_constant: + class_constant + { + $$ = $1 + } + | namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Const: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + Const: &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + Const: &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + } + } +; + +scalar: + T_STRING_VARNAME + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | general_constant + { + $$ = $1 + } + | class_name_scalar + { + $$ = $1 + } + | common_scalar + { + $$ = $1 + } + | '"' encaps_list '"' + { + $$ = &ast.ScalarEncapsed{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenQuoteTkn: $1, + Parts: $2, + CloseQuoteTkn: $3, + } + } + | T_START_HEREDOC encaps_list T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenHeredocTkn: $1, + Parts: $2, + CloseHeredocTkn: $3, + } + } + | T_CLASS_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } +; + +static_array_pair_list: + /* empty */ + { + $$ = &ParserSeparatedList{} + } + | non_empty_static_array_pair_list possible_comma + { + if $2 != nil { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, &ast.ExprArrayItem{}) + } + + $$ = $1 + } +; + +possible_comma: + /* empty */ + { + $$ = nil + } + | ',' + { + $$ = $1 + } +; + +non_empty_static_array_pair_list: + non_empty_static_array_pair_list ',' static_scalar_value T_DOUBLE_ARROW static_scalar_value + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($3, $5), + Key: $3, + DoubleArrowTkn: $4, + Val: $5, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | non_empty_static_array_pair_list ',' static_scalar_value + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($3), + Val: $3, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | static_scalar_value T_DOUBLE_ARROW static_scalar_value + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Key: $1, + DoubleArrowTkn: $2, + Val: $3, + }, + }, + } + } + | static_scalar_value + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Val: $1, + }, + }, + } + } +; + +expr: + r_variable + { + $$ = $1 + } + | expr_without_variable + { + $$ = $1 + } +; + +parenthesis_expr: + '(' expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } + | '(' yield_expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } +; + + +r_variable: + variable + { + $$ = $1 + } +; + + +w_variable: + variable + { + $$ = $1 + } +; + +rw_variable: + variable + { + $$ = $1 + } +; + +variable: + base_variable_with_function_calls T_OBJECT_OPERATOR object_property method_or_not variable_properties + { + $$ = $1 + + $3[0].(*ast.ExprPropertyFetch).ObjectOperatorTkn = $2 + + if $4 != nil { + last := $3[len($3)-1] + switch l := last.(type) { + case *ast.ExprArrayDimFetch: + mc := $4[0].(*ast.ExprMethodCall) + $3 = append($3, &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodePosition(mc), + OpenParenthesisTkn: mc.OpenParenthesisTkn, + Args: mc.Args, + SeparatorTkns: mc.SeparatorTkns, + CloseParenthesisTkn: mc.CloseParenthesisTkn, + }, + ) + $3 = append($3, $4[1:len($4)]...) + case *ast.ExprPropertyFetch: + $4[0].(*ast.ExprMethodCall).OpenCurlyBracketTkn = l.OpenCurlyBracketTkn + $4[0].(*ast.ExprMethodCall).Method = l.Prop + $4[0].(*ast.ExprMethodCall).CloseCurlyBracketTkn = l.CloseCurlyBracketTkn + $4[0].(*ast.ExprMethodCall).ObjectOperatorTkn = l.ObjectOperatorTkn + $3 = append($3[:len($3)-1], $4...) + } + } + + for _, n := range($3) { + switch nn := n.(type) { + case *ast.ExprFunctionCall: + nn.Function = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprArrayDimFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprPropertyFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprMethodCall: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + } + } + + for _, n := range($5) { + switch nn := n.(type) { + case *ast.ExprFunctionCall: + nn.Function = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprArrayDimFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprPropertyFetch: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + + case *ast.ExprMethodCall: + nn.Var = $$ + nn.Position = yylex.(*Parser).builder.NewNodesPosition($$, nn) + $$ = nn + } + } + } + | base_variable_with_function_calls + { + $$ = $1 + } +; + +variable_properties: + variable_properties variable_property + { + $$ = append($1, $2...) + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + + +variable_property: + T_OBJECT_OPERATOR object_property method_or_not + { + $2[0].(*ast.ExprPropertyFetch).ObjectOperatorTkn = $1 + + if $3 != nil { + last := $2[len($2)-1] + switch l := last.(type) { + case *ast.ExprArrayDimFetch: + mc := $3[0].(*ast.ExprMethodCall) + $2 = append($2, &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodePosition(mc), + OpenParenthesisTkn: mc.OpenParenthesisTkn, + Args: mc.Args, + SeparatorTkns: mc.SeparatorTkns, + CloseParenthesisTkn: mc.OpenParenthesisTkn, + }, + ) + $2 = append($2, $3[1:len($3)]...) + case *ast.ExprPropertyFetch: + $3[0].(*ast.ExprMethodCall).OpenCurlyBracketTkn = l.OpenCurlyBracketTkn + $3[0].(*ast.ExprMethodCall).Method = l.Prop + $3[0].(*ast.ExprMethodCall).CloseCurlyBracketTkn = l.CloseCurlyBracketTkn + $3[0].(*ast.ExprMethodCall).ObjectOperatorTkn = l.ObjectOperatorTkn + $2 = append($2[:len($2)-1], $3...) + } + } + + $$ = $2 + } +; + +array_method_dereference: + array_method_dereference '[' dim_offset ']' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($2, $4), + Var: nil, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + + $$ = append($1, fetch) + } + | method '[' dim_offset ']' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($2, $4), + Var: nil, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + + $$ = []ast.Vertex{$1, fetch} + } +; + +method: + function_call_parameter_list + { + $$ = &ast.ExprMethodCall{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + OpenParenthesisTkn: $1.(*ArgumentList).OpenParenthesisTkn, + Args: $1.(*ArgumentList).Arguments, + SeparatorTkns: $1.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $1.(*ArgumentList).CloseParenthesisTkn, + } + } +; + +method_or_not: + method + { + $$ = []ast.Vertex{$1} + } + | array_method_dereference + { + $$ = $1 + } + | /* empty */ + { + $$ = nil + } +; + +variable_without_objects: + reference_variable + { + $$ = $1 + } + | simple_indirect_reference reference_variable + { + for i := len($1)-1; i>=0; i-- { + $1[i].(*ast.ExprVariable).Name = $2 + $1[i].(*ast.ExprVariable).Position = yylex.(*Parser).builder.NewNodesPosition($1[i], $2) + $2 = $1[i] + } + + $$ = $1[0] + } +; + +static_member: + class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } +; + +variable_class_name: + reference_variable + { + $$ = $1 + } +; + +array_function_dereference: + array_function_dereference '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | function_call '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } +; + +base_variable_with_function_calls: + base_variable + { + $$ = $1 + } + | array_function_dereference + { + $$ = $1 + } + | function_call + { + $$ = $1 + } +; + + +base_variable: + reference_variable + { + $$ = $1 + } + | simple_indirect_reference reference_variable + { + for i := len($1)-1; i>=0; i-- { + $1[i].(*ast.ExprVariable).Name = $2 + $1[i].(*ast.ExprVariable).Position = yylex.(*Parser).builder.NewNodesPosition($1[i], $2) + $2 = $1[i] + } + + $$ = $1[0] + } + | static_member + { + $$ = $1 + } +; + +reference_variable: + reference_variable '[' dim_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | reference_variable '{' expr '}' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | compound_variable + { + $$ = $1 + } +; + + +compound_variable: + T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | '$' '{' expr '}' + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + DollarTkn: $1, + OpenCurlyBracketTkn: $2, + Name: $3, + CloseCurlyBracketTkn: $4, + } + } +; + +dim_offset: + /* empty */ + { + $$ = nil + } + | expr + { + $$ = $1 + } +; + + +object_property: + object_dim_list + { + $$ = $1 + } + | variable_without_objects + { + $$ = []ast.Vertex{ + &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Prop: $1, + }, + } + } +; + +object_dim_list: + object_dim_list '[' dim_offset ']' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($2, $4), + Var: nil, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + + $$ = append($1, fetch) + } + | object_dim_list '{' expr '}' + { + fetch := &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($2, $4), + Var: nil, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + + $$ = append($1, fetch) + } + | variable_name + { + property := &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Prop: $1, + } + + if brackets, ok := $1.(*ParserBrackets); ok { + property.OpenCurlyBracketTkn = brackets.OpenBracketTkn + property.Prop = brackets.Child + property.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = []ast.Vertex{ property } + } +; + +variable_name: + T_STRING + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | '{' expr '}' + { + $$ = &ParserBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Child: $2, + CloseBracketTkn: $3, + } + } +; + +simple_indirect_reference: + '$' + { + $$ = []ast.Vertex{ + &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + DollarTkn: $1, + }, + } + } + | simple_indirect_reference '$' + { + $$ = append($1, &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + DollarTkn: $2, + }) + } +; + +assignment_list: + assignment_list ',' assignment_list_element + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | assignment_list_element + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + + +assignment_list_element: + variable + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Val: $1, + } + } + | T_LIST '(' assignment_list ')' + { + pairList := $3.(*ParserSeparatedList) + fistPair := pairList.Items[0].(*ast.ExprArrayItem) + + if fistPair.Key == nil && fistPair.Val == nil && len(pairList.Items) == 1 { + pairList.Items = nil + } + + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + Val: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + }, + } + } + | /* empty */ + { + $$ = &ast.ExprArrayItem{} + } +; + + +array_pair_list: + /* empty */ + { + $$ = &ParserSeparatedList{} + } + | non_empty_array_pair_list possible_comma + { + if $2 != nil { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, &ast.ExprArrayItem{}) + } + + $$ = $1 + } +; + +non_empty_array_pair_list: + non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($3, $5), + Key: $3, + DoubleArrowTkn: $4, + Val: $5, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | non_empty_array_pair_list ',' expr + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($3), + Val: $3, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | expr T_DOUBLE_ARROW expr + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Key: $1, + DoubleArrowTkn: $2, + Val: $3, + }, + }, + } + } + | expr + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Val: $1, + }, + }, + } + } + | non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($3, $6), + Key: $3, + DoubleArrowTkn: $4, + AmpersandTkn: $5, + Val: $6, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | non_empty_array_pair_list ',' '&' w_variable + { + arrayItem := &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($3, $4), + AmpersandTkn: $3, + Val: $4, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, arrayItem) + + $$ = $1 + } + | expr T_DOUBLE_ARROW '&' w_variable + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Key: $1, + DoubleArrowTkn: $2, + AmpersandTkn: $3, + Val: $4, + }, + }, + } + } + | '&' w_variable + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AmpersandTkn: $1, + Val: $2, + }, + }, + } + } +; + +encaps_list: + encaps_list encaps_var + { + $$ = append($1, $2) + } + | encaps_list T_ENCAPSED_AND_WHITESPACE + { + $$ = append( + $1, + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + EncapsedStrTkn: $2, + Value: $2.Value, + }, + ) + } + | encaps_var + { + $$ = []ast.Vertex{$1} + } + | T_ENCAPSED_AND_WHITESPACE encaps_var + { + $$ = []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + EncapsedStrTkn: $1, + Value: $1.Value, + }, + $2, + } + } +; + +encaps_var: + T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | T_VARIABLE '[' encaps_var_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | T_VARIABLE T_OBJECT_OPERATOR T_STRING + { + $$ = &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + ObjectOperatorTkn: $2, + Prop: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES expr '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: $2, + CloseCurlyBracketTkn: $3, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + CloseCurlyBracketTkn: $3, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenSquareBracketTkn: $3, + Dim: $4, + CloseSquareBracketTkn: $5, + CloseCurlyBracketTkn: $6, + } + } + | T_CURLY_OPEN variable '}' + { + $$ = &ast.ScalarEncapsedStringBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Var: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +encaps_var_offset: + T_STRING + { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } + | T_NUM_STRING + { + // TODO: add option to handle 64 bit integer + if _, err := strconv.Atoi(string($1.Value)); err == nil { + $$ = &ast.ScalarLnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } else { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } + } + | T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } +; + +internal_functions_in_yacc: + T_ISSET '(' isset_variables ')' + { + $$ = &ast.ExprIsset{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + IssetTkn: $1, + OpenParenthesisTkn: $2, + Vars: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $4, + } + } + | T_EMPTY '(' variable ')' + { + $$ = &ast.ExprEmpty{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + EmptyTkn: $1, + OpenParenthesisTkn: $2, + Expr: $3, + CloseParenthesisTkn: $4, + } + } + | T_EMPTY '(' expr ')' + { + $$ = &ast.ExprEmpty{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + EmptyTkn: $1, + OpenParenthesisTkn: $2, + Expr: $3, + CloseParenthesisTkn: $4, + } + } + | T_INCLUDE expr + { + $$ = &ast.ExprInclude{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncludeTkn: $1, + Expr: $2, + } + } + | T_INCLUDE_ONCE expr + { + $$ = &ast.ExprIncludeOnce{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncludeOnceTkn: $1, + Expr: $2, + } + } + | T_EVAL '(' expr ')' + { + $$ = &ast.ExprEval{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + EvalTkn: $1, + OpenParenthesisTkn: $2, + Expr: $3, + CloseParenthesisTkn: $4, + } + } + | T_REQUIRE expr + { + $$ = &ast.ExprRequire{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + RequireTkn: $1, + Expr: $2, + } + } + | T_REQUIRE_ONCE expr + { + $$ = &ast.ExprRequireOnce{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + RequireOnceTkn: $1, + Expr: $2, + } + } +; + +isset_variables: + isset_variable + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | isset_variables ',' isset_variable + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +isset_variable: + variable + { + $$ = $1 + } + | expr_without_variable + { + $$ = $1 + } +; + +class_constant: + class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +static_class_name_scalar: + class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +class_name_scalar: + class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +%% diff --git a/internal/php5/php5_bench_test.go b/internal/php5/php5_bench_test.go new file mode 100644 index 0000000..b17c36f --- /dev/null +++ b/internal/php5/php5_bench_test.go @@ -0,0 +1,30 @@ +package php5_test + +import ( + "io/ioutil" + "testing" + + "github.com/z7zmey/php-parser/internal/php5" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/version" +) + +func BenchmarkPhp5(b *testing.B) { + src, err := ioutil.ReadFile("test.php") + if err != nil { + b.Fatal("can not read test.php: " + err.Error()) + } + + for n := 0; n < b.N; n++ { + config := cfg.Config{ + Version: &version.Version{ + Major: 5, + Minor: 6, + }, + } + lexer := scanner.NewLexer(src, config) + php5parser := php5.NewParser(lexer, config) + php5parser.Parse() + } +} diff --git a/internal/php5/test.php b/internal/php5/test.php new file mode 100644 index 0000000..c811eb1 --- /dev/null +++ b/internal/php5/test.php @@ -0,0 +1,381 @@ +bar($a, ...$b); +foo::bar($a, ...$b); +$foo::bar($a, ...$b); +new foo($a, ...$b); + +function foo(bar $bar=null, baz &...$baz) {} +class foo {public function foo(bar $bar=null, baz &...$baz) {}} +function(bar $bar=null, baz &...$baz) {}; +static function(bar $bar=null, baz &...$baz) {}; + +1234567890123456789; +12345678901234567890; +0.; +0b0111111111111111111111111111111111111111111111111111111111111111; +0b1111111111111111111111111111111111111111111111111111111111111111; +0x007111111111111111; +0x8111111111111111; +__CLASS__; +__DIR__; +__FILE__; +__FUNCTION__; +__LINE__; +__NAMESPACE__; +__METHOD__; +__TRAIT__; + +"test $var"; +"test $var[1]"; +"test $var[1234567890123456789012345678901234567890]"; +"test $var[bar]"; +"test $var[$bar]"; +"$foo $bar"; +"test $foo->bar()"; +"test ${foo}"; +"test ${foo[0]}"; +"test {$foo->bar()}"; + +if ($a) : +endif; +if ($a) : +elseif ($b): +endif; +if ($a) : +else: +endif; +if ($a) : +elseif ($b): +elseif ($c): +else: +endif; + +while (1) { break; } +while (1) { break 2; } +while (1) : break(3); endwhile; +class foo{ const FOO = 1, BAR = 2; } +class foo{ function bar() {} } +class foo{ public static function &bar() {} } +class foo{ final private function bar() {} protected function baz() {} } +abstract class foo{ abstract public function bar(); } +final class foo extends bar { } +final class foo implements bar { } +final class foo implements bar, baz { } + +const FOO = 1, BAR = 2; +while (1) { continue; } +while (1) { continue 2; } +while (1) { continue(3); } +declare(ticks=1); +declare(ticks=1, strict_types=1) {} +declare(ticks=1): enddeclare; +do {} while(1); +echo $a, 1; +echo($a); +for($i = 0; $i < 10; $i++, $i++) {} +for(; $i < 10; $i++) : endfor; +foreach ($a as $v) {} +foreach ([] as $v) {} +foreach ($a as $v) : endforeach; +foreach ($a as $k => $v) {} +foreach ([] as $k => $v) {} +foreach ($a as $k => &$v) {} +foreach ($a as $k => list($v)) {} +function foo() {} + +function foo() { + function bar() {} + class Baz {} + return $a; +} + +function foo(array $a, callable $b) {return;} +function &foo() {return 1;} +function &foo() {} +global $a, $b, $$c, ${foo()}; +a: +goto a; +if ($a) {} +if ($a) {} elseif ($b) {} +if ($a) {} else {} +if ($a) {} elseif ($b) {} elseif ($c) {} else {} +if ($a) {} elseif ($b) {} else if ($c) {} else {} +?>
1, &$b,); +array(3 =>&$b); +array(&$b, 1=>1, 1, 3 =>&$b); +~$a; +!$a; + +Foo::Bar; +clone($a); +clone $a; +function(){}; +function($a, $b) use ($c, &$d) {}; +function($a, $b) use (&$c, $d) {}; +function() {}; +foo; +namespace\foo; +\foo; + +empty($a); +empty(Foo); +@$a; +eval($a); +exit; +exit($a); +die(); +die($a); +foo(); +namespace\foo(&$a); +\foo([]); +$foo(yield $a); + +$a--; +$a++; +--$a; +++$a; + +include $a; +include_once $a; +require $a; +require_once $a; + +$a instanceof Foo; +$a instanceof namespace\Foo; +$a instanceof \Foo; + +isset($a, $b); +isset(Foo); +list() = $b; +list($a, $b) = $b; +list($a[]) = $b; +list(list($a)) = $b; + +$a->foo(); +new Foo; +new namespace\Foo(); +new \Foo(); +print($a); +$a->foo; +$a->foo[1]; +$a->foo->bar->baz()->quux[0]; +$a->foo()[1][1]; +`cmd $a`; +`cmd`; +``; +[]; +[1]; +[1=>1, &$b,]; + +Foo::bar(); +namespace\Foo::bar(); +\Foo::bar(); +Foo::$bar(); +$foo::$bar(); +Foo::$bar; +namespace\Foo::$bar; +\Foo::$bar; +$a ? $b : $c; +$a ? : $c; +$a ? $b ? $c : $d : $e; +$a ? $b : $c ? $d : $e; +-$a; ++$a; +$$a; +$$$a; +yield; +yield $a; +yield $a => $b; +yield Foo::class; +yield $a => Foo::class; + +(array)$a; +(boolean)$a; +(bool)$a; +(double)$a; +(float)$a; +(integer)$a; +(int)$a; +(object)$a; +(string)$a; +(unset)$a; + +$a & $b; +$a | $b; +$a ^ $b; +$a && $b; +$a || $b; +$a . $b; +$a / $b; +$a == $b; +$a >= $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 =& new Foo; +$a =& new Foo($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; + + +(new \Foo()); +(new \Foo())->bar()->baz; +(new \Foo())[0][0]; +(new \Foo())[0]->bar(); + +array([0])[0][0]; +"foo"[0]; +foo[0]; +static::foo; + +new $foo; +new $foo::$bar; +new $a->b[0]; +new $a->b{$b ?: null}->$c->d[0];static $a = [1][0]; + +static $a = !1; +static $a = ~1; +static $a = +1; +static $a = -1; +static $a = (1); +static $a = 1 ?: 2; +static $a = 1 ? 2 : 3; +static $a = 1 & 2; +static $a = 1 | 2; +static $a = 1 ^ 2; +static $a = 1 && 2; +static $a = 1 || 2; +static $a = 1 . 2; +static $a = 1 / 2; +static $a = 1 == 2; +static $a = 1 >= 2; +static $a = 1 > 2; +static $a = 1 === 2; +static $a = 1 and 2; +static $a = 1 or 2; +static $a = 1 xor 2; +static $a = 1 - 2; +static $a = 1 % 2; +static $a = 1 * 2; +static $a = 1 != 2; +static $a = 1 !== 2; +static $a = 1 + 2; +static $a = 1 ** 2; +static $a = 1 << 2; +static $a = 1 >> 2; +static $a = 1 <= 2; +static $a = 1 < 2; +static $a = Foo::bar; +static $a = Foo::class; +static $a = __CLASS__; +static $a = Foo; +static $a = namespace\Foo; +static $a = \Foo; +static $a = array(); +static $a = array(1 => 1, 2); +static $a = [1, 2 => 2][0]; + +if (yield 1) {} +Foo::$$bar; + +$foo(); +$foo()[0][0]; +$a{$b}; +${$a}; +$foo::{$bar}(); +$foo::bar; + +__halt_compiler(); + +parsing process must be terminated \ No newline at end of file diff --git a/internal/php7/node.go b/internal/php7/node.go new file mode 100644 index 0000000..dfb0236 --- /dev/null +++ b/internal/php7/node.go @@ -0,0 +1,99 @@ +package php7 + +import ( + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" +) + +type ParserBrackets struct { + Position *position.Position + OpenBracketTkn *token.Token + Child ast.Vertex + CloseBracketTkn *token.Token +} + +func (n *ParserBrackets) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ParserBrackets) GetPosition() *position.Position { + return n.Position +} + +type ParserSeparatedList struct { + Position *position.Position + Items []ast.Vertex + SeparatorTkns []*token.Token +} + +func (n *ParserSeparatedList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ParserSeparatedList) GetPosition() *position.Position { + return n.Position +} + +// TraitAdaptationList node +type TraitAdaptationList struct { + Position *position.Position + OpenCurlyBracketTkn *token.Token + Adaptations []ast.Vertex + CloseCurlyBracketTkn *token.Token +} + +func (n *TraitAdaptationList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *TraitAdaptationList) GetPosition() *position.Position { + return n.Position +} + +// ArgumentList node +type ArgumentList struct { + Position *position.Position + OpenParenthesisTkn *token.Token + Arguments []ast.Vertex + SeparatorTkns []*token.Token + CloseParenthesisTkn *token.Token +} + +func (n *ArgumentList) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ArgumentList) GetPosition() *position.Position { + return n.Position +} + +type ReturnType struct { + Position *position.Position + ColonTkn *token.Token + Type ast.Vertex +} + +func (n *ReturnType) Accept(v ast.Visitor) { + // do nothing +} + +func (n *ReturnType) GetPosition() *position.Position { + return n.Position +} + +// TraitMethodRef node +type TraitMethodRef struct { + Position *position.Position + Trait ast.Vertex + DoubleColonTkn *token.Token + Method ast.Vertex +} + +func (n *TraitMethodRef) Accept(v ast.Visitor) { + // do nothing +} + +func (n *TraitMethodRef) GetPosition() *position.Position { + return n.Position +} diff --git a/internal/php7/parser.go b/internal/php7/parser.go new file mode 100644 index 0000000..eda2135 --- /dev/null +++ b/internal/php7/parser.go @@ -0,0 +1,66 @@ +package php7 + +import ( + "github.com/z7zmey/php-parser/internal/position" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/token" +) + +// Parser structure +type Parser struct { + Lexer *scanner.Lexer + currentToken *token.Token + rootNode ast.Vertex + errHandlerFunc func(*errors.Error) + builder *position.Builder +} + +// NewParser creates and returns new Parser +func NewParser(lexer *scanner.Lexer, config cfg.Config) *Parser { + return &Parser{ + Lexer: lexer, + errHandlerFunc: config.ErrorHandlerFunc, + builder: position.NewBuilder(), + } +} + +func (p *Parser) Lex(lval *yySymType) int { + t := p.Lexer.Lex() + + p.currentToken = t + lval.token = t + + return int(t.ID) +} + +func (p *Parser) Error(msg string) { + if p.errHandlerFunc == nil { + return + } + + p.errHandlerFunc(errors.NewError(msg, p.currentToken.Position)) +} + +// Parse the php7 Parser entrypoint +func (p *Parser) Parse() int { + p.rootNode = nil + + return yyParse(p) +} + +// GetRootNode returns root node +func (p *Parser) GetRootNode() ast.Vertex { + return p.rootNode +} + +// helpers + +func lastNode(nn []ast.Vertex) ast.Vertex { + if len(nn) == 0 { + return nil + } + return nn[len(nn)-1] +} diff --git a/internal/php7/parser_test.go b/internal/php7/parser_test.go new file mode 100644 index 0000000..3df90af --- /dev/null +++ b/internal/php7/parser_test.go @@ -0,0 +1,57013 @@ +package php7_test + +import ( + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/internal/php7" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "github.com/z7zmey/php-parser/pkg/version" +) + +func TestIdentifier(t *testing.T) { + src := `bar($a, ...$b); + foo::bar($a, ...$b); + $foo::bar($a, ...$b); + new foo($a, ...$b); + /** anonymous class */ + new class ($a, ...$b) {};` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 9, + StartPos: 5, + EndPos: 185, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 20, + }, + Expr: &ast.ExprFunctionCall{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 19, + }, + Function: &ast.Name{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 46, + EndPos: 48, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 48, + EndPos: 51, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 48, + EndPos: 51, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 51, + EndPos: 52, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 52, + EndPos: 54, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 56, + EndPos: 61, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 56, + EndPos: 59, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 55, + EndPos: 56, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 59, + EndPos: 61, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 54, + EndPos: 55, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 61, + EndPos: 62, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 62, + EndPos: 63, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 86, + }, + Expr: &ast.ExprStaticCall{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 85, + }, + Class: &ast.Name{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 66, + EndPos: 69, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 4, + EndLine: 5, + StartPos: 63, + EndPos: 66, + }, + }, + }, + }, + Value: []byte("foo"), + }, + }, + }, + DoubleColonTkn: &token.Token{ + ID: token.T_PAAMAYIM_NEKUDOTAYIM, + Value: []byte("::"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 69, + EndPos: 71, + }, + }, + Call: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 71, + EndPos: 74, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 71, + EndPos: 74, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 74, + EndPos: 75, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 75, + EndPos: 77, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 79, + EndPos: 84, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 79, + EndPos: 82, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 78, + EndPos: 79, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 82, + EndPos: 84, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 77, + EndPos: 78, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 84, + EndPos: 85, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 85, + EndPos: 86, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 110, + }, + Expr: &ast.ExprStaticCall{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 109, + }, + Class: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$foo"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 89, + EndPos: 93, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 5, + EndLine: 6, + StartPos: 86, + EndPos: 89, + }, + }, + }, + }, + Value: []byte("$foo"), + }, + }, + DoubleColonTkn: &token.Token{ + ID: token.T_PAAMAYIM_NEKUDOTAYIM, + Value: []byte("::"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 93, + EndPos: 95, + }, + }, + Call: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 95, + EndPos: 98, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 95, + EndPos: 98, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 98, + EndPos: 99, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 99, + EndPos: 101, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 103, + EndPos: 108, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 103, + EndPos: 106, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 102, + EndPos: 103, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 106, + EndPos: 108, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 101, + EndPos: 102, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 108, + EndPos: 109, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 6, + EndLine: 6, + StartPos: 109, + EndPos: 110, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 132, + }, + Expr: &ast.ExprNew{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 131, + }, + NewTkn: &token.Token{ + ID: token.T_NEW, + Value: []byte("new"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 113, + EndPos: 116, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 6, + EndLine: 7, + StartPos: 110, + EndPos: 113, + }, + }, + }, + }, + Class: &ast.Name{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + Parts: []ast.Vertex{ + &ast.NamePart{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + StringTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 117, + EndPos: 120, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 116, + EndPos: 117, + }, + }, + }, + }, + Value: []byte("foo"), + }, + }, + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 120, + EndPos: 121, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 121, + EndPos: 123, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 125, + EndPos: 130, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 125, + EndPos: 128, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 124, + EndPos: 125, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 128, + EndPos: 130, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 123, + EndPos: 124, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 130, + EndPos: 131, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 7, + EndLine: 7, + StartPos: 131, + EndPos: 132, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 160, + EndPos: 185, + }, + Expr: &ast.ExprNew{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 160, + EndPos: 184, + }, + NewTkn: &token.Token{ + ID: token.T_NEW, + Value: []byte("new"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 160, + EndPos: 163, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 7, + EndLine: 8, + StartPos: 132, + EndPos: 135, + }, + }, + { + ID: token.T_DOC_COMMENT, + Value: []byte("/** anonymous class */"), + Position: &position.Position{ + StartLine: 8, + EndLine: 8, + StartPos: 135, + EndPos: 157, + }, + }, + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 8, + EndLine: 9, + StartPos: 157, + EndPos: 160, + }, + }, + }, + }, + Class: &ast.StmtClass{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 164, + EndPos: 184, + }, + ClassTkn: &token.Token{ + ID: token.T_CLASS, + Value: []byte("class"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 164, + EndPos: 169, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 163, + EndPos: 164, + }, + }, + }, + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 170, + EndPos: 171, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 169, + EndPos: 170, + }, + }, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 171, + EndPos: 173, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 171, + EndPos: 173, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 171, + EndPos: 173, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 171, + EndPos: 173, + }, + }, + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 175, + EndPos: 180, + }, + VariadicTkn: &token.Token{ + ID: token.T_ELLIPSIS, + Value: []byte("..."), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 175, + EndPos: 178, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 174, + EndPos: 175, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 178, + EndPos: 180, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 178, + EndPos: 180, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 178, + EndPos: 180, + }, + }, + Value: []byte("$b"), + }, + }, + }, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 173, + EndPos: 174, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 180, + EndPos: 181, + }, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 182, + EndPos: 183, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 181, + EndPos: 182, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 183, + EndPos: 184, + }, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 9, + EndLine: 9, + StartPos: 184, + EndPos: 185, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestPhp7ParameterNode(t *testing.T) { + src := `bar()";` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 22, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 22, + }, + Expr: &ast.ScalarEncapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + OpenQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 15, + }, + }, + Prop: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + }, + Value: []byte("bar"), + }, + }, + &ast.ScalarEncapsedStringPart{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 20, + }, + EncapsedStrTkn: &token.Token{ + ID: token.T_ENCAPSED_AND_WHITESPACE, + Value: []byte("()"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 20, + }, + }, + Value: []byte("()"), + }, + }, + CloseQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 22, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestScalarEncapsed_DollarOpenCurlyBraces(t *testing.T) { + src := `bar()}";` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 24, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 24, + }, + Expr: &ast.ScalarEncapsed{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 23, + }, + OpenQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 16, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 19, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("bar"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 19, + }, + }, + Value: []byte("bar"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 22, + }, + }, + }, + }, + CloseQuoteTkn: &token.Token{ + ID: token.ID(34), + Value: []byte("\""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 22, + EndPos: 23, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestScalarHeredoc_HeredocSimpleLabel(t *testing.T) { + src := ` $v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 30, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_ExprWithKey(t *testing.T) { + src := ` $v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 30, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 26, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 26, + EndPos: 27, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 30, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_WithRef(t *testing.T) { + src := ` &$v) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 31, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 31, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 25, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 25, + EndPos: 27, + }, + }, + Value: []byte("$v"), + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 27, + EndPos: 28, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 30, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 30, + EndPos: 31, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtForeach_WithList(t *testing.T) { + src := ` list($v)) {}` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 36, + }, + Stmts: []ast.Vertex{ + &ast.StmtForeach{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 36, + }, + ForeachTkn: &token.Token{ + ID: token.T_FOREACH, + Value: []byte("foreach"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 21, + EndPos: 23, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + Var: &ast.ExprList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 32, + }, + ListTkn: &token.Token{ + ID: token.T_LIST, + Value: []byte("list"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 24, + EndPos: 28, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 23, + EndPos: 24, + }, + }, + }, + }, + OpenBracketTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 28, + EndPos: 29, + }, + }, + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$v"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 29, + EndPos: 31, + }, + }, + Value: []byte("$v"), + }, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 31, + EndPos: 32, + }, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 32, + EndPos: 33, + }, + }, + Stmt: &ast.StmtStmtList{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 34, + EndPos: 36, + }, + OpenCurlyBracketTkn: &token.Token{ + ID: token.ID(123), + Value: []byte("{"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 34, + EndPos: 35, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 33, + EndPos: 34, + }, + }, + }, + }, + Stmts: []ast.Vertex{}, + CloseCurlyBracketTkn: &token.Token{ + ID: token.ID(125), + Value: []byte("}"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 35, + EndPos: 36, + }, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtFunction(t *testing.T) { + src := `
` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte("?>"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 17, + }, + }, + Value: []byte("
"), + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestStmtInterface(t *testing.T) { + src := `1, &$b,);` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 21, + }, + Expr: &ast.ExprArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 20, + }, + ArrayTkn: &token.Token{ + ID: token.T_ARRAY, + Value: []byte("array"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 12, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + }, + Value: []byte("1"), + }, + }, + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 18, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 18, + }, + }, + Value: []byte("$b"), + }, + }, + }, + &ast.ExprArrayItem{}, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + }, + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 18, + EndPos: 19, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 21, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprArray_ItemUnpack(t *testing.T) { + src := ` $a;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 14, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 14, + }, + Expr: &ast.ExprArrowFunction{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 13, + }, + FnTkn: &token.Token{ + ID: token.T_FN, + Value: []byte("fn"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 10, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 8, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprArrowFunction_ReturnType(t *testing.T) { + src := ` $a;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 23, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 23, + }, + Expr: &ast.ExprArrowFunction{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 22, + }, + FnTkn: &token.Token{ + ID: token.T_FN, + Value: []byte("fn"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 19, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 17, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 22, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 22, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 20, + EndPos: 22, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 19, + EndPos: 20, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 22, + EndPos: 23, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprBitwiseNot(t *testing.T) { + src := `foo();` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 13, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 13, + }, + Expr: &ast.ExprMethodCall{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 12, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Method: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + }, + Value: []byte("foo"), + }, + OpenParenthesisTkn: &token.Token{ + ID: token.ID(40), + Value: []byte("("), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + }, + CloseParenthesisTkn: &token.Token{ + ID: token.ID(41), + Value: []byte(")"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 13, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprNew(t *testing.T) { + src := `foo;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 11, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 11, + }, + Expr: &ast.ExprPropertyFetch{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 10, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 5, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Prop: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + IdentifierTkn: &token.Token{ + ID: token.T_STRING, + Value: []byte("foo"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 10, + }, + }, + Value: []byte("foo"), + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprShellExec(t *testing.T) { + src := "1, &$b,];` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + Expr: &ast.ExprArray{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 15, + }, + OpenBracketTkn: &token.Token{ + ID: token.ID(91), + Value: []byte("["), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 4, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 5, + EndPos: 7, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 8, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 7, + EndPos: 8, + }, + }, + Value: []byte("1"), + }, + }, + &ast.ExprArrayItem{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 13, + }, + AmpersandTkn: &token.Token{ + ID: token.ID(38), + Value: []byte("&"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 10, + EndPos: 11, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 9, + EndPos: 10, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 13, + }, + }, + Value: []byte("$b"), + }, + }, + }, + &ast.ExprArrayItem{}, + }, + SeparatorTkns: []*token.Token{ + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 8, + EndPos: 9, + }, + }, + { + ID: token.ID(44), + Value: []byte(","), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 13, + EndPos: 14, + }, + }, + }, + CloseBracketTkn: &token.Token{ + ID: token.ID(93), + Value: []byte("]"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprShortList(t *testing.T) { + src := ` $b;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 18, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 18, + }, + Expr: &ast.ExprYield{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + YieldTkn: &token.Token{ + ID: token.T_YIELD, + Value: []byte("yield"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 14, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + }, + Val: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 17, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 17, + EndPos: 18, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprYield_Expr(t *testing.T) { + src := ` 1;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 17, + }, + Expr: &ast.ExprYield{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 16, + }, + YieldTkn: &token.Token{ + ID: token.T_YIELD, + Value: []byte("yield"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 3, + EndPos: 8, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(""), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 12, + EndPos: 14, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 11, + EndPos: 12, + }, + }, + }, + }, + Val: &ast.ScalarLnumber{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + NumberTkn: &token.Token{ + ID: token.T_LNUMBER, + Value: []byte("1"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 15, + EndPos: 16, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 14, + EndPos: 15, + }, + }, + }, + }, + Value: []byte("1"), + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 16, + EndPos: 17, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +func TestExprYieldFrom(t *testing.T) { + src := `>= $b; + $a ??= $b;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 18, + StartPos: 5, + EndPos: 223, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 13, + }, + Expr: &ast.ExprAssign{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 12, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(">="), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 203, + EndPos: 206, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 202, + EndPos: 203, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 207, + EndPos: 209, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 206, + EndPos: 207, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 209, + EndPos: 210, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 213, + EndPos: 223, + }, + Expr: &ast.ExprAssignCoalesce{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 213, + EndPos: 222, + }, + Var: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 213, + EndPos: 215, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 213, + EndPos: 215, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 213, + EndPos: 215, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 17, + EndLine: 18, + StartPos: 210, + EndPos: 213, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + EqualTkn: &token.Token{ + ID: token.T_COALESCE_EQUAL, + Value: []byte("??="), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 216, + EndPos: 219, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 215, + EndPos: 216, + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 220, + EndPos: 222, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 220, + EndPos: 222, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 220, + EndPos: 222, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 219, + EndPos: 220, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 222, + EndPos: 223, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +// expr binary + +func TestExprBinary_BitwiseAnd(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;` + + expected := &ast.Root{ + Position: &position.Position{ + StartLine: 2, + EndLine: 28, + StartPos: 5, + EndPos: 320, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 13, + }, + Expr: &ast.ExprBinaryBitwiseAnd{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 12, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 5, + EndPos: 7, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte("="), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 111, + EndPos: 113, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 110, + EndPos: 111, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 114, + EndPos: 116, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 114, + EndPos: 116, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 114, + EndPos: 116, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 113, + EndPos: 114, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 11, + EndLine: 11, + StartPos: 116, + EndPos: 117, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 120, + EndPos: 128, + }, + Expr: &ast.ExprBinaryGreater{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 120, + EndPos: 127, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 120, + EndPos: 122, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 120, + EndPos: 122, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 120, + EndPos: 122, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 11, + EndLine: 12, + StartPos: 117, + EndPos: 120, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(62), + Value: []byte(">"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 123, + EndPos: 124, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 122, + EndPos: 123, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 125, + EndPos: 127, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 125, + EndPos: 127, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 125, + EndPos: 127, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 124, + EndPos: 125, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 12, + EndLine: 12, + StartPos: 127, + EndPos: 128, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 131, + EndPos: 141, + }, + Expr: &ast.ExprBinaryIdentical{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 131, + EndPos: 140, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 131, + EndPos: 133, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 131, + EndPos: 133, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 131, + EndPos: 133, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 12, + EndLine: 13, + StartPos: 128, + EndPos: 131, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_IDENTICAL, + Value: []byte("==="), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 134, + EndPos: 137, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 133, + EndPos: 134, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 138, + EndPos: 140, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 138, + EndPos: 140, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 138, + EndPos: 140, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 137, + EndPos: 138, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 13, + EndLine: 13, + StartPos: 140, + EndPos: 141, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 144, + EndPos: 154, + }, + Expr: &ast.ExprBinaryLogicalAnd{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 144, + EndPos: 153, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 144, + EndPos: 146, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 144, + EndPos: 146, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 144, + EndPos: 146, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 13, + EndLine: 14, + StartPos: 141, + EndPos: 144, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_AND, + Value: []byte("and"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 147, + EndPos: 150, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 146, + EndPos: 147, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 151, + EndPos: 153, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 150, + EndPos: 151, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 14, + EndLine: 14, + StartPos: 153, + EndPos: 154, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 166, + }, + Expr: &ast.ExprBinaryLogicalOr{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 165, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 157, + EndPos: 159, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 14, + EndLine: 15, + StartPos: 154, + EndPos: 157, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_OR, + Value: []byte("or"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 160, + EndPos: 162, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 159, + EndPos: 160, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 163, + EndPos: 165, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 163, + EndPos: 165, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 163, + EndPos: 165, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 162, + EndPos: 163, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 15, + EndLine: 15, + StartPos: 165, + EndPos: 166, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 169, + EndPos: 179, + }, + Expr: &ast.ExprBinaryLogicalXor{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 169, + EndPos: 178, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 169, + EndPos: 171, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 169, + EndPos: 171, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 169, + EndPos: 171, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 15, + EndLine: 16, + StartPos: 166, + EndPos: 169, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_LOGICAL_XOR, + Value: []byte("xor"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 172, + EndPos: 175, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 171, + EndPos: 172, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 176, + EndPos: 178, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 176, + EndPos: 178, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 176, + EndPos: 178, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 175, + EndPos: 176, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 16, + EndLine: 16, + StartPos: 178, + EndPos: 179, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 182, + EndPos: 190, + }, + Expr: &ast.ExprBinaryMinus{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 182, + EndPos: 189, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 182, + EndPos: 184, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 182, + EndPos: 184, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 182, + EndPos: 184, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 16, + EndLine: 17, + StartPos: 179, + EndPos: 182, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(45), + Value: []byte("-"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 185, + EndPos: 186, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 184, + EndPos: 185, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 187, + EndPos: 189, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 187, + EndPos: 189, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 187, + EndPos: 189, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 186, + EndPos: 187, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 17, + EndLine: 17, + StartPos: 189, + EndPos: 190, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 193, + EndPos: 201, + }, + Expr: &ast.ExprBinaryMod{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 193, + EndPos: 200, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 193, + EndPos: 195, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 193, + EndPos: 195, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 193, + EndPos: 195, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 17, + EndLine: 18, + StartPos: 190, + EndPos: 193, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(37), + Value: []byte("%"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 196, + EndPos: 197, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 195, + EndPos: 196, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 198, + EndPos: 200, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 198, + EndPos: 200, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 198, + EndPos: 200, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 197, + EndPos: 198, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 18, + EndLine: 18, + StartPos: 200, + EndPos: 201, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 204, + EndPos: 212, + }, + Expr: &ast.ExprBinaryMul{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 204, + EndPos: 211, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 204, + EndPos: 206, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 204, + EndPos: 206, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 204, + EndPos: 206, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 18, + EndLine: 19, + StartPos: 201, + EndPos: 204, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(42), + Value: []byte("*"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 207, + EndPos: 208, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 206, + EndPos: 207, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 209, + EndPos: 211, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 208, + EndPos: 209, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 19, + EndLine: 19, + StartPos: 211, + EndPos: 212, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 224, + }, + Expr: &ast.ExprBinaryNotEqual{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 223, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 215, + EndPos: 217, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 19, + EndLine: 20, + StartPos: 212, + EndPos: 215, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_NOT_EQUAL, + Value: []byte("!="), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 218, + EndPos: 220, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 217, + EndPos: 218, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 221, + EndPos: 223, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 221, + EndPos: 223, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 221, + EndPos: 223, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 220, + EndPos: 221, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 20, + EndLine: 20, + StartPos: 223, + EndPos: 224, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 227, + EndPos: 237, + }, + Expr: &ast.ExprBinaryNotIdentical{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 227, + EndPos: 236, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 227, + EndPos: 229, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 227, + EndPos: 229, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 227, + EndPos: 229, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 20, + EndLine: 21, + StartPos: 224, + EndPos: 227, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_NOT_IDENTICAL, + Value: []byte("!=="), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 230, + EndPos: 233, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 229, + EndPos: 230, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 234, + EndPos: 236, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 234, + EndPos: 236, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 234, + EndPos: 236, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 233, + EndPos: 234, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 21, + EndLine: 21, + StartPos: 236, + EndPos: 237, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 240, + EndPos: 248, + }, + Expr: &ast.ExprBinaryPlus{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 240, + EndPos: 247, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 240, + EndPos: 242, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 240, + EndPos: 242, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 240, + EndPos: 242, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 21, + EndLine: 22, + StartPos: 237, + EndPos: 240, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(43), + Value: []byte("+"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 243, + EndPos: 244, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 242, + EndPos: 243, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 245, + EndPos: 247, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 244, + EndPos: 245, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 22, + EndLine: 22, + StartPos: 247, + EndPos: 248, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 260, + }, + Expr: &ast.ExprBinaryPow{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 259, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 251, + EndPos: 253, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 22, + EndLine: 23, + StartPos: 248, + EndPos: 251, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_POW, + Value: []byte("**"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 254, + EndPos: 256, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 253, + EndPos: 254, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 257, + EndPos: 259, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 256, + EndPos: 257, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 23, + EndLine: 23, + StartPos: 259, + EndPos: 260, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 272, + }, + Expr: &ast.ExprBinaryShiftLeft{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 271, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 263, + EndPos: 265, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 23, + EndLine: 24, + StartPos: 260, + EndPos: 263, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_SL, + Value: []byte("<<"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 266, + EndPos: 268, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 265, + EndPos: 266, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 269, + EndPos: 271, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 268, + EndPos: 269, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 24, + EndLine: 24, + StartPos: 271, + EndPos: 272, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 284, + }, + Expr: &ast.ExprBinaryShiftRight{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 283, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 275, + EndPos: 277, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 24, + EndLine: 25, + StartPos: 272, + EndPos: 275, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_SR, + Value: []byte(">>"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 278, + EndPos: 280, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 277, + EndPos: 278, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 281, + EndPos: 283, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 280, + EndPos: 281, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 25, + EndLine: 25, + StartPos: 283, + EndPos: 284, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 296, + }, + Expr: &ast.ExprBinarySmallerOrEqual{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 295, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 287, + EndPos: 289, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 25, + EndLine: 26, + StartPos: 284, + EndPos: 287, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_IS_SMALLER_OR_EQUAL, + Value: []byte("<="), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 290, + EndPos: 292, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 289, + EndPos: 290, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 293, + EndPos: 295, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 293, + EndPos: 295, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 293, + EndPos: 295, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 292, + EndPos: 293, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 26, + EndLine: 26, + StartPos: 295, + EndPos: 296, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 299, + EndPos: 307, + }, + Expr: &ast.ExprBinarySmaller{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 299, + EndPos: 306, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 299, + EndPos: 301, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 299, + EndPos: 301, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 299, + EndPos: 301, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 26, + EndLine: 27, + StartPos: 296, + EndPos: 299, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.ID(60), + Value: []byte("<"), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 302, + EndPos: 303, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 301, + EndPos: 302, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 304, + EndPos: 306, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 304, + EndPos: 306, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 304, + EndPos: 306, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 303, + EndPos: 304, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 27, + EndLine: 27, + StartPos: 306, + EndPos: 307, + }, + }, + }, + &ast.StmtExpression{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 310, + EndPos: 320, + }, + Expr: &ast.ExprBinarySpaceship{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 310, + EndPos: 319, + }, + Left: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 310, + EndPos: 312, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 310, + EndPos: 312, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$a"), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 310, + EndPos: 312, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte("\n\t\t"), + Position: &position.Position{ + StartLine: 27, + EndLine: 28, + StartPos: 307, + EndPos: 310, + }, + }, + }, + }, + Value: []byte("$a"), + }, + }, + OpTkn: &token.Token{ + ID: token.T_SPACESHIP, + Value: []byte("<=>"), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 313, + EndPos: 316, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 312, + EndPos: 313, + }, + }, + }, + }, + Right: &ast.ExprVariable{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 317, + EndPos: 319, + }, + Name: &ast.Identifier{ + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 317, + EndPos: 319, + }, + IdentifierTkn: &token.Token{ + ID: token.T_VARIABLE, + Value: []byte("$b"), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 317, + EndPos: 319, + }, + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 316, + EndPos: 317, + }, + }, + }, + }, + Value: []byte("$b"), + }, + }, + }, + SemiColonTkn: &token.Token{ + ID: token.ID(59), + Value: []byte(";"), + Position: &position.Position{ + StartLine: 28, + EndLine: 28, + StartPos: 319, + EndPos: 320, + }, + }, + }, + }, + EndTkn: &token.Token{}, + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer([]byte(src), config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + actual := php7parser.GetRootNode() + assert.DeepEqual(t, expected, actual) +} + +// expr cast + +func TestExprCast_Array(t *testing.T) { + src := ` T_INCLUDE +%token T_INCLUDE_ONCE +%token T_EXIT +%token T_IF +%token T_LNUMBER +%token T_DNUMBER +%token T_STRING +%token T_STRING_VARNAME +%token T_VARIABLE +%token T_NUM_STRING +%token T_INLINE_HTML +%token T_CHARACTER +%token T_BAD_CHARACTER +%token T_ENCAPSED_AND_WHITESPACE +%token T_CONSTANT_ENCAPSED_STRING +%token T_ECHO +%token T_DO +%token T_WHILE +%token T_ENDWHILE +%token T_FOR +%token T_ENDFOR +%token T_FOREACH +%token T_ENDFOREACH +%token T_DECLARE +%token T_ENDDECLARE +%token T_AS +%token T_SWITCH +%token T_ENDSWITCH +%token T_CASE +%token T_DEFAULT +%token T_BREAK +%token T_CONTINUE +%token T_GOTO +%token T_FUNCTION +%token T_FN +%token T_CONST +%token T_RETURN +%token T_TRY +%token T_CATCH +%token T_FINALLY +%token T_THROW +%token T_USE +%token T_INSTEADOF +%token T_GLOBAL +%token T_VAR +%token T_UNSET +%token T_ISSET +%token T_EMPTY +%token T_HALT_COMPILER +%token T_CLASS +%token T_TRAIT +%token T_INTERFACE +%token T_EXTENDS +%token T_IMPLEMENTS +%token T_OBJECT_OPERATOR +%token T_DOUBLE_ARROW +%token T_LIST +%token T_ARRAY +%token T_CALLABLE +%token T_CLASS_C +%token T_TRAIT_C +%token T_METHOD_C +%token T_FUNC_C +%token T_LINE +%token T_FILE +%token T_COMMENT +%token T_DOC_COMMENT +%token T_OPEN_TAG +%token T_OPEN_TAG_WITH_ECHO +%token T_CLOSE_TAG +%token T_WHITESPACE +%token T_START_HEREDOC +%token T_END_HEREDOC +%token T_DOLLAR_OPEN_CURLY_BRACES +%token T_CURLY_OPEN +%token T_PAAMAYIM_NEKUDOTAYIM +%token T_NAMESPACE +%token T_NS_C +%token T_DIR +%token T_NS_SEPARATOR +%token T_ELLIPSIS +%token T_EVAL +%token T_REQUIRE +%token T_REQUIRE_ONCE +%token T_LOGICAL_OR +%token T_LOGICAL_XOR +%token T_LOGICAL_AND +%token T_INSTANCEOF +%token T_NEW +%token T_CLONE +%token T_ELSEIF +%token T_ELSE +%token T_ENDIF +%token T_PRINT +%token T_YIELD +%token T_STATIC +%token T_ABSTRACT +%token T_FINAL +%token T_PRIVATE +%token T_PROTECTED +%token T_PUBLIC +%token T_INC +%token T_DEC +%token T_YIELD_FROM +%token T_INT_CAST +%token T_DOUBLE_CAST +%token T_STRING_CAST +%token T_ARRAY_CAST +%token T_OBJECT_CAST +%token T_BOOL_CAST +%token T_UNSET_CAST +%token T_COALESCE +%token T_SPACESHIP +%token T_NOELSE +%token T_PLUS_EQUAL +%token T_MINUS_EQUAL +%token T_MUL_EQUAL +%token T_POW_EQUAL +%token T_DIV_EQUAL +%token T_CONCAT_EQUAL +%token T_MOD_EQUAL +%token T_AND_EQUAL +%token T_OR_EQUAL +%token T_XOR_EQUAL +%token T_SL_EQUAL +%token T_SR_EQUAL +%token T_COALESCE_EQUAL +%token T_BOOLEAN_OR +%token T_BOOLEAN_AND +%token T_POW +%token T_SL +%token T_SR +%token T_IS_IDENTICAL +%token T_IS_NOT_IDENTICAL +%token T_IS_EQUAL +%token T_IS_NOT_EQUAL +%token T_IS_SMALLER_OR_EQUAL +%token T_IS_GREATER_OR_EQUAL +%token '"' +%token '`' +%token '{' +%token '}' +%token ';' +%token ':' +%token '(' +%token ')' +%token '[' +%token ']' +%token '?' +%token '&' +%token '-' +%token '+' +%token '!' +%token '~' +%token '@' +%token '$' +%token ',' +%token '|' +%token '=' +%token '^' +%token '*' +%token '/' +%token '%' +%token '<' +%token '>' +%token '.' + +%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE +%left ',' +%left T_LOGICAL_OR +%left T_LOGICAL_XOR +%left T_LOGICAL_AND +%right T_PRINT +%right T_YIELD +%right T_DOUBLE_ARROW +%right T_YIELD_FROM +%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL T_COALESCE_EQUAL +%left '?' ':' +%right T_COALESCE +%left T_BOOLEAN_OR +%left T_BOOLEAN_AND +%left '|' +%left '^' +%left '&' +%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP +%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL +%left T_SL T_SR +%left '+' '-' '.' +%left '*' '/' '%' +%right '!' +%nonassoc T_INSTANCEOF +%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' +%right T_POW +%right '[' +%nonassoc T_NEW T_CLONE +%left T_NOELSE +%left T_ELSEIF +%left T_ELSE +%left T_ENDIF +%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC + +%type is_reference is_variadic returns_ref + +%type reserved_non_modifiers +%type semi_reserved +%type identifier +%type possible_comma +%type case_separator + +%type top_statement name statement function_declaration_statement +%type class_declaration_statement trait_declaration_statement +%type interface_declaration_statement +%type group_use_declaration inline_use_declaration +%type mixed_group_use_declaration use_declaration unprefixed_use_declaration +%type const_decl inner_statement for_exprs non_empty_for_exprs +%type expr optional_expr parameter_list non_empty_parameter_list +%type declare_statement finally_statement unset_variable variable +%type parameter optional_type argument expr_without_variable global_var_list global_var +%type static_var_list static_var class_statement trait_adaptation trait_precedence trait_alias +%type absolute_trait_method_reference trait_method_reference property echo_expr +%type new_expr anonymous_class class_name class_name_reference simple_variable +%type internal_functions_in_yacc non_empty_array_pair_list array_pair_list +%type exit_expr scalar lexical_var function_call member_name property_name +%type variable_class_name dereferencable_scalar constant dereferencable +%type callable_expr callable_variable static_member new_variable +%type encaps_var encaps_var_offset echo_expr_list catch_name_list name_list +%type if_stmt const_list non_empty_argument_list property_list +%type alt_if_stmt lexical_var_list isset_variables class_const_list +%type if_stmt_without_else unprefixed_use_declarations inline_use_declarations use_declarations +%type class_const_decl namespace_name +%type alt_if_stmt_without_else +%type array_pair possible_array_pair +%type isset_variable type return_type type_expr +%type class_modifier +%type argument_list ctor_arguments +%type trait_adaptations +%type switch_case_list +%type method_body +%type foreach_statement for_statement while_statement +%type inline_function +%type unset_variables +%type extends_from +%type implements_list +%type interface_extends_list +%type lexical_vars + +%type member_modifier +%type use_type +%type foreach_variable + + +%type encaps_list backticks_expr catch_list +%type case_list trait_adaptation_list +%type top_statement_list +%type inner_statement_list class_statement_list +%type method_modifiers variable_modifiers +%type non_empty_member_modifiers class_modifiers + +%% + +///////////////////////////////////////////////////////////////////////// + +start: + top_statement_list + { + yylex.(*Parser).currentToken.Value = nil + + yylex.(*Parser).rootNode = &ast.Root{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1), + Stmts: $1, + EndTkn: yylex.(*Parser).currentToken, + } + } +; + +reserved_non_modifiers: + T_INCLUDE {$$=$1} | T_INCLUDE_ONCE {$$=$1} | T_EVAL {$$=$1} | T_REQUIRE {$$=$1} | T_REQUIRE_ONCE {$$=$1} | T_LOGICAL_OR {$$=$1} | T_LOGICAL_XOR {$$=$1} | T_LOGICAL_AND {$$=$1} + | T_INSTANCEOF {$$=$1} | T_NEW {$$=$1} | T_CLONE {$$=$1} | T_EXIT {$$=$1} | T_IF {$$=$1} | T_ELSEIF {$$=$1} | T_ELSE {$$=$1} | T_ENDIF {$$=$1} | T_ECHO {$$=$1} | T_DO {$$=$1} | T_WHILE {$$=$1} | T_ENDWHILE {$$=$1} + | T_FOR {$$=$1} | T_ENDFOR {$$=$1} | T_FOREACH {$$=$1} | T_ENDFOREACH {$$=$1} | T_DECLARE {$$=$1} | T_ENDDECLARE {$$=$1} | T_AS {$$=$1} | T_TRY {$$=$1} | T_CATCH {$$=$1} | T_FINALLY {$$=$1} + | T_THROW {$$=$1} | T_USE {$$=$1} | T_INSTEADOF {$$=$1} | T_GLOBAL {$$=$1} | T_VAR {$$=$1} | T_UNSET {$$=$1} | T_ISSET {$$=$1} | T_EMPTY {$$=$1} | T_CONTINUE {$$=$1} | T_GOTO {$$=$1} + | T_FUNCTION {$$=$1} | T_CONST {$$=$1} | T_RETURN {$$=$1} | T_PRINT {$$=$1} | T_YIELD {$$=$1} | T_LIST {$$=$1} | T_SWITCH {$$=$1} | T_ENDSWITCH {$$=$1} | T_CASE {$$=$1} | T_DEFAULT {$$=$1} | T_BREAK {$$=$1} + | T_ARRAY {$$=$1} | T_CALLABLE {$$=$1} | T_EXTENDS {$$=$1} | T_IMPLEMENTS {$$=$1} | T_NAMESPACE {$$=$1} | T_TRAIT {$$=$1} | T_INTERFACE {$$=$1} | T_CLASS {$$=$1} + | T_CLASS_C {$$=$1} | T_TRAIT_C {$$=$1} | T_FUNC_C {$$=$1} | T_METHOD_C {$$=$1} | T_LINE {$$=$1} | T_FILE {$$=$1} | T_DIR {$$=$1} | T_NS_C {$$=$1} | T_FN {$$=$1} +; + +semi_reserved: + reserved_non_modifiers + { + $$ = $1 + } + | T_STATIC {$$=$1} | T_ABSTRACT {$$=$1} | T_FINAL {$$=$1} | T_PRIVATE {$$=$1} | T_PROTECTED {$$=$1} | T_PUBLIC {$$=$1} +; + +identifier: + T_STRING + { + $$ = $1 + } + | semi_reserved + { + $$ = $1 + } +; + +top_statement_list: + top_statement_list top_statement + { + if $2 != nil { + $$ = append($1, $2) + } + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + +namespace_name: + T_STRING + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{ + &ast.NamePart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + }, + }, + } + } + | namespace_name T_NS_SEPARATOR T_STRING + { + part := &ast.NamePart{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + StringTkn: $3, + Value: $3.Value, + } + + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, part) + + $$ = $1 + } +; + +name: + namespace_name + { + $$ = &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NAMESPACE T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameRelative{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $3.(*ParserSeparatedList).Items), + NsTkn: $1, + NsSeparatorTkn: $2, + Parts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + } + } + | T_NS_SEPARATOR namespace_name + { + $$ = &ast.NameFullyQualified{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + NsSeparatorTkn: $1, + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + } + } +; + +top_statement: + error + { + // error + $$ = nil + } + | statement + { + $$ = $1 + } + | function_declaration_statement + { + $$ = $1 + } + | class_declaration_statement + { + $$ = $1 + } + | trait_declaration_statement + { + $$ = $1 + } + | interface_declaration_statement + { + $$ = $1 + } + | T_HALT_COMPILER '(' ')' ';' + { + $$ = &ast.StmtHaltCompiler{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + HaltCompilerTkn: $1, + OpenParenthesisTkn: $2, + CloseParenthesisTkn: $3, + SemiColonTkn: $4, + } + } + | T_NAMESPACE namespace_name ';' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + NsTkn: $1, + Name: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + SemiColonTkn: $3, + } + } + | T_NAMESPACE namespace_name '{' top_statement_list '}' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + NsTkn: $1, + Name: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + OpenCurlyBracketTkn: $3, + Stmts: $4, + CloseCurlyBracketTkn: $5, + } + } + | T_NAMESPACE '{' top_statement_list '}' + { + $$ = &ast.StmtNamespace{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + NsTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + } + } + | T_USE mixed_group_use_declaration ';' + { + use := $2.(*ast.StmtGroupUseList) + + use.Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + use.UseTkn = $1 + use.SemiColonTkn = $3 + + $$ = $2 + } + | T_USE use_type group_use_declaration ';' + { + use := $3.(*ast.StmtGroupUseList) + + use.Position = yylex.(*Parser).builder.NewTokensPosition($1, $4) + use.UseTkn = $1 + use.Type = $2 + use.SemiColonTkn = $4 + + $$ = $3 + } + | T_USE use_declarations ';' + { + $$ = &ast.StmtUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + UseTkn: $1, + Uses: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $3, + } + } + | T_USE use_type use_declarations ';' + { + $$ = &ast.StmtUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + UseTkn: $1, + Type: $2, + Uses: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $4, + } + } + | T_CONST const_list ';' + { + $$ = &ast.StmtConstList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ConstTkn: $1, + Consts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $3, + } + } +; + +use_type: + T_FUNCTION + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_CONST + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } +; + +group_use_declaration: + namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' + { + if $5 != nil { + $4.(*ParserSeparatedList).SeparatorTkns = append($4.(*ParserSeparatedList).SeparatorTkns, $5) + } + + $$ = &ast.StmtGroupUseList{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $6), + Prefix: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + NsSeparatorTkn: $2, + OpenCurlyBracketTkn: $3, + Uses: $4.(*ParserSeparatedList).Items, + SeparatorTkns: $4.(*ParserSeparatedList).SeparatorTkns, + CloseCurlyBracketTkn: $6, + } + } + | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' + { + if $6 != nil { + $5.(*ParserSeparatedList).SeparatorTkns = append($5.(*ParserSeparatedList).SeparatorTkns, $6) + } + + $$ = &ast.StmtGroupUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $7), + LeadingNsSeparatorTkn: $1, + Prefix: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + NsSeparatorTkn: $3, + OpenCurlyBracketTkn: $4, + Uses: $5.(*ParserSeparatedList).Items, + SeparatorTkns: $5.(*ParserSeparatedList).SeparatorTkns, + CloseCurlyBracketTkn: $7, + } + } +; + +mixed_group_use_declaration: + namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' + { + if $5 != nil { + $4.(*ParserSeparatedList).SeparatorTkns = append($4.(*ParserSeparatedList).SeparatorTkns, $5) + } + + $$ = &ast.StmtGroupUseList{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $6), + Prefix: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + NsSeparatorTkn: $2, + OpenCurlyBracketTkn: $3, + Uses: $4.(*ParserSeparatedList).Items, + SeparatorTkns: $4.(*ParserSeparatedList).SeparatorTkns, + CloseCurlyBracketTkn: $6, + } + } + | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' + { + if $6 != nil { + $5.(*ParserSeparatedList).SeparatorTkns = append($5.(*ParserSeparatedList).SeparatorTkns, $6) + } + + $$ = &ast.StmtGroupUseList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $7), + LeadingNsSeparatorTkn: $1, + Prefix: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2.(*ParserSeparatedList).Items), + Parts: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }, + NsSeparatorTkn: $3, + OpenCurlyBracketTkn: $4, + Uses: $5.(*ParserSeparatedList).Items, + SeparatorTkns: $5.(*ParserSeparatedList).SeparatorTkns, + CloseCurlyBracketTkn: $7, + } + } +; + +possible_comma: + /* empty */ + { + $$ = nil + } + | ',' + { + $$ = $1 + } +; + +inline_use_declarations: + inline_use_declarations ',' inline_use_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | inline_use_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +unprefixed_use_declarations: + unprefixed_use_declarations ',' unprefixed_use_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | unprefixed_use_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +use_declarations: + use_declarations ',' use_declaration + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | use_declaration + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +inline_use_declaration: + unprefixed_use_declaration + { + $$ = $1 + } + | use_type unprefixed_use_declaration + { + decl := $2.(*ast.StmtUse) + decl.Type = $1 + decl.Position = yylex.(*Parser).builder.NewNodesPosition($1, $2) + + $$ = $2 + } +; + +unprefixed_use_declaration: + namespace_name + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + } + } + | namespace_name T_AS T_STRING + { + $$ = &ast.StmtUse{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1.(*ParserSeparatedList).Items, $3), + Use: &ast.Name{ + Position: yylex.(*Parser).builder.NewNodeListPosition($1.(*ParserSeparatedList).Items), + Parts: $1.(*ParserSeparatedList).Items, + SeparatorTkns: $1.(*ParserSeparatedList).SeparatorTkns, + }, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +use_declaration: + unprefixed_use_declaration + { + $$ = $1 + } + | T_NS_SEPARATOR unprefixed_use_declaration + { + decl := $2.(*ast.StmtUse) + decl.NsSeparatorTkn = $1 + decl.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2) + + $$ = $2 + } +; + +const_list: + const_list ',' const_decl + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | const_decl + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +inner_statement_list: + inner_statement_list inner_statement + { + if $2 != nil { + $$ = append($1, $2) + } + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + +inner_statement: + error + { + // error + $$ = nil + } + | statement + { + $$ = $1 + } + | function_declaration_statement + { + $$ = $1 + } + | class_declaration_statement + { + $$ = $1 + } + | trait_declaration_statement + { + $$ = $1 + } + | interface_declaration_statement + { + $$ = $1 + } + | T_HALT_COMPILER '(' ')' ';' + { + $$ = &ast.StmtHaltCompiler{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + HaltCompilerTkn: $1, + OpenParenthesisTkn: $2, + CloseParenthesisTkn: $3, + SemiColonTkn: $4, + } + } + +statement: + '{' inner_statement_list '}' + { + $$ = &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Stmts: $2, + CloseCurlyBracketTkn: $3, + } + } + | if_stmt + { + $$ = $1 + } + | alt_if_stmt + { + $$ = $1 + } + | T_WHILE '(' expr ')' while_statement + { + $5.(*ast.StmtWhile).WhileTkn = $1 + $5.(*ast.StmtWhile).OpenParenthesisTkn = $2 + $5.(*ast.StmtWhile).Cond = $3 + $5.(*ast.StmtWhile).CloseParenthesisTkn = $4 + $5.(*ast.StmtWhile).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $5) + + $$ = $5 + } + | T_DO statement T_WHILE '(' expr ')' ';' + { + $$ = &ast.StmtDo{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $7), + DoTkn: $1, + Stmt: $2, + WhileTkn: $3, + OpenParenthesisTkn: $4, + Cond: $5, + CloseParenthesisTkn: $6, + SemiColonTkn: $7, + } + } + | T_FOR '(' for_exprs ';' for_exprs ';' for_exprs ')' for_statement + { + $9.(*ast.StmtFor).ForTkn = $1 + $9.(*ast.StmtFor).OpenParenthesisTkn = $2 + $9.(*ast.StmtFor).Init = $3.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).InitSeparatorTkns = $3.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).InitSemiColonTkn = $4 + $9.(*ast.StmtFor).Cond = $5.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).CondSeparatorTkns = $5.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).CondSemiColonTkn = $6 + $9.(*ast.StmtFor).Loop = $7.(*ParserSeparatedList).Items + $9.(*ast.StmtFor).LoopSeparatorTkns = $7.(*ParserSeparatedList).SeparatorTkns + $9.(*ast.StmtFor).CloseParenthesisTkn = $8 + $9.(*ast.StmtFor).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $9) + + $$ = $9 + } + | T_SWITCH '(' expr ')' switch_case_list + { + $5.(*ast.StmtSwitch).SwitchTkn = $1 + $5.(*ast.StmtSwitch).OpenParenthesisTkn = $2 + $5.(*ast.StmtSwitch).Cond = $3 + $5.(*ast.StmtSwitch).CloseParenthesisTkn = $4 + $5.(*ast.StmtSwitch).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $5) + + $$ = $5 + } + | T_BREAK optional_expr ';' + { + $$ = &ast.StmtBreak{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + BreakTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_CONTINUE optional_expr ';' + { + $$ = &ast.StmtContinue{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ContinueTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_RETURN optional_expr ';' + { + $$ = &ast.StmtReturn{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ReturnTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_GLOBAL global_var_list ';' + { + $2.(*ast.StmtGlobal).GlobalTkn = $1 + $2.(*ast.StmtGlobal).SemiColonTkn = $3 + $2.(*ast.StmtGlobal).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_STATIC static_var_list ';' + { + $2.(*ast.StmtStatic).StaticTkn = $1 + $2.(*ast.StmtStatic).SemiColonTkn = $3 + $2.(*ast.StmtStatic).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_ECHO echo_expr_list ';' + { + $2.(*ast.StmtEcho).EchoTkn = $1 + $2.(*ast.StmtEcho).SemiColonTkn = $3 + $2.(*ast.StmtEcho).Position = yylex.(*Parser).builder.NewTokensPosition($1, $3) + + $$ = $2 + } + | T_INLINE_HTML + { + $$ = &ast.StmtInlineHtml{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + InlineHtmlTkn: $1, + Value: $1.Value, + } + } + | expr ';' + { + $$ = &ast.StmtExpression{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Expr: $1, + SemiColonTkn: $2, + } + } + | T_UNSET '(' unset_variables possible_comma ')' ';' + { + $3.(*ast.StmtUnset).UnsetTkn = $1 + $3.(*ast.StmtUnset).OpenParenthesisTkn = $2 + if $4 != nil { + $3.(*ast.StmtUnset).SeparatorTkns = append($3.(*ast.StmtUnset).SeparatorTkns, $4) + } + $3.(*ast.StmtUnset).CloseParenthesisTkn = $5 + $3.(*ast.StmtUnset).SemiColonTkn = $6 + $3.(*ast.StmtUnset).Position = yylex.(*Parser).builder.NewTokensPosition($1, $6) + + $$ = $3 + } + | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement + { + foreach := $7.(*ast.StmtForeach) + + foreach.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $7) + foreach.ForeachTkn = $1 + foreach.OpenParenthesisTkn = $2 + foreach.Expr = $3 + foreach.AsTkn = $4 + foreach.Var = $5 + foreach.CloseParenthesisTkn = $6 + + if val, ok := $5.(*ast.StmtForeach); ok { + foreach.AmpersandTkn = val.AmpersandTkn + foreach.Var = val.Var + } + + $$ = foreach + } + | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement + { + foreach := $9.(*ast.StmtForeach) + + foreach.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $9) + foreach.ForeachTkn = $1 + foreach.OpenParenthesisTkn = $2 + foreach.Expr = $3 + foreach.AsTkn = $4 + foreach.Key = $5 + foreach.DoubleArrowTkn = $6 + foreach.Var = $7 + foreach.CloseParenthesisTkn = $8 + + if val, ok := $7.(*ast.StmtForeach); ok { + foreach.AmpersandTkn = val.AmpersandTkn + foreach.Var = val.Var + } + + $$ = foreach + } + | T_DECLARE '(' const_list ')' declare_statement + { + $5.(*ast.StmtDeclare).DeclareTkn = $1 + $5.(*ast.StmtDeclare).OpenParenthesisTkn = $2 + $5.(*ast.StmtDeclare).Consts = $3.(*ParserSeparatedList).Items + $5.(*ast.StmtDeclare).SeparatorTkns = $3.(*ParserSeparatedList).SeparatorTkns + $5.(*ast.StmtDeclare).CloseParenthesisTkn = $4 + $5.(*ast.StmtDeclare).Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $5) + + $$ = $5 + } + | ';' + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | T_TRY '{' inner_statement_list '}' catch_list finally_statement + { + pos := yylex.(*Parser).builder.NewTokenNodeListPosition($1, $5) + if $6 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($1, $6) + } + + $$ = &ast.StmtTry{ + Position: pos, + TryTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + Catches: $5, + Finally: $6, + } + } + | T_THROW expr ';' + { + $$ = &ast.StmtThrow{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + ThrowTkn: $1, + Expr: $2, + SemiColonTkn: $3, + } + } + | T_GOTO T_STRING ';' + { + $$ = &ast.StmtGoto{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + GotoTkn: $1, + Label: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + SemiColonTkn: $3, + } + } + | T_STRING ':' + { + $$ = &ast.StmtLabel{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + ColonTkn: $2, + } + } + +catch_list: + /* empty */ + { + $$ = []ast.Vertex{} + } + | catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}' + { + catch := $4.(*ast.StmtCatch) + catch.CatchTkn = $2 + catch.OpenParenthesisTkn = $3 + catch.Var = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($5), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($5), + IdentifierTkn: $5, + Value: $5.Value, + }, + } + catch.CloseParenthesisTkn = $6 + catch.OpenCurlyBracketTkn = $7 + catch.Stmts = $8 + catch.CloseCurlyBracketTkn = $9 + catch.Position = yylex.(*Parser).builder.NewTokensPosition($2, $9) + + $$ = append($1, catch) + } +; +catch_name_list: + name + { + $$ = &ast.StmtCatch{ + Types: []ast.Vertex{$1}, + } + } + | catch_name_list '|' name + { + $1.(*ast.StmtCatch).SeparatorTkns = append($1.(*ast.StmtCatch).SeparatorTkns, $2) + $1.(*ast.StmtCatch).Types = append($1.(*ast.StmtCatch).Types, $3) + + $$ = $1 + } +; + +finally_statement: + /* empty */ + { + $$ = nil + } + | T_FINALLY '{' inner_statement_list '}' + { + $$ = &ast.StmtFinally{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + FinallyTkn: $1, + OpenCurlyBracketTkn: $2, + Stmts: $3, + CloseCurlyBracketTkn: $4, + } + } +; + +unset_variables: + unset_variable + { + $$ = &ast.StmtUnset{ + Vars: []ast.Vertex{$1}, + } + } + | unset_variables ',' unset_variable + { + $1.(*ast.StmtUnset).Vars = append($1.(*ast.StmtUnset).Vars, $3) + $1.(*ast.StmtUnset).SeparatorTkns = append($1.(*ast.StmtUnset).SeparatorTkns, $2) + + $$ = $1 + } +; + +unset_variable: + variable + { + $$ = $1 + } +; + +function_declaration_statement: + T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}' + { + $$ = &ast.StmtFunction{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $11), + FunctionTkn: $1, + AmpersandTkn: $2, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + OpenParenthesisTkn: $5, + Params: $6.(*ParserSeparatedList).Items, + SeparatorTkns: $6.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $7, + ColonTkn: $8.(*ReturnType).ColonTkn, + ReturnType: $8.(*ReturnType).Type, + OpenCurlyBracketTkn: $9, + Stmts: $10, + CloseCurlyBracketTkn: $11, + } + } +; + +is_reference: + /* empty */ + { + $$ = nil + } + | '&' + { + $$ = $1 + } +; + +is_variadic: + /* empty */ + { + $$ = nil + } + | T_ELLIPSIS + { + $$ = $1 + } +; + +class_declaration_statement: + class_modifiers T_CLASS T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' + { + class := &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewOptionalListTokensPosition($1, $2, $9), + Modifiers: $1, + ClassTkn: $2, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + OpenCurlyBracketTkn: $7, + Stmts: $8, + CloseCurlyBracketTkn: $9, + } + + if $4 != nil { + class.ExtendsTkn = $4.(*ast.StmtClass).ExtendsTkn + class.Extends = $4.(*ast.StmtClass).Extends + } + + if $5 != nil { + class.ImplementsTkn = $5.(*ast.StmtClass).ImplementsTkn + class.Implements = $5.(*ast.StmtClass).Implements + class.ImplementsSeparatorTkns = $5.(*ast.StmtClass).ImplementsSeparatorTkns + } + + $$ = class + } + | T_CLASS T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' + { + class := &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $8), + ClassTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenCurlyBracketTkn: $6, + Stmts: $7, + CloseCurlyBracketTkn: $8, + } + + if $3 != nil { + class.ExtendsTkn = $3.(*ast.StmtClass).ExtendsTkn + class.Extends = $3.(*ast.StmtClass).Extends + } + + if $4 != nil { + class.ImplementsTkn = $4.(*ast.StmtClass).ImplementsTkn + class.Implements = $4.(*ast.StmtClass).Implements + class.ImplementsSeparatorTkns = $4.(*ast.StmtClass).ImplementsSeparatorTkns + } + + $$ = class + } +; + +class_modifiers: + class_modifier + { + $$ = []ast.Vertex{$1} + } + | class_modifiers class_modifier + { + $$ = append($1, $2) + } +; + +class_modifier: + T_ABSTRACT + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_FINAL + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } +; + +trait_declaration_statement: + T_TRAIT T_STRING backup_doc_comment '{' class_statement_list '}' + { + $$ = &ast.StmtTrait{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $6), + TraitTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenCurlyBracketTkn: $4, + Stmts: $5, + CloseCurlyBracketTkn: $6, + } + } +; + +interface_declaration_statement: + T_INTERFACE T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}' + { + iface := &ast.StmtInterface{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $7), + InterfaceTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenCurlyBracketTkn: $5, + Stmts: $6, + CloseCurlyBracketTkn: $7, + } + + if $3 != nil { + iface.ExtendsTkn = $3.(*ast.StmtInterface).ExtendsTkn + iface.Extends = $3.(*ast.StmtInterface).Extends + iface.ExtendsSeparatorTkns = $3.(*ast.StmtInterface).ExtendsSeparatorTkns + } + + $$ = iface + } +; + +extends_from: + /* empty */ + { + $$ = nil + } + | T_EXTENDS name + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ExtendsTkn: $1, + Extends: $2, + } + } +; + +interface_extends_list: + /* empty */ + { + $$ = nil + } + | T_EXTENDS name_list + { + $$ = &ast.StmtInterface{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + ExtendsTkn: $1, + Extends: $2.(*ParserSeparatedList).Items, + ExtendsSeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }; + } +; + +implements_list: + /* empty */ + { + $$ = nil + } + | T_IMPLEMENTS name_list + { + $$ = &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $2.(*ParserSeparatedList).Items), + ImplementsTkn: $1, + Implements: $2.(*ParserSeparatedList).Items, + ImplementsSeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + }; + } +; + +foreach_variable: + variable + { + $$ = $1 + } + | '&' variable + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AmpersandTkn: $1, + Var: $2, + } + } + | T_LIST '(' array_pair_list ')' + { + $$ = &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + } + } + | '[' array_pair_list ']' + { + $$ = &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Items: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $3, + } + } +; + +for_statement: + statement + { + $$ = &ast.StmtFor{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDFOR ';' + { + $$ = &ast.StmtFor{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndForTkn: $3, + SemiColonTkn: $4, + } + } +; + +foreach_statement: + statement + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDFOREACH ';' + { + $$ = &ast.StmtForeach{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndForeachTkn: $3, + SemiColonTkn: $4, + } + } +; + +declare_statement: + statement + { + $$ = &ast.StmtDeclare{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDDECLARE ';' + { + $$ = &ast.StmtDeclare{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndDeclareTkn: $3, + SemiColonTkn: $4, + } + } +; + +switch_case_list: + '{' case_list '}' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Cases: $2, + CloseCurlyBracketTkn: $3, + } + } + | '{' ';' case_list '}' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + OpenCurlyBracketTkn: $1, + CaseSeparatorTkn: $2, + Cases: $3, + CloseCurlyBracketTkn: $4, + } + } + | ':' case_list T_ENDSWITCH ';' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Cases: $2, + EndSwitchTkn: $3, + SemiColonTkn: $4, + } + } + | ':' ';' case_list T_ENDSWITCH ';' + { + $$ = &ast.StmtSwitch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + ColonTkn: $1, + CaseSeparatorTkn: $2, + Cases: $3, + EndSwitchTkn: $4, + SemiColonTkn: $5, + } + } +; + +case_list: + /* empty */ + { + $$ = nil + } + | case_list T_CASE expr case_separator inner_statement_list + { + $$ = append($1, &ast.StmtCase{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $5), + CaseTkn: $2, + Cond: $3, + CaseSeparatorTkn: $4, + Stmts: $5, + }) + } + | case_list T_DEFAULT case_separator inner_statement_list + { + $$ = append($1, &ast.StmtDefault{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $4), + DefaultTkn: $2, + CaseSeparatorTkn: $3, + Stmts: $4, + }) + } +; + +case_separator: + ':' + { + $$ = $1 + } + | ';' + { + $$ = $1 + } +; + +while_statement: + statement + { + $$ = &ast.StmtWhile{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Stmt: $1, + } + } + | ':' inner_statement_list T_ENDWHILE ';' + { + $$ = &ast.StmtWhile{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ColonTkn: $1, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($2), + Stmts: $2, + }, + EndWhileTkn: $3, + SemiColonTkn: $4, + } + } +; + +if_stmt_without_else: + T_IF '(' expr ')' statement + { + $$ = &ast.StmtIf{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $5), + IfTkn: $1, + OpenParenthesisTkn: $2, + Cond: $3, + CloseParenthesisTkn: $4, + Stmt: $5, + } + } + | if_stmt_without_else T_ELSEIF '(' expr ')' statement + { + $1.(*ast.StmtIf).ElseIf = append($1.(*ast.StmtIf).ElseIf, &ast.StmtElseIf{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $6), + ElseIfTkn: $2, + OpenParenthesisTkn: $3, + Cond: $4, + CloseParenthesisTkn: $5, + Stmt: $6, + }) + + $1.(*ast.StmtIf).Position = yylex.(*Parser).builder.NewNodesPosition($1, $6) + + $$ = $1 + } +; + +if_stmt: + if_stmt_without_else %prec T_NOELSE + { + $$ = $1 + } + | if_stmt_without_else T_ELSE statement + { + $1.(*ast.StmtIf).Else = &ast.StmtElse{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($2, $3), + ElseTkn: $2, + Stmt: $3, + } + + $1.(*ast.StmtIf).Position = yylex.(*Parser).builder.NewNodesPosition($1, $3) + + $$ = $1 + } +; + +alt_if_stmt_without_else: + T_IF '(' expr ')' ':' inner_statement_list + { + $$ = &ast.StmtIf{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($1, $6), + IfTkn: $1, + OpenParenthesisTkn: $2, + Cond: $3, + CloseParenthesisTkn: $4, + ColonTkn: $5, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($6), + Stmts: $6, + }, + } + } + | alt_if_stmt_without_else T_ELSEIF '(' expr ')' ':' inner_statement_list + { + $1.(*ast.StmtIf).ElseIf = append($1.(*ast.StmtIf).ElseIf, &ast.StmtElseIf{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $7), + ElseIfTkn: $2, + OpenParenthesisTkn: $3, + Cond: $4, + CloseParenthesisTkn: $5, + ColonTkn: $6, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($7), + Stmts: $7, + }, + }) + + $$ = $1 + } +; + +alt_if_stmt: + alt_if_stmt_without_else T_ENDIF ';' + { + $1.(*ast.StmtIf).EndIfTkn = $2 + $1.(*ast.StmtIf).SemiColonTkn = $3 + $1.(*ast.StmtIf).Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $3) + + $$ = $1 + } + | alt_if_stmt_without_else T_ELSE ':' inner_statement_list T_ENDIF ';' + { + $1.(*ast.StmtIf).Else = &ast.StmtElse{ + Position: yylex.(*Parser).builder.NewTokenNodeListPosition($2, $4), + ElseTkn: $2, + ColonTkn: $3, + Stmt: &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewNodeListPosition($4), + Stmts: $4, + }, + } + $1.(*ast.StmtIf).EndIfTkn = $5 + $1.(*ast.StmtIf).SemiColonTkn = $6 + $1.(*ast.StmtIf).Position = yylex.(*Parser).builder.NewNodeTokenPosition($1, $6) + + $$ = $1 + } +; + +parameter_list: + non_empty_parameter_list + { + $$ = $1 + } + | /* empty */ + { + $$ = &ParserSeparatedList{} + } +; + +non_empty_parameter_list: + parameter + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | non_empty_parameter_list ',' parameter + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +parameter: + optional_type is_reference is_variadic T_VARIABLE + { + pos := yylex.(*Parser).builder.NewTokenPosition($4) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodeTokenPosition($1, $4) + } else if $2 != nil { + pos = yylex.(*Parser).builder.NewTokensPosition($2, $4) + } else if $3 != nil { + pos = yylex.(*Parser).builder.NewTokensPosition($3, $4) + } + + $$ = &ast.Parameter{ + Position: pos, + Type: $1, + AmpersandTkn: $2, + VariadicTkn: $3, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + } + } + | optional_type is_reference is_variadic T_VARIABLE '=' expr + { + pos := yylex.(*Parser).builder.NewTokenNodePosition($4, $6) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodesPosition($1, $6) + } else if $2 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($2, $6) + } else if $3 != nil { + pos = yylex.(*Parser).builder.NewTokenNodePosition($3, $6) + } + + $$ = &ast.Parameter{ + Position: pos, + Type: $1, + AmpersandTkn: $2, + VariadicTkn: $3, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + }, + EqualTkn: $5, + DefaultValue: $6, + } + } +; + +optional_type: + /* empty */ + { + $$ = nil + } + | type_expr + { + $$ = $1 + } +; + +type_expr: + type + { + $$ = $1 + } + | '?' type + { + $$ = &ast.Nullable{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + QuestionTkn: $1, + Expr: $2, + } + } +; + +type: + T_ARRAY + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_CALLABLE + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | name + { + $$ = $1 + } +; + +return_type: + /* empty */ + { + $$ = &ReturnType{} + } + | ':' type_expr + { + $$ = &ReturnType{ + ColonTkn: $1, + Type: $2, + } + } +; + +argument_list: + '(' ')' + { + $$ = &ArgumentList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenParenthesisTkn: $1, + CloseParenthesisTkn: $2, + } + } + | '(' non_empty_argument_list possible_comma ')' + { + argumentList := $2.(*ArgumentList) + argumentList.Position = yylex.(*Parser).builder.NewTokensPosition($1, $4) + argumentList.OpenParenthesisTkn = $1 + if $3 != nil { + argumentList.SeparatorTkns = append(argumentList.SeparatorTkns, $3) + } + argumentList.CloseParenthesisTkn = $4 + + $$ = argumentList + } +; + +non_empty_argument_list: + argument + { + $$ = &ArgumentList{ + Arguments: []ast.Vertex{$1}, + } + } + | non_empty_argument_list ',' argument + { + $1.(*ArgumentList).SeparatorTkns = append($1.(*ArgumentList).SeparatorTkns, $2) + $1.(*ArgumentList).Arguments = append($1.(*ArgumentList).Arguments, $3) + + $$ = $1 + } +; + +argument: + expr + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Expr: $1, + } + } + | T_ELLIPSIS expr + { + $$ = &ast.Argument{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + VariadicTkn: $1, + Expr: $2, + } + } +; + +global_var_list: + global_var_list ',' global_var + { + $1.(*ast.StmtGlobal).Vars = append($1.(*ast.StmtGlobal).Vars, $3) + $1.(*ast.StmtGlobal).SeparatorTkns = append($1.(*ast.StmtGlobal).SeparatorTkns, $2) + + $$ = $1 + } + | global_var + { + $$ = &ast.StmtGlobal{ + Vars: []ast.Vertex{$1}, + } + } +; + +global_var: + simple_variable + { + $$ = $1 + } +; + +static_var_list: + static_var_list ',' static_var + { + $1.(*ast.StmtStatic).Vars = append($1.(*ast.StmtStatic).Vars, $3) + $1.(*ast.StmtStatic).SeparatorTkns = append($1.(*ast.StmtStatic).SeparatorTkns, $2) + + $$ = $1 + } + | static_var + { + $$ = &ast.StmtStatic{ + Vars: []ast.Vertex{$1}, + } + } +; + +static_var: + T_VARIABLE + { + + $$ = &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + } + } + | T_VARIABLE '=' expr + { + $$ = &ast.StmtStaticVar{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + EqualTkn: $2, + Expr: $3, + } + } +; + +class_statement_list: + class_statement_list class_statement + { + $$ = append($1, $2) + } + | /* empty */ + { + $$ = []ast.Vertex{} + } +; + +class_statement: + variable_modifiers optional_type property_list ';' + { + $$ = &ast.StmtPropertyList{ + Position: yylex.(*Parser).builder.NewNodeListTokenPosition($1, $4), + Modifiers: $1, + Type: $2, + Props: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $4, + } + } + | method_modifiers T_CONST class_const_list ';' + { + $$ = &ast.StmtClassConstList{ + Position: yylex.(*Parser).builder.NewOptionalListTokensPosition($1, $2, $4), + Modifiers: $1, + ConstTkn: $2, + Consts: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + SemiColonTkn: $4, + } + } + | T_USE name_list trait_adaptations + { + traitUse := &ast.StmtTraitUse{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + UseTkn: $1, + Traits: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + } + + switch n := $3.(type) { + case *TraitAdaptationList : + traitUse.OpenCurlyBracketTkn = n.OpenCurlyBracketTkn + traitUse.Adaptations = n.Adaptations + traitUse.CloseCurlyBracketTkn = n.CloseCurlyBracketTkn + case *ast.StmtNop : + traitUse.SemiColonTkn = n.SemiColonTkn + }; + + $$ = traitUse + } + | method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body + { + pos := yylex.(*Parser).builder.NewTokenNodePosition($2, $10) + if $1 != nil { + pos = yylex.(*Parser).builder.NewNodeListNodePosition($1, $10) + } + + $$ = &ast.StmtClassMethod{ + Position: pos, + Modifiers: $1, + FunctionTkn: $2, + AmpersandTkn: $3, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + OpenParenthesisTkn: $6, + Params: $7.(*ParserSeparatedList).Items, + SeparatorTkns: $7.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $8, + ColonTkn: $9.(*ReturnType).ColonTkn, + ReturnType: $9.(*ReturnType).Type, + Stmt: $10, + } + } +; + +name_list: + name + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | name_list ',' name + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +trait_adaptations: + ';' + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | '{' '}' + { + $$ = &TraitAdaptationList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenCurlyBracketTkn: $1, + CloseCurlyBracketTkn: $2, + } + } + | '{' trait_adaptation_list '}' + { + $$ = &TraitAdaptationList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Adaptations: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +trait_adaptation_list: + trait_adaptation + { + $$ = []ast.Vertex{$1} + } + | trait_adaptation_list trait_adaptation + { + $$ = append($1, $2) + } +; + +trait_adaptation: + trait_precedence ';' + { + $1.(*ast.StmtTraitUsePrecedence).SemiColonTkn = $2 + + $$ = $1; + } + | trait_alias ';' + { + $1.(*ast.StmtTraitUseAlias).SemiColonTkn = $2 + + $$ = $1; + } +; + +trait_precedence: + absolute_trait_method_reference T_INSTEADOF name_list + { + $$ = &ast.StmtTraitUsePrecedence{ + Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ParserSeparatedList).Items), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + InsteadofTkn: $2, + Insteadof: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + } + } +; + +trait_alias: + trait_method_reference T_AS T_STRING + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | trait_method_reference T_AS reserved_non_modifiers + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | trait_method_reference T_AS member_modifier identifier + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Modifier: $3, + Alias: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($4), + IdentifierTkn: $4, + Value: $4.Value, + }, + } + } + | trait_method_reference T_AS member_modifier + { + $$ = &ast.StmtTraitUseAlias{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Trait: $1.(*TraitMethodRef).Trait, + DoubleColonTkn: $1.(*TraitMethodRef).DoubleColonTkn, + Method: $1.(*TraitMethodRef).Method, + AsTkn: $2, + Modifier: $3, + } + } +; + +trait_method_reference: + identifier + { + $$ = &TraitMethodRef{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Method: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | absolute_trait_method_reference + { + $$ = $1 + } +; + +absolute_trait_method_reference: + name T_PAAMAYIM_NEKUDOTAYIM identifier + { + $$ = &TraitMethodRef{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Trait: $1, + DoubleColonTkn: $2, + Method: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +method_body: + ';' /* abstract method */ + { + $$ = &ast.StmtNop{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + SemiColonTkn: $1, + } + } + | '{' inner_statement_list '}' + { + $$ = &ast.StmtStmtList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Stmts: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +variable_modifiers: + non_empty_member_modifiers + { + $$ = $1 + } + | T_VAR + { + $$ = []ast.Vertex{ + &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } +; + +method_modifiers: + /* empty */ + { + $$ = nil + } + | non_empty_member_modifiers + { + $$ = $1 + } +; + +non_empty_member_modifiers: + member_modifier + { + $$ = []ast.Vertex{$1} + } + | non_empty_member_modifiers member_modifier + { + $$ = append($1, $2) + } +; + +member_modifier: + T_PUBLIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_PROTECTED + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_PRIVATE + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_STATIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_ABSTRACT + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | T_FINAL + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } +; + +property_list: + property_list ',' property + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | property + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +property: + T_VARIABLE backup_doc_comment + { + $$ = &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + Expr: nil, + } + } + | T_VARIABLE '=' expr backup_doc_comment + { + $$ = &ast.StmtProperty{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + EqualTkn: $2, + Expr: $3, + } + } +; + +class_const_list: + class_const_list ',' class_const_decl + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | class_const_decl + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +class_const_decl: + identifier '=' expr backup_doc_comment + { + $$ = &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + EqualTkn: $2, + Expr: $3, + } + } +; + +const_decl: + T_STRING '=' expr backup_doc_comment + { + $$ = &ast.StmtConstant{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + EqualTkn: $2, + Expr: $3, + } + } +; + +echo_expr_list: + echo_expr_list ',' echo_expr + { + $1.(*ast.StmtEcho).Exprs = append($1.(*ast.StmtEcho).Exprs, $3) + $1.(*ast.StmtEcho).SeparatorTkns = append($1.(*ast.StmtEcho).SeparatorTkns, $2) + + $$ = $1 + } + | echo_expr + { + $$ = &ast.StmtEcho{ + Exprs: []ast.Vertex{$1}, + } + } +; + +echo_expr: + expr + { + $$ = $1 + } +; + +for_exprs: + /* empty */ + { + $$ = &ParserSeparatedList{} + } + | non_empty_for_exprs + { + $$ = $1 + } +; + +non_empty_for_exprs: + non_empty_for_exprs ',' expr + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | expr + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +anonymous_class: + T_CLASS ctor_arguments extends_from implements_list backup_doc_comment '{' class_statement_list '}' + { + class := &ast.StmtClass{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $8), + ClassTkn: $1, + OpenParenthesisTkn: $2.(*ArgumentList).OpenParenthesisTkn, + Args: $2.(*ArgumentList).Arguments, + SeparatorTkns: $2.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $2.(*ArgumentList).CloseParenthesisTkn, + OpenCurlyBracketTkn: $6, + Stmts: $7, + CloseCurlyBracketTkn: $8, + } + + if $3 != nil { + class.ExtendsTkn = $3.(*ast.StmtClass).ExtendsTkn + class.Extends = $3.(*ast.StmtClass).Extends + } + + if $4 != nil { + class.ImplementsTkn = $4.(*ast.StmtClass).ImplementsTkn + class.Implements = $4.(*ast.StmtClass).Implements + class.ImplementsSeparatorTkns = $4.(*ast.StmtClass).ImplementsSeparatorTkns + } + + $$ = class + } +; + +new_expr: + T_NEW class_name_reference ctor_arguments + { + if $3 != nil { + $$ = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3), + NewTkn: $1, + Class: $2, + OpenParenthesisTkn: $3.(*ArgumentList).OpenParenthesisTkn, + Args: $3.(*ArgumentList).Arguments, + SeparatorTkns: $3.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $3.(*ArgumentList).CloseParenthesisTkn, + } + } else { + $$ = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + NewTkn: $1, + Class: $2, + } + } + } + | T_NEW anonymous_class + { + $$ = &ast.ExprNew{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + NewTkn: $1, + Class: $2, + } + } +; + +expr_without_variable: + T_LIST '(' array_pair_list ')' '=' expr + { + $$ = &ast.ExprAssign{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $6), + Var: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + }, + EqualTkn: $5, + Expr: $6, + } + } + | '[' array_pair_list ']' '=' expr + { + $$ = &ast.ExprAssign{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $5), + Var: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Items: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $3, + }, + EqualTkn: $4, + Expr: $5, + } + } + | variable '=' expr + { + $$ = &ast.ExprAssign{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable '=' '&' expr + { + $$ = &ast.ExprAssignReference{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Var: $1, + EqualTkn: $2, + AmpersandTkn: $3, + Expr: $4, + } + } + | T_CLONE expr + { + $$ = &ast.ExprClone{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CloneTkn: $1, + Expr: $2, + } + } + | variable T_PLUS_EQUAL expr + { + $$ = &ast.ExprAssignPlus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MINUS_EQUAL expr + { + $$ = &ast.ExprAssignMinus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MUL_EQUAL expr + { + $$ = &ast.ExprAssignMul{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_POW_EQUAL expr + { + $$ = &ast.ExprAssignPow{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_DIV_EQUAL expr + { + $$ = &ast.ExprAssignDiv{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_CONCAT_EQUAL expr + { + $$ = &ast.ExprAssignConcat{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_MOD_EQUAL expr + { + $$ = &ast.ExprAssignMod{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_AND_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_OR_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_XOR_EQUAL expr + { + $$ = &ast.ExprAssignBitwiseXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_SL_EQUAL expr + { + $$ = &ast.ExprAssignShiftLeft{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_SR_EQUAL expr + { + $$ = &ast.ExprAssignShiftRight{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_COALESCE_EQUAL expr + { + $$ = &ast.ExprAssignCoalesce{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + EqualTkn: $2, + Expr: $3, + } + } + | variable T_INC + { + $$ = &ast.ExprPostInc{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Var: $1, + IncTkn: $2, + } + } + | T_INC variable + { + $$ = &ast.ExprPreInc{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncTkn: $1, + Var: $2, + } + } + | variable T_DEC + { + $$ = &ast.ExprPostDec{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $2), + Var: $1, + DecTkn: $2, + } + } + | T_DEC variable + { + $$ = &ast.ExprPreDec{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + DecTkn: $1, + Var: $2, + } + } + | expr T_BOOLEAN_OR expr + { + $$ = &ast.ExprBinaryBooleanOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_BOOLEAN_AND expr + { + $$ = &ast.ExprBinaryBooleanAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_OR expr + { + $$ = &ast.ExprBinaryLogicalOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_AND expr + { + $$ = &ast.ExprBinaryLogicalAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_LOGICAL_XOR expr + { + $$ = &ast.ExprBinaryLogicalXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '|' expr + { + $$ = &ast.ExprBinaryBitwiseOr{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '&' expr + { + $$ = &ast.ExprBinaryBitwiseAnd{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '^' expr + { + $$ = &ast.ExprBinaryBitwiseXor{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '.' expr + { + $$ = &ast.ExprBinaryConcat{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '+' expr + { + $$ = &ast.ExprBinaryPlus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '-' expr + { + $$ = &ast.ExprBinaryMinus{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '*' expr + { + $$ = &ast.ExprBinaryMul{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_POW expr + { + $$ = &ast.ExprBinaryPow{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '/' expr + { + $$ = &ast.ExprBinaryDiv{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '%' expr + { + $$ = &ast.ExprBinaryMod{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_SL expr + { + $$ = &ast.ExprBinaryShiftLeft{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_SR expr + { + $$ = &ast.ExprBinaryShiftRight{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | '+' expr %prec T_INC + { + $$ = &ast.ExprUnaryPlus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + PlusTkn: $1, + Expr: $2, + } + } + | '-' expr %prec T_INC + { + $$ = &ast.ExprUnaryMinus{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + MinusTkn: $1, + Expr: $2, + } + } + | '!' expr + { + $$ = &ast.ExprBooleanNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + ExclamationTkn: $1, + Expr: $2, + } + } + | '~' expr + { + $$ = &ast.ExprBitwiseNot{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + TildaTkn: $1, + Expr: $2, + } + } + | expr T_IS_IDENTICAL expr + { + $$ = &ast.ExprBinaryIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_NOT_IDENTICAL expr + { + $$ = &ast.ExprBinaryNotIdentical{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_EQUAL expr + { + $$ = &ast.ExprBinaryEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_NOT_EQUAL expr + { + $$ = &ast.ExprBinaryNotEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '<' expr + { + $$ = &ast.ExprBinarySmaller{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_SMALLER_OR_EQUAL expr + { + $$ = &ast.ExprBinarySmallerOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr '>' expr + { + $$ = &ast.ExprBinaryGreater{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_IS_GREATER_OR_EQUAL expr + { + $$ = &ast.ExprBinaryGreaterOrEqual{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_SPACESHIP expr + { + $$ = &ast.ExprBinarySpaceship{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | expr T_INSTANCEOF class_name_reference + { + $$ = &ast.ExprInstanceOf{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Expr: $1, + InstanceOfTkn: $2, + Class: $3, + } + } + | '(' expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } + | new_expr + { + $$ = $1 + } + | expr '?' expr ':' expr + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $5), + Cond: $1, + QuestionTkn: $2, + IfTrue: $3, + ColonTkn: $4, + IfFalse: $5, + } + } + | expr '?' ':' expr + { + $$ = &ast.ExprTernary{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Cond: $1, + QuestionTkn: $2, + ColonTkn: $3, + IfFalse: $4, + } + } + | expr T_COALESCE expr + { + $$ = &ast.ExprBinaryCoalesce{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Left: $1, + OpTkn: $2, + Right: $3, + } + } + | internal_functions_in_yacc + { + $$ = $1 + } + | T_INT_CAST expr + { + $$ = &ast.ExprCastInt{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_DOUBLE_CAST expr + { + $$ = &ast.ExprCastDouble{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_STRING_CAST expr + { + $$ = &ast.ExprCastString{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_ARRAY_CAST expr + { + $$ = &ast.ExprCastArray{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_OBJECT_CAST expr + { + $$ = &ast.ExprCastObject{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_BOOL_CAST expr + { + $$ = &ast.ExprCastBool{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_UNSET_CAST expr + { + $$ = &ast.ExprCastUnset{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + CastTkn: $1, + Expr: $2, + } + } + | T_EXIT exit_expr + { + exit := &ast.ExprExit{ + ExitTkn: $1, + } + + if $2 == nil { + exit.Position = yylex.(*Parser).builder.NewTokenPosition($1) + } else { + exit.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2) + exit.OpenParenthesisTkn = $2.(*ast.ExprBrackets).OpenParenthesisTkn + exit.Expr = $2.(*ast.ExprBrackets).Expr + exit.CloseParenthesisTkn = $2.(*ast.ExprBrackets).CloseParenthesisTkn + } + + $$ = exit + } + | '@' expr + { + $$ = &ast.ExprErrorSuppress{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AtTkn: $1, + Expr: $2, + } + } + | scalar + { + $$ = $1 + } + | '`' backticks_expr '`' + { + $$ = &ast.ExprShellExec{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBacktickTkn: $1, + Parts: $2, + CloseBacktickTkn: $3, + } + } + | T_PRINT expr + { + $$ = &ast.ExprPrint{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + PrintTkn: $1, + Expr: $2, + } + } + | T_YIELD + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + YieldTkn: $1, + } + } + | T_YIELD expr + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + YieldTkn: $1, + Val: $2, + } + } + | T_YIELD expr T_DOUBLE_ARROW expr + { + $$ = &ast.ExprYield{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $4), + YieldTkn: $1, + Key: $2, + DoubleArrowTkn: $3, + Val: $4, + } + } + | T_YIELD_FROM expr + { + $$ = &ast.ExprYieldFrom{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + YieldFromTkn: $1, + Expr: $2, + } + } + | inline_function + { + $$ = $1; + } + | T_STATIC inline_function + { + switch n := $2.(type) { + case *ast.ExprClosure : + n.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2) + n.StaticTkn = $1; + case *ast.ExprArrowFunction : + n.Position = yylex.(*Parser).builder.NewTokenNodePosition($1, $2) + n.StaticTkn = $1; + }; + + $$ = $2 + } +; + +inline_function: + T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}' + { + closure := $7.(*ast.ExprClosure) + + closure.Position = yylex.(*Parser).builder.NewTokensPosition($1, $11) + closure.FunctionTkn = $1 + closure.AmpersandTkn = $2 + closure.OpenParenthesisTkn = $4 + closure.Params = $5.(*ParserSeparatedList).Items + closure.SeparatorTkns = $5.(*ParserSeparatedList).SeparatorTkns + closure.CloseParenthesisTkn = $6 + closure.ColonTkn = $8.(*ReturnType).ColonTkn + closure.ReturnType = $8.(*ReturnType).Type + closure.OpenCurlyBracketTkn = $9 + closure.Stmts = $10 + closure.CloseCurlyBracketTkn = $11 + + $$ = closure + } + | T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr + { + $$ = &ast.ExprArrowFunction{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $9), + FnTkn: $1, + AmpersandTkn: $2, + OpenParenthesisTkn: $3, + Params: $4.(*ParserSeparatedList).Items, + SeparatorTkns: $4.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $5, + ColonTkn: $6.(*ReturnType).ColonTkn, + ReturnType: $6.(*ReturnType).Type, + DoubleArrowTkn: $8, + Expr: $9, + } + } +; + +backup_doc_comment: + /* empty */ +; + +returns_ref: + /* empty */ + { + $$ = nil + } + | '&' + { + $$ = $1 + } +; + +lexical_vars: + /* empty */ + { + $$ = &ast.ExprClosure{} + } + | T_USE '(' lexical_var_list ')' + { + $$ = &ast.ExprClosure{ + UseTkn: $1, + UseOpenParenthesisTkn: $2, + Uses: $3.(*ParserSeparatedList).Items, + UseSeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + UseCloseParenthesisTkn: $4, + } + } +; + +lexical_var_list: + lexical_var_list ',' lexical_var + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | lexical_var + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +lexical_var: + T_VARIABLE + { + $$ = &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + } + } + | '&' T_VARIABLE + { + $$ = &ast.ExprClosureUse{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + AmpersandTkn: $1, + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + }, + } + } +; + +function_call: + name argument_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $2), + Function: $1, + OpenParenthesisTkn: $2.(*ArgumentList).OpenParenthesisTkn, + Args: $2.(*ArgumentList).Arguments, + SeparatorTkns: $2.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $2.(*ArgumentList).CloseParenthesisTkn, + } + } + | class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list + { + staticCall := &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + staticCall.OpenCurlyBracketTkn = brackets.OpenBracketTkn + staticCall.Call = brackets.Child + staticCall.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = staticCall + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list + { + staticCall := &ast.ExprStaticCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Class: $1, + DoubleColonTkn: $2, + Call: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + staticCall.OpenCurlyBracketTkn = brackets.OpenBracketTkn + staticCall.Call = brackets.Child + staticCall.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = staticCall + } + | callable_expr argument_list + { + $$ = &ast.ExprFunctionCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $2), + Function: $1, + OpenParenthesisTkn: $2.(*ArgumentList).OpenParenthesisTkn, + Args: $2.(*ArgumentList).Arguments, + SeparatorTkns: $2.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $2.(*ArgumentList).CloseParenthesisTkn, + } + } +; + +class_name: + T_STATIC + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | name + { + $$ = $1 + } +; + +class_name_reference: + class_name + { + $$ = $1 + } + | new_variable + { + $$ = $1 + } +; + +exit_expr: + /* empty */ + { + $$ = nil + } + | '(' optional_expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } +; + +backticks_expr: + /* empty */ + { + $$ = []ast.Vertex{} + } + | T_ENCAPSED_AND_WHITESPACE + { + $$ = []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + EncapsedStrTkn: $1, + Value: $1.Value, + }, + } + } + | encaps_list + { + $$ = $1 + } +; + +ctor_arguments: + /* empty */ + { + $$ = &ArgumentList{} + } + | argument_list + { + $$ = $1 + } +; + +dereferencable_scalar: + T_ARRAY '(' array_pair_list ')' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ArrayTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + } + } + | '[' array_pair_list ']' + { + $$ = &ast.ExprArray{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Items: $2.(*ParserSeparatedList).Items, + SeparatorTkns: $2.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $3, + } + } + | T_CONSTANT_ENCAPSED_STRING + { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } +; + +scalar: + T_LNUMBER + { + $$ = &ast.ScalarLnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } + | T_DNUMBER + { + $$ = &ast.ScalarDnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } + | T_LINE + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_FILE + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_DIR + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_TRAIT_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_METHOD_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_FUNC_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_NS_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_CLASS_C + { + $$ = &ast.ScalarMagicConstant{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + MagicConstTkn: $1, + Value: $1.Value, + } + } + | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenHeredocTkn: $1, + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + EncapsedStrTkn: $2, + Value: $2.Value, + }, + }, + CloseHeredocTkn: $3, + } + } + | T_START_HEREDOC T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + OpenHeredocTkn: $1, + CloseHeredocTkn: $2, + } + } + | '"' encaps_list '"' + { + $$ = &ast.ScalarEncapsed{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenQuoteTkn: $1, + Parts: $2, + CloseQuoteTkn: $3, + } + } + | T_START_HEREDOC encaps_list T_END_HEREDOC + { + $$ = &ast.ScalarHeredoc{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenHeredocTkn: $1, + Parts: $2, + CloseHeredocTkn: $3, + } + } + | dereferencable_scalar + { + $$ = $1 + } + | constant + { + $$ = $1 + } +; + +constant: + name + { + $$ = &ast.ExprConstFetch{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Const: $1, + } + } + | class_name T_PAAMAYIM_NEKUDOTAYIM identifier + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier + { + $$ = &ast.ExprClassConstFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Const: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } +; + +expr: + variable + { + $$ = $1 + } + | expr_without_variable + { + $$ = $1 + } +; + +optional_expr: + /* empty */ + { + $$ = nil + } + | expr + { + $$ = $1 + } +; + +variable_class_name: + dereferencable + { + $$ = $1 + } +; + +dereferencable: + variable + { + $$ = $1 + } + | '(' expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } + | dereferencable_scalar + { + $$ = $1; + } +; + +callable_expr: + callable_variable + { + $$ = $1 + } + | '(' expr ')' + { + $$ = &ast.ExprBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenParenthesisTkn: $1, + Expr: $2, + CloseParenthesisTkn: $3, + } + } + | dereferencable_scalar + { + $$ = $1 + } +; + +callable_variable: + simple_variable + { + $$ = $1 + } + | dereferencable '[' optional_expr ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | constant '[' optional_expr ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | dereferencable '{' expr '}' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | dereferencable T_OBJECT_OPERATOR property_name argument_list + { + methodCall := &ast.ExprMethodCall{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Var: $1, + ObjectOperatorTkn: $2, + Method: $3, + OpenParenthesisTkn: $4.(*ArgumentList).OpenParenthesisTkn, + Args: $4.(*ArgumentList).Arguments, + SeparatorTkns: $4.(*ArgumentList).SeparatorTkns, + CloseParenthesisTkn: $4.(*ArgumentList).CloseParenthesisTkn, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + methodCall.OpenCurlyBracketTkn = brackets.OpenBracketTkn + methodCall.Method = brackets.Child + methodCall.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = methodCall + } + | function_call + { + $$ = $1 + } +; + +variable: + callable_variable + { + $$ = $1 + } + | static_member + { + $$ = $1 + } + | dereferencable T_OBJECT_OPERATOR property_name + { + propertyFetch := &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + ObjectOperatorTkn: $2, + Prop: $3, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + propertyFetch.OpenCurlyBracketTkn = brackets.OpenBracketTkn + propertyFetch.Prop = brackets.Child + propertyFetch.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = propertyFetch + } +; + +simple_variable: + T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | '$' '{' expr '}' + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + DollarTkn: $1, + OpenCurlyBracketTkn: $2, + Name: $3, + CloseCurlyBracketTkn: $4, + } + } + | '$' simple_variable + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + DollarTkn: $1, + Name: $2, + } + } +; + +static_member: + class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } +; + +new_variable: + simple_variable + { + $$ = $1 + } + | new_variable '[' optional_expr ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | new_variable '{' expr '}' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4), + Var: $1, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | new_variable T_OBJECT_OPERATOR property_name + { + propertyFetch := &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Var: $1, + ObjectOperatorTkn: $2, + Prop: $3, + } + + if brackets, ok := $3.(*ParserBrackets); ok { + propertyFetch.OpenCurlyBracketTkn = brackets.OpenBracketTkn + propertyFetch.Prop = brackets.Child + propertyFetch.CloseCurlyBracketTkn = brackets.CloseBracketTkn + } + + $$ = propertyFetch + } + | class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } + | new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable + { + $$ = &ast.ExprStaticPropertyFetch{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Class: $1, + DoubleColonTkn: $2, + Prop: $3, + } + } +; + +member_name: + identifier + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | '{' expr '}' + { + $$ = &ParserBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Child: $2, + CloseBracketTkn: $3, + } + } + | simple_variable + { + $$ = $1 + } +; + +property_name: + T_STRING + { + $$ = &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + } + } + | '{' expr '}' + { + $$ = &ParserBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenBracketTkn: $1, + Child: $2, + CloseBracketTkn: $3, + } + } + | simple_variable + { + $$ = $1 + } +; + +array_pair_list: + non_empty_array_pair_list + { + pairList := $1.(*ParserSeparatedList) + fistPair := pairList.Items[0].(*ast.ExprArrayItem) + + if fistPair.Key == nil && fistPair.Val == nil && len(pairList.Items) == 1 { + pairList.Items = nil + } + + $$ = $1 + } +; + +possible_array_pair: + /* empty */ + { + $$ = &ast.ExprArrayItem{} + } + | array_pair + { + $$ = $1 + } +; + +non_empty_array_pair_list: + non_empty_array_pair_list ',' possible_array_pair + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } + | possible_array_pair + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } +; + +array_pair: + expr T_DOUBLE_ARROW expr + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $3), + Key: $1, + DoubleArrowTkn: $2, + Val: $3, + } + } + | expr + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodePosition($1), + Val: $1, + } + } + | expr T_DOUBLE_ARROW '&' variable + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodesPosition($1, $4), + Key: $1, + DoubleArrowTkn: $2, + AmpersandTkn: $3, + Val: $4, + } + } + | '&' variable + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + AmpersandTkn: $1, + Val: $2, + } + } + | T_ELLIPSIS expr + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + EllipsisTkn: $1, + Val: $2, + } + } + | expr T_DOUBLE_ARROW T_LIST '(' array_pair_list ')' + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $6), + Key: $1, + DoubleArrowTkn: $2, + Val: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($3, $6), + ListTkn: $3, + OpenBracketTkn: $4, + Items: $5.(*ParserSeparatedList).Items, + SeparatorTkns: $5.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $6, + }, + } + } + | T_LIST '(' array_pair_list ')' + { + $$ = &ast.ExprArrayItem{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + Val: &ast.ExprList{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + ListTkn: $1, + OpenBracketTkn: $2, + Items: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseBracketTkn: $4, + }, + } + } +; + +encaps_list: + encaps_list encaps_var + { + $$ = append($1, $2) + } + | encaps_list T_ENCAPSED_AND_WHITESPACE + { + $$ = append( + $1, + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + EncapsedStrTkn: $2, + Value: $2.Value, + }, + ) + } + | encaps_var + { + $$ = []ast.Vertex{$1} + } + | T_ENCAPSED_AND_WHITESPACE encaps_var + { + $$ = []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + EncapsedStrTkn: $1, + Value: $1.Value, + }, + $2, + } + } +; + +encaps_var: + T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } + | T_VARIABLE '[' encaps_var_offset ']' + { + $$ = &ast.ExprArrayDimFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + OpenBracketTkn: $2, + Dim: $3, + CloseBracketTkn: $4, + } + } + | T_VARIABLE T_OBJECT_OPERATOR T_STRING + { + $$ = &ast.ExprPropertyFetch{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + Var: &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + }, + ObjectOperatorTkn: $2, + Prop: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($3), + IdentifierTkn: $3, + Value: $3.Value, + }, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES expr '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: $2, + CloseCurlyBracketTkn: $3, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + CloseCurlyBracketTkn: $3, + } + } + | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' + { + $$ = &ast.ScalarEncapsedStringVar{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + DollarOpenCurlyBracketTkn: $1, + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + IdentifierTkn: $2, + Value: $2.Value, + }, + OpenSquareBracketTkn: $3, + Dim: $4, + CloseSquareBracketTkn: $5, + CloseCurlyBracketTkn: $6, + } + } + | T_CURLY_OPEN variable '}' + { + $$ = &ast.ScalarEncapsedStringBrackets{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $3), + OpenCurlyBracketTkn: $1, + Var: $2, + CloseCurlyBracketTkn: $3, + } + } +; + +encaps_var_offset: + T_STRING + { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } + | T_NUM_STRING + { + // TODO: add option to handle 64 bit integer + if _, err := strconv.Atoi(string($1.Value)); err == nil { + $$ = &ast.ScalarLnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + NumberTkn: $1, + Value: $1.Value, + } + } else { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + StringTkn: $1, + Value: $1.Value, + } + } + } + | '-' T_NUM_STRING + { + _, err := strconv.Atoi(string($2.Value)); + isInt := err == nil + + if isInt { + $$ = &ast.ExprUnaryMinus{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + MinusTkn: $1, + Expr: &ast.ScalarLnumber{ + Position: yylex.(*Parser).builder.NewTokenPosition($2), + NumberTkn: $2, + Value: $2.Value, + }, + } + } else { + $$ = &ast.ScalarString{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $2), + MinusTkn: $1, + StringTkn: $2, + Value: append([]byte("-"), $2.Value...), + } + } + } + | T_VARIABLE + { + $$ = &ast.ExprVariable{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + Name: &ast.Identifier{ + Position: yylex.(*Parser).builder.NewTokenPosition($1), + IdentifierTkn: $1, + Value: $1.Value, + }, + } + } +; + +internal_functions_in_yacc: + T_ISSET '(' isset_variables possible_comma ')' + { + if $4 != nil { + $3.(*ParserSeparatedList).SeparatorTkns = append($3.(*ParserSeparatedList).SeparatorTkns, $4) + } + + $$ = &ast.ExprIsset{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $5), + IssetTkn: $1, + OpenParenthesisTkn: $2, + Vars: $3.(*ParserSeparatedList).Items, + SeparatorTkns: $3.(*ParserSeparatedList).SeparatorTkns, + CloseParenthesisTkn: $5, + } + } + | T_EMPTY '(' expr ')' + { + $$ = &ast.ExprEmpty{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + EmptyTkn: $1, + OpenParenthesisTkn: $2, + Expr: $3, + CloseParenthesisTkn: $4, + } + } + | T_INCLUDE expr + { + $$ = &ast.ExprInclude{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncludeTkn: $1, + Expr: $2, + } + } + | T_INCLUDE_ONCE expr + { + $$ = &ast.ExprIncludeOnce{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + IncludeOnceTkn: $1, + Expr: $2, + } + } + | T_EVAL '(' expr ')' + { + $$ = &ast.ExprEval{ + Position: yylex.(*Parser).builder.NewTokensPosition($1, $4), + EvalTkn: $1, + OpenParenthesisTkn: $2, + Expr: $3, + CloseParenthesisTkn: $4, + } + } + | T_REQUIRE expr + { + $$ = &ast.ExprRequire{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + RequireTkn: $1, + Expr: $2, + } + } + | T_REQUIRE_ONCE expr + { + $$ = &ast.ExprRequireOnce{ + Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $2), + RequireOnceTkn: $1, + Expr: $2, + } + } +; + +isset_variables: + isset_variable + { + $$ = &ParserSeparatedList{ + Items: []ast.Vertex{$1}, + } + } + | isset_variables ',' isset_variable + { + $1.(*ParserSeparatedList).SeparatorTkns = append($1.(*ParserSeparatedList).SeparatorTkns, $2) + $1.(*ParserSeparatedList).Items = append($1.(*ParserSeparatedList).Items, $3) + + $$ = $1 + } +; + +isset_variable: + expr + { + $$ = $1 + } +; + +///////////////////////////////////////////////////////////////////////// + +%% diff --git a/internal/php7/php7_bench_test.go b/internal/php7/php7_bench_test.go new file mode 100644 index 0000000..961688d --- /dev/null +++ b/internal/php7/php7_bench_test.go @@ -0,0 +1,31 @@ +package php7_test + +import ( + "io/ioutil" + "testing" + + "github.com/z7zmey/php-parser/internal/php7" + "github.com/z7zmey/php-parser/internal/scanner" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/version" +) + +func BenchmarkPhp7(b *testing.B) { + src, err := ioutil.ReadFile("test.php") + + if err != nil { + b.Fatal("can not read test.php: " + err.Error()) + } + + for n := 0; n < b.N; n++ { + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := scanner.NewLexer(src, config) + php7parser := php7.NewParser(lexer, config) + php7parser.Parse() + } +} diff --git a/internal/php7/test.php b/internal/php7/test.php new file mode 100644 index 0000000..1260892 --- /dev/null +++ b/internal/php7/test.php @@ -0,0 +1,350 @@ +bar($a, ...$b); +foo::bar($a, ...$b); +$foo::bar($a, ...$b); +new foo($a, ...$b); +/** anonymous class */ +new class ($a, ...$b) {}; +new class {}; +new $foo; +new $foo[1]; +new $foo{$bar}; +new $foo->bar; +new $foo::$bar; +new static::$bar; + +function foo(?bar $bar=null, baz &...$baz) {} +class foo {public function foo(?bar $bar=null, baz &...$baz) {}} +function(?bar $bar=null, baz &...$baz) {}; +static function(?bar $bar=null, baz &...$baz) {}; + +1234567890123456789; +12345678901234567890; +0.; +0b0111111111111111111111111111111111111111111111111111111111111111; +0b1111111111111111111111111111111111111111111111111111111111111111; +0x007111111111111111; +0x8111111111111111; +__CLASS__; +__DIR__; +__FILE__; +__FUNCTION__; +__LINE__; +__NAMESPACE__; +__METHOD__; +__TRAIT__; + +"test $var"; +"test $var[1]"; +"test $var[-1]"; +"test $var[1234567890123456789012345678901234567890]"; +"test $var[-1234567890123456789012345678901234567890]"; +"test $var[bar]"; +"test $var[$bar]"; +"$foo $bar"; +"test $foo->bar()"; +"test ${foo}"; +"test ${foo[0]}"; +"test ${$foo}"; +"test {$foo->bar()}"; + +if ($a) : +endif; +if ($a) : +elseif ($b): +endif; +if ($a) : +else: +endif; +if ($a) : +elseif ($b): +elseif ($c): +else: +endif; + +while (1) { break; } +while (1) { break 2; } +while (1) : break(3); endwhile; +class foo{ public const FOO = 1, BAR = 2; } +class foo{ const FOO = 1, BAR = 2; } +class foo{ function bar() {} } +class foo{ public static function &bar() {} } +class foo{ public static function &bar(): void {} } +abstract class foo{ } +final class foo extends bar { } +final class foo implements bar { } +final class foo implements bar, baz { } +new class() extends foo implements bar, baz { }; + +const FOO = 1, BAR = 2; +while (1) { continue; } +while (1) { continue 2; } +while (1) { continue(3); } +declare(ticks=1); +declare(ticks=1) {} +declare(ticks=1): enddeclare; +do {} while(1); +echo $a, 1; +echo($a); +for($i = 0; $i < 10; $i++, $i++) {} +for(; $i < 10; $i++, $i++) : endfor; +foreach ($a as $v) {} +foreach ($a as $v) : endforeach; +foreach ($a as $k => $v) {} +foreach ($a as $k => &$v) {} +foreach ($a as $k => list($v)) {} +foreach ($a as $k => [$v]) {} +function foo() {} +function foo() {return;} +function &foo() {return 1;} +function &foo(): void {} +global $a, $b; +a: +goto a; +if ($a) {} +if ($a) {} elseif ($b) {} +if ($a) {} else {} +if ($a) {} elseif ($b) {} elseif ($c) {} else {} +if ($a) {} elseif ($b) {} else if ($c) {} else {} +?>
1, &$b,); +~$a; +!$a; + +Foo::Bar; +$foo::Bar; +clone($a); +clone $a; +function(){}; +function($a, $b) use ($c, &$d) {}; +function(): void {}; +foo; +namespace\foo; +\foo; + +empty($a); +@$a; +eval($a); +exit; +exit($a); +die; +die($a); +foo(); +namespace\foo(); +\foo(); +$foo(); + +$a--; +$a++; +--$a; +++$a; + +include $a; +include_once $a; +require $a; +require_once $a; + +$a instanceof Foo; +$a instanceof namespace\Foo; +$a instanceof \Foo; + +isset($a, $b); +list($a) = $b; +list($a[]) = $b; +list(list($a)) = $b; + +$a->foo(); +new Foo(); +new namespace\Foo(); +new \Foo(); +new class ($a, ...$b) {}; +print($a); +$a->foo; +`cmd $a`; +`cmd`; +``; +[]; +[1]; +[1=>1, &$b,]; + +[$a] = $b; +[$a[]] = $b; +[list($a)] = $b; +Foo::bar(); +namespace\Foo::bar(); +\Foo::bar(); +Foo::$bar; +$foo::$bar; +namespace\Foo::$bar; +\Foo::$bar; +$a ? $b : $c; +$a ? : $c; +$a ? $b ? $c : $d : $e; +$a ? $b : $c ? $d : $e; +-$a; ++$a; +$$a; +yield; +yield $a; +yield $a => $b; +yield from $a; + +(array)$a; +(boolean)$a; +(bool)$a; +(double)$a; +(float)$a; +(integer)$a; +(int)$a; +(object)$a; +(string)$a; +(unset)$a; + +$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 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; +$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; + +class foo {public function class() {} } +\foo\bar(); + +function foo(&$a, ...$b) { + + function bar() {} + class Baz {} + trait Quux{} + interface Quuux {} +} + +function foo(&$a = 1, ...$b = 1, $c = 1) {} +function foo(array $a, callable $b) {} +abstract final class foo { abstract protected static function bar(); final private function baz() {} } + +(new Foo)->bar; +(new Foo)(); +[$foo][0](); +foo[1](); +"foo"(); +[1]{$foo}(); +${foo()}; + +Foo::$bar(); +Foo::{$bar[0]}(); + +$foo->$bar; +$foo->{$bar[0]}; + +[1=>&$a, 2=>list($b)]; + +__halt_compiler(); + +parsing process must be terminated \ No newline at end of file diff --git a/internal/position/position.go b/internal/position/position.go new file mode 100644 index 0000000..e6be89a --- /dev/null +++ b/internal/position/position.go @@ -0,0 +1,237 @@ +package position + +import ( + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" +) + +type startPos struct { + startLine int + startPos int +} + +type endPos struct { + endLine int + endPos int +} + +type Builder struct { + pool *position.Pool +} + +func NewBuilder() *Builder { + return &Builder{ + pool: position.NewPool(position.DefaultBlockSize), + } +} + +func getListStartPos(l []ast.Vertex) startPos { + if l == nil { + return startPos{-1, -1} + } + + if len(l) == 0 { + return startPos{-1, -1} + } + + return getNodeStartPos(l[0]) +} + +func getNodeStartPos(n ast.Vertex) startPos { + sl := -1 + sp := -1 + + if n == nil { + return startPos{-1, -1} + } + + p := n.GetPosition() + if p != nil { + sl = p.StartLine + sp = p.StartPos + } + + return startPos{sl, sp} +} + +func getListEndPos(l []ast.Vertex) endPos { + if l == nil { + return endPos{-1, -1} + } + + if len(l) == 0 { + return endPos{-1, -1} + } + + return getNodeEndPos(l[len(l)-1]) +} + +func getNodeEndPos(n ast.Vertex) endPos { + el := -1 + ep := -1 + + if n == nil { + return endPos{-1, -1} + } + + p := n.GetPosition() + if p != nil { + el = p.EndLine + ep = p.EndPos + } + + return endPos{el, ep} +} + +// NewNodeListPosition returns new Position +func (b *Builder) NewNodeListPosition(list []ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getListStartPos(list).startLine + pos.EndLine = getListEndPos(list).endLine + pos.StartPos = getListStartPos(list).startPos + pos.EndPos = getListEndPos(list).endPos + + return pos +} + +// NewNodePosition returns new Position +func (b *Builder) NewNodePosition(n ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getNodeStartPos(n).startLine + pos.EndLine = getNodeEndPos(n).endLine + pos.StartPos = getNodeStartPos(n).startPos + pos.EndPos = getNodeEndPos(n).endPos + + return pos +} + +// NewTokenPosition returns new Position +func (b *Builder) NewTokenPosition(t *token.Token) *position.Position { + pos := b.pool.Get() + + pos.StartLine = t.Position.StartLine + pos.EndLine = t.Position.EndLine + pos.StartPos = t.Position.StartPos + pos.EndPos = t.Position.EndPos + + return pos +} + +// NewTokensPosition returns new Position +func (b *Builder) NewTokensPosition(startToken *token.Token, endToken *token.Token) *position.Position { + pos := b.pool.Get() + + pos.StartLine = startToken.Position.StartLine + pos.EndLine = endToken.Position.EndLine + pos.StartPos = startToken.Position.StartPos + pos.EndPos = endToken.Position.EndPos + + return pos +} + +// NewTokenNodePosition returns new Position +func (b *Builder) NewTokenNodePosition(t *token.Token, n ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = t.Position.StartLine + pos.EndLine = getNodeEndPos(n).endLine + pos.StartPos = t.Position.StartPos + pos.EndPos = getNodeEndPos(n).endPos + + return pos +} + +// NewNodeTokenPosition returns new Position +func (b *Builder) NewNodeTokenPosition(n ast.Vertex, t *token.Token) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getNodeStartPos(n).startLine + pos.EndLine = t.Position.EndLine + pos.StartPos = getNodeStartPos(n).startPos + pos.EndPos = t.Position.EndPos + + return pos +} + +// NewNodesPosition returns new Position +func (b *Builder) NewNodesPosition(startNode ast.Vertex, endNode ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getNodeStartPos(startNode).startLine + pos.EndLine = getNodeEndPos(endNode).endLine + pos.StartPos = getNodeStartPos(startNode).startPos + pos.EndPos = getNodeEndPos(endNode).endPos + + return pos +} + +// NewNodeListTokenPosition returns new Position +func (b *Builder) NewNodeListTokenPosition(list []ast.Vertex, t *token.Token) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getListStartPos(list).startLine + pos.EndLine = t.Position.EndLine + pos.StartPos = getListStartPos(list).startPos + pos.EndPos = t.Position.EndPos + + return pos +} + +// NewTokenNodeListPosition returns new Position +func (b *Builder) NewTokenNodeListPosition(t *token.Token, list []ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = t.Position.StartLine + pos.EndLine = getListEndPos(list).endLine + pos.StartPos = t.Position.StartPos + pos.EndPos = getListEndPos(list).endPos + + return pos +} + +// NewNodeNodeListPosition returns new Position +func (b *Builder) NewNodeNodeListPosition(n ast.Vertex, list []ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getNodeStartPos(n).startLine + pos.EndLine = getListEndPos(list).endLine + pos.StartPos = getNodeStartPos(n).startPos + pos.EndPos = getListEndPos(list).endPos + + return pos +} + +// NewNodeListNodePosition returns new Position +func (b *Builder) NewNodeListNodePosition(list []ast.Vertex, n ast.Vertex) *position.Position { + pos := b.pool.Get() + + pos.StartLine = getListStartPos(list).startLine + pos.EndLine = getNodeEndPos(n).endLine + pos.StartPos = getListStartPos(list).startPos + pos.EndPos = getNodeEndPos(n).endPos + + return pos +} + +// NewOptionalListTokensPosition returns new Position +func (b *Builder) NewOptionalListTokensPosition(list []ast.Vertex, t *token.Token, endToken *token.Token) *position.Position { + pos := b.pool.Get() + + if list == nil { + pos.StartLine = t.Position.StartLine + pos.EndLine = endToken.Position.EndLine + pos.StartPos = t.Position.StartPos + pos.EndPos = endToken.Position.EndPos + + return pos + } + pos.StartLine = getListStartPos(list).startLine + pos.EndLine = endToken.Position.EndLine + pos.StartPos = getListStartPos(list).startPos + pos.EndPos = endToken.Position.EndPos + + return pos +} diff --git a/internal/position/position_test.go b/internal/position/position_test.go new file mode 100644 index 0000000..4609179 --- /dev/null +++ b/internal/position/position_test.go @@ -0,0 +1,431 @@ +package position_test + +import ( + "gotest.tools/assert" + "testing" + + builder "github.com/z7zmey/php-parser/internal/position" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" +) + +func TestNewTokenPosition(t *testing.T) { + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + + pos := builder.NewBuilder().NewTokenPosition(tkn) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 1, EndPos: 3}, pos) +} + +func TestNewTokensPosition(t *testing.T) { + token1 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + token2 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 4, + EndPos: 6, + }, + } + + pos := builder.NewBuilder().NewTokensPosition(token1, token2) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 6}, pos) +} + +func TestNewNodePosition(t *testing.T) { + n := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + + pos := builder.NewBuilder().NewNodePosition(n) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 1, EndPos: 3}, pos) +} + +func TestNewTokenNodePosition(t *testing.T) { + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + n := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 4, + EndPos: 12, + }, + } + + pos := builder.NewBuilder().NewTokenNodePosition(tkn, n) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 12}, pos) +} + +func TestNewNodeTokenPosition(t *testing.T) { + n := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 9, + }, + } + + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 10, + EndPos: 12, + }, + } + + pos := builder.NewBuilder().NewNodeTokenPosition(n, tkn) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 12}, pos) +} + +func TestNewNodeListPosition(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 9, + }, + } + + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 10, + EndPos: 19, + }, + } + + pos := builder.NewBuilder().NewNodeListPosition([]ast.Vertex{n1, n2}) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 19}, pos) +} + +func TestNewNodesPosition(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 9, + }, + } + + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 10, + EndPos: 19, + }, + } + + pos := builder.NewBuilder().NewNodesPosition(n1, n2) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 19}, pos) +} + +func TestNewNodeListTokenPosition(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 9, + }, + } + + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 10, + EndPos: 19, + }, + } + + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 20, + EndPos: 22, + }, + } + + pos := builder.NewBuilder().NewNodeListTokenPosition([]ast.Vertex{n1, n2}, tkn) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 3, EndPos: 22}, pos) +} + +func TestNewTokenNodeListPosition(t *testing.T) { + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 2, + }, + } + + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 3, + EndPos: 10, + }, + } + + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 11, + EndPos: 20, + }, + } + + pos := builder.NewBuilder().NewTokenNodeListPosition(tkn, []ast.Vertex{n1, n2}) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 3, EndPos: 20}, pos) +} + +func TestNewNodeNodeListPosition(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 8, + }, + } + + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 9, + EndPos: 17, + }, + } + + n3 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 18, + EndPos: 26, + }, + } + + pos := builder.NewBuilder().NewNodeNodeListPosition(n1, []ast.Vertex{n2, n3}) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 3, EndPos: 26}, pos) +} + +func TestNewNodeListNodePosition(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 8, + }, + } + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 9, + EndPos: 17, + }, + } + n3 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 18, + EndPos: 26, + }, + } + + pos := builder.NewBuilder().NewNodeListNodePosition([]ast.Vertex{n1, n2}, n3) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 3, EndPos: 26}, pos) +} + +func TestNewOptionalListTokensPosition(t *testing.T) { + token1 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + token2 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 4, + EndPos: 6, + }, + } + + pos := builder.NewBuilder().NewOptionalListTokensPosition(nil, token1, token2) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: 2, EndPos: 6}, pos) +} + +func TestNewOptionalListTokensPosition2(t *testing.T) { + n2 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 2, + EndLine: 2, + StartPos: 9, + EndPos: 17, + }, + } + n3 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 3, + EndLine: 3, + StartPos: 18, + EndPos: 26, + }, + } + + token1 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 4, + EndLine: 4, + StartPos: 27, + EndPos: 29, + }, + } + token2 := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 5, + EndLine: 5, + StartPos: 30, + EndPos: 32, + }, + } + + pos := builder.NewBuilder().NewOptionalListTokensPosition([]ast.Vertex{n2, n3}, token1, token2) + + assert.DeepEqual(t, &position.Position{StartLine: 2, EndLine: 5, StartPos: 9, EndPos: 32}, pos) +} + +func TestNilNodePos(t *testing.T) { + pos := builder.NewBuilder().NewNodesPosition(nil, nil) + + assert.DeepEqual(t, &position.Position{StartLine: -1, EndLine: -1, StartPos: -1, EndPos: -1}, pos) +} + +func TestNilNodeListPos(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 8, + }, + } + + pos := builder.NewBuilder().NewNodeNodeListPosition(n1, nil) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: -1, EndPos: -1}, pos) +} + +func TestNilNodeListTokenPos(t *testing.T) { + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + + pos := builder.NewBuilder().NewNodeListTokenPosition(nil, tkn) + + assert.DeepEqual(t, &position.Position{StartLine: -1, EndLine: 1, StartPos: -1, EndPos: 3}, pos) +} + +func TestEmptyNodeListPos(t *testing.T) { + n1 := &ast.Identifier{ + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 8, + }, + } + + pos := builder.NewBuilder().NewNodeNodeListPosition(n1, []ast.Vertex{}) + + assert.DeepEqual(t, &position.Position{StartLine: 1, EndLine: -1, EndPos: -1}, pos) +} + +func TestEmptyNodeListTokenPos(t *testing.T) { + tkn := &token.Token{ + Value: []byte(`foo`), + Position: &position.Position{ + StartLine: 1, + EndLine: 1, + StartPos: 0, + EndPos: 3, + }, + } + + pos := builder.NewBuilder().NewNodeListTokenPosition([]ast.Vertex{}, tkn) + + assert.DeepEqual(t, &position.Position{StartLine: -1, EndLine: 1, StartPos: -1, EndPos: 3}, pos) +} diff --git a/scanner/lexer.go b/internal/scanner/lexer.go similarity index 56% rename from scanner/lexer.go rename to internal/scanner/lexer.go index 42e46ff..eea6e16 100644 --- a/scanner/lexer.go +++ b/internal/scanner/lexer.go @@ -4,103 +4,71 @@ import ( "bytes" "strings" - "github.com/z7zmey/php-parser/errors" - "github.com/z7zmey/php-parser/freefloating" - "github.com/z7zmey/php-parser/position" - "github.com/z7zmey/php-parser/version" + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "github.com/z7zmey/php-parser/pkg/version" ) -type Scanner interface { - Lex(lval Lval) int - ReturnTokenToPool(t *Token) - GetPhpDocComment() string - SetPhpDocComment(string) - GetErrors() []*errors.Error - GetWithFreeFloating() bool - SetWithFreeFloating(bool) - AddError(e *errors.Error) - SetErrors(e []*errors.Error) -} - -// Lval parsers yySymType must implement this interface -type Lval interface { - Token(tkn *Token) -} - type Lexer struct { - data []byte - p, pe, cs int - ts, te, act int - stack []int - top int + data []byte + phpVersion *version.Version + errHandlerFunc func(*errors.Error) + + p, pe, cs int + ts, te, act int + stack []int + top int + heredocLabel []byte - - TokenPool *TokenPool - FreeFloating []freefloating.String - WithFreeFloating bool - PhpDocComment string - lastToken *Token - Errors []*errors.Error - NewLines NewLines - PHPVersion string + tokenPool *token.Pool + positionPool *position.Pool + newLines NewLines } -func (l *Lexer) ReturnTokenToPool(t *Token) { - l.TokenPool.Put(t) -} +func NewLexer(data []byte, config cfg.Config) *Lexer { + lex := &Lexer{ + data: data, + phpVersion: config.Version, + errHandlerFunc: config.ErrorHandlerFunc, -func (l *Lexer) GetPhpDocComment() string { - return l.PhpDocComment -} + pe: len(data), + stack: make([]int, 0), -func (l *Lexer) SetPhpDocComment(s string) { - l.PhpDocComment = s -} - -func (l *Lexer) GetErrors() []*errors.Error { - return l.Errors -} - -func (l *Lexer) GetWithFreeFloating() bool { - return l.WithFreeFloating -} - -func (l *Lexer) SetWithFreeFloating(b bool) { - l.WithFreeFloating = b -} - -func (l *Lexer) AddError(e *errors.Error) { - l.Errors = append(l.Errors, e) -} - -func (l *Lexer) SetErrors(e []*errors.Error) { - l.Errors = e -} - -func (lex *Lexer) setTokenPosition(token *Token) { - token.StartLine = lex.NewLines.GetLine(lex.ts) - token.EndLine = lex.NewLines.GetLine(lex.te - 1) - token.StartPos = lex.ts - token.EndPos = lex.te -} - -func (lex *Lexer) addFreeFloating(t freefloating.StringType, ps, pe int) { - if !lex.WithFreeFloating { - return + tokenPool: token.NewPool(position.DefaultBlockSize), + positionPool: position.NewPool(token.DefaultBlockSize), + newLines: NewLines{make([]int, 0, 128)}, } - pos := position.NewPosition( - lex.NewLines.GetLine(lex.ts), - lex.NewLines.GetLine(lex.te-1), - lex.ts, - lex.te, - ) + initLexer(lex) - lex.FreeFloating = append(lex.FreeFloating, freefloating.String{ - StringType: t, - Value: string(lex.data[ps:pe]), - Position: pos, - }) + return lex +} + +func (lex *Lexer) setTokenPosition(token *token.Token) { + pos := lex.positionPool.Get() + + pos.StartLine = lex.newLines.GetLine(lex.ts) + pos.EndLine = lex.newLines.GetLine(lex.te - 1) + pos.StartPos = lex.ts + pos.EndPos = lex.te + + token.Position = pos +} + +func (lex *Lexer) addFreeFloatingToken(t *token.Token, id token.ID, ps, pe int) { + skippedTkn := lex.tokenPool.Get() + skippedTkn.ID = id + skippedTkn.Value = lex.data[ps:pe] + + lex.setTokenPosition(skippedTkn) + + if t.FreeFloating == nil { + t.FreeFloating = make([]*token.Token, 0, 2) + } + + t.FreeFloating = append(t.FreeFloating, skippedTkn) } func (lex *Lexer) isNotStringVar() bool { @@ -134,16 +102,16 @@ func (lex *Lexer) isNotStringEnd(s byte) bool { } func (lex *Lexer) isHeredocEnd(p int) bool { - r, err := version.Compare(lex.PHPVersion, "7.3") + o, err := version.New("7.3") if err != nil { + panic(err) + } + + if lex.phpVersion.GreaterOrEqual(o) { return lex.isHeredocEndSince73(p) } - if r == -1 { - return lex.isHeredocEndBefore73(p) - } - - return lex.isHeredocEndSince73(p) + return lex.isHeredocEndBefore73(p) } func (lex *Lexer) isHeredocEndBefore73(p int) bool { @@ -255,21 +223,25 @@ func (lex *Lexer) ungetCnt(n int) { lex.te = lex.te - n } -func (lex *Lexer) Error(msg string) { +func (lex *Lexer) error(msg string) { + if lex.errHandlerFunc == nil { + return + } + pos := position.NewPosition( - lex.NewLines.GetLine(lex.ts), - lex.NewLines.GetLine(lex.te-1), + lex.newLines.GetLine(lex.ts), + lex.newLines.GetLine(lex.te-1), lex.ts, lex.te, ) - lex.Errors = append(lex.Errors, errors.NewError(msg, pos)) + lex.errHandlerFunc(errors.NewError(msg, pos)) } func isValidVarNameStart(r byte) bool { - return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || r == '_' || (r >= 0x80 && r <= 0xff) + return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || r == '_' || r >= 0x80 } func isValidVarName(r byte) bool { - return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' || (r >= 0x80 && r <= 0xff) + return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' || r >= 0x80 } diff --git a/scanner/newline.go b/internal/scanner/newline.go similarity index 100% rename from scanner/newline.go rename to internal/scanner/newline.go diff --git a/scanner/scanner.go b/internal/scanner/scanner.go similarity index 87% rename from scanner/scanner.go rename to internal/scanner/scanner.go index 3851d6b..7fd94d1 100644 Binary files a/scanner/scanner.go and b/internal/scanner/scanner.go differ diff --git a/scanner/scanner.rl b/internal/scanner/scanner.rl similarity index 56% rename from scanner/scanner.rl rename to internal/scanner/scanner.rl index 9890adc..812c742 100644 --- a/scanner/scanner.rl +++ b/internal/scanner/scanner.rl @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/z7zmey/php-parser/freefloating" + "github.com/z7zmey/php-parser/pkg/token" ) %%{ @@ -16,27 +16,15 @@ import ( variable pe lex.pe; }%% -func NewLexer(data []byte) *Lexer { - lex := &Lexer{ - data: data, - pe: len(data), - stack: make([]int, 0), - - TokenPool: &TokenPool{}, - NewLines: NewLines{make([]int, 0, 128)}, - } +func initLexer(lex *Lexer) { %% write init; - return lex } -func (lex *Lexer) Lex(lval Lval) int { - lex.FreeFloating = nil +func (lex *Lexer) Lex() *token.Token { eof := lex.pe - var tok TokenID + var tok token.ID - token := lex.TokenPool.Get() - token.FreeFloating = lex.FreeFloating - token.Value = string(lex.data[0:0]) + tkn := lex.tokenPool.Get() lblStart := 0 lblEnd := 0 @@ -49,11 +37,11 @@ func (lex *Lexer) Lex(lval Lval) int { action new_line { if lex.data[lex.p] == '\n' { - lex.NewLines.Append(lex.p+1) + lex.newLines.Append(lex.p+1) } if lex.data[lex.p] == '\r' && lex.data[lex.p+1] != '\n' { - lex.NewLines.Append(lex.p+1) + lex.newLines.Append(lex.p+1) } } @@ -127,16 +115,17 @@ func (lex *Lexer) Lex(lval Lval) int { | '"' -> final ), double_qoute_nonvarname: ( - (any - [\\{"\r\n] - varname_first) -> double_qoute - | "\r" @new_line -> double_qoute - | "\n" @new_line -> double_qoute - | "\\" -> double_qoute_any - | '"' -> final + (any - [\\${"\r\n] - varname_first) -> double_qoute + | "\r" @new_line -> double_qoute + | "\n" @new_line -> double_qoute + | "\\" -> double_qoute_any + | '$' -> double_qoute_nonvarname + | '"' -> final ); main := |* "#!" any* :>> newline => { - lex.addFreeFloating(freefloating.CommentType, lex.ts, lex.te) + lex.addFreeFloatingToken(tkn, token.T_COMMENT, lex.ts, lex.te) }; any => { fnext html; @@ -147,42 +136,42 @@ func (lex *Lexer) Lex(lval Lval) int { html := |* any_line+ -- ' { lex.ungetStr("<") - lex.setTokenPosition(token) - tok = T_INLINE_HTML; + lex.setTokenPosition(tkn) + tok = token.T_INLINE_HTML; fbreak; }; ' { - lex.addFreeFloating(freefloating.TokenType, lex.ts, lex.te) + lex.addFreeFloatingToken(tkn, token.T_OPEN_TAG, lex.ts, lex.te) fnext php; }; ' { lex.ungetCnt(lex.te - lex.ts - 5) - lex.addFreeFloating(freefloating.TokenType, lex.ts, lex.ts+5) + lex.addFreeFloatingToken(tkn, token.T_OPEN_TAG, lex.ts, lex.ts+5) fnext php; }; ' { - lex.setTokenPosition(token); - tok = T_ECHO; + lex.setTokenPosition(tkn); + tok = token.T_ECHO; fnext php; fbreak; }; *|; php := |* - whitespace_line* => {lex.addFreeFloating(freefloating.WhiteSpaceType, lex.ts, lex.te)}; - '?>' newline? => {lex.setTokenPosition(token); tok = TokenID(int(';')); fnext html; fbreak;}; - ';' whitespace_line* '?>' newline? => {lex.setTokenPosition(token); tok = TokenID(int(';')); fnext html; fbreak;}; + whitespace_line* => {lex.addFreeFloatingToken(tkn, token.T_WHITESPACE, lex.ts, lex.te)}; + '?>' newline? => {lex.setTokenPosition(tkn); tok = token.ID(int(';')); fnext html; fbreak;}; + ';' whitespace_line* '?>' newline? => {lex.setTokenPosition(tkn); tok = token.ID(int(';')); fnext html; fbreak;}; - (dnum | exponent_dnum) => {lex.setTokenPosition(token); tok = T_DNUMBER; fbreak;}; + (dnum | exponent_dnum) => {lex.setTokenPosition(tkn); tok = token.T_DNUMBER; fbreak;}; bnum => { s := strings.Replace(string(lex.data[lex.ts+2:lex.te]), "_", "", -1) _, err := strconv.ParseInt(s, 2, 0) if err == nil { - lex.setTokenPosition(token); tok = T_LNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_LNUMBER; fbreak; } - lex.setTokenPosition(token); tok = T_DNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_DNUMBER; fbreak; }; lnum => { base := 10 @@ -194,180 +183,179 @@ func (lex *Lexer) Lex(lval Lval) int { _, err := strconv.ParseInt(s, base, 0) if err == nil { - lex.setTokenPosition(token); tok = T_LNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_LNUMBER; fbreak; } - lex.setTokenPosition(token); tok = T_DNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_DNUMBER; fbreak; }; hnum => { s := strings.Replace(string(lex.data[lex.ts+2:lex.te]), "_", "", -1) _, err := strconv.ParseInt(s, 16, 0) if err == nil { - lex.setTokenPosition(token); tok = T_LNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_LNUMBER; fbreak; } - lex.setTokenPosition(token); tok = T_DNUMBER; fbreak; + lex.setTokenPosition(tkn); tok = token.T_DNUMBER; fbreak; }; - 'abstract'i => {lex.setTokenPosition(token); tok = T_ABSTRACT; fbreak;}; - 'array'i => {lex.setTokenPosition(token); tok = T_ARRAY; fbreak;}; - 'as'i => {lex.setTokenPosition(token); tok = T_AS; fbreak;}; - 'break'i => {lex.setTokenPosition(token); tok = T_BREAK; fbreak;}; - 'callable'i => {lex.setTokenPosition(token); tok = T_CALLABLE; fbreak;}; - 'case'i => {lex.setTokenPosition(token); tok = T_CASE; fbreak;}; - 'catch'i => {lex.setTokenPosition(token); tok = T_CATCH; fbreak;}; - 'class'i => {lex.setTokenPosition(token); tok = T_CLASS; fbreak;}; - 'clone'i => {lex.setTokenPosition(token); tok = T_CLONE; fbreak;}; - 'const'i => {lex.setTokenPosition(token); tok = T_CONST; fbreak;}; - 'continue'i => {lex.setTokenPosition(token); tok = T_CONTINUE; fbreak;}; - 'declare'i => {lex.setTokenPosition(token); tok = T_DECLARE; fbreak;}; - 'default'i => {lex.setTokenPosition(token); tok = T_DEFAULT; fbreak;}; - 'do'i => {lex.setTokenPosition(token); tok = T_DO; fbreak;}; - 'echo'i => {lex.setTokenPosition(token); tok = T_ECHO; fbreak;}; - 'else'i => {lex.setTokenPosition(token); tok = T_ELSE; fbreak;}; - 'elseif'i => {lex.setTokenPosition(token); tok = T_ELSEIF; fbreak;}; - 'empty'i => {lex.setTokenPosition(token); tok = T_EMPTY; fbreak;}; - 'enddeclare'i => {lex.setTokenPosition(token); tok = T_ENDDECLARE; fbreak;}; - 'endfor'i => {lex.setTokenPosition(token); tok = T_ENDFOR; fbreak;}; - 'endforeach'i => {lex.setTokenPosition(token); tok = T_ENDFOREACH; fbreak;}; - 'endif'i => {lex.setTokenPosition(token); tok = T_ENDIF; fbreak;}; - 'endswitch'i => {lex.setTokenPosition(token); tok = T_ENDSWITCH; fbreak;}; - 'endwhile'i => {lex.setTokenPosition(token); tok = T_ENDWHILE; fbreak;}; - 'eval'i => {lex.setTokenPosition(token); tok = T_EVAL; fbreak;}; - 'exit'i | 'die'i => {lex.setTokenPosition(token); tok = T_EXIT; fbreak;}; - 'extends'i => {lex.setTokenPosition(token); tok = T_EXTENDS; fbreak;}; - 'final'i => {lex.setTokenPosition(token); tok = T_FINAL; fbreak;}; - 'finally'i => {lex.setTokenPosition(token); tok = T_FINALLY; fbreak;}; - 'for'i => {lex.setTokenPosition(token); tok = T_FOR; fbreak;}; - 'foreach'i => {lex.setTokenPosition(token); tok = T_FOREACH; fbreak;}; - 'function'i | 'cfunction'i => {lex.setTokenPosition(token); tok = T_FUNCTION; fbreak;}; - 'fn'i => {lex.setTokenPosition(token); tok = T_FN; fbreak;}; - 'global'i => {lex.setTokenPosition(token); tok = T_GLOBAL; fbreak;}; - 'goto'i => {lex.setTokenPosition(token); tok = T_GOTO; fbreak;}; - 'if'i => {lex.setTokenPosition(token); tok = T_IF; fbreak;}; - 'isset'i => {lex.setTokenPosition(token); tok = T_ISSET; fbreak;}; - 'implements'i => {lex.setTokenPosition(token); tok = T_IMPLEMENTS; fbreak;}; - 'instanceof'i => {lex.setTokenPosition(token); tok = T_INSTANCEOF; fbreak;}; - 'insteadof'i => {lex.setTokenPosition(token); tok = T_INSTEADOF; fbreak;}; - 'interface'i => {lex.setTokenPosition(token); tok = T_INTERFACE; fbreak;}; - 'list'i => {lex.setTokenPosition(token); tok = T_LIST; fbreak;}; - 'namespace'i => {lex.setTokenPosition(token); tok = T_NAMESPACE; fbreak;}; - 'private'i => {lex.setTokenPosition(token); tok = T_PRIVATE; fbreak;}; - 'public'i => {lex.setTokenPosition(token); tok = T_PUBLIC; fbreak;}; - 'print'i => {lex.setTokenPosition(token); tok = T_PRINT; fbreak;}; - 'protected'i => {lex.setTokenPosition(token); tok = T_PROTECTED; fbreak;}; - 'return'i => {lex.setTokenPosition(token); tok = T_RETURN; fbreak;}; - 'static'i => {lex.setTokenPosition(token); tok = T_STATIC; fbreak;}; - 'switch'i => {lex.setTokenPosition(token); tok = T_SWITCH; fbreak;}; - 'throw'i => {lex.setTokenPosition(token); tok = T_THROW; fbreak;}; - 'trait'i => {lex.setTokenPosition(token); tok = T_TRAIT; fbreak;}; - 'try'i => {lex.setTokenPosition(token); tok = T_TRY; fbreak;}; - 'unset'i => {lex.setTokenPosition(token); tok = T_UNSET; fbreak;}; - 'use'i => {lex.setTokenPosition(token); tok = T_USE; fbreak;}; - 'var'i => {lex.setTokenPosition(token); tok = T_VAR; fbreak;}; - 'while'i => {lex.setTokenPosition(token); tok = T_WHILE; fbreak;}; - 'yield'i whitespace_line* 'from'i => {lex.setTokenPosition(token); tok = T_YIELD_FROM; fbreak;}; - 'yield'i => {lex.setTokenPosition(token); tok = T_YIELD; fbreak;}; - 'include'i => {lex.setTokenPosition(token); tok = T_INCLUDE; fbreak;}; - 'include_once'i => {lex.setTokenPosition(token); tok = T_INCLUDE_ONCE; fbreak;}; - 'require'i => {lex.setTokenPosition(token); tok = T_REQUIRE; fbreak;}; - 'require_once'i => {lex.setTokenPosition(token); tok = T_REQUIRE_ONCE; fbreak;}; - '__CLASS__'i => {lex.setTokenPosition(token); tok = T_CLASS_C; fbreak;}; - '__DIR__'i => {lex.setTokenPosition(token); tok = T_DIR; fbreak;}; - '__FILE__'i => {lex.setTokenPosition(token); tok = T_FILE; fbreak;}; - '__FUNCTION__'i => {lex.setTokenPosition(token); tok = T_FUNC_C; fbreak;}; - '__LINE__'i => {lex.setTokenPosition(token); tok = T_LINE; fbreak;}; - '__NAMESPACE__'i => {lex.setTokenPosition(token); tok = T_NS_C; fbreak;}; - '__METHOD__'i => {lex.setTokenPosition(token); tok = T_METHOD_C; fbreak;}; - '__TRAIT__'i => {lex.setTokenPosition(token); tok = T_TRAIT_C; fbreak;}; - '__halt_compiler'i => {lex.setTokenPosition(token); tok = T_HALT_COMPILER; fnext halt_compiller_open_parenthesis; fbreak;}; - 'new'i => {lex.setTokenPosition(token); tok = T_NEW; fbreak;}; - 'and'i => {lex.setTokenPosition(token); tok = T_LOGICAL_AND; fbreak;}; - 'or'i => {lex.setTokenPosition(token); tok = T_LOGICAL_OR; fbreak;}; - 'xor'i => {lex.setTokenPosition(token); tok = T_LOGICAL_XOR; fbreak;}; - '\\' => {lex.setTokenPosition(token); tok = T_NS_SEPARATOR; fbreak;}; - '...' => {lex.setTokenPosition(token); tok = T_ELLIPSIS; fbreak;}; - '::' => {lex.setTokenPosition(token); tok = T_PAAMAYIM_NEKUDOTAYIM; fbreak;}; - '&&' => {lex.setTokenPosition(token); tok = T_BOOLEAN_AND; fbreak;}; - '||' => {lex.setTokenPosition(token); tok = T_BOOLEAN_OR; fbreak;}; - '&=' => {lex.setTokenPosition(token); tok = T_AND_EQUAL; fbreak;}; - '|=' => {lex.setTokenPosition(token); tok = T_OR_EQUAL; fbreak;}; - '.=' => {lex.setTokenPosition(token); tok = T_CONCAT_EQUAL; fbreak;}; - '*=' => {lex.setTokenPosition(token); tok = T_MUL_EQUAL; fbreak;}; - '**=' => {lex.setTokenPosition(token); tok = T_POW_EQUAL; fbreak;}; - '/=' => {lex.setTokenPosition(token); tok = T_DIV_EQUAL; fbreak;}; - '+=' => {lex.setTokenPosition(token); tok = T_PLUS_EQUAL; fbreak;}; - '-=' => {lex.setTokenPosition(token); tok = T_MINUS_EQUAL; fbreak;}; - '^=' => {lex.setTokenPosition(token); tok = T_XOR_EQUAL; fbreak;}; - '%=' => {lex.setTokenPosition(token); tok = T_MOD_EQUAL; fbreak;}; - '--' => {lex.setTokenPosition(token); tok = T_DEC; fbreak;}; - '++' => {lex.setTokenPosition(token); tok = T_INC; fbreak;}; - '=>' => {lex.setTokenPosition(token); tok = T_DOUBLE_ARROW; fbreak;}; - '<=>' => {lex.setTokenPosition(token); tok = T_SPACESHIP; fbreak;}; - '!=' | '<>' => {lex.setTokenPosition(token); tok = T_IS_NOT_EQUAL; fbreak;}; - '!==' => {lex.setTokenPosition(token); tok = T_IS_NOT_IDENTICAL; fbreak;}; - '==' => {lex.setTokenPosition(token); tok = T_IS_EQUAL; fbreak;}; - '===' => {lex.setTokenPosition(token); tok = T_IS_IDENTICAL; fbreak;}; - '<<=' => {lex.setTokenPosition(token); tok = T_SL_EQUAL; fbreak;}; - '>>=' => {lex.setTokenPosition(token); tok = T_SR_EQUAL; fbreak;}; - '>=' => {lex.setTokenPosition(token); tok = T_IS_GREATER_OR_EQUAL; fbreak;}; - '<=' => {lex.setTokenPosition(token); tok = T_IS_SMALLER_OR_EQUAL; fbreak;}; - '**' => {lex.setTokenPosition(token); tok = T_POW; fbreak;}; - '<<' => {lex.setTokenPosition(token); tok = T_SL; fbreak;}; - '>>' => {lex.setTokenPosition(token); tok = T_SR; fbreak;}; - '??' => {lex.setTokenPosition(token); tok = T_COALESCE; fbreak;}; - '??=' => {lex.setTokenPosition(token); tok = T_COALESCE_EQUAL; fbreak;}; + 'abstract'i => {lex.setTokenPosition(tkn); tok = token.T_ABSTRACT; fbreak;}; + 'array'i => {lex.setTokenPosition(tkn); tok = token.T_ARRAY; fbreak;}; + 'as'i => {lex.setTokenPosition(tkn); tok = token.T_AS; fbreak;}; + 'break'i => {lex.setTokenPosition(tkn); tok = token.T_BREAK; fbreak;}; + 'callable'i => {lex.setTokenPosition(tkn); tok = token.T_CALLABLE; fbreak;}; + 'case'i => {lex.setTokenPosition(tkn); tok = token.T_CASE; fbreak;}; + 'catch'i => {lex.setTokenPosition(tkn); tok = token.T_CATCH; fbreak;}; + 'class'i => {lex.setTokenPosition(tkn); tok = token.T_CLASS; fbreak;}; + 'clone'i => {lex.setTokenPosition(tkn); tok = token.T_CLONE; fbreak;}; + 'const'i => {lex.setTokenPosition(tkn); tok = token.T_CONST; fbreak;}; + 'continue'i => {lex.setTokenPosition(tkn); tok = token.T_CONTINUE; fbreak;}; + 'declare'i => {lex.setTokenPosition(tkn); tok = token.T_DECLARE; fbreak;}; + 'default'i => {lex.setTokenPosition(tkn); tok = token.T_DEFAULT; fbreak;}; + 'do'i => {lex.setTokenPosition(tkn); tok = token.T_DO; fbreak;}; + 'echo'i => {lex.setTokenPosition(tkn); tok = token.T_ECHO; fbreak;}; + 'else'i => {lex.setTokenPosition(tkn); tok = token.T_ELSE; fbreak;}; + 'elseif'i => {lex.setTokenPosition(tkn); tok = token.T_ELSEIF; fbreak;}; + 'empty'i => {lex.setTokenPosition(tkn); tok = token.T_EMPTY; fbreak;}; + 'enddeclare'i => {lex.setTokenPosition(tkn); tok = token.T_ENDDECLARE; fbreak;}; + 'endfor'i => {lex.setTokenPosition(tkn); tok = token.T_ENDFOR; fbreak;}; + 'endforeach'i => {lex.setTokenPosition(tkn); tok = token.T_ENDFOREACH; fbreak;}; + 'endif'i => {lex.setTokenPosition(tkn); tok = token.T_ENDIF; fbreak;}; + 'endswitch'i => {lex.setTokenPosition(tkn); tok = token.T_ENDSWITCH; fbreak;}; + 'endwhile'i => {lex.setTokenPosition(tkn); tok = token.T_ENDWHILE; fbreak;}; + 'eval'i => {lex.setTokenPosition(tkn); tok = token.T_EVAL; fbreak;}; + 'exit'i | 'die'i => {lex.setTokenPosition(tkn); tok = token.T_EXIT; fbreak;}; + 'extends'i => {lex.setTokenPosition(tkn); tok = token.T_EXTENDS; fbreak;}; + 'final'i => {lex.setTokenPosition(tkn); tok = token.T_FINAL; fbreak;}; + 'finally'i => {lex.setTokenPosition(tkn); tok = token.T_FINALLY; fbreak;}; + 'for'i => {lex.setTokenPosition(tkn); tok = token.T_FOR; fbreak;}; + 'foreach'i => {lex.setTokenPosition(tkn); tok = token.T_FOREACH; fbreak;}; + 'function'i | 'cfunction'i => {lex.setTokenPosition(tkn); tok = token.T_FUNCTION; fbreak;}; + 'fn'i => {lex.setTokenPosition(tkn); tok = token.T_FN; fbreak;}; + 'global'i => {lex.setTokenPosition(tkn); tok = token.T_GLOBAL; fbreak;}; + 'goto'i => {lex.setTokenPosition(tkn); tok = token.T_GOTO; fbreak;}; + 'if'i => {lex.setTokenPosition(tkn); tok = token.T_IF; fbreak;}; + 'isset'i => {lex.setTokenPosition(tkn); tok = token.T_ISSET; fbreak;}; + 'implements'i => {lex.setTokenPosition(tkn); tok = token.T_IMPLEMENTS; fbreak;}; + 'instanceof'i => {lex.setTokenPosition(tkn); tok = token.T_INSTANCEOF; fbreak;}; + 'insteadof'i => {lex.setTokenPosition(tkn); tok = token.T_INSTEADOF; fbreak;}; + 'interface'i => {lex.setTokenPosition(tkn); tok = token.T_INTERFACE; fbreak;}; + 'list'i => {lex.setTokenPosition(tkn); tok = token.T_LIST; fbreak;}; + 'namespace'i => {lex.setTokenPosition(tkn); tok = token.T_NAMESPACE; fbreak;}; + 'private'i => {lex.setTokenPosition(tkn); tok = token.T_PRIVATE; fbreak;}; + 'public'i => {lex.setTokenPosition(tkn); tok = token.T_PUBLIC; fbreak;}; + 'print'i => {lex.setTokenPosition(tkn); tok = token.T_PRINT; fbreak;}; + 'protected'i => {lex.setTokenPosition(tkn); tok = token.T_PROTECTED; fbreak;}; + 'return'i => {lex.setTokenPosition(tkn); tok = token.T_RETURN; fbreak;}; + 'static'i => {lex.setTokenPosition(tkn); tok = token.T_STATIC; fbreak;}; + 'switch'i => {lex.setTokenPosition(tkn); tok = token.T_SWITCH; fbreak;}; + 'throw'i => {lex.setTokenPosition(tkn); tok = token.T_THROW; fbreak;}; + 'trait'i => {lex.setTokenPosition(tkn); tok = token.T_TRAIT; fbreak;}; + 'try'i => {lex.setTokenPosition(tkn); tok = token.T_TRY; fbreak;}; + 'unset'i => {lex.setTokenPosition(tkn); tok = token.T_UNSET; fbreak;}; + 'use'i => {lex.setTokenPosition(tkn); tok = token.T_USE; fbreak;}; + 'var'i => {lex.setTokenPosition(tkn); tok = token.T_VAR; fbreak;}; + 'while'i => {lex.setTokenPosition(tkn); tok = token.T_WHILE; fbreak;}; + 'yield'i whitespace_line+ 'from'i => {lex.setTokenPosition(tkn); tok = token.T_YIELD_FROM; fbreak;}; + 'yield'i => {lex.setTokenPosition(tkn); tok = token.T_YIELD; fbreak;}; + 'include'i => {lex.setTokenPosition(tkn); tok = token.T_INCLUDE; fbreak;}; + 'include_once'i => {lex.setTokenPosition(tkn); tok = token.T_INCLUDE_ONCE; fbreak;}; + 'require'i => {lex.setTokenPosition(tkn); tok = token.T_REQUIRE; fbreak;}; + 'require_once'i => {lex.setTokenPosition(tkn); tok = token.T_REQUIRE_ONCE; fbreak;}; + '__CLASS__'i => {lex.setTokenPosition(tkn); tok = token.T_CLASS_C; fbreak;}; + '__DIR__'i => {lex.setTokenPosition(tkn); tok = token.T_DIR; fbreak;}; + '__FILE__'i => {lex.setTokenPosition(tkn); tok = token.T_FILE; fbreak;}; + '__FUNCTION__'i => {lex.setTokenPosition(tkn); tok = token.T_FUNC_C; fbreak;}; + '__LINE__'i => {lex.setTokenPosition(tkn); tok = token.T_LINE; fbreak;}; + '__NAMESPACE__'i => {lex.setTokenPosition(tkn); tok = token.T_NS_C; fbreak;}; + '__METHOD__'i => {lex.setTokenPosition(tkn); tok = token.T_METHOD_C; fbreak;}; + '__TRAIT__'i => {lex.setTokenPosition(tkn); tok = token.T_TRAIT_C; fbreak;}; + '__halt_compiler'i => {lex.setTokenPosition(tkn); tok = token.T_HALT_COMPILER; fnext halt_compiller_open_parenthesis; fbreak;}; + 'new'i => {lex.setTokenPosition(tkn); tok = token.T_NEW; fbreak;}; + 'and'i => {lex.setTokenPosition(tkn); tok = token.T_LOGICAL_AND; fbreak;}; + 'or'i => {lex.setTokenPosition(tkn); tok = token.T_LOGICAL_OR; fbreak;}; + 'xor'i => {lex.setTokenPosition(tkn); tok = token.T_LOGICAL_XOR; fbreak;}; + '\\' => {lex.setTokenPosition(tkn); tok = token.T_NS_SEPARATOR; fbreak;}; + '...' => {lex.setTokenPosition(tkn); tok = token.T_ELLIPSIS; fbreak;}; + '::' => {lex.setTokenPosition(tkn); tok = token.T_PAAMAYIM_NEKUDOTAYIM; fbreak;}; + '&&' => {lex.setTokenPosition(tkn); tok = token.T_BOOLEAN_AND; fbreak;}; + '||' => {lex.setTokenPosition(tkn); tok = token.T_BOOLEAN_OR; fbreak;}; + '&=' => {lex.setTokenPosition(tkn); tok = token.T_AND_EQUAL; fbreak;}; + '|=' => {lex.setTokenPosition(tkn); tok = token.T_OR_EQUAL; fbreak;}; + '.=' => {lex.setTokenPosition(tkn); tok = token.T_CONCAT_EQUAL; fbreak;}; + '*=' => {lex.setTokenPosition(tkn); tok = token.T_MUL_EQUAL; fbreak;}; + '**=' => {lex.setTokenPosition(tkn); tok = token.T_POW_EQUAL; fbreak;}; + '/=' => {lex.setTokenPosition(tkn); tok = token.T_DIV_EQUAL; fbreak;}; + '+=' => {lex.setTokenPosition(tkn); tok = token.T_PLUS_EQUAL; fbreak;}; + '-=' => {lex.setTokenPosition(tkn); tok = token.T_MINUS_EQUAL; fbreak;}; + '^=' => {lex.setTokenPosition(tkn); tok = token.T_XOR_EQUAL; fbreak;}; + '%=' => {lex.setTokenPosition(tkn); tok = token.T_MOD_EQUAL; fbreak;}; + '--' => {lex.setTokenPosition(tkn); tok = token.T_DEC; fbreak;}; + '++' => {lex.setTokenPosition(tkn); tok = token.T_INC; fbreak;}; + '=>' => {lex.setTokenPosition(tkn); tok = token.T_DOUBLE_ARROW; fbreak;}; + '<=>' => {lex.setTokenPosition(tkn); tok = token.T_SPACESHIP; fbreak;}; + '!=' | '<>' => {lex.setTokenPosition(tkn); tok = token.T_IS_NOT_EQUAL; fbreak;}; + '!==' => {lex.setTokenPosition(tkn); tok = token.T_IS_NOT_IDENTICAL; fbreak;}; + '==' => {lex.setTokenPosition(tkn); tok = token.T_IS_EQUAL; fbreak;}; + '===' => {lex.setTokenPosition(tkn); tok = token.T_IS_IDENTICAL; fbreak;}; + '<<=' => {lex.setTokenPosition(tkn); tok = token.T_SL_EQUAL; fbreak;}; + '>>=' => {lex.setTokenPosition(tkn); tok = token.T_SR_EQUAL; fbreak;}; + '>=' => {lex.setTokenPosition(tkn); tok = token.T_IS_GREATER_OR_EQUAL; fbreak;}; + '<=' => {lex.setTokenPosition(tkn); tok = token.T_IS_SMALLER_OR_EQUAL; fbreak;}; + '**' => {lex.setTokenPosition(tkn); tok = token.T_POW; fbreak;}; + '<<' => {lex.setTokenPosition(tkn); tok = token.T_SL; fbreak;}; + '>>' => {lex.setTokenPosition(tkn); tok = token.T_SR; fbreak;}; + '??' => {lex.setTokenPosition(tkn); tok = token.T_COALESCE; fbreak;}; + '??=' => {lex.setTokenPosition(tkn); tok = token.T_COALESCE_EQUAL; fbreak;}; - '(' whitespace* 'array'i whitespace* ')' => {lex.setTokenPosition(token); tok = T_ARRAY_CAST; fbreak;}; - '(' whitespace* ('bool'i|'boolean'i) whitespace* ')' => {lex.setTokenPosition(token); tok = T_BOOL_CAST; fbreak;}; - '(' whitespace* ('real'i|'double'i|'float'i) whitespace* ')' => {lex.setTokenPosition(token); tok = T_DOUBLE_CAST; fbreak;}; - '(' whitespace* ('int'i|'integer'i) whitespace* ')' => {lex.setTokenPosition(token); tok = T_INT_CAST; fbreak;}; - '(' whitespace* 'object'i whitespace* ')' => {lex.setTokenPosition(token); tok = T_OBJECT_CAST; fbreak;}; - '(' whitespace* ('string'i|'binary'i) whitespace* ')' => {lex.setTokenPosition(token); tok = T_STRING_CAST; fbreak;}; - '(' whitespace* 'unset'i whitespace* ')' => {lex.setTokenPosition(token); tok = T_UNSET_CAST; fbreak;}; + '(' whitespace* 'array'i whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_ARRAY_CAST; fbreak;}; + '(' whitespace* ('bool'i|'boolean'i) whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_BOOL_CAST; fbreak;}; + '(' whitespace* ('real'i|'double'i|'float'i) whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_DOUBLE_CAST; fbreak;}; + '(' whitespace* ('int'i|'integer'i) whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_INT_CAST; fbreak;}; + '(' whitespace* 'object'i whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_OBJECT_CAST; fbreak;}; + '(' whitespace* ('string'i|'binary'i) whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_STRING_CAST; fbreak;}; + '(' whitespace* 'unset'i whitespace* ')' => {lex.setTokenPosition(tkn); tok = token.T_UNSET_CAST; fbreak;}; ('#' | '//') any_line* when is_not_comment_end => { lex.ungetStr("?>") - lex.addFreeFloating(freefloating.CommentType, lex.ts, lex.te) + lex.addFreeFloatingToken(tkn, token.T_COMMENT, lex.ts, lex.te) }; '/*' any_line* :>> '*/' { isDocComment := false; if lex.te - lex.ts > 4 && string(lex.data[lex.ts:lex.ts+3]) == "/**" { isDocComment = true; } - lex.addFreeFloating(freefloating.CommentType, lex.ts, lex.te) if isDocComment { - lex.PhpDocComment = string(lex.data[lex.ts:lex.te]) + lex.addFreeFloatingToken(tkn, token.T_DOC_COMMENT, lex.ts, lex.te) + } else { + lex.addFreeFloatingToken(tkn, token.T_COMMENT, lex.ts, lex.te) } }; operators => { - // rune, _ := utf8.DecodeRune(lex.data[lex.ts:lex.te]); - // tok = TokenID(Rune2Class(rune)); - lex.setTokenPosition(token); - tok = TokenID(int(lex.data[lex.ts])); + lex.setTokenPosition(tkn); + tok = token.ID(int(lex.data[lex.ts])); fbreak; }; - "{" => { lex.setTokenPosition(token); tok = TokenID(int('{')); lex.call(ftargs, fentry(php)); goto _out; }; - "}" => { lex.setTokenPosition(token); tok = TokenID(int('}')); lex.ret(1); lex.PhpDocComment = ""; goto _out;}; - "$" varname => { lex.setTokenPosition(token); tok = T_VARIABLE; fbreak; }; - varname => { lex.setTokenPosition(token); tok = T_STRING; fbreak; }; + "{" => { lex.setTokenPosition(tkn); tok = token.ID(int('{')); lex.call(ftargs, fentry(php)); goto _out; }; + "}" => { lex.setTokenPosition(tkn); tok = token.ID(int('}')); lex.ret(1); goto _out;}; + "$" varname => { lex.setTokenPosition(tkn); tok = token.T_VARIABLE; fbreak; }; + varname => { lex.setTokenPosition(tkn); tok = token.T_STRING; fbreak; }; - "->" => { lex.setTokenPosition(token); tok = T_OBJECT_OPERATOR; fnext property; fbreak; }; + "->" => { lex.setTokenPosition(tkn); tok = token.T_OBJECT_OPERATOR; fnext property; fbreak; }; constant_string => { - lex.setTokenPosition(token); - tok = T_CONSTANT_ENCAPSED_STRING; + lex.setTokenPosition(tkn); + tok = token.T_CONSTANT_ENCAPSED_STRING; fbreak; }; "b"i? "<<<" [ \t]* ( heredoc_label | ("'" heredoc_label "'") | ('"' heredoc_label '"') ) newline => { lex.heredocLabel = lex.data[lblStart:lblEnd] - lex.setTokenPosition(token); - tok = T_START_HEREDOC; + lex.setTokenPosition(tkn); + tok = token.T_START_HEREDOC; if lex.isHeredocEnd(lex.p+1) { fnext heredoc_end; @@ -378,38 +366,38 @@ func (lex *Lexer) Lex(lval Lval) int { } fbreak; }; - "`" => {lex.setTokenPosition(token); tok = TokenID(int('`')); fnext backqote; fbreak;}; - '"' => {lex.setTokenPosition(token); tok = TokenID(int('"')); fnext template_string; fbreak;}; + "`" => {lex.setTokenPosition(tkn); tok = token.ID(int('`')); fnext backqote; fbreak;}; + '"' => {lex.setTokenPosition(tkn); tok = token.ID(int('"')); fnext template_string; fbreak;}; any_line => { c := lex.data[lex.p] - lex.Error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", c, c)); + lex.error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", c, c)); }; *|; property := |* - whitespace_line* => {lex.addFreeFloating(freefloating.WhiteSpaceType, lex.ts, lex.te)}; - "->" => {lex.setTokenPosition(token); tok = T_OBJECT_OPERATOR; fbreak;}; - varname => {lex.setTokenPosition(token); tok = T_STRING; fnext php; fbreak;}; + whitespace_line* => {lex.addFreeFloatingToken(tkn, token.T_WHITESPACE, lex.ts, lex.te)}; + "->" => {lex.setTokenPosition(tkn); tok = token.T_OBJECT_OPERATOR; fbreak;}; + varname => {lex.setTokenPosition(tkn); tok = token.T_STRING; fnext php; fbreak;}; any => {lex.ungetCnt(1); fgoto php;}; *|; nowdoc := |* any_line* when is_not_heredoc_end => { - lex.setTokenPosition(token); - tok = T_ENCAPSED_AND_WHITESPACE; + lex.setTokenPosition(tkn); + tok = token.T_ENCAPSED_AND_WHITESPACE; fnext heredoc_end; fbreak; }; *|; heredoc := |* - "{$" => {lex.ungetCnt(1); lex.setTokenPosition(token); tok = T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; - "${" => {lex.setTokenPosition(token); tok = T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; + "{$" => {lex.ungetCnt(1); lex.setTokenPosition(tkn); tok = token.T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; + "${" => {lex.setTokenPosition(tkn); tok = token.T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; "$" => {lex.ungetCnt(1); fcall string_var;}; any_line* when is_not_heredoc_end_or_var => { - lex.setTokenPosition(token); - tok = T_ENCAPSED_AND_WHITESPACE; + lex.setTokenPosition(tkn); + tok = token.T_ENCAPSED_AND_WHITESPACE; if len(lex.data) > lex.p+1 && lex.data[lex.p+1] != '$' && lex.data[lex.p+1] != '{' { fnext heredoc_end; @@ -419,99 +407,97 @@ func (lex *Lexer) Lex(lval Lval) int { *|; backqote := |* - "{$" => {lex.ungetCnt(1); lex.setTokenPosition(token); tok = T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; - "${" => {lex.setTokenPosition(token); tok = T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; + "{$" => {lex.ungetCnt(1); lex.setTokenPosition(tkn); tok = token.T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; + "${" => {lex.setTokenPosition(tkn); tok = token.T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; "$" varname_first => {lex.ungetCnt(2); fcall string_var;}; - '`' => {lex.setTokenPosition(token); tok = TokenID(int('`')); fnext php; fbreak;}; + '`' => {lex.setTokenPosition(tkn); tok = token.ID(int('`')); fnext php; fbreak;}; any_line* when is_not_backqoute_end_or_var => { - lex.setTokenPosition(token); - tok = T_ENCAPSED_AND_WHITESPACE; + lex.setTokenPosition(tkn); + tok = token.T_ENCAPSED_AND_WHITESPACE; fbreak; }; *|; template_string := |* - "{$" => {lex.ungetCnt(1); lex.setTokenPosition(token); tok = T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; - "${" => {lex.setTokenPosition(token); tok = T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; + "{$" => {lex.ungetCnt(1); lex.setTokenPosition(tkn); tok = token.T_CURLY_OPEN; lex.call(ftargs, fentry(php)); goto _out;}; + "${" => {lex.setTokenPosition(tkn); tok = token.T_DOLLAR_OPEN_CURLY_BRACES; lex.call(ftargs, fentry(string_var_name)); goto _out;}; "$" varname_first => {lex.ungetCnt(2); fcall string_var;}; - '"' => {lex.setTokenPosition(token); tok = TokenID(int('"')); fnext php; fbreak;}; + '"' => {lex.setTokenPosition(tkn); tok = token.ID(int('"')); fnext php; fbreak;}; any_line* when is_not_string_end_or_var => { - lex.setTokenPosition(token); - tok = T_ENCAPSED_AND_WHITESPACE; + lex.setTokenPosition(tkn); + tok = token.T_ENCAPSED_AND_WHITESPACE; fbreak; }; *|; heredoc_end := |* varname -- ";" => { - lex.setTokenPosition(token); - tok = T_END_HEREDOC; + lex.setTokenPosition(tkn); + tok = token.T_END_HEREDOC; fnext php; fbreak; }; varname => { - lex.setTokenPosition(token); - tok = T_END_HEREDOC; + lex.setTokenPosition(tkn); + tok = token.T_END_HEREDOC; fnext php; fbreak; }; *|; string_var := |* - '$' varname => {lex.setTokenPosition(token); tok = T_VARIABLE; fbreak;}; - '->' varname_first => {lex.ungetCnt(1); lex.setTokenPosition(token); tok = T_OBJECT_OPERATOR; fbreak;}; - varname => {lex.setTokenPosition(token); tok = T_STRING; fbreak;}; - '[' => {lex.setTokenPosition(token); tok = TokenID(int('[')); lex.call(ftargs, fentry(string_var_index)); goto _out;}; + '$' varname => {lex.setTokenPosition(tkn); tok = token.T_VARIABLE; fbreak;}; + '->' varname_first => {lex.ungetCnt(1); lex.setTokenPosition(tkn); tok = token.T_OBJECT_OPERATOR; fbreak;}; + varname => {lex.setTokenPosition(tkn); tok = token.T_STRING; fbreak;}; + '[' => {lex.setTokenPosition(tkn); tok = token.ID(int('[')); lex.call(ftargs, fentry(string_var_index)); goto _out;}; any => {lex.ungetCnt(1); fret;}; *|; string_var_index := |* - lnum | hnum | bnum => {lex.setTokenPosition(token); tok = T_NUM_STRING; fbreak;}; - '$' varname => {lex.setTokenPosition(token); tok = T_VARIABLE; fbreak;}; - varname => {lex.setTokenPosition(token); tok = T_STRING; fbreak;}; - whitespace_line | [\\'#] => {lex.setTokenPosition(token); tok = T_ENCAPSED_AND_WHITESPACE; lex.ret(2); goto _out;}; - operators > (svi, 1) => {lex.setTokenPosition(token); tok = TokenID(int(lex.data[lex.ts])); fbreak;}; - ']' > (svi, 2) => {lex.setTokenPosition(token); tok = TokenID(int(']')); lex.ret(2); goto _out;}; + lnum | hnum | bnum => {lex.setTokenPosition(tkn); tok = token.T_NUM_STRING; fbreak;}; + '$' varname => {lex.setTokenPosition(tkn); tok = token.T_VARIABLE; fbreak;}; + varname => {lex.setTokenPosition(tkn); tok = token.T_STRING; fbreak;}; + whitespace_line | [\\'#] => {lex.setTokenPosition(tkn); tok = token.T_ENCAPSED_AND_WHITESPACE; lex.ret(2); goto _out;}; + operators > (svi, 1) => {lex.setTokenPosition(tkn); tok = token.ID(int(lex.data[lex.ts])); fbreak;}; + ']' > (svi, 2) => {lex.setTokenPosition(tkn); tok = token.ID(int(']')); lex.ret(2); goto _out;}; any_line => { c := lex.data[lex.p] - lex.Error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", c, c)); + lex.error(fmt.Sprintf("WARNING: Unexpected character in input: '%c' (ASCII=%d)", c, c)); }; *|; string_var_name := |* - varname ("[" | "}") => {lex.ungetCnt(1); lex.setTokenPosition(token); tok = T_STRING_VARNAME; fnext php; fbreak;}; + varname ("[" | "}") => {lex.ungetCnt(1); lex.setTokenPosition(tkn); tok = token.T_STRING_VARNAME; fnext php; fbreak;}; any => {lex.ungetCnt(1); fnext php;}; *|; halt_compiller_open_parenthesis := |* - whitespace_line* => {lex.addFreeFloating(freefloating.WhiteSpaceType, lex.ts, lex.te)}; - "(" => {lex.setTokenPosition(token); tok = TokenID(int('(')); fnext halt_compiller_close_parenthesis; fbreak;}; + whitespace_line* => {lex.addFreeFloatingToken(tkn, token.T_WHITESPACE, lex.ts, lex.te)}; + "(" => {lex.setTokenPosition(tkn); tok = token.ID(int('(')); fnext halt_compiller_close_parenthesis; fbreak;}; any => {lex.ungetCnt(1); fnext php;}; *|; halt_compiller_close_parenthesis := |* - whitespace_line* => {lex.addFreeFloating(freefloating.WhiteSpaceType, lex.ts, lex.te)}; - ")" => {lex.setTokenPosition(token); tok = TokenID(int(')')); fnext halt_compiller_close_semicolon; fbreak;}; + whitespace_line* => {lex.addFreeFloatingToken(tkn, token.T_WHITESPACE, lex.ts, lex.te)}; + ")" => {lex.setTokenPosition(tkn); tok = token.ID(int(')')); fnext halt_compiller_close_semicolon; fbreak;}; any => {lex.ungetCnt(1); fnext php;}; *|; halt_compiller_close_semicolon := |* - whitespace_line* => {lex.addFreeFloating(freefloating.WhiteSpaceType, lex.ts, lex.te)}; - ";" => {lex.setTokenPosition(token); tok = TokenID(int(';')); fnext halt_compiller_end; fbreak;}; + whitespace_line* => {lex.addFreeFloatingToken(tkn, token.T_WHITESPACE, lex.ts, lex.te)}; + ";" => {lex.setTokenPosition(tkn); tok = token.ID(int(';')); fnext halt_compiller_end; fbreak;}; any => {lex.ungetCnt(1); fnext php;}; *|; halt_compiller_end := |* - any_line* => { lex.addFreeFloating(freefloating.TokenType, lex.ts, lex.te); }; + any_line* => { lex.addFreeFloatingToken(tkn, token.T_HALT_COMPILER, lex.ts, lex.te); }; *|; write exec; }%% - token.FreeFloating = lex.FreeFloating - token.Value = string(lex.data[lex.ts:lex.te]) + tkn.Value = lex.data[lex.ts:lex.te] + tkn.ID = token.ID(tok) - lval.Token(token) - - return int(tok); + return tkn } \ No newline at end of file diff --git a/internal/scanner/scanner_test.go b/internal/scanner/scanner_test.go new file mode 100644 index 0000000..af6da1f --- /dev/null +++ b/internal/scanner/scanner_test.go @@ -0,0 +1,1872 @@ +package scanner + +import ( + "gotest.tools/assert" + "testing" + + "github.com/z7zmey/php-parser/pkg/cfg" + "github.com/z7zmey/php-parser/pkg/errors" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "github.com/z7zmey/php-parser/pkg/version" +) + +func TestTokens(t *testing.T) { + src := `inline html - + + + + <=> + != + <> + !== + == + === + <<= + >>= + >= + <= + ** + << + >> + ?? + + # inline comment + // inline comment + + /* + multiline comment + */ + + /** + * PHP Doc comment + */ + + ; + : + , + . + [ + ] + ( + ) + | + / + ^ + & + + + - + * + = + % + ! + ~ + $ + < + > + ? + @ + { + } + + $var + str + + -> ` + "\t\r\n" + ` ->prop + + ( array ) + ( bool ) + ( boolean ) + ( real ) + ( double ) + ( float ) + ( int ) + ( integer ) + ( object ) + ( string ) + ( binary ) + ( unset ) + + ` + + expected := []string{ + token.T_INLINE_HTML.String(), + token.ID(int(';')).String(), + token.T_INLINE_HTML.String(), + token.T_ECHO.String(), + token.ID(int(';')).String(), + token.T_INLINE_HTML.String(), + + token.T_ABSTRACT.String(), + token.T_ARRAY.String(), + token.T_AS.String(), + token.T_BREAK.String(), + token.T_CALLABLE.String(), + token.T_CASE.String(), + token.T_CATCH.String(), + token.T_CLASS.String(), + token.T_CLONE.String(), + token.T_CONST.String(), + token.T_CONTINUE.String(), + token.T_DECLARE.String(), + token.T_DEFAULT.String(), + token.T_DO.String(), + token.T_ECHO.String(), + token.T_ELSE.String(), + token.T_ELSEIF.String(), + token.T_EMPTY.String(), + token.T_ENDDECLARE.String(), + token.T_ENDFOR.String(), + token.T_ENDFOREACH.String(), + token.T_ENDIF.String(), + token.T_ENDSWITCH.String(), + token.T_ENDWHILE.String(), + token.T_EVAL.String(), + token.T_EXIT.String(), + token.T_EXTENDS.String(), + token.T_FINAL.String(), + token.T_FINALLY.String(), + token.T_FOR.String(), + token.T_FOREACH.String(), + token.T_FUNCTION.String(), + token.T_FUNCTION.String(), + token.T_GLOBAL.String(), + token.T_GOTO.String(), + token.T_IF.String(), + token.T_ISSET.String(), + token.T_IMPLEMENTS.String(), + token.T_INSTANCEOF.String(), + token.T_INSTEADOF.String(), + token.T_INTERFACE.String(), + token.T_LIST.String(), + token.T_NAMESPACE.String(), + token.T_PRIVATE.String(), + token.T_PUBLIC.String(), + token.T_PRINT.String(), + token.T_PROTECTED.String(), + token.T_RETURN.String(), + token.T_STATIC.String(), + token.T_SWITCH.String(), + token.T_THROW.String(), + token.T_TRAIT.String(), + token.T_TRY.String(), + token.T_UNSET.String(), + token.T_USE.String(), + token.T_VAR.String(), + token.T_WHILE.String(), + token.T_YIELD_FROM.String(), + token.T_YIELD.String(), + token.T_INCLUDE.String(), + token.T_INCLUDE_ONCE.String(), + token.T_REQUIRE.String(), + token.T_REQUIRE_ONCE.String(), + + token.T_CLASS_C.String(), + token.T_DIR.String(), + token.T_FILE.String(), + token.T_FUNC_C.String(), + token.T_LINE.String(), + token.T_NS_C.String(), + token.T_METHOD_C.String(), + token.T_TRAIT_C.String(), + token.T_HALT_COMPILER.String(), + + token.T_NEW.String(), + token.T_LOGICAL_AND.String(), + token.T_LOGICAL_OR.String(), + token.T_LOGICAL_XOR.String(), + + token.T_NS_SEPARATOR.String(), + token.T_ELLIPSIS.String(), + token.T_PAAMAYIM_NEKUDOTAYIM.String(), + token.T_BOOLEAN_AND.String(), + token.T_BOOLEAN_OR.String(), + token.T_AND_EQUAL.String(), + token.T_OR_EQUAL.String(), + token.T_CONCAT_EQUAL.String(), + token.T_MUL_EQUAL.String(), + token.T_POW_EQUAL.String(), + token.T_DIV_EQUAL.String(), + token.T_PLUS_EQUAL.String(), + token.T_MINUS_EQUAL.String(), + token.T_XOR_EQUAL.String(), + token.T_MOD_EQUAL.String(), + token.T_DEC.String(), + token.T_INC.String(), + token.T_DOUBLE_ARROW.String(), + token.T_SPACESHIP.String(), + token.T_IS_NOT_EQUAL.String(), + token.T_IS_NOT_EQUAL.String(), + token.T_IS_NOT_IDENTICAL.String(), + token.T_IS_EQUAL.String(), + token.T_IS_IDENTICAL.String(), + token.T_SL_EQUAL.String(), + token.T_SR_EQUAL.String(), + token.T_IS_GREATER_OR_EQUAL.String(), + token.T_IS_SMALLER_OR_EQUAL.String(), + token.T_POW.String(), + token.T_SL.String(), + token.T_SR.String(), + token.T_COALESCE.String(), + + token.ID(int(';')).String(), + token.ID(int(':')).String(), + token.ID(int(',')).String(), + token.ID(int('.')).String(), + token.ID(int('[')).String(), + token.ID(int(']')).String(), + token.ID(int('(')).String(), + token.ID(int(')')).String(), + token.ID(int('|')).String(), + token.ID(int('/')).String(), + token.ID(int('^')).String(), + token.ID(int('&')).String(), + token.ID(int('+')).String(), + token.ID(int('-')).String(), + token.ID(int('*')).String(), + token.ID(int('=')).String(), + token.ID(int('%')).String(), + token.ID(int('!')).String(), + token.ID(int('~')).String(), + token.ID(int('$')).String(), + token.ID(int('<')).String(), + token.ID(int('>')).String(), + token.ID(int('?')).String(), + token.ID(int('@')).String(), + token.ID(int('{')).String(), + token.ID(int('}')).String(), + + token.T_VARIABLE.String(), + token.T_STRING.String(), + + token.T_OBJECT_OPERATOR.String(), + token.T_OBJECT_OPERATOR.String(), + token.T_STRING.String(), + + token.T_ARRAY_CAST.String(), + token.T_BOOL_CAST.String(), + token.T_BOOL_CAST.String(), + token.T_DOUBLE_CAST.String(), + token.T_DOUBLE_CAST.String(), + token.T_DOUBLE_CAST.String(), + token.T_INT_CAST.String(), + token.T_INT_CAST.String(), + token.T_OBJECT_CAST.String(), + token.T_STRING_CAST.String(), + token.T_STRING_CAST.String(), + token.T_UNSET_CAST.String(), + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := NewLexer([]byte(src), config) + actual := []string{} + + for { + tkn := lexer.Lex() + if tkn.ID == 0 { + break + } + + actual = append(actual, tkn.ID.String()) + } + + assert.DeepEqual(t, expected, actual) +} + +func TestShebang(t *testing.T) { + src := `#!/usr/bin/env php +prop + $var[1] + $var[0x1] + $var[0b1] + $var[var_name] + $var[$var] + + {$var} + ${var_name} + {s $ \$a +CAT; + ` + + expected := []string{ + token.T_START_HEREDOC.String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_END_HEREDOC.String(), + token.ID(int(';')).String(), + + token.T_START_HEREDOC.String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_END_HEREDOC.String(), + token.ID(int(';')).String(), + + token.T_START_HEREDOC.String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.T_OBJECT_OPERATOR.String(), + token.T_STRING.String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.ID(int('[')).String(), + token.T_NUM_STRING.String(), + token.ID(int(']')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.ID(int('[')).String(), + token.T_NUM_STRING.String(), + token.ID(int(']')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.ID(int('[')).String(), + token.T_NUM_STRING.String(), + token.ID(int(']')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.ID(int('[')).String(), + token.T_STRING.String(), + token.ID(int(']')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_VARIABLE.String(), + token.ID(int('[')).String(), + token.T_VARIABLE.String(), + token.ID(int(']')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_CURLY_OPEN.String(), + token.T_VARIABLE.String(), + token.ID(int('}')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_DOLLAR_OPEN_CURLY_BRACES.String(), + token.T_STRING_VARNAME.String(), + token.ID(int('}')).String(), + token.T_ENCAPSED_AND_WHITESPACE.String(), + token.T_END_HEREDOC.String(), + token.ID(int(';')).String(), + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := NewLexer([]byte(src), config) + actual := []string{} + + for { + tkn := lexer.Lex() + if tkn.ID == 0 { + break + } + + actual = append(actual, tkn.ID.String()) + } + + assert.DeepEqual(t, expected, actual) +} + +func TestHereDocTokens2(t *testing.T) { + src := ` test test + ` + + expected := []string{ + token.T_VARIABLE.String(), + token.ID(int(';')).String(), + token.T_INLINE_HTML.String(), + + token.T_VARIABLE.String(), + token.ID(int(';')).String(), + token.T_INLINE_HTML.String(), + } + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := NewLexer([]byte(src), config) + actual := []string{} + + for { + tkn := lexer.Lex() + if tkn.ID == 0 { + break + } + + actual = append(actual, tkn.ID.String()) + } + + assert.DeepEqual(t, expected, actual) +} + +func TestStringTokensAfterVariable(t *testing.T) { + src := ` test` + + expected := []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(" bar ( '' ) ;` + + config := cfg.Config{ + Version: &version.Version{ + Major: 7, + Minor: 4, + }, + } + lexer := NewLexer([]byte(src), config) + + expected := []*token.Token{ + { + ID: token.T_OPEN_TAG, + Value: []byte(">= $b;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Expr: &assign.ShiftRight{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 12, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 12, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestCoalesce(t *testing.T) { - src := `= $b;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Expr: &binary.GreaterOrEqual{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestGreater(t *testing.T) { - src := ` $b;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Expr: &binary.Greater{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 10, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 8, - EndPos: 10, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 8, - EndPos: 10, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestIdentical(t *testing.T) { - src := `> $b;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Expr: &binary.ShiftRight{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestSmallerOrEqual(t *testing.T) { - src := ` $b;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Expr: &binary.Spaceship{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 12, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 12, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/binary/t_freefloating_test.go b/node/expr/binary/t_freefloating_test.go deleted file mode 100644 index 7db5cf4..0000000 --- a/node/expr/binary/t_freefloating_test.go +++ /dev/null @@ -1,117 +0,0 @@ -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 deleted file mode 100644 index 079e380..0000000 --- a/node/expr/binary/t_position_test.go +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 7962e23..0000000 --- a/node/expr/binary/t_visitor_test.go +++ /dev/null @@ -1,285 +0,0 @@ -package binary_test - -import ( - "testing" - - "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 { - node node.Node // node - expectedVisitedKeys []string // visited keys - expectedAttributes map[string]interface{} -}{ - { - &binary.BitwiseAnd{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.BitwiseOr{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.BitwiseXor{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.BooleanAnd{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.BooleanOr{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Coalesce{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Concat{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Div{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Equal{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.GreaterOrEqual{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Greater{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Identical{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.LogicalAnd{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.LogicalOr{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.LogicalXor{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Minus{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Mod{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Mul{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.NotEqual{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.NotIdentical{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Plus{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Pow{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.ShiftLeft{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.ShiftRight{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.SmallerOrEqual{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Smaller{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, - { - &binary.Spaceship{ - Left: &expr.Variable{}, - Right: &expr.Variable{}, - }, - []string{"Left", "Right"}, - nil, - }, -} - -type visitorMock struct { - visitChildren bool - visitedKeys []string -} - -func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } -func (v *visitorMock) LeaveNode(n walker.Walkable) {} -func (v *visitorMock) EnterChildNode(key string, w walker.Walkable) { - v.visitedKeys = append(v.visitedKeys, key) -} -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, []string{}} - tt.node.Walk(v) - - expected := []string{} - actual := v.visitedKeys - - assert.DeepEqual(t, expected, actual) - } -} - -func TestVisitor(t *testing.T) { - for _, tt := range nodesToTest { - v := &visitorMock{true, []string{}} - tt.node.Walk(v) - - expected := tt.expectedVisitedKeys - actual := v.visitedKeys - - assert.DeepEqual(t, expected, actual) - } -} - -// test Attributes() - -func TestNameAttributes(t *testing.T) { - for _, tt := range nodesToTest { - expected := tt.expectedAttributes - actual := tt.node.Attributes() - - assert.DeepEqual(t, expected, actual) - } -} diff --git a/node/expr/cast/n_cast_array.go b/node/expr/cast/n_cast_array.go deleted file mode 100644 index f12458b..0000000 --- a/node/expr/cast/n_cast_array.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewArray node constructor -func NewArray(Expr node.Node) *Array { - return &Array{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Array) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index a794df8..0000000 --- a/node/expr/cast/n_cast_bool.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewBool node constructor -func NewBool(Expr node.Node) *Bool { - return &Bool{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Bool) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index 61dcc43..0000000 --- a/node/expr/cast/n_cast_double.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewDouble node constructor -func NewDouble(Expr node.Node) *Double { - return &Double{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Double) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index fc3f98d..0000000 --- a/node/expr/cast/n_cast_int.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewInt node constructor -func NewInt(Expr node.Node) *Int { - return &Int{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Int) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index ea67ce2..0000000 --- a/node/expr/cast/n_cast_object.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewObject node constructor -func NewObject(Expr node.Node) *Object { - return &Object{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Object) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index 68a09e2..0000000 --- a/node/expr/cast/n_cast_string.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewString node constructor -func NewString(Expr node.Node) *String { - return &String{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *String) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index a792daa..0000000 --- a/node/expr/cast/n_cast_unset.go +++ /dev/null @@ -1,58 +0,0 @@ -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 { - FreeFloating freefloating.Collection - Position *position.Position - Expr node.Node -} - -// NewUnset node constructor -func NewUnset(Expr node.Node) *Unset { - return &Unset{ - 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 -} - -// Walk traverses nodes -// Walk is invoked recursively until v.EnterNode returns true -func (n *Unset) Walk(v walker.Visitor) { - if v.EnterNode(n) == false { - return - } - - if n.Expr != nil { - 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 deleted file mode 100644 index 0314800..0000000 --- a/node/expr/cast/t_cast_test.go +++ /dev/null @@ -1,653 +0,0 @@ -package cast_test - -import ( - "testing" - - "gotest.tools/assert" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/node/expr" - "github.com/z7zmey/php-parser/node/expr/cast" - "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 TestArray(t *testing.T) { - src := `1, &$b,);` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 21, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 21, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 20, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 13, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 10, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 13, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 18, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 18, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 16, - EndPos: 18, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 16, - EndPos: 18, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestArrayItemUnpack(t *testing.T) { - src := ` $a;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 14, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 14, - }, - Expr: &expr.ArrowFunction{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 11, - EndPos: 13, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 11, - EndPos: 13, - }, - Value: "a", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestArrowFunctionReturnType(t *testing.T) { - src := ` $a;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 23, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 23, - }, - Expr: &expr.ArrowFunction{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 22, - }, - Static: false, - PhpDocComment: "", - ReturnsRef: true, - ReturnType: &name.Name{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 13, - EndPos: 16, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 13, - EndPos: 16, - }, - Value: "foo", - }, - }, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 20, - EndPos: 22, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 20, - EndPos: 22, - }, - Value: "a", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/t_bitwise_not_test.go b/node/expr/t_bitwise_not_test.go deleted file mode 100644 index a5688b0..0000000 --- a/node/expr/t_bitwise_not_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package expr_test - -import ( - "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" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestBitwiseNot(t *testing.T) { - src := `foo();` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 13, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 12, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 7, - EndPos: 10, - }, - Value: "foo", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 12, - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/t_new_test.go b/node/expr/t_new_test.go deleted file mode 100644 index d0670f8..0000000 --- a/node/expr/t_new_test.go +++ /dev/null @@ -1,323 +0,0 @@ -package expr_test - -import ( - "testing" - - "gotest.tools/assert" - - "github.com/z7zmey/php-parser/node/name" - "github.com/z7zmey/php-parser/position" - - "github.com/z7zmey/php-parser/node/expr" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/node/stmt" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestNew(t *testing.T) { - src := `foo;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 11, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 10, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 7, - EndPos: 10, - }, - Value: "foo", - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/t_reference_test.go b/node/expr/t_reference_test.go deleted file mode 100644 index 8a9c38e..0000000 --- a/node/expr/t_reference_test.go +++ /dev/null @@ -1,117 +0,0 @@ -package expr_test - -import ( - "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" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestForeachWithRef(t *testing.T) { - t.Helper() - src := ` &$v) {}` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 31, - }, - Stmts: []node.Node{ - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 31, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "k", - }, - }, - Variable: &expr.Reference{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 27, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 25, - EndPos: 27, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 25, - EndPos: 27, - }, - Value: "v", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 29, - EndPos: 31, - }, - Stmts: []node.Node{}, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/t_shell_exec_test.go b/node/expr/t_shell_exec_test.go deleted file mode 100644 index 4932334..0000000 --- a/node/expr/t_shell_exec_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package expr_test - -import ( - "testing" - - "gotest.tools/assert" - - "github.com/z7zmey/php-parser/node/scalar" - "github.com/z7zmey/php-parser/position" - - "github.com/z7zmey/php-parser/node/expr" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/node/stmt" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestShellExec(t *testing.T) { - src := "1, &$b,];` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 16, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 16, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 15, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 4, - EndPos: 8, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 4, - EndPos: 5, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 7, - EndPos: 8, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 13, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 13, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 11, - EndPos: 13, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 11, - EndPos: 13, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/expr/t_short_list_test.go b/node/expr/t_short_list_test.go deleted file mode 100644 index 76f0bbe..0000000 --- a/node/expr/t_short_list_test.go +++ /dev/null @@ -1,304 +0,0 @@ -package expr_test - -import ( - "testing" - - "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: 3, - EndPos: 18, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 18, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 17, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - Value: "a", - }, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 17, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 17, - }, - Value: "b", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestYieldExpr(t *testing.T) { - src := ` 1;` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 17, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 17, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 16, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 11, - }, - Value: "a", - }, - }, - Value: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 16, - }, - Value: "1", - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestYieldFrom(t *testing.T) { - src := `bar()";` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 22, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 22, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 21, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 4, - EndPos: 9, - }, - Value: "test ", - }, - &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 18, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 13, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 9, - EndPos: 13, - }, - Value: "foo", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 15, - EndPos: 18, - }, - Value: "bar", - }, - }, - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "()", - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestDollarOpenCurlyBraces(t *testing.T) { - src := `bar()}";` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 24, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 24, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 23, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 4, - EndPos: 9, - }, - Value: "test ", - }, - &expr.MethodCall{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 21, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 14, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 10, - EndPos: 14, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 16, - EndPos: 19, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 19, - EndPos: 21, - }, - }, - }, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/scalar/t_freefloating_test.go b/node/scalar/t_freefloating_test.go deleted file mode 100644 index c30e2ff..0000000 --- a/node/scalar/t_freefloating_test.go +++ /dev/null @@ -1,57 +0,0 @@ -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 deleted file mode 100644 index ae0ce1f..0000000 --- a/node/scalar/t_heredoc_test.go +++ /dev/null @@ -1,336 +0,0 @@ -package scalar_test - -import ( - "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" - "github.com/z7zmey/php-parser/node/stmt" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestHeredocSimpleLabel(t *testing.T) { - src := ` $v) {}` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 30, - }, - Stmts: []node.Node{ - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 30, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "k", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 26, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 26, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 28, - EndPos: 30, - }, - Stmts: []node.Node{}, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestForeachExprWithKey(t *testing.T) { - src := ` $v) {}` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 30, - }, - Stmts: []node.Node{ - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 30, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - Items: []node.Node{}, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "k", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 26, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 26, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 28, - EndPos: 30, - }, - Stmts: []node.Node{}, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestForeachWithRef(t *testing.T) { - src := ` &$v) {}` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 31, - }, - Stmts: []node.Node{ - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 31, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "k", - }, - }, - Variable: &expr.Reference{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 27, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 25, - EndPos: 27, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 25, - EndPos: 27, - }, - Value: "v", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 29, - EndPos: 31, - }, - Stmts: []node.Node{}, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestForeachWithList(t *testing.T) { - src := ` list($v)) {}` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 36, - }, - Stmts: []node.Node{ - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 36, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 12, - EndPos: 14, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 18, - EndPos: 20, - }, - Value: "k", - }, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 24, - EndPos: 32, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 29, - EndPos: 31, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 29, - EndPos: 31, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 29, - EndPos: 31, - }, - Value: "v", - }, - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 34, - EndPos: 36, - }, - Stmts: []node.Node{}, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/stmt/t_freefloating_test.go b/node/stmt/t_freefloating_test.go deleted file mode 100644 index 182c5d9..0000000 --- a/node/stmt/t_freefloating_test.go +++ /dev/null @@ -1,216 +0,0 @@ -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 deleted file mode 100644 index 4b8fbe3..0000000 --- a/node/stmt/t_function_test.go +++ /dev/null @@ -1,383 +0,0 @@ -package stmt_test - -import ( - "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" - "github.com/z7zmey/php-parser/node/stmt" - "github.com/z7zmey/php-parser/php5" - "github.com/z7zmey/php-parser/php7" -) - -func TestSimpleFunction(t *testing.T) { - src := `
` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 17, - }, - Stmts: []node.Node{ - &stmt.Nop{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 3, - EndPos: 5, - }, - }, - &stmt.InlineHtml{ - Position: &position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 5, - EndPos: 17, - }, - Value: "
", - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual = php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} diff --git a/node/stmt/t_interface_test.go b/node/stmt/t_interface_test.go deleted file mode 100644 index 5b018ec..0000000 --- a/node/stmt/t_interface_test.go +++ /dev/null @@ -1,224 +0,0 @@ -package stmt_test - -import ( - "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" - "github.com/z7zmey/php-parser/php7" -) - -func TestInterface(t *testing.T) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - /** anonymous class */ - new class ($a, ...$b) {}; - ` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 2, - EndLine: 9, - StartPos: 6, - EndPos: 186, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 21, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 20, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 9, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 9, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 20, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 14, - EndPos: 19, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 17, - EndPos: 19, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 17, - EndPos: 19, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 40, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 39, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 28, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 28, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 39, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 33, - EndPos: 38, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 36, - EndPos: 38, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 36, - EndPos: 38, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 64, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 63, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 47, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 47, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 49, - EndPos: 52, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 63, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 57, - EndPos: 62, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 60, - EndPos: 62, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 60, - EndPos: 62, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 87, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 86, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 70, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 70, - }, - Value: "foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 72, - EndPos: 75, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 86, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 80, - EndPos: 85, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 83, - EndPos: 85, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 83, - EndPos: 85, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 111, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 110, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 94, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 94, - }, - Value: "foo", - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 96, - EndPos: 99, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 110, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 104, - EndPos: 109, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 107, - EndPos: 109, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 107, - EndPos: 109, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 114, - EndPos: 133, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 114, - EndPos: 132, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 118, - EndPos: 121, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 118, - EndPos: 121, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 132, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 126, - EndPos: 131, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 129, - EndPos: 131, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 129, - EndPos: 131, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 161, - EndPos: 186, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 161, - EndPos: 185, - }, - Class: &stmt.Class{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 165, - EndPos: 185, - }, - PhpDocComment: "/** anonymous class */", - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 171, - EndPos: 182, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 172, - EndPos: 174, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 172, - EndPos: 174, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 172, - EndPos: 174, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 176, - EndPos: 181, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 179, - EndPos: 181, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 179, - EndPos: 181, - }, - Value: "b", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestPhp5ArgumentNode(t *testing.T) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - ` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 2, - EndLine: 7, - StartPos: 6, - EndPos: 133, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 21, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 20, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 9, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 6, - EndPos: 9, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 20, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 14, - EndPos: 19, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 17, - EndPos: 19, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 17, - EndPos: 19, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 40, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 39, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 28, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 24, - EndPos: 28, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 39, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 29, - EndPos: 31, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 33, - EndPos: 38, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 36, - EndPos: 38, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 36, - EndPos: 38, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 64, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 63, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 47, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 43, - EndPos: 47, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 49, - EndPos: 52, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 63, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 53, - EndPos: 55, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 57, - EndPos: 62, - }, - IsReference: false, - Variadic: true, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 60, - EndPos: 62, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 60, - EndPos: 62, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 87, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 86, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 70, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 67, - EndPos: 70, - }, - Value: "foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 72, - EndPos: 75, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 86, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 76, - EndPos: 78, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 80, - EndPos: 85, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 83, - EndPos: 85, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 83, - EndPos: 85, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 111, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 110, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 94, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 90, - EndPos: 94, - }, - Value: "foo", - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 96, - EndPos: 99, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 110, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 100, - EndPos: 102, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 104, - EndPos: 109, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 107, - EndPos: 109, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 107, - EndPos: 109, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 114, - EndPos: 133, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 114, - EndPos: 132, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 118, - EndPos: 121, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 118, - EndPos: 121, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 132, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 122, - EndPos: 124, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 126, - EndPos: 131, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 129, - EndPos: 131, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 129, - EndPos: 131, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - }, - } - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual := php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestPhp7ParameterNode(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.Lexer.ReturnTokenToPool(yyDollar[i].token) - } - yyDollar[i].token = nil - } - yyVAL.token = nil -} diff --git a/php5/php5.go b/php5/php5.go deleted file mode 100644 index 8bb5291..0000000 --- a/php5/php5.go +++ /dev/null @@ -1,9823 +0,0 @@ -// line php5/php5.y:2 -package php5 - -import __yyfmt__ "fmt" - -// line php5/php5.y:2 -import ( - "strconv" - "strings" - - "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" - "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/scanner" -) - -// line php5/php5.y:22 -type yySymType struct { - yys int - node node.Node - token *scanner.Token - list []node.Node - simpleIndirectReference simpleIndirectReference - - ClassExtends *stmt.ClassExtends - ClassImplements *stmt.ClassImplements - InterfaceExtends *stmt.InterfaceExtends - ClosureUse *expr.ClosureUse -} - -const T_INCLUDE = 57346 -const T_INCLUDE_ONCE = 57347 -const T_EXIT = 57348 -const T_IF = 57349 -const T_LNUMBER = 57350 -const T_DNUMBER = 57351 -const T_STRING = 57352 -const T_STRING_VARNAME = 57353 -const T_VARIABLE = 57354 -const T_NUM_STRING = 57355 -const T_INLINE_HTML = 57356 -const T_CHARACTER = 57357 -const T_BAD_CHARACTER = 57358 -const T_ENCAPSED_AND_WHITESPACE = 57359 -const T_CONSTANT_ENCAPSED_STRING = 57360 -const T_ECHO = 57361 -const T_DO = 57362 -const T_WHILE = 57363 -const T_ENDWHILE = 57364 -const T_FOR = 57365 -const T_ENDFOR = 57366 -const T_FOREACH = 57367 -const T_ENDFOREACH = 57368 -const T_DECLARE = 57369 -const T_ENDDECLARE = 57370 -const T_AS = 57371 -const T_SWITCH = 57372 -const T_ENDSWITCH = 57373 -const T_CASE = 57374 -const T_DEFAULT = 57375 -const T_BREAK = 57376 -const T_CONTINUE = 57377 -const T_GOTO = 57378 -const T_FUNCTION = 57379 -const T_FN = 57380 -const T_CONST = 57381 -const T_RETURN = 57382 -const T_TRY = 57383 -const T_CATCH = 57384 -const T_FINALLY = 57385 -const T_THROW = 57386 -const T_USE = 57387 -const T_INSTEADOF = 57388 -const T_GLOBAL = 57389 -const T_VAR = 57390 -const T_UNSET = 57391 -const T_ISSET = 57392 -const T_EMPTY = 57393 -const T_HALT_COMPILER = 57394 -const T_CLASS = 57395 -const T_TRAIT = 57396 -const T_INTERFACE = 57397 -const T_EXTENDS = 57398 -const T_IMPLEMENTS = 57399 -const T_OBJECT_OPERATOR = 57400 -const T_DOUBLE_ARROW = 57401 -const T_LIST = 57402 -const T_ARRAY = 57403 -const T_CALLABLE = 57404 -const T_CLASS_C = 57405 -const T_TRAIT_C = 57406 -const T_METHOD_C = 57407 -const T_FUNC_C = 57408 -const T_LINE = 57409 -const T_FILE = 57410 -const T_COMMENT = 57411 -const T_DOC_COMMENT = 57412 -const T_OPEN_TAG = 57413 -const T_OPEN_TAG_WITH_ECHO = 57414 -const T_CLOSE_TAG = 57415 -const T_WHITESPACE = 57416 -const T_START_HEREDOC = 57417 -const T_END_HEREDOC = 57418 -const T_DOLLAR_OPEN_CURLY_BRACES = 57419 -const T_CURLY_OPEN = 57420 -const T_PAAMAYIM_NEKUDOTAYIM = 57421 -const T_NAMESPACE = 57422 -const T_NS_C = 57423 -const T_DIR = 57424 -const T_NS_SEPARATOR = 57425 -const T_ELLIPSIS = 57426 -const T_EVAL = 57427 -const T_REQUIRE = 57428 -const T_REQUIRE_ONCE = 57429 -const T_LOGICAL_OR = 57430 -const T_LOGICAL_XOR = 57431 -const T_LOGICAL_AND = 57432 -const T_INSTANCEOF = 57433 -const T_NEW = 57434 -const T_CLONE = 57435 -const T_ELSEIF = 57436 -const T_ELSE = 57437 -const T_ENDIF = 57438 -const T_PRINT = 57439 -const T_YIELD = 57440 -const T_STATIC = 57441 -const T_ABSTRACT = 57442 -const T_FINAL = 57443 -const T_PRIVATE = 57444 -const T_PROTECTED = 57445 -const T_PUBLIC = 57446 -const T_INC = 57447 -const T_DEC = 57448 -const T_YIELD_FROM = 57449 -const T_INT_CAST = 57450 -const T_DOUBLE_CAST = 57451 -const T_STRING_CAST = 57452 -const T_ARRAY_CAST = 57453 -const T_OBJECT_CAST = 57454 -const T_BOOL_CAST = 57455 -const T_UNSET_CAST = 57456 -const T_COALESCE = 57457 -const T_SPACESHIP = 57458 -const T_NOELSE = 57459 -const T_PLUS_EQUAL = 57460 -const T_MINUS_EQUAL = 57461 -const T_MUL_EQUAL = 57462 -const T_POW_EQUAL = 57463 -const T_DIV_EQUAL = 57464 -const T_CONCAT_EQUAL = 57465 -const T_MOD_EQUAL = 57466 -const T_AND_EQUAL = 57467 -const T_OR_EQUAL = 57468 -const T_XOR_EQUAL = 57469 -const T_SL_EQUAL = 57470 -const T_SR_EQUAL = 57471 -const T_COALESCE_EQUAL = 57472 -const T_BOOLEAN_OR = 57473 -const T_BOOLEAN_AND = 57474 -const T_POW = 57475 -const T_SL = 57476 -const T_SR = 57477 -const T_IS_IDENTICAL = 57478 -const T_IS_NOT_IDENTICAL = 57479 -const T_IS_EQUAL = 57480 -const T_IS_NOT_EQUAL = 57481 -const T_IS_SMALLER_OR_EQUAL = 57482 -const T_IS_GREATER_OR_EQUAL = 57483 - -var yyToknames = [...]string{ - "$end", - "error", - "$unk", - "T_INCLUDE", - "T_INCLUDE_ONCE", - "T_EXIT", - "T_IF", - "T_LNUMBER", - "T_DNUMBER", - "T_STRING", - "T_STRING_VARNAME", - "T_VARIABLE", - "T_NUM_STRING", - "T_INLINE_HTML", - "T_CHARACTER", - "T_BAD_CHARACTER", - "T_ENCAPSED_AND_WHITESPACE", - "T_CONSTANT_ENCAPSED_STRING", - "T_ECHO", - "T_DO", - "T_WHILE", - "T_ENDWHILE", - "T_FOR", - "T_ENDFOR", - "T_FOREACH", - "T_ENDFOREACH", - "T_DECLARE", - "T_ENDDECLARE", - "T_AS", - "T_SWITCH", - "T_ENDSWITCH", - "T_CASE", - "T_DEFAULT", - "T_BREAK", - "T_CONTINUE", - "T_GOTO", - "T_FUNCTION", - "T_FN", - "T_CONST", - "T_RETURN", - "T_TRY", - "T_CATCH", - "T_FINALLY", - "T_THROW", - "T_USE", - "T_INSTEADOF", - "T_GLOBAL", - "T_VAR", - "T_UNSET", - "T_ISSET", - "T_EMPTY", - "T_HALT_COMPILER", - "T_CLASS", - "T_TRAIT", - "T_INTERFACE", - "T_EXTENDS", - "T_IMPLEMENTS", - "T_OBJECT_OPERATOR", - "T_DOUBLE_ARROW", - "T_LIST", - "T_ARRAY", - "T_CALLABLE", - "T_CLASS_C", - "T_TRAIT_C", - "T_METHOD_C", - "T_FUNC_C", - "T_LINE", - "T_FILE", - "T_COMMENT", - "T_DOC_COMMENT", - "T_OPEN_TAG", - "T_OPEN_TAG_WITH_ECHO", - "T_CLOSE_TAG", - "T_WHITESPACE", - "T_START_HEREDOC", - "T_END_HEREDOC", - "T_DOLLAR_OPEN_CURLY_BRACES", - "T_CURLY_OPEN", - "T_PAAMAYIM_NEKUDOTAYIM", - "T_NAMESPACE", - "T_NS_C", - "T_DIR", - "T_NS_SEPARATOR", - "T_ELLIPSIS", - "T_EVAL", - "T_REQUIRE", - "T_REQUIRE_ONCE", - "T_LOGICAL_OR", - "T_LOGICAL_XOR", - "T_LOGICAL_AND", - "T_INSTANCEOF", - "T_NEW", - "T_CLONE", - "T_ELSEIF", - "T_ELSE", - "T_ENDIF", - "T_PRINT", - "T_YIELD", - "T_STATIC", - "T_ABSTRACT", - "T_FINAL", - "T_PRIVATE", - "T_PROTECTED", - "T_PUBLIC", - "T_INC", - "T_DEC", - "T_YIELD_FROM", - "T_INT_CAST", - "T_DOUBLE_CAST", - "T_STRING_CAST", - "T_ARRAY_CAST", - "T_OBJECT_CAST", - "T_BOOL_CAST", - "T_UNSET_CAST", - "T_COALESCE", - "T_SPACESHIP", - "T_NOELSE", - "T_PLUS_EQUAL", - "T_MINUS_EQUAL", - "T_MUL_EQUAL", - "T_POW_EQUAL", - "T_DIV_EQUAL", - "T_CONCAT_EQUAL", - "T_MOD_EQUAL", - "T_AND_EQUAL", - "T_OR_EQUAL", - "T_XOR_EQUAL", - "T_SL_EQUAL", - "T_SR_EQUAL", - "T_COALESCE_EQUAL", - "T_BOOLEAN_OR", - "T_BOOLEAN_AND", - "T_POW", - "T_SL", - "T_SR", - "T_IS_IDENTICAL", - "T_IS_NOT_IDENTICAL", - "T_IS_EQUAL", - "T_IS_NOT_EQUAL", - "T_IS_SMALLER_OR_EQUAL", - "T_IS_GREATER_OR_EQUAL", - "'\"'", - "'`'", - "'{'", - "'}'", - "';'", - "':'", - "'('", - "')'", - "'['", - "']'", - "'?'", - "'&'", - "'-'", - "'+'", - "'!'", - "'~'", - "'@'", - "'$'", - "','", - "'|'", - "'='", - "'^'", - "'*'", - "'/'", - "'%'", - "'<'", - "'>'", - "'.'", -} -var yyStatenames = [...]string{} - -const yyEofCode = 1 -const yyErrCode = 2 -const yyInitialStackSize = 16 - -// line php5/php5.y:7200 - -type simpleIndirectReference struct { - all []*expr.Variable - last *expr.Variable -} - -// line yacctab:1 -var yyExca = [...]int{ - -1, 1, - 1, -1, - -2, 0, - -1, 2, - 1, 1, - -2, 0, - -1, 51, - 105, 435, - 106, 435, - -2, 433, - -1, 102, - 79, 332, - -2, 411, - -1, 114, - 79, 451, - 148, 447, - -2, 457, - -1, 154, - 105, 435, - 106, 435, - -2, 433, - -1, 204, - 146, 306, - 149, 306, - -2, 430, - -1, 205, - 105, 435, - 106, 435, - 146, 307, - 149, 307, - -2, 433, - -1, 271, - 79, 451, - -2, 457, - -1, 298, - 79, 334, - -2, 413, - -1, 302, - 148, 448, - -2, 458, - -1, 311, - 79, 333, - -2, 412, - -1, 378, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 274, - -1, 379, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 275, - -1, 380, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 276, - -1, 381, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 277, - -1, 382, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 278, - -1, 383, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 279, - -1, 384, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 280, - -1, 385, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 281, - -1, 392, - 105, 435, - 106, 435, - -2, 433, - -1, 400, - 149, 142, - -2, 147, - -1, 462, - 105, 435, - 106, 435, - 149, 515, - 160, 515, - -2, 433, - -1, 463, - 149, 516, - 160, 516, - -2, 430, - -1, 464, - 105, 435, - 106, 435, - -2, 433, - -1, 486, - 149, 156, - 160, 156, - -2, 430, - -1, 487, - 105, 435, - 106, 435, - 149, 157, - 160, 157, - -2, 433, - -1, 493, - 148, 472, - -2, 517, - -1, 499, - 148, 472, - -2, 518, - -1, 521, - 79, 332, - -2, 369, - -1, 539, - 94, 135, - 95, 135, - 96, 135, - -2, 0, - -1, 551, - 149, 142, - -2, 147, - -1, 564, - 149, 142, - -2, 147, - -1, 581, - 146, 308, - 149, 308, - -2, 430, - -1, 582, - 105, 435, - 106, 435, - 146, 309, - 149, 309, - -2, 433, - -1, 682, - 79, 334, - -2, 371, - -1, 780, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 397, - -1, 781, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 398, - -1, 782, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 399, - -1, 783, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 400, - -1, 784, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 401, - -1, 785, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 402, - -1, 786, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 403, - -1, 787, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 404, - -1, 790, - 79, 333, - -2, 370, - -1, 840, - 37, 201, - -2, 198, - -1, 880, - 31, 128, - 32, 128, - 33, 128, - 145, 128, - -2, 0, - -1, 915, - 96, 140, - -2, 0, - -1, 917, - 31, 127, - 32, 127, - 33, 127, - 145, 127, - -2, 0, - -1, 944, - 94, 136, - 95, 136, - 96, 136, - -2, 0, - -1, 972, - 29, 189, - -2, 4, - -1, 981, - 149, 142, - -2, 147, - -1, 998, - 146, 193, - -2, 195, -} - -const yyPrivate = 57344 - -const yyLast = 8877 - -var yyAct = [...]int{ - - 102, 571, 844, 565, 1007, 966, 715, 61, 420, 827, - 123, 131, 919, 200, 340, 594, 567, 607, 452, 816, - 461, 808, 474, 735, 592, 684, 138, 140, 421, 142, - 145, 390, 39, 98, 444, 579, 264, 517, 118, 319, - 158, 315, 331, 330, 447, 7, 6, 544, 485, 130, - 2, 979, 26, 960, 938, 935, 228, 228, 162, 477, - 932, 942, 289, 941, 44, 670, 658, 664, 665, 672, - 673, 674, 675, 678, 679, 822, 738, 940, 658, 1003, - 251, 267, 710, 654, 258, 562, 662, 656, 655, 516, - 153, 658, 664, 665, 661, 654, 663, 657, 659, 660, - 676, 677, 666, 358, 298, 325, 736, 204, 654, 657, - 659, 660, 656, 655, 270, 794, 241, 137, 977, 729, - 954, 933, 657, 659, 660, 543, 311, 666, 475, 316, - 320, 955, 192, 323, 43, 934, 329, 922, 854, 5, - 898, 126, 450, 121, 121, 499, 192, 121, 586, 586, - 121, 658, 664, 665, 899, 633, 339, 141, 678, 679, - 619, 228, 201, 930, 114, 121, 634, 39, 654, 750, - 585, 620, 656, 655, 179, 310, 357, 115, 159, 162, - 432, 586, 657, 659, 660, 676, 677, 666, 179, 182, - 183, 192, 241, 267, 908, 228, 907, 905, 510, 493, - 862, 121, 296, 749, 506, 178, 180, 181, 192, 177, - 176, 229, 511, 856, 230, 792, 560, 104, 507, 178, - 180, 181, 746, 228, 175, 640, 270, 561, 117, 386, - 233, 425, 168, 179, 182, 183, 184, 185, 186, 187, - 189, 191, 494, 359, 595, 271, 126, 632, 121, 631, - 179, 1019, 625, 173, 177, 176, 624, 360, 272, 978, - 393, 172, 228, 174, 178, 180, 181, 188, 190, 175, - 456, 177, 176, 231, 231, 333, 451, 336, 556, 451, - 302, 178, 180, 181, 232, 232, 175, 355, 658, 557, - 120, 120, 350, 228, 120, 352, 423, 120, 265, 597, - 596, 356, 446, 241, 931, 654, 351, 473, 294, 273, - 312, 126, 303, 121, 131, 396, 229, 301, 509, 230, - 133, 305, 513, 300, 313, 160, 521, 604, 595, 126, - 440, 121, 605, 451, 134, 233, 741, 293, 492, 463, - 39, 436, 437, 498, 491, 287, 541, 281, 120, 497, - 484, 472, 612, 7, 6, 658, 254, 271, 611, 521, - 502, 718, 486, 505, 253, 1002, 951, 437, 436, 436, - 272, 437, 654, 916, 886, 883, 656, 655, 231, 871, - 826, 229, 815, 295, 230, 399, 657, 659, 660, 232, - 728, 666, 548, 546, 694, 120, 552, 635, 626, 229, - 233, 572, 230, 572, 577, 572, 580, 430, 228, 428, - 265, 584, 231, 126, 307, 121, 1014, 981, 233, 893, - 593, 273, 439, 232, 139, 588, 39, 297, 448, 825, - 126, 819, 121, 810, 809, 434, 683, 458, 587, 564, - 231, 449, 551, 400, 537, 288, 344, 5, 297, 345, - 295, 232, 539, 278, 717, 540, 616, 275, 274, 250, - 120, 222, 467, 196, 448, 492, 498, 453, 471, 448, - 581, 491, 497, 195, 479, 480, 194, 449, 120, 231, - 144, 495, 449, 229, 122, 1011, 230, 1010, 1000, 228, - 232, 914, 617, 615, 877, 135, 446, 990, 618, 985, - 268, 490, 233, 269, 704, 705, 984, 924, 316, 913, - 231, 309, 320, 308, 504, 881, 812, 521, 806, 233, - 805, 232, 799, 400, 682, 713, 521, 704, 705, 700, - 547, 545, 39, 521, 521, 521, 521, 521, 542, 501, - 398, 348, 156, 531, 91, 7, 6, 353, 636, 646, - 982, 649, 572, 126, 653, 711, 906, 701, 228, 228, - 228, 606, 120, 521, 435, 572, 719, 1020, 727, 39, - 39, 976, 918, 892, 891, 732, 531, 572, 580, 120, - 889, 733, 730, 578, 306, 267, 197, 228, 228, 714, - 179, 448, 448, 706, 875, 708, 740, 224, 225, 257, - 724, 192, 803, 804, 449, 449, 831, 518, 743, 696, - 697, 295, 734, 126, 613, 739, 742, 811, 270, 448, - 731, 737, 448, 126, 448, 231, 125, 681, 490, 228, - 745, 228, 449, 455, 446, 449, 232, 449, 424, 5, - 703, 755, 126, 179, 125, 988, 688, 610, 259, 459, - 128, 651, 129, 438, 126, 521, 521, 521, 521, 521, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 521, 521, 790, 759, 521, 463, 321, 124, 757, 454, - 758, 648, 282, 286, 638, 639, 132, 721, 972, 486, - 642, 643, 427, 426, 800, 295, 231, 515, 793, 791, - 126, 521, 573, 260, 261, 574, 512, 232, 228, 848, - 849, 850, 847, 846, 845, 508, 304, 317, 322, 299, - 572, 469, 832, 126, 531, 687, 62, 572, 851, 820, - 817, 865, 595, 531, 457, 295, 829, 263, 814, 271, - 531, 531, 531, 531, 531, 576, 852, 833, 743, 404, - 448, 295, 272, 857, 859, 402, 796, 259, 573, 208, - 295, 574, 438, 449, 744, 231, 231, 231, 468, 295, - 531, 54, 295, 132, 569, 570, 232, 232, 232, 521, - 259, 504, 751, 207, 285, 521, 521, 986, 828, 1008, - 239, 842, 265, 573, 231, 231, 574, 843, 824, 797, - 841, 876, 726, 273, 163, 232, 232, 45, 228, 987, - 228, 878, 559, 521, 884, 882, 572, 890, 885, 879, - 338, 470, 260, 261, 801, 1018, 992, 226, 234, 45, - 821, 958, 956, 901, 572, 904, 231, 926, 231, 897, - 259, 39, 894, 259, 469, 260, 261, 232, 284, 232, - 888, 848, 849, 850, 847, 846, 845, 550, 228, 900, - 519, 521, 531, 531, 531, 531, 531, 531, 531, 531, - 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, - 531, 531, 531, 531, 531, 531, 531, 531, 531, 923, - 909, 531, 1, 519, 446, 1004, 599, 895, 601, 600, - 39, 999, 961, 521, 937, 260, 261, 285, 260, 261, - 936, 902, 855, 813, 704, 705, 880, 910, 531, 126, - 860, 861, 761, 521, 760, 231, 521, 874, 723, 521, - 453, 572, 963, 572, 971, 39, 232, 39, 610, 707, - 704, 705, 652, 650, 647, 39, 602, 39, 39, 259, - 514, 521, 481, 259, 438, 395, 572, 971, 283, 324, - 957, 983, 203, 959, 39, 202, 962, 199, 39, 39, - 521, 136, 572, 830, 748, 994, 754, 572, 996, 259, - 998, 864, 445, 609, 256, 915, 589, 917, 980, 590, - 591, 685, 255, 39, 572, 1012, 531, 925, 840, 927, - 928, 1013, 531, 531, 995, 572, 1016, 993, 965, 964, - 920, 39, 903, 920, 260, 261, 483, 896, 260, 261, - 448, 839, 944, 836, 566, 231, 948, 231, 1006, 949, - 531, 842, 1005, 449, 725, 39, 232, 843, 232, 192, - 841, 39, 394, 946, 260, 261, 389, 164, 341, 698, - 538, 519, 929, 290, 460, 973, 161, 157, 318, 314, - 519, 127, 403, 575, 401, 335, 945, 519, 519, 519, - 519, 519, 1009, 343, 939, 231, 528, 608, 531, 997, - 970, 179, 182, 183, 991, 969, 232, 968, 189, 191, - 967, 848, 849, 850, 847, 846, 845, 519, 838, 837, - 835, 40, 177, 176, 568, 169, 171, 170, 192, 15, - 14, 823, 178, 180, 181, 188, 190, 175, 720, 1015, - 531, 802, 695, 686, 11, 249, 75, 76, 1021, 116, - 689, 690, 691, 692, 693, 266, 64, 834, 89, 598, - 531, 90, 520, 531, 101, 74, 531, 12, 167, 168, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 326, - 100, 99, 79, 810, 809, 119, 526, 3, 531, 193, - 173, 177, 176, 41, 0, 0, 0, 0, 172, 0, - 174, 178, 180, 181, 188, 190, 175, 531, 0, 519, - 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, - 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, - 519, 519, 519, 519, 519, 519, 0, 0, 519, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 669, - 667, 668, 0, 0, 0, 519, 0, 0, 0, 0, - 0, 0, 762, 763, 764, 765, 766, 767, 768, 769, - 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, - 780, 781, 782, 783, 784, 785, 786, 787, 789, 0, - 0, 686, 671, 670, 658, 664, 665, 672, 673, 674, - 675, 678, 679, 0, 169, 171, 170, 192, 870, 0, - 0, 654, 0, 680, 662, 656, 655, 0, 0, 0, - 0, 0, 661, 0, 663, 657, 659, 660, 676, 677, - 666, 0, 0, 519, 0, 0, 0, 0, 0, 519, - 519, 0, 0, 0, 0, 0, 0, 167, 168, 179, - 182, 183, 184, 185, 186, 187, 189, 191, 0, 0, - 0, 863, 31, 0, 0, 0, 0, 519, 193, 173, - 177, 176, 0, 0, 0, 0, 0, 172, 0, 174, - 178, 180, 181, 188, 190, 175, 147, 151, 155, 0, - 0, 0, 165, 0, 0, 0, 869, 0, 0, 51, - 198, 0, 872, 873, 0, 206, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 519, 223, 0, 0, 0, - 235, 236, 237, 238, 0, 154, 240, 0, 242, 243, - 244, 245, 246, 247, 248, 0, 252, 0, 0, 0, - 0, 262, 205, 0, 0, 0, 276, 277, 0, 279, - 280, 0, 0, 0, 0, 227, 227, 519, 0, 0, - 291, 0, 0, 671, 670, 658, 664, 665, 672, 673, - 674, 675, 678, 679, 0, 0, 0, 519, 911, 0, - 519, 0, 654, 519, 680, 662, 656, 655, 0, 0, - 0, 0, 0, 661, 0, 663, 657, 659, 660, 676, - 677, 666, 240, 0, 0, 519, 0, 342, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 943, 0, 0, 0, 519, 0, 0, 0, 0, 0, - 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, - 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, - 381, 382, 383, 384, 385, 0, 387, 0, 155, 0, - 354, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 406, 408, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 419, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 391, 392, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 912, 0, 0, 0, 0, - 0, 0, 0, 240, 0, 0, 433, 433, 0, 0, - 0, 0, 422, 441, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 669, 667, 668, 155, 465, 0, - 0, 466, 0, 0, 433, 0, 0, 0, 0, 0, - 433, 291, 0, 0, 0, 0, 433, 433, 0, 0, - 155, 443, 0, 433, 496, 0, 0, 0, 0, 500, - 0, 0, 0, 0, 462, 464, 0, 671, 670, 658, - 664, 665, 672, 673, 674, 675, 678, 679, 0, 0, - 0, 0, 478, 0, 0, 0, 654, 487, 680, 662, - 656, 655, 0, 0, 0, 0, 0, 661, 0, 663, - 657, 659, 660, 676, 677, 666, 549, 0, 0, 0, - 0, 0, 0, 553, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4, 0, 83, - 84, 72, 18, 105, 106, 13, 88, 121, 0, 30, - 0, 555, 0, 95, 29, 20, 19, 0, 21, 0, - 33, 0, 34, 0, 0, 22, 0, 0, 155, 23, - 24, 38, 45, 0, 16, 25, 36, 0, 0, 37, - 10, 0, 27, 0, 32, 81, 82, 8, 46, 48, - 50, 0, 0, 0, 0, 52, 96, 0, 94, 110, - 111, 112, 107, 108, 0, 582, 0, 583, 0, 0, - 93, 0, 0, 0, 614, 9, 113, 109, 103, 0, - 85, 86, 87, 0, 0, 0, 0, 80, 53, 0, - 0, 0, 78, 42, 28, 47, 49, 0, 627, 629, - 55, 56, 0, 65, 66, 67, 68, 69, 70, 71, - 0, 0, 637, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 658, 664, 665, 672, 673, - 674, 675, 678, 679, 0, 0, 0, 92, 77, 17, - 645, 35, 654, 63, 0, 97, 656, 655, 478, 58, - 57, 59, 60, 73, 120, 0, 657, 659, 660, 676, - 677, 666, 0, 192, 0, 342, 702, 658, 664, 665, - 672, 673, 674, 675, 678, 679, 0, 712, 0, 0, - 0, 0, 0, 0, 654, 0, 0, 662, 656, 655, - 0, 0, 0, 0, 0, 661, 0, 663, 657, 659, - 660, 676, 677, 666, 0, 179, 182, 183, 184, 185, - 186, 187, 189, 191, 0, 0, 433, 391, 716, 716, - 669, 667, 668, 0, 0, 173, 177, 176, 747, 0, - 0, 0, 0, 0, 433, 752, 178, 180, 181, 188, - 190, 175, 0, 155, 0, 0, 422, 422, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 155, 0, 169, - 171, 170, 192, 671, 670, 658, 664, 665, 672, 673, - 674, 675, 678, 679, 0, 0, 0, 0, 0, 0, - 462, 0, 654, 868, 680, 662, 656, 655, 478, 0, - 478, 0, 0, 661, 487, 663, 657, 659, 660, 676, - 677, 666, 167, 168, 179, 182, 183, 184, 185, 186, - 187, 189, 191, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 858, 193, 173, 177, 176, 807, 0, 0, - 0, 0, 172, 0, 174, 178, 180, 181, 188, 190, - 175, 0, 0, 0, 0, 0, 0, 0, 0, 658, - 664, 665, 672, 673, 674, 675, 678, 679, 0, 0, - 0, 853, 0, 0, 433, 0, 654, 0, 0, 662, - 656, 655, 433, 433, 0, 0, 0, 818, 0, 866, - 657, 659, 660, 676, 677, 666, 0, 210, 211, 212, - 213, 214, 215, 216, 217, 218, 219, 220, 221, 0, - 0, 0, 4, 0, 83, 84, 72, 18, 105, 106, - 13, 88, 121, 0, 30, 349, 0, 0, 95, 29, - 20, 19, 0, 21, 0, 33, 0, 34, 0, 342, - 22, 209, 0, 0, 23, 24, 38, 45, 0, 16, - 25, 36, 0, 0, 37, 10, 0, 27, 0, 32, - 81, 82, 8, 46, 48, 50, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 716, 0, 422, - 9, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 28, - 47, 49, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 478, 0, 0, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - 220, 221, 92, 77, 17, 503, 35, 0, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 4, 621, 83, 84, 72, 18, 105, 106, 13, 88, - 121, 0, 30, 0, 209, 0, 95, 29, 20, 19, - 0, 21, 0, 33, 0, 34, 558, 0, 22, 0, - 0, 0, 23, 24, 38, 45, 0, 16, 25, 36, - 0, 0, 37, 10, 0, 27, 0, 32, 81, 82, - 8, 46, 48, 50, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 9, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 42, 28, 47, 49, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 0, 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 210, 211, 212, - 213, 214, 215, 216, 217, 218, 219, 220, 221, 0, - 92, 77, 17, 0, 35, 0, 63, 0, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 328, 209, - 83, 84, 72, 18, 105, 106, 13, 88, 121, 0, - 30, 209, 0, 0, 95, 29, 20, 19, 0, 21, - 0, 33, 0, 34, 0, 0, 22, 0, 0, 0, - 23, 24, 38, 45, 0, 0, 25, 36, 0, 0, - 37, 0, 0, 27, 0, 32, 81, 82, 332, 46, - 48, 50, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 42, 28, 47, 49, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 17, 1022, 35, 0, 63, 0, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 328, 0, 83, 84, - 72, 18, 105, 106, 13, 88, 121, 0, 30, 0, - 0, 0, 95, 29, 20, 19, 0, 21, 0, 33, - 0, 34, 0, 0, 22, 0, 0, 0, 23, 24, - 38, 45, 0, 0, 25, 36, 0, 0, 37, 0, - 0, 27, 0, 32, 81, 82, 332, 46, 48, 50, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 42, 28, 47, 49, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 17, 1017, - 35, 0, 63, 0, 97, 0, 0, 0, 58, 57, - 59, 60, 73, 120, 328, 0, 83, 84, 72, 18, - 105, 106, 13, 88, 121, 0, 30, 0, 0, 0, - 95, 29, 20, 19, 0, 21, 0, 33, 0, 34, - 0, 0, 22, 0, 0, 0, 23, 24, 38, 45, - 0, 0, 25, 36, 0, 0, 37, 0, 0, 27, - 0, 32, 81, 82, 332, 46, 48, 50, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 42, 28, 47, 49, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 17, 1001, 35, 0, - 63, 0, 97, 0, 0, 0, 58, 57, 59, 60, - 73, 120, 328, 0, 83, 84, 72, 18, 105, 106, - 13, 88, 121, 0, 30, 0, 0, 0, 95, 29, - 20, 19, 0, 21, 989, 33, 0, 34, 0, 0, - 22, 0, 0, 0, 23, 24, 38, 45, 0, 0, - 25, 36, 0, 0, 37, 0, 0, 27, 0, 32, - 81, 82, 332, 46, 48, 50, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 28, - 47, 49, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 17, 0, 35, 0, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 328, 0, 83, 84, 72, 18, 105, 106, 13, 88, - 121, 0, 30, 0, 0, 0, 95, 29, 20, 19, - 0, 21, 0, 33, 975, 34, 0, 0, 22, 0, - 0, 0, 23, 24, 38, 45, 0, 0, 25, 36, - 0, 0, 37, 0, 0, 27, 0, 32, 81, 82, - 332, 46, 48, 50, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 42, 28, 47, 49, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 17, 0, 35, 0, 63, 0, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 328, 0, - 83, 84, 72, 18, 105, 106, 13, 88, 121, 0, - 30, 0, 0, 0, 95, 29, 20, 19, 0, 21, - 0, 33, 0, 34, 0, 0, 22, 0, 0, 0, - 23, 24, 38, 45, 0, 0, 25, 36, 0, 0, - 37, 0, 0, 27, 0, 32, 81, 82, 332, 46, - 48, 50, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 42, 28, 47, 49, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 17, 974, 35, 0, 63, 0, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 328, 0, 83, 84, - 72, 18, 105, 106, 13, 88, 121, 0, 30, 0, - 0, 0, 95, 29, 20, 19, 0, 21, 0, 33, - 0, 34, 0, 0, 22, 0, 0, 0, 23, 24, - 38, 45, 0, 0, 25, 36, 0, 0, 37, 0, - 0, 27, 0, 32, 81, 82, 332, 46, 48, 50, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 42, 28, 47, 49, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 17, 953, - 35, 0, 63, 0, 97, 0, 0, 0, 58, 57, - 59, 60, 73, 120, 328, 0, 83, 84, 72, 18, - 105, 106, 13, 88, 121, 0, 30, 0, 0, 0, - 95, 29, 20, 19, 0, 21, 0, 33, 0, 34, - 0, 0, 22, 0, 0, 0, 23, 24, 38, 45, - 0, 0, 25, 36, 0, 0, 37, 0, 0, 27, - 0, 32, 81, 82, 332, 46, 48, 50, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 42, 28, 47, 49, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 17, 952, 35, 0, - 63, 0, 97, 0, 0, 0, 58, 57, 59, 60, - 73, 120, 328, 0, 83, 84, 72, 18, 105, 106, - 13, 88, 121, 0, 30, 0, 0, 0, 95, 29, - 20, 19, 0, 21, 0, 33, 0, 34, 0, 0, - 22, 0, 0, 0, 23, 24, 38, 45, 0, 0, - 25, 36, 0, 0, 37, 0, 0, 27, 0, 32, - 81, 82, 332, 46, 48, 50, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 28, - 47, 49, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 17, 950, 35, 0, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 328, 0, 83, 84, 72, 18, 105, 106, 13, 88, - 121, 0, 30, 0, 0, 0, 95, 29, 20, 19, - 0, 21, 0, 33, 0, 34, 887, 0, 22, 0, - 0, 0, 23, 24, 38, 45, 0, 0, 25, 36, - 0, 0, 37, 0, 0, 27, 0, 32, 81, 82, - 332, 46, 48, 50, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 42, 28, 47, 49, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 17, 0, 35, 0, 63, 0, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 328, 0, - 83, 84, 72, 18, 105, 106, 13, 88, 121, 0, - 30, 0, 0, 0, 95, 29, 20, 19, 699, 21, - 0, 33, 0, 34, 0, 0, 22, 0, 0, 0, - 23, 24, 38, 45, 0, 0, 25, 36, 0, 0, - 37, 0, 0, 27, 0, 32, 81, 82, 332, 46, - 48, 50, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 42, 28, 47, 49, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 17, 0, 35, 0, 63, 0, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 328, 0, 83, 84, - 72, 18, 105, 106, 13, 88, 121, 0, 30, 0, - 0, 0, 95, 29, 20, 19, 0, 21, 0, 33, - 0, 34, 0, 0, 22, 0, 0, 0, 23, 24, - 38, 45, 0, 0, 25, 36, 0, 0, 37, 0, - 0, 27, 0, 32, 81, 82, 332, 46, 48, 50, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 42, 28, 47, 49, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 17, 563, - 35, 0, 63, 0, 97, 0, 0, 0, 58, 57, - 59, 60, 73, 120, 328, 0, 83, 84, 72, 18, - 105, 106, 13, 88, 121, 0, 30, 0, 0, 0, - 95, 29, 20, 19, 0, 21, 0, 33, 0, 34, - 0, 0, 22, 0, 0, 0, 23, 24, 38, 45, - 0, 0, 25, 36, 0, 0, 37, 0, 0, 27, - 0, 32, 81, 82, 332, 46, 48, 50, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 42, 28, 47, 49, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 17, 327, 35, 0, - 63, 0, 97, 0, 0, 0, 58, 57, 59, 60, - 73, 120, 328, 0, 83, 84, 72, 18, 105, 106, - 13, 88, 121, 0, 30, 0, 0, 0, 95, 29, - 20, 19, 0, 21, 0, 33, 0, 34, 0, 0, - 22, 0, 0, 0, 23, 24, 38, 45, 0, 0, - 25, 36, 0, 0, 37, 0, 0, 27, 0, 32, - 81, 82, 332, 46, 48, 50, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 28, - 47, 49, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 17, 0, 35, 0, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 83, 84, 72, 18, 105, 106, 13, 88, 121, 0, - 30, 0, 0, 0, 95, 29, 20, 19, 0, 21, - 0, 33, 0, 34, 0, 0, 22, 0, 0, 0, - 23, 24, 38, 45, 0, 0, 25, 36, 0, 0, - 37, 0, 0, 27, 0, 32, 81, 82, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 42, 28, 0, 0, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 17, 0, 35, 947, 63, 0, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 83, 84, 72, 18, - 105, 106, 13, 88, 121, 0, 30, 0, 0, 0, - 95, 29, 20, 19, 0, 21, 0, 33, 0, 34, - 0, 0, 22, 0, 0, 0, 23, 24, 38, 45, - 0, 0, 25, 36, 0, 0, 37, 0, 0, 27, - 0, 32, 81, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 42, 28, 0, 0, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 17, 0, 35, 921, - 63, 0, 97, 0, 0, 0, 58, 57, 59, 60, - 73, 120, 83, 84, 72, 18, 105, 106, 13, 88, - 121, 0, 30, 0, 0, 0, 95, 29, 20, 19, - 0, 21, 0, 33, 0, 34, 0, 0, 22, 0, - 0, 0, 23, 24, 38, 45, 0, 0, 25, 36, - 0, 0, 37, 0, 0, 27, 0, 32, 81, 82, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 42, 28, 0, 0, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 17, 0, 35, 722, 63, 0, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 83, 84, - 72, 18, 105, 106, 13, 88, 121, 0, 30, 0, - 0, 0, 95, 29, 20, 19, 0, 21, 0, 33, - 0, 34, 0, 0, 22, 0, 0, 0, 23, 24, - 38, 45, 0, 0, 25, 36, 0, 0, 37, 0, - 0, 27, 0, 32, 81, 82, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 42, 28, 0, 0, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 17, 0, - 35, 337, 63, 0, 97, 0, 0, 0, 58, 57, - 59, 60, 73, 120, 83, 84, 72, 18, 105, 106, - 13, 88, 121, 0, 30, 0, 0, 0, 95, 29, - 20, 19, 0, 21, 0, 33, 0, 34, 0, 0, - 22, 0, 0, 0, 23, 24, 38, 45, 0, 0, - 25, 36, 0, 0, 37, 0, 0, 27, 0, 32, - 81, 82, 0, 0, 0, 0, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 28, - 0, 0, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 17, 0, 35, 334, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 83, 84, 72, 18, 105, 106, 13, 88, 121, 0, - 30, 0, 0, 0, 95, 29, 20, 19, 0, 21, - 0, 33, 0, 34, 0, 0, 22, 0, 0, 0, - 23, 24, 38, 45, 0, 0, 25, 36, 0, 0, - 37, 0, 0, 27, 0, 32, 81, 82, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 42, 28, 0, 0, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 83, 84, 72, 0, 105, 106, 126, 88, - 121, 0, 0, 0, 0, 0, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 17, 0, 35, 0, 63, 45, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 0, 0, 81, 82, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 489, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 42, 149, 0, 0, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 0, 0, 83, 84, 72, 0, - 105, 106, 126, 88, 121, 0, 0, 0, 0, 0, - 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 0, 0, 0, 0, 63, 482, 97, 45, - 0, 488, 58, 57, 59, 60, 73, 120, 0, 0, - 0, 0, 81, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 489, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 148, 149, 0, 0, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 83, 84, - 72, 0, 105, 106, 126, 88, 121, 0, 0, 0, - 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 0, 0, 0, 0, - 63, 45, 97, 0, 0, 488, 58, 57, 59, 60, - 73, 120, 0, 0, 81, 82, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 148, 149, 0, 0, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 83, 84, 72, 0, 105, 106, 126, 88, 121, 0, - 0, 0, 0, 0, 95, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 0, 0, - 0, 0, 63, 45, 97, 0, 0, 867, 58, 57, - 59, 60, 73, 120, 0, 0, 81, 82, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 148, 149, 0, 0, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 83, 84, 72, 0, 105, 106, 126, 88, - 121, 0, 0, 0, 0, 0, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 0, 0, 0, 0, 63, 45, 97, 0, 0, 630, - 58, 57, 59, 60, 73, 120, 0, 0, 81, 82, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 148, 149, 0, 0, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 83, 84, 72, 0, 105, 106, - 126, 88, 121, 0, 0, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 0, 0, 0, 0, 63, 45, 97, 0, - 0, 628, 58, 57, 59, 60, 73, 120, 0, 0, - 81, 82, 0, 0, 0, 0, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 148, 149, - 0, 0, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 83, 84, 72, 0, - 105, 106, 126, 88, 121, 0, 0, 0, 0, 0, - 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 0, 0, 0, 0, 63, 45, - 97, 0, 0, 292, 58, 57, 59, 60, 73, 120, - 0, 0, 81, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 42, 149, 0, 0, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, - 83, 84, 72, 0, 105, 106, 126, 88, 121, 0, - 0, 0, 0, 0, 95, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 0, 0, 0, 0, - 63, 431, 97, 45, 0, 0, 58, 57, 59, 60, - 73, 120, 0, 0, 0, 0, 81, 82, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 148, 149, 0, 0, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 83, 84, 72, 0, 105, 106, 126, 88, - 121, 0, 0, 0, 0, 0, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 0, 0, 0, 0, 63, 45, 97, 0, 0, 407, - 58, 57, 59, 60, 73, 120, 0, 0, 81, 82, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 148, 149, 0, 0, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 83, 84, 72, 0, 105, 106, - 126, 88, 121, 0, 0, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 0, 0, 0, 388, 63, 45, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 0, 0, - 81, 82, 0, 0, 0, 0, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 148, 149, - 0, 0, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 83, 84, 72, 0, - 105, 106, 126, 88, 121, 0, 0, 0, 0, 0, - 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 0, 0, 152, 0, 63, 45, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 0, 0, 81, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 52, 96, 0, 94, 110, 111, 112, 107, - 108, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 0, 143, 113, 109, 103, 0, 85, 86, 87, - 0, 0, 0, 0, 80, 53, 0, 0, 0, 78, - 148, 149, 0, 0, 0, 0, 0, 55, 56, 0, - 65, 66, 67, 68, 69, 70, 71, 0, 83, 84, - 72, 0, 105, 106, 126, 88, 121, 0, 0, 0, - 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 92, 77, 0, 0, 150, 0, - 63, 45, 97, 0, 0, 0, 58, 57, 59, 60, - 73, 120, 0, 0, 81, 82, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 96, 0, 94, 110, 111, - 112, 107, 108, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 143, 113, 109, 103, 0, 85, - 86, 87, 0, 0, 0, 0, 80, 53, 0, 0, - 0, 78, 148, 149, 0, 0, 0, 0, 0, 55, - 56, 0, 65, 66, 67, 68, 69, 70, 71, 0, - 83, 84, 72, 0, 105, 106, 126, 88, 121, 0, - 0, 0, 0, 0, 95, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 92, 77, 0, 0, - 146, 0, 63, 45, 97, 0, 0, 0, 58, 57, - 59, 60, 73, 120, 0, 0, 81, 82, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 96, 0, 94, - 110, 111, 112, 107, 108, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 0, 143, 113, 109, 103, - 0, 85, 86, 87, 0, 0, 0, 0, 80, 53, - 0, 0, 0, 78, 148, 149, 0, 0, 0, 0, - 0, 55, 56, 0, 65, 66, 67, 68, 69, 70, - 71, 0, 83, 84, 72, 0, 105, 106, 126, 442, - 121, 0, 0, 0, 0, 0, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 92, 77, - 0, 0, 0, 0, 63, 45, 97, 0, 0, 0, - 58, 57, 59, 60, 73, 120, 0, 0, 81, 82, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 96, - 0, 94, 110, 111, 112, 107, 108, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 0, 143, 113, - 109, 103, 0, 85, 86, 87, 0, 0, 0, 0, - 80, 53, 0, 0, 0, 78, 148, 149, 0, 0, - 0, 0, 0, 55, 56, 0, 65, 66, 67, 68, - 69, 70, 71, 0, 83, 84, 72, 0, 105, 106, - 126, 88, 121, 0, 0, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 77, 0, 0, 0, 0, 63, 45, 97, 0, - 0, 0, 58, 57, 59, 60, 73, 120, 0, 0, - 81, 82, 0, 0, 0, 0, 0, 0, 0, 0, - 52, 96, 0, 94, 110, 111, 112, 107, 108, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 143, 113, 109, 103, 0, 85, 86, 87, 0, 0, - 0, 0, 80, 53, 0, 0, 0, 78, 42, 149, - 0, 0, 0, 0, 0, 55, 56, 0, 65, 66, - 67, 68, 69, 70, 71, 0, 0, 669, 667, 668, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 92, 77, 795, 0, 0, 0, 63, 0, - 97, 0, 0, 0, 58, 57, 59, 60, 73, 120, - 671, 670, 658, 664, 665, 672, 673, 674, 675, 678, - 679, 0, 0, 669, 667, 668, 0, 0, 798, 654, - 0, 680, 662, 656, 655, 0, 0, 0, 0, 0, - 661, 0, 663, 657, 659, 660, 676, 677, 666, 756, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 671, 670, 658, 664, - 665, 672, 673, 674, 675, 678, 679, 0, 169, 171, - 170, 192, 0, 0, 0, 654, 0, 680, 662, 656, - 655, 0, 0, 0, 0, 0, 661, 0, 663, 657, - 659, 660, 676, 677, 666, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 169, 171, 170, - 192, 167, 168, 179, 182, 183, 184, 185, 186, 187, - 189, 191, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 193, 173, 177, 176, 0, 0, 0, 0, - 0, 172, 0, 174, 178, 180, 181, 188, 190, 175, - 167, 168, 179, 182, 183, 184, 185, 186, 187, 189, - 191, 0, 0, 0, 753, 169, 171, 170, 192, 0, - 0, 193, 173, 177, 176, 0, 0, 0, 0, 0, - 172, 0, 174, 178, 180, 181, 188, 190, 175, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 169, 171, 170, 192, 167, 168, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 0, - 0, 0, 709, 0, 0, 0, 0, 0, 0, 193, - 173, 177, 176, 0, 0, 0, 0, 0, 172, 0, - 174, 178, 180, 181, 188, 190, 175, 167, 168, 179, - 182, 183, 184, 185, 186, 187, 189, 191, 0, 0, - 0, 644, 169, 171, 170, 192, 0, 0, 193, 173, - 177, 176, 0, 0, 0, 0, 0, 172, 0, 174, - 178, 180, 181, 188, 190, 175, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 169, 171, 170, 192, 167, 168, 179, 182, 183, - 184, 185, 186, 187, 189, 191, 0, 0, 0, 641, - 0, 0, 0, 0, 0, 0, 193, 173, 177, 176, - 0, 0, 0, 0, 0, 172, 0, 174, 178, 180, - 181, 188, 190, 175, 167, 168, 179, 182, 183, 184, - 185, 186, 187, 189, 191, 169, 171, 170, 192, 0, - 0, 0, 623, 0, 0, 193, 173, 177, 176, 0, - 0, 0, 0, 0, 172, 0, 174, 178, 180, 181, - 188, 190, 175, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 169, 171, 170, 192, 167, 168, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 0, - 0, 0, 0, 0, 0, 0, 622, 0, 0, 193, - 173, 177, 176, 0, 0, 0, 0, 0, 172, 0, - 174, 178, 180, 181, 188, 190, 175, 167, 168, 179, - 182, 183, 184, 185, 186, 187, 189, 191, 0, 0, - 0, 603, 169, 171, 170, 192, 0, 0, 193, 173, - 177, 176, 476, 0, 0, 0, 0, 172, 0, 174, - 178, 180, 181, 188, 190, 175, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 169, 171, 170, 192, 167, 168, 179, 182, 183, - 184, 185, 186, 187, 189, 191, 0, 0, 0, 0, - 0, 554, 0, 0, 0, 0, 193, 173, 177, 176, - 0, 0, 0, 0, 0, 172, 0, 174, 178, 180, - 181, 188, 190, 175, 167, 168, 179, 182, 183, 184, - 185, 186, 187, 189, 191, 169, 171, 170, 192, 0, - 0, 0, 0, 0, 0, 193, 173, 177, 176, 0, - 0, 0, 0, 0, 172, 0, 174, 178, 180, 181, - 188, 190, 175, 405, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 167, 168, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 0, - 0, 0, 169, 171, 170, 192, 429, 0, 0, 193, - 173, 177, 176, 0, 0, 0, 0, 0, 172, 0, - 174, 178, 180, 181, 188, 190, 175, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 169, 171, 170, 192, 167, 168, 179, 182, 183, - 184, 185, 186, 187, 189, 191, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 193, 173, 177, 176, - 0, 0, 0, 0, 0, 172, 0, 174, 178, 180, - 181, 188, 190, 175, 167, 168, 179, 182, 183, 184, - 185, 186, 187, 189, 191, 169, 171, 170, 192, 397, - 0, 0, 0, 0, 0, 193, 173, 177, 176, 0, - 0, 0, 0, 0, 172, 0, 174, 178, 180, 181, - 188, 190, 175, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 169, 171, 170, 192, 167, 168, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 0, - 0, 0, 0, 347, 0, 0, 0, 0, 0, 193, - 173, 177, 176, 0, 0, 0, 0, 0, 172, 0, - 174, 178, 180, 181, 188, 190, 175, 167, 168, 179, - 182, 183, 184, 185, 186, 187, 189, 191, 169, 171, - 170, 192, 346, 0, 0, 0, 0, 0, 193, 173, - 177, 176, 0, 0, 0, 0, 0, 172, 0, 174, - 178, 180, 181, 188, 190, 175, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 669, 667, 668, - 0, 167, 168, 179, 182, 183, 184, 185, 186, 187, - 189, 191, 0, 0, 0, 0, 166, 0, 0, 0, - 0, 0, 193, 173, 177, 176, 0, 0, 0, 0, - 0, 172, 0, 174, 178, 180, 181, 188, 190, 175, - 671, 670, 658, 664, 665, 672, 673, 674, 675, 678, - 679, 169, 171, 170, 192, 0, 0, 0, 0, 654, - 0, 680, 662, 656, 655, 0, 0, 0, 0, 0, - 661, 0, 663, 657, 659, 660, 676, 677, 666, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 667, 668, 0, 167, 168, 179, 182, 183, 184, - 185, 186, 187, 189, 191, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 193, 173, 177, 176, 0, - 0, 0, 0, 0, 172, 0, 174, 178, 180, 181, - 188, 190, 175, 671, 670, 658, 664, 665, 672, 673, - 674, 675, 678, 679, 171, 170, 192, 0, 0, 0, - 0, 0, 654, 0, 680, 662, 656, 655, 0, 0, - 0, 0, 0, 661, 0, 663, 657, 659, 660, 676, - 677, 666, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 668, 0, 167, 168, 179, 182, - 183, 184, 185, 186, 187, 189, 191, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 193, 173, 177, - 176, 0, 0, 0, 0, 0, 172, 0, 174, 178, - 180, 181, 188, 190, 175, 671, 670, 658, 664, 665, - 672, 673, 674, 675, 678, 679, 170, 192, 0, 0, - 0, 0, 0, 0, 654, 0, 680, 662, 656, 655, - 0, 0, 0, 0, 0, 661, 0, 663, 657, 659, - 660, 676, 677, 666, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 192, 167, 168, 179, - 182, 183, 184, 185, 186, 187, 189, 191, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 193, 173, - 177, 176, 0, 0, 0, 0, 0, 172, 0, 174, - 178, 180, 181, 188, 190, 175, 167, 168, 179, 182, - 183, 184, 185, 186, 187, 189, 191, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 193, 173, 177, - 176, 0, 0, 0, 0, 0, 172, 0, 174, 178, - 180, 181, 188, 190, 175, 671, 670, 658, 664, 665, - 672, 673, 674, 675, 678, 679, 192, 0, 0, 0, - 0, 0, 0, 0, 654, 0, 0, 662, 656, 655, - 0, 0, 0, 0, 0, 661, 0, 663, 657, 659, - 660, 676, 677, 666, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 192, 0, 0, 167, 168, 179, 182, - 183, 184, 185, 186, 187, 189, 191, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 173, 177, - 176, 0, 0, 0, 0, 0, 172, 0, 174, 178, - 180, 181, 188, 190, 175, 179, 182, 183, 184, 185, - 186, 187, 189, 191, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 173, 177, 176, 0, 0, - 0, 0, 0, 172, 0, 174, 178, 180, 181, 188, - 190, 175, 658, 664, 665, 672, 673, 674, 675, 678, - 679, 192, 0, 0, 0, 0, 0, 0, 0, 654, - 0, 0, 662, 656, 655, 0, 0, 0, 0, 0, - 0, 0, 663, 657, 659, 660, 676, 677, 666, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, - 0, 0, 0, 179, 182, 183, 184, 185, 186, 187, - 189, 191, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 173, 177, 176, 0, 0, 0, 0, - 0, 0, 0, 174, 178, 180, 181, 188, 190, 175, - 179, 182, 183, 184, 185, 186, 187, 189, 191, 105, - 106, 126, 0, 0, 0, 0, 0, 0, 0, 529, - 0, 177, 176, 0, 0, 0, 0, 0, 0, 0, - 0, 178, 180, 181, 188, 190, 175, 105, 106, 126, - 0, 0, 0, 0, 0, 0, 0, 529, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 524, 0, 527, 110, 111, 112, 107, 108, - 0, 0, 0, 0, 0, 0, 530, 0, 0, 0, - 0, 522, 113, 109, 523, 0, 0, 0, 0, 0, - 524, 0, 527, 110, 111, 112, 107, 108, 0, 0, - 233, 0, 0, 0, 530, 0, 0, 0, 0, 522, - 113, 109, 523, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 233, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 788, 536, - 0, 525, 0, 0, 0, 535, 534, 532, 533, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 536, 0, 525, - 0, 0, 0, 535, 534, 532, 533, -} -var yyPact = [...]int{ - - -1000, -1000, 2298, -1000, -1000, -1000, -1000, -1000, 336, 543, - 613, 174, -1000, 348, -1000, -1000, 971, -1000, 276, 276, - 5446, 332, 276, 6794, 6682, 6570, 396, 166, 802, 6906, - -1000, 7990, 328, 325, 315, -1000, 442, 6906, 967, 9, - 965, 962, 6906, -1000, -1000, -1000, -1000, 740, -1000, 716, - -1000, 2309, 313, 6906, 492, 131, 131, 6906, 6906, 6906, - 6906, -1000, -1000, 7130, -1000, 6906, 6906, 6906, 6906, 6906, - 6906, 6906, 311, 6906, -1000, 214, 206, 977, 6906, 689, - 420, 310, 309, 6906, 6906, 305, 6906, 6906, -1000, 197, - -1000, -1000, 951, 841, -1000, 195, 297, 6120, -1000, 187, - 158, -1000, 300, 919, 650, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 173, 153, -1000, 647, 279, -1000, - 440, -1000, 265, 367, -1000, 919, -1000, 164, 644, 603, - -1000, 699, 919, -1000, 959, -1000, -57, 4352, 5290, 7130, - 5134, 809, 9, 561, 6906, 302, -1000, 7936, -1000, 780, - -1000, 7897, -1000, 395, 2009, 8083, -1000, 146, -1000, -1000, - 403, 141, 9, -59, 97, 8083, -1000, 6906, 6906, 6906, - 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, - 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, - 6906, 6906, 420, 6458, 131, 6906, 955, -1000, 7843, 394, - 375, -1000, 709, 703, -1000, 2309, 7804, -1000, -1000, 6346, - 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, 6906, - 6906, 6906, 236, -1000, -1000, -1000, -1000, -1000, 300, 555, - 919, 624, 623, -1000, -1000, 457, 457, 510, 457, 260, - 7747, 258, 457, 457, 457, 457, 457, 457, 457, -1000, - 6232, -1000, 457, 6906, 6906, 421, 838, 947, -1000, 272, - 7018, 131, 8305, 132, 279, 610, -1000, 528, 550, 919, - 686, 173, 153, 570, 6906, 6906, 8083, 8083, 6906, 8083, - 8083, 6906, 636, 838, 778, -1000, 755, 6906, 6120, 156, - -32, 7693, 131, 6906, 6906, 952, -1000, 5558, 300, 189, - 6906, 6906, 173, 440, 135, -1000, 6906, 393, -1000, -1000, - 2140, 300, -1000, 700, 58, -1000, 696, 919, 52, -1000, - 687, 919, 950, 678, -73, 8719, -1000, -1000, -1000, -1000, - -1000, -1000, 296, -1000, -1000, -1000, -1000, -1000, 276, 295, - 392, -35, 8083, -1000, 385, 384, -1000, -1000, -1000, -1000, - -1000, 166, -1000, 6906, -1000, -1000, 855, 294, 8719, -1000, - 6906, 100, 8432, 8175, 8305, 8266, 8520, 8557, 1812, 41, - 41, 41, 510, 457, 510, 510, 117, 117, 958, 958, - 958, 958, 55, 55, 55, 55, -1000, 7654, 6906, 129, - -1000, -1000, 2297, 793, 67, -77, 4194, -1000, -1000, 291, - 723, 698, 632, 439, 632, 6906, 8305, 319, 8305, 8305, - 8305, 8305, 8305, 8305, 8305, 8305, 8305, 8305, 8305, 8305, - 21, -1000, -1000, 290, 919, 300, 132, 132, 270, -1000, - -1000, -1000, 149, 8083, 148, -1000, -1000, -1000, -1000, 896, - 946, 7596, 182, 416, 279, 208, -1000, -1000, 173, 153, - -1000, 6906, -1000, -1000, 138, 919, 528, 132, 173, 138, - 11, -1000, 2309, -1000, 2152, 7557, 7503, 105, -1000, -1000, - -1000, 101, 249, -1000, -1000, 6008, 5896, -1000, -1000, 98, - 96, -1000, -1000, 6, 248, -1000, -1000, 2309, 131, 6906, - -1000, 279, 279, -1000, -1000, 74, 7464, 279, 279, -1000, - 7406, -1000, 1735, -1000, -1000, -1000, -1000, 644, 944, 662, - -1000, 603, 943, 622, -1000, 942, 8719, -1000, 8029, -1000, - -1000, 528, 544, 919, 288, 8719, -1000, -1000, -1000, -1000, - 718, 567, 8719, 8719, 8719, 8719, 8719, 245, 515, 4510, - 4036, 383, 6906, 6906, 495, -1000, 918, -1000, -1000, 7367, - -80, 723, -1000, 8083, 6906, 8395, 379, 131, 301, 301, - 4978, 928, 8719, 770, 723, 241, -41, -1000, 9, -1000, - -1000, -1000, 528, 537, 919, 437, 632, -1000, -1000, -54, - -1000, -1000, 2309, -1000, 420, -86, 236, 236, 300, -1000, - -1000, 186, 684, 6906, -1000, 132, -1000, -1000, 71, -1000, - -1000, -1000, -1000, -1000, -1000, 6906, -1000, -1000, 53, 19, - -1000, 6906, 6906, 173, 7309, -1000, 528, -1000, -1000, -1000, - 6906, -1000, -1000, -1000, -1000, -1000, -1000, 7270, 131, 8083, - 131, -1000, -1000, -1000, 5672, -1000, -1000, 8083, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 924, -1000, - -1000, 922, -1000, -1000, 8719, 8719, 8719, 8719, 8719, 8719, - 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, - 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, 8719, - 8691, 919, 528, 8719, 64, -45, 7215, 655, 756, 155, - 155, -55, -55, 7159, 376, -1000, 276, 5446, 508, 374, - -1000, 372, 8083, -1000, 6906, 287, 472, 370, 892, -1000, - 8719, 233, 8395, -1000, -1000, 681, -1000, 131, 283, 681, - -1000, -1000, -1000, -87, -1000, 765, 281, 231, 753, 723, - 522, 919, 528, -1000, -54, 1002, 632, 279, 6906, -1000, - -11, 6906, 684, -1000, 62, 279, -1000, 1911, 684, 6906, - 6906, 49, 1216, -1000, 683, -1000, 5784, -1000, -1000, -1000, - -1000, -1000, 1872, -55, -55, 155, 155, 155, 155, 8469, - 1732, 1956, 222, 222, -55, 8214, 1332, 8122, 1774, -67, - 18, 18, 18, 18, -42, -42, -42, -42, 8719, 1161, - 528, 230, -1000, -1000, 8719, 8719, -1000, -1000, -1000, -1000, - 5446, -1000, 498, 276, 347, -1000, 6906, 1027, -1000, -1000, - -1000, -1000, -1000, 369, -1000, 753, 226, 301, -1000, 236, - 225, 3878, 8719, -1000, 436, 632, 430, 429, 271, -1000, - 840, -1000, 528, 762, -1000, -1000, 837, -6, -1000, 780, - 620, -1000, 911, 632, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 8305, -1000, 46, -1000, -1000, 411, -1000, - 45, 43, -1000, -1000, -1000, 132, 8083, 131, -1000, 8344, - 8719, -1000, 1546, 8029, -1000, 363, 344, -1000, 224, -1000, - 4510, -1000, 428, 4822, -1000, -12, 4822, 361, -1000, -1000, - 835, -1000, -1000, 151, -102, -1000, -25, -107, -1000, 910, - 9, -1000, -108, -83, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, 8344, 8719, -1000, -1000, 4510, 4666, 4510, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, 3720, 217, 3562, 3404, -29, - -1000, 830, 8719, -1000, 829, 8719, -109, 902, 8719, -1000, - 632, -1000, 688, 8029, 4510, -1000, -1000, -1000, 3246, 3088, - -1000, 427, -1000, -1000, -1000, 106, -1000, -1000, -111, -1000, - 8719, 269, -1000, -1000, 405, 688, -1000, 360, 353, 751, - 790, 566, -1000, 2930, -1000, 351, -1000, -1000, 824, 8719, - -1000, 723, -1000, -1000, -1000, -1000, 632, 620, 901, 342, - -1000, 2772, -1000, -1000, 216, -81, -1000, 895, -1000, -1000, - -1000, 757, 341, 632, -1000, -1000, 757, -1000, 268, -1000, - -1000, -1000, -1000, -1000, 632, 2614, 823, -1000, 102, 423, - -1000, 2456, -1000, -} -var yyPgo = [...]int{ - - 0, 29, 1183, 22, 21, 1177, 49, 41, 39, 544, - 1176, 1175, 164, 217, 228, 180, 1362, 64, 134, 59, - 781, 1399, 1172, 33, 1171, 1170, 1169, 136, 1157, 40, - 37, 1155, 1154, 1152, 1151, 84, 1149, 1148, 20, 1146, - 28, 44, 38, 1145, 736, 36, 1139, 1, 1137, 1136, - 7, 1135, 52, 43, 42, 1134, 1132, 1131, 31, 1128, - 1121, 4, 1120, 1119, 1114, 16, 1111, 1110, 1109, 1108, - 48, 5, 1100, 1097, 1095, 1090, 1089, 2, 1087, 607, - 1086, 18, 202, 1084, 1083, 1082, 12, 1076, 1075, 6, - 19, 1074, 1073, 1072, 9, 50, 0, 1071, 1069, 1068, - 117, 1067, 1066, 599, 1064, 1063, 62, 8, 1062, 1060, - 1059, 1058, 14, 47, 1057, 1056, 1052, 1044, 1042, 1038, - 3, 1034, 23, 1033, 1031, 1027, 35, 1026, 1022, 1019, - 1018, 1014, 1008, 1002, 25, 1001, 1000, 999, 24, 996, - 15, 17, 993, 34, 992, 991, 986, 984, 177, 13, - 983, 902, -} -var yyR1 = [...]int{ - - 0, 151, 95, 95, 96, 96, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 97, 97, - 6, 6, 6, 6, 98, 98, 7, 7, 7, 7, - 99, 99, 8, 8, 8, 8, 55, 55, 100, 100, - 26, 26, 26, 26, 26, 27, 27, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 117, 117, 60, 60, 118, - 118, 119, 119, 61, 115, 115, 58, 53, 54, 149, - 149, 150, 150, 62, 63, 63, 66, 66, 66, 66, - 91, 91, 2, 93, 93, 92, 92, 126, 126, 90, - 90, 89, 89, 89, 87, 87, 86, 86, 59, 59, - 116, 116, 84, 84, 84, 84, 113, 113, 113, 4, - 4, 88, 88, 109, 109, 110, 110, 56, 56, 57, - 57, 120, 120, 121, 121, 65, 65, 64, 64, 64, - 64, 82, 82, 82, 127, 127, 70, 70, 70, 70, - 101, 101, 29, 29, 29, 102, 102, 102, 102, 122, - 122, 67, 67, 67, 67, 69, 128, 128, 83, 83, - 129, 129, 130, 130, 71, 71, 72, 131, 131, 75, - 75, 74, 73, 73, 76, 76, 85, 85, 123, 123, - 124, 124, 132, 132, 77, 77, 77, 77, 77, 77, - 125, 125, 125, 125, 68, 68, 114, 114, 112, 112, - 111, 111, 138, 138, 136, 136, 137, 137, 137, 139, - 139, 44, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 52, 52, 52, 52, - 49, 49, 49, 49, 48, 48, 1, 94, 94, 108, - 108, 108, 108, 25, 25, 25, 25, 25, 25, 25, - 25, 13, 13, 13, 13, 47, 47, 47, 45, 45, - 43, 43, 146, 146, 145, 51, 51, 51, 133, 133, - 133, 81, 81, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 10, 30, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 37, 37, 37, 37, 31, 31, 31, 31, 31, 31, - 31, 134, 134, 3, 3, 135, 135, 135, 135, 16, - 16, 50, 50, 18, 19, 20, 21, 21, 147, 147, - 140, 142, 142, 78, 141, 141, 141, 42, 42, 46, - 46, 14, 24, 24, 22, 22, 22, 23, 23, 23, - 12, 12, 12, 11, 11, 15, 15, 143, 143, 144, - 144, 144, 41, 41, 148, 148, 107, 107, 40, 40, - 40, 106, 106, 105, 105, 105, 105, 105, 105, 105, - 105, 103, 103, 103, 103, 35, 35, 35, 35, 35, - 35, 35, 36, 36, 36, 39, 39, 39, 39, 39, - 39, 39, 39, 104, 104, 38, 38, 32, 32, 33, - 34, -} -var yyR2 = [...]int{ - - 0, 1, 2, 0, 1, 3, 1, 1, 1, 1, - 4, 3, 5, 4, 3, 4, 4, 2, 3, 1, - 1, 3, 2, 4, 3, 1, 1, 3, 2, 4, - 3, 1, 1, 3, 2, 4, 5, 4, 2, 0, - 1, 1, 1, 1, 4, 1, 2, 3, 5, 8, - 3, 5, 9, 3, 2, 3, 2, 3, 2, 3, - 3, 2, 3, 3, 3, 1, 2, 5, 8, 8, - 5, 1, 6, 3, 3, 0, 9, 0, 4, 1, - 0, 1, 2, 8, 1, 3, 1, 1, 1, 0, - 1, 0, 1, 9, 7, 6, 1, 2, 1, 2, - 0, 2, 1, 0, 2, 0, 2, 1, 3, 0, - 2, 1, 2, 4, 1, 4, 1, 4, 1, 4, - 3, 5, 3, 4, 4, 5, 0, 5, 4, 1, - 1, 1, 4, 0, 4, 0, 5, 0, 2, 0, - 3, 1, 0, 1, 3, 4, 6, 0, 1, 1, - 1, 2, 3, 3, 1, 3, 1, 1, 2, 2, - 3, 1, 1, 2, 4, 3, 5, 1, 3, 2, - 0, 3, 2, 1, 8, 3, 1, 3, 1, 3, - 0, 1, 1, 2, 2, 2, 3, 1, 3, 1, - 1, 3, 4, 3, 0, 1, 1, 3, 1, 1, - 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 3, 5, 1, 3, 5, 4, 3, 1, 0, 1, - 3, 1, 2, 1, 4, 3, 2, 1, 1, 0, - 1, 3, 6, 3, 4, 6, 2, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, - 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 1, 1, 4, 5, 4, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, - 1, 3, 2, 1, 9, 10, 2, 2, 4, 4, - 4, 4, 4, 4, 4, 3, 1, 0, 4, 3, - 4, 1, 2, 2, 4, 3, 4, 4, 4, 4, - 2, 1, 1, 3, 2, 1, 3, 2, 1, 1, - 4, 1, 2, 0, 2, 0, 2, 1, 0, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 2, 3, 1, 1, 1, 1, - 3, 2, 4, 3, 1, 1, 1, 4, 3, 3, - 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 4, 5, 2, 2, 3, - 1, 1, 3, 2, 1, 1, 1, 1, 3, 3, - 1, 0, 2, 0, 1, 5, 3, 3, 1, 1, - 1, 3, 3, 1, 1, 1, 5, 1, 2, 0, - 3, 4, 4, 1, 1, 1, 0, 1, 2, 3, - 3, 1, 4, 4, 1, 1, 1, 1, 2, 1, - 4, 4, 1, 1, 4, 0, 1, 1, 1, 4, - 4, 1, 1, 3, 1, 2, 3, 1, 1, 4, - 0, 0, 2, 5, 3, 3, 1, 6, 4, 4, - 2, 2, 2, 1, 2, 1, 4, 3, 3, 3, - 6, 3, 1, 1, 1, 4, 4, 4, 2, 2, - 4, 2, 2, 1, 3, 1, 1, 3, 3, 3, - 3, -} -var yyChk = [...]int{ - - -1000, -151, -95, -5, 2, -27, -53, -54, 52, 80, - 45, -55, -28, 10, -62, -63, 39, 144, 7, 21, - 20, 23, 30, 34, 35, 40, -52, 47, 99, 19, - 14, -16, 49, 25, 27, 146, 41, 44, 36, -1, - -66, -2, 98, -18, -17, 37, 53, 100, 54, 101, - 55, -21, 60, 93, -20, 105, 106, 155, 154, 156, - 157, -50, -44, 148, -39, 108, 109, 110, 111, 112, - 113, 114, 6, 158, -31, -49, -48, 143, 97, -22, - 92, 50, 51, 4, 5, 85, 86, 87, 11, -37, - -34, -9, 142, 75, 63, 18, 61, 150, -23, -24, - -25, -32, -96, 83, -13, 8, 9, 67, 68, 82, - 64, 65, 66, 81, -12, -148, -46, -14, -42, -11, - 159, 12, 148, -96, 144, 83, 10, -97, 37, 39, - -6, -96, 83, 146, 160, 147, 10, -100, -50, 148, - -50, -27, -1, 80, 148, -50, 146, -16, 98, 99, - 146, -16, 146, -17, -21, -16, 146, -101, -29, 12, - 159, -102, -1, 12, -114, -16, 146, 131, 132, 88, - 90, 89, 161, 153, 163, 169, 155, 154, 164, 133, - 165, 166, 134, 135, 136, 137, 138, 139, 167, 140, - 168, 141, 91, 152, 148, 148, 148, 144, -16, 10, - -149, 153, 10, 10, -17, -21, -16, 53, 53, 162, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 148, -16, 105, 106, -20, -21, -96, 80, - 83, -13, -14, 99, -20, -16, -16, -16, -16, -44, - -16, -52, -16, -16, -16, -16, -16, -16, -16, -51, - 148, -50, -16, 150, 150, -133, 17, -103, -35, 12, - 77, 78, -16, 58, -45, -13, -43, -96, 80, 83, - -23, -12, -148, -14, 148, 148, -16, -16, 148, -16, - -16, 150, -103, 17, 17, 76, -103, 150, 148, -106, - -105, -16, 153, 150, 150, 83, -82, 148, -96, 79, - 150, 144, -12, 159, 79, -82, 144, 149, 146, 144, - -95, -96, 146, 160, -98, -7, -96, 83, -99, -8, - -96, 83, 29, -96, 10, 162, -26, 145, 2, -27, - -53, -54, 52, -27, 147, -88, -27, 147, 21, -149, - -112, -111, -16, -84, 144, 147, 146, 146, 146, 146, - 146, 160, -18, 144, -21, 146, 160, -149, 162, 146, - 160, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -45, -16, 147, -115, - -58, -21, -21, -17, -116, 10, -100, 146, 146, 10, - 148, -91, 56, -93, 56, 59, -16, 153, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -107, -40, -21, 60, 83, -96, 79, 79, 149, 149, - 149, 149, -15, -16, -15, 143, -35, -35, 17, 150, - 58, -16, 11, -21, -143, -144, -42, -41, -12, -148, - 10, 144, -81, -82, 79, 83, -96, 58, -12, 79, - -104, -38, -21, -17, -21, -16, -16, -15, 142, 76, - 76, -15, -106, 151, -3, 160, 59, -19, -21, -15, - -15, 10, 149, -127, -52, -70, -17, -21, 153, 84, - -82, -41, -42, 10, 53, -15, -16, -41, -42, 10, - -16, 146, -95, 145, -82, -6, 146, 160, 29, -96, - 146, 160, 29, -96, 10, 29, 162, -30, -79, -9, - -33, -96, 80, 83, 61, 150, -10, 63, -80, 18, - 75, -13, 156, 157, 155, 154, 148, 148, -109, -100, - -100, -50, 146, 160, -113, 146, -113, 146, -29, -16, - 12, 148, -30, -16, 147, -16, 149, 160, 29, 29, - 149, 160, 162, 145, 148, -120, -121, -65, -64, 61, - 62, -47, -96, 80, 83, -92, 57, -47, 144, -126, - -47, -17, -21, -21, 92, 149, 160, 148, -96, -139, - -137, -136, -138, 150, -140, 58, 151, 151, -36, 10, - 13, 12, 10, 145, 145, 150, 145, -141, -78, -142, - -82, 150, 144, -12, -16, -42, -96, -143, -42, 149, - 160, 149, 149, 149, 151, 151, 149, -16, 153, -16, - 153, 151, 151, 149, 160, 149, -19, -16, -82, -82, - 151, 145, -82, -82, 145, 145, -7, 10, 29, -8, - 10, 29, 10, -30, 150, 155, 154, 164, 133, 165, - 166, 161, 153, 163, 134, 135, 169, 89, 90, 88, - 132, 131, 136, 137, 138, 139, 167, 168, 140, 141, - 152, 83, -96, 148, -134, -135, -79, 17, 79, -79, - -79, -79, -79, -79, 149, -56, 94, 95, -110, 22, - 146, -112, -16, 145, 32, 33, -113, 31, -113, 145, - 162, -120, -16, 146, -58, -89, -21, 153, 60, -89, - -59, -27, 147, 10, -30, -117, 42, -120, 149, 160, - -149, 83, -96, 144, -126, -122, 160, -45, 162, -40, - -107, 150, -138, -140, -15, -143, 151, -16, -147, 150, - 150, -15, -16, 145, -146, -38, 59, -19, -19, -70, - 10, 10, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, - -79, -79, -79, -79, -79, -79, -79, -79, 147, -79, - -96, -134, 151, -3, 160, 59, 10, 53, 149, 146, - -50, -27, -57, 94, 95, 146, 146, -16, -4, 147, - 146, 145, 146, 31, -30, 149, -90, 59, -21, 148, - -90, -100, 162, -60, 43, 148, 149, -94, 45, -65, - -150, 84, -96, -122, 145, -67, -123, -68, -69, -124, - -132, 48, 39, 45, -77, 104, 103, 102, 99, 100, - 101, -47, -81, -16, 149, -15, 151, -141, 151, -140, - -15, -15, 151, 145, -145, 58, -16, 153, 151, -79, - 147, 149, -79, -79, -27, 96, -50, 147, -112, -4, - -100, 146, -94, 149, -89, -107, 149, 28, -30, 144, - -47, 144, 144, 148, 12, 145, -125, 12, 146, 160, - -1, -77, 10, -128, -47, 151, 145, 151, 151, -143, - -19, -79, 59, 146, 147, -100, 149, -100, 144, -86, - -27, 147, 149, -86, 146, -100, 12, -100, -100, -108, - 12, 153, 162, 146, 160, 162, 10, -149, 162, -83, - 160, 146, 144, -79, -100, -87, -27, 147, -100, -100, - 145, 149, 145, 145, 149, 160, 12, -30, 12, -30, - 162, 10, -30, -47, -129, -130, -71, -72, -73, -74, - -75, -47, 10, -100, 145, 26, 144, 12, 153, 162, - -30, 148, 145, -71, 146, 146, 46, 29, 79, 24, - 146, -100, 12, -30, -120, -131, -47, -76, -77, 10, - 146, 145, 149, 160, 10, -118, -119, -61, 42, -85, - 146, 144, -47, -61, 148, -100, -47, 145, 12, 149, - 144, -100, 145, -} -var yyDef = [...]int{ - - 3, -2, -2, 2, 6, 7, 8, 9, 0, 0, - 0, 0, 45, 4, 87, 88, 0, 39, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 331, 0, - 65, 0, 0, 0, 0, 71, 0, 0, 0, 89, - 0, 0, 303, 429, 430, 316, 96, 0, 98, 0, - 102, -2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 283, 284, 0, 288, 0, 0, 0, 0, 0, - 0, 0, 345, 0, 298, 299, 300, 348, 0, 437, - 0, 0, 0, 0, 0, 0, 0, 0, 414, 415, - 416, 417, 0, 0, 420, 355, 0, 481, 454, 455, - 456, 410, -2, 0, 0, 353, 354, 356, 357, 358, - 359, 360, 361, 362, -2, 0, 459, 0, 0, 462, - 474, 463, 0, 0, 3, 0, 4, 0, 0, 0, - 19, 20, 0, 17, 0, 46, 0, 0, 0, 0, - 0, 0, 89, 0, 218, 0, 54, 0, 303, 331, - 56, 0, 58, 430, -2, 0, 61, 0, 161, 162, - 0, 0, 89, 167, 0, 217, 66, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, - 0, 90, 100, 103, -2, -2, 0, 97, 99, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 480, 236, 249, 251, 250, 435, 332, 0, - 0, 0, 0, 331, 252, 270, 271, 272, 273, 284, - 0, 0, 289, 290, 291, 292, 293, 294, 295, 296, - 0, 347, 297, 465, 465, 0, 349, 350, 493, 495, - 0, 0, 302, 0, 351, 338, 339, 332, 0, 0, - 341, -2, 0, 0, 0, 0, 508, 509, 0, 511, - 512, 465, 0, 0, 0, 364, 0, 465, 481, 0, - 423, 486, 0, 465, 465, 0, 323, 0, -2, 0, - 465, 0, -2, 475, 0, 330, 0, 0, 11, 3, - 0, -2, 14, 0, 0, 25, 26, 0, 0, 31, - 32, 0, 0, 22, 0, 0, 38, 47, 40, 41, - 42, 43, 0, 133, 39, 50, 131, 39, 0, 0, - 0, 219, 221, 53, 126, 126, 55, 57, 59, 60, - 62, 0, 163, 0, 433, 63, 0, 0, 0, 64, - 0, 253, 254, 255, 256, 257, 258, 259, 260, 261, - 262, 263, 264, 265, 266, 267, 268, 269, -2, -2, - -2, -2, -2, -2, -2, -2, 282, 0, 0, 0, - 84, 86, -2, 430, 0, 0, 0, 73, 74, 0, - -2, 105, 0, 0, 0, 0, 233, 0, 237, 238, - 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - 0, 477, 478, 0, 0, 334, 0, 0, 229, 431, - 432, 346, 0, 466, 0, 301, 494, 491, 492, 0, - 0, 0, 414, 0, 446, 467, 468, 471, 447, 0, - 472, 0, 231, 352, 0, 0, 334, 0, 458, 0, - 0, 513, -2, -2, -2, 0, 0, 0, 418, 363, - 419, 0, 0, 315, 482, 424, 0, 490, 434, 0, - 0, 5, 151, 0, 0, 154, -2, -2, 0, 0, - 325, 0, 449, -2, 520, 0, 0, 0, 450, -2, - 0, 10, 0, 13, 324, 18, 15, 0, 0, 28, - 16, 0, 0, 34, 21, 0, 0, 37, 366, 367, - 368, -2, 0, 0, 0, 421, 374, 375, 376, 355, - 0, 0, 0, 0, 0, 0, 0, 0, 137, -2, - 0, 0, 218, 0, 0, 126, 0, 126, 160, 0, - 165, -2, 168, 216, 0, 287, 0, 0, 0, 0, - 0, 0, 0, 75, -2, 0, 141, 143, 89, 148, - 149, 150, 335, 0, 0, 0, 0, 101, 170, 104, - 107, -2, -2, 234, 0, 0, 480, 480, 333, 285, - 230, 227, 228, 465, 223, 0, 311, 310, 0, 502, - 503, 504, 497, 498, 499, 0, 501, 439, 444, 445, - 443, 465, 0, 448, 0, 449, 333, 343, 450, 505, - 0, 506, 507, 510, 313, 312, 314, 484, 0, 485, - 0, 452, 453, 152, 0, 153, 158, 159, 326, 327, - 460, 461, 328, 329, 464, 12, 24, 27, 0, 30, - 33, 0, 23, 36, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -2, 421, 0, 423, 428, 0, 0, 384, - 385, 407, 408, 0, 0, 48, 0, 0, 139, 0, - 51, 0, 220, 122, 0, 0, 0, 0, 0, 164, - 0, 0, 286, 67, 85, 109, 111, 0, 0, 109, - 70, 118, 39, 0, 120, 77, 0, 0, 317, 147, - 91, 0, 337, 170, 106, 200, 0, 351, 0, 476, - 0, 465, 226, 222, 0, 446, 496, 0, 436, 465, - 465, 0, 0, 473, 340, 514, 0, 488, 489, 155, - 29, 35, 0, 378, 379, 380, 381, 382, 383, 386, - 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, - -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, - -2, 0, 373, 422, 424, 0, 365, 519, 409, 44, - 0, 138, 0, 0, 0, 132, 218, 0, 39, 129, - 130, 123, 124, 0, 166, 317, 0, 0, 112, 480, - 0, 0, 0, 72, 0, 0, 0, 0, 0, 144, - 0, 92, 336, 200, 95, 169, 0, 0, 173, 0, - -2, 199, 0, 0, 202, 204, 205, 206, 207, 208, - 209, 108, 235, 232, 479, 0, 225, 440, 0, 438, - 0, 0, 469, 470, 342, 0, 483, 0, 377, 405, - 0, 372, 426, 427, 134, 0, 0, 39, 0, 39, - -2, 125, 0, 0, 110, 0, 0, 0, 121, 39, - 0, 39, 39, 0, 145, 94, 0, 212, 172, 0, - 89, 203, 0, 0, 176, 224, 500, 442, 441, 344, - 487, 406, 0, 49, 39, -2, 0, -2, 39, 68, - 116, 39, 113, 69, 119, 0, 0, 0, 0, 0, - 321, 0, 0, 171, 0, 0, 0, 0, 0, 175, - 0, 178, 180, 425, -2, 52, 114, 39, 0, 0, - 78, 0, 93, 304, 318, 0, 322, 146, 210, 213, - 0, 0, 215, 177, 0, 181, 182, 0, 0, 190, - 0, 0, -2, 0, 305, 0, 39, 319, 0, 0, - 214, -2, 179, 183, 184, 185, 0, 194, 0, 0, - 117, 0, 320, 211, 0, 186, 187, 0, -2, 191, - 115, 80, 0, 0, 192, 76, 79, 81, 0, 174, - 196, 39, 188, 82, 0, 0, 0, 197, 0, 0, - 39, 0, 83, -} -var yyTok1 = [...]int{ - - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 156, 142, 3, 159, 166, 153, 3, - 148, 149, 164, 155, 160, 154, 169, 165, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 147, 146, - 167, 162, 168, 152, 158, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 150, 3, 151, 163, 3, 143, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 144, 161, 145, 157, -} -var yyTok2 = [...]int{ - - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, -} -var yyTok3 = [...]int{ - 0, -} - -var yyErrorMessages = [...]struct { - state int - token int - msg string -}{} - -// line yaccpar:1 - -/* parser for yacc output */ - -var ( - yyDebug = 0 - yyErrorVerbose = true -) - -type yyLexer interface { - Lex(lval *yySymType) int - Error(s string) -} - -type yyParser interface { - Parse(yyLexer) int - Lookahead() int -} - -type yyParserImpl struct { - lval yySymType - stack [yyInitialStackSize]yySymType - char int -} - -func (p *yyParserImpl) Lookahead() int { - return p.char -} - -func yyNewParser() yyParser { - return &yyParserImpl{} -} - -const yyFlag = -1000 - -func yyTokname(c int) string { - if c >= 1 && c-1 < len(yyToknames) { - if yyToknames[c-1] != "" { - return yyToknames[c-1] - } - } - return __yyfmt__.Sprintf("tok-%v", c) -} - -func yyStatname(s int) string { - if s >= 0 && s < len(yyStatenames) { - if yyStatenames[s] != "" { - return yyStatenames[s] - } - } - return __yyfmt__.Sprintf("state-%v", s) -} - -func yyErrorMessage(state, lookAhead int) string { - const TOKSTART = 4 - - if !yyErrorVerbose { - return "syntax error" - } - - for _, e := range yyErrorMessages { - if e.state == state && e.token == lookAhead { - return "syntax error: " + e.msg - } - } - - res := "syntax error: unexpected " + yyTokname(lookAhead) - - // To match Bison, suggest at most four expected tokens. - expected := make([]int, 0, 4) - - // Look for shiftable tokens. - base := yyPact[state] - for tok := TOKSTART; tok-1 < len(yyToknames); tok++ { - if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok { - if len(expected) == cap(expected) { - return res - } - expected = append(expected, tok) - } - } - - if yyDef[state] == -2 { - i := 0 - for yyExca[i] != -1 || yyExca[i+1] != state { - i += 2 - } - - // Look for tokens that we accept or reduce. - for i += 2; yyExca[i] >= 0; i += 2 { - tok := yyExca[i] - if tok < TOKSTART || yyExca[i+1] == 0 { - continue - } - if len(expected) == cap(expected) { - return res - } - expected = append(expected, tok) - } - - // If the default action is to accept or reduce, give up. - if yyExca[i+1] != 0 { - return res - } - } - - for i, tok := range expected { - if i == 0 { - res += ", expecting " - } else { - res += " or " - } - res += yyTokname(tok) - } - return res -} - -func yylex1(lex yyLexer, lval *yySymType) (char, token int) { - token = 0 - char = lex.Lex(lval) - if char <= 0 { - token = yyTok1[0] - goto out - } - if char < len(yyTok1) { - token = yyTok1[char] - goto out - } - if char >= yyPrivate { - if char < yyPrivate+len(yyTok2) { - token = yyTok2[char-yyPrivate] - goto out - } - } - for i := 0; i < len(yyTok3); i += 2 { - token = yyTok3[i+0] - if token == char { - token = yyTok3[i+1] - goto out - } - } - -out: - if token == 0 { - token = yyTok2[1] /* unknown char */ - } - if yyDebug >= 3 { - __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char)) - } - return char, token -} - -func yyParse(yylex yyLexer) int { - return yyNewParser().Parse(yylex) -} - -func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int { - var yyn int - var yyVAL yySymType - var yyDollar []yySymType - _ = yyDollar // silence set and not used - yyS := yyrcvr.stack[:] - - Nerrs := 0 /* number of errors */ - Errflag := 0 /* error recovery flag */ - yystate := 0 - yyrcvr.char = -1 - yytoken := -1 // yyrcvr.char translated into internal numbering - defer func() { - // Make sure we report no lookahead when not parsing. - yystate = -1 - yyrcvr.char = -1 - yytoken = -1 - }() - yyp := -1 - goto yystack - -ret0: - return 0 - -ret1: - return 1 - -yystack: - /* put a state and value onto the stack */ - if yyDebug >= 4 { - __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate)) - } - - yyp++ - if yyp >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyS[yyp] = yyVAL - yyS[yyp].yys = yystate - -yynewstate: - yyn = yyPact[yystate] - if yyn <= yyFlag { - goto yydefault /* simple state */ - } - if yyrcvr.char < 0 { - yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) - } - yyn += yytoken - if yyn < 0 || yyn >= yyLast { - goto yydefault - } - yyn = yyAct[yyn] - if yyChk[yyn] == yytoken { /* valid shift */ - yyrcvr.char = -1 - yytoken = -1 - yyVAL = yyrcvr.lval - yystate = yyn - if Errflag > 0 { - Errflag-- - } - goto yystack - } - -yydefault: - /* default state action */ - yyn = yyDef[yystate] - if yyn == -2 { - if yyrcvr.char < 0 { - yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) - } - - /* look through exception table */ - xi := 0 - for { - if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate { - break - } - xi += 2 - } - for xi += 2; ; xi += 2 { - yyn = yyExca[xi+0] - if yyn < 0 || yyn == yytoken { - break - } - } - yyn = yyExca[xi+1] - if yyn < 0 { - goto ret0 - } - } - if yyn == 0 { - /* error ... attempt to resume parsing */ - switch Errflag { - case 0: /* brand new error */ - yylex.Error(yyErrorMessage(yystate, yytoken)) - Nerrs++ - if yyDebug >= 1 { - __yyfmt__.Printf("%s", yyStatname(yystate)) - __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken)) - } - fallthrough - - case 1, 2: /* incompletely recovered error ... try again */ - Errflag = 3 - - /* find a state where "error" is a legal shift action */ - for yyp >= 0 { - yyn = yyPact[yyS[yyp].yys] + yyErrCode - if yyn >= 0 && yyn < yyLast { - yystate = yyAct[yyn] /* simulate a shift of "error" */ - if yyChk[yystate] == yyErrCode { - goto yystack - } - } - - /* the current p has no shift on "error", pop stack */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) - } - yyp-- - } - /* there is no state on the stack with an error shift ... abort */ - goto ret1 - - case 3: /* no shift yet; clobber input char */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken)) - } - if yytoken == yyEofCode { - goto ret1 - } - yyrcvr.char = -1 - yytoken = -1 - goto yynewstate /* try again in the same state */ - } - } - - /* reduction by production yyn */ - if yyDebug >= 2 { - __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate)) - } - - yynt := yyn - yypt := yyp - _ = yypt // guard against "declared and not used" - - yyp -= yyR2[yyn] - // yyp is now the index of $0. Perform the default action. Iff the - // reduced production is ε, $1 is possibly out of range. - if yyp+1 >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyVAL = yyS[yyp+1] - - /* consult goto table to find next state */ - yyn = yyR1[yyn] - yyg := yyPgo[yyn] - yyj := yyg + yyS[yyp].yys + 1 - - if yyj >= yyLast { - yystate = yyAct[yyg] - } else { - yystate = yyAct[yyj] - if yyChk[yystate] != -yyn { - yystate = yyAct[yyg] - } - } - // dummy call; replaced with literal code - switch yynt { - - case 1: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:283 - { - yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) - yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - - yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 2: - yyDollar = yyS[yypt-2 : yypt+1] - // 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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 3: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:308 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 4: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:317 - { - namePart := name.NewNamePart(yyDollar[1].token.Value) - yyVAL.list = []node.Node{namePart} - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:330 - { - namePart := name.NewNamePart(yyDollar[3].token.Value) - yyVAL.list = append(yyDollar[1].list, namePart) - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - - // save comments - 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:347 - { - // error - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 7: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:354 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 8: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:360 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 9: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:366 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 10: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:372 - { - yyVAL.node = stmt.NewHaltCompiler() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 11: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:388 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewNamespace(name, nil) - - // save position - 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).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:405 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewNamespace(name, yyDollar[4].list) - - // save position - 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).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:422 - { - yyVAL.node = stmt.NewNamespace(nil, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:436 - { - yyVAL.node = stmt.NewUseList(nil, yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:450 - { - useType := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewUseList(useType, yyDollar[3].list) - - // save position - 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).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:467 - { - useType := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewUseList(useType, yyDollar[3].list) - - // save position - 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).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:484 - { - yyVAL.node = yyDollar[1].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:500 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:509 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 20: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:518 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - 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:532 - { - name := name.NewName(yyDollar[1].list) - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:550 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - - // save comments - 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:566 - { - name := name.NewName(yyDollar[2].list) - alias := node.NewIdentifier(yyDollar[4].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:589 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:598 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 26: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:607 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - 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:621 - { - name := name.NewName(yyDollar[1].list) - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:639 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - - // save comments - 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:655 - { - name := name.NewName(yyDollar[2].list) - alias := node.NewIdentifier(yyDollar[4].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:678 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:687 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 32: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:696 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - 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:710 - { - name := name.NewName(yyDollar[1].list) - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:728 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[2].list)) - - // save comments - 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:744 - { - name := name.NewName(yyDollar[2].list) - alias := node.NewIdentifier(yyDollar[4].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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:767 - { - 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 - 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).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:788 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - constant := stmt.NewConstant(name, yyDollar[4].node, "") - constList := []node.Node{constant} - yyVAL.node = stmt.NewConstList(constList) - - // save position - 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).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:810 - { - 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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 39: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:823 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 40: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:833 - { - // error - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 41: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:840 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 42: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:846 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 43: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:852 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 44: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:858 - { - yyVAL.node = stmt.NewHaltCompiler() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 45: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:878 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 46: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:884 - { - label := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewLabel(label) - - // save position - 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).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:902 - { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:915 - { - yyVAL.node = stmt.NewIf(yyDollar[2].node, yyDollar[3].node, yyDollar[4].list, yyDollar[5].node) - - // save position - if yyDollar[5].node != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - } else if len(yyDollar[4].list) > 0 { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[4].list)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - } - - // save comments - 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:939 - { - stmts := stmt.NewStmtList(yyDollar[4].list) - yyVAL.node = stmt.NewAltIf(yyDollar[2].node, stmts, yyDollar[5].list, yyDollar[6].node) - - // save position - 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).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:963 - { - switch n := yyDollar[3].node.(type) { - case *stmt.While: - n.Cond = yyDollar[2].node - case *stmt.AltWhile: - n.Cond = yyDollar[2].node - } - - yyVAL.node = yyDollar[3].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - - // save comments - 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:988 - { - yyVAL.node = stmt.NewDo(yyDollar[2].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) - - // save comments - 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:1009 - { - switch n := yyDollar[9].node.(type) { - case *stmt.For: - n.Init = yyDollar[3].list - n.Cond = yyDollar[5].list - n.Loop = yyDollar[7].list - case *stmt.AltFor: - n.Init = yyDollar[3].list - n.Cond = yyDollar[5].list - n.Loop = yyDollar[7].list - } - - yyVAL.node = yyDollar[9].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) - - // save comments - 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:1036 - { - switch n := yyDollar[3].node.(type) { - case *stmt.Switch: - n.Cond = yyDollar[2].node - case *stmt.AltSwitch: - n.Cond = yyDollar[2].node - default: - panic("unexpected node type") - } - - yyVAL.node = yyDollar[3].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - - // save comments - 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:1063 - { - yyVAL.node = stmt.NewBreak(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:1077 - { - yyVAL.node = stmt.NewBreak(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1091 - { - yyVAL.node = stmt.NewContinue(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:1105 - { - yyVAL.node = stmt.NewContinue(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1119 - { - yyVAL.node = stmt.NewReturn(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:1133 - { - yyVAL.node = stmt.NewReturn(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1147 - { - yyVAL.node = stmt.NewReturn(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1161 - { - yyVAL.node = stmt.NewExpression(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:1175 - { - yyVAL.node = stmt.NewGlobal(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1189 - { - yyVAL.node = stmt.NewStatic(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1203 - { - yyVAL.node = stmt.NewEcho(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1218 - { - yyVAL.node = stmt.NewInlineHtml(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:1230 - { - yyVAL.node = stmt.NewExpression(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:1244 - { - yyVAL.node = stmt.NewUnset(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) - - // save comments - 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:1260 - { - if yyDollar[6].node == nil { - switch n := yyDollar[8].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - } - } else { - switch n := yyDollar[8].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[6].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[6].node - } - } - - yyVAL.node = yyDollar[8].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) - - // save comments - 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:1300 - { - if yyDollar[6].node == nil { - switch n := yyDollar[8].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - } - } else { - switch n := yyDollar[8].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[6].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[6].node - } - } - - // save position - yyVAL.node = yyDollar[8].node - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[8].node)) - - // save comments - 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:1340 - { - yyVAL.node = yyDollar[5].node - yyVAL.node.(*stmt.Declare).Consts = yyDollar[3].list - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - - // save comments - 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:1355 - { - yyVAL.node = stmt.NewNop() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:1368 - { - yyVAL.node = stmt.NewTry(yyDollar[3].list, yyDollar[5].list, yyDollar[6].node) - - // save position - if yyDollar[6].node == nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[5].list)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) - } - - // save comments - 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:1386 - { - yyVAL.node = stmt.NewThrow(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1400 - { - label := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewGoto(label) - - // save position - 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).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:1420 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 76: - yyDollar = yyS[yypt-9 : yypt+1] - // line php5/php5.y:1426 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - catchNode := stmt.NewCatch([]node.Node{yyDollar[3].node}, variable, yyDollar[7].list) - yyVAL.list = append([]node.Node{catchNode}, yyDollar[9].list...) - - // save position - 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).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:1452 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 78: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:1458 - { - yyVAL.node = stmt.NewFinally(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:1475 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 80: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:1481 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 81: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:1490 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 82: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1496 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 83: - yyDollar = yyS[yypt-8 : yypt+1] - // line php5/php5.y:1505 - { - 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 - 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).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:1530 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 85: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:1536 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:1548 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 87: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:1557 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 88: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:1566 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 89: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:1575 - { - yyVAL.token = nil - } - case 90: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:1579 - { - yyVAL.token = yyDollar[1].token - } - case 91: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:1586 - { - yyVAL.token = nil - } - case 92: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:1590 - { - yyVAL.token = yyDollar[1].token - } - case 93: - yyDollar = yyS[yypt-9 : yypt+1] - // line php5/php5.y:1597 - { - 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 - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - if yyDollar[2].token != nil { - 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[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:1624 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - switch n := yyDollar[1].node.(type) { - case *stmt.Class: - n.ClassName = name - n.Stmts = yyDollar[6].list - n.Extends = yyDollar[3].ClassExtends - n.Implements = yyDollar[4].ClassImplements - - case *stmt.Trait: - // TODO: is it possible that trait extend or implement - n.TraitName = name - n.Stmts = yyDollar[6].list - } - yyVAL.node = yyDollar[1].node - - // save position - 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).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:1652 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewInterface(name, yyDollar[3].InterfaceExtends, yyDollar[5].list, "") - - // save position - 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).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:1673 - { - yyVAL.node = stmt.NewClass(nil, nil, nil, nil, nil, nil, "") - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:1685 - { - classModifier := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") - - // save position - 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).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:1700 - { - yyVAL.node = stmt.NewTrait(nil, nil, "") - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:1712 - { - classModifier := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") - - // save position - 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).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:1730 - { - yyVAL.ClassExtends = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 101: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1736 - { - yyVAL.ClassExtends = stmt.NewClassExtends(yyDollar[2].node) - - // save position - yyVAL.ClassExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:1751 - { - yyVAL.token = yyDollar[1].token - } - case 103: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:1758 - { - yyVAL.InterfaceExtends = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 104: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1764 - { - yyVAL.InterfaceExtends = stmt.NewInterfaceExtends(yyDollar[2].list) - - // save position - yyVAL.InterfaceExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - 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:1779 - { - yyVAL.ClassImplements = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 106: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1785 - { - yyVAL.ClassImplements = stmt.NewClassImplements(yyDollar[2].list) - - // save position - yyVAL.ClassImplements.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - 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:1800 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 108: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:1806 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:1818 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 110: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1824 - { - yyVAL.node = yyDollar[2].node - - // save comments - 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:1836 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 112: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:1842 - { - yyVAL.node = expr.NewReference(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:1854 - { - yyVAL.node = expr.NewList(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:1871 - { - yyVAL.node = stmt.NewFor(nil, nil, nil, yyDollar[1].node) - - // save position - 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:1880 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltFor(nil, nil, nil, stmtList) - - // save position - 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).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:1900 - { - yyVAL.node = stmt.NewForeach(nil, nil, nil, yyDollar[1].node) - - // save position - 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:1909 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltForeach(nil, nil, nil, stmtList) - - // save position - 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).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:1930 - { - 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:1939 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewDeclare(nil, stmtList, true) - - // save position - 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).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:1960 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - constant := stmt.NewConstant(name, yyDollar[3].node, "") - yyVAL.list = []node.Node{constant} - - // save position - 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).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:1976 - { - name := node.NewIdentifier(yyDollar[3].token.Value) - constant := stmt.NewConstant(name, yyDollar[5].node, "") - yyVAL.list = append(yyDollar[1].list, constant) - - // save position - 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).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:1997 - { - caseList := stmt.NewCaseList(yyDollar[2].list) - yyVAL.node = stmt.NewSwitch(nil, caseList) - - // save position - 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).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:2012 - { - caseList := stmt.NewCaseList(yyDollar[3].list) - yyVAL.node = stmt.NewSwitch(nil, caseList) - - // save position - 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).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:2028 - { - caseList := stmt.NewCaseList(yyDollar[2].list) - yyVAL.node = stmt.NewAltSwitch(nil, caseList) - - // save position - 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).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:2045 - { - - caseList := stmt.NewCaseList(yyDollar[3].list) - yyVAL.node = stmt.NewAltSwitch(nil, caseList) - - // save position - 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).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:2068 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 127: - yyDollar = yyS[yypt-5 : yypt+1] - // line php5/php5.y:2074 - { - _case := stmt.NewCase(yyDollar[3].node, yyDollar[5].list) - yyVAL.list = append(yyDollar[1].list, _case) - - // save position - _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) - - // save comments - 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:2089 - { - _default := stmt.NewDefault(yyDollar[4].list) - yyVAL.list = append(yyDollar[1].list, _default) - - // save position - _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) - - // save comments - 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:2108 - { - yyVAL.token = yyDollar[1].token - } - case 130: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2112 - { - yyVAL.token = yyDollar[1].token - } - case 131: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2120 - { - yyVAL.node = stmt.NewWhile(nil, yyDollar[1].node) - - // save position - 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:2129 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltWhile(nil, stmtList) - - // save position - 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).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:2151 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 134: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:2157 - { - _elseIf := stmt.NewElseIf(yyDollar[3].node, yyDollar[4].node) - yyVAL.list = append(yyDollar[1].list, _elseIf) - - // save position - _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[4].node)) - - // save comments - 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:2180 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 136: - yyDollar = yyS[yypt-5 : yypt+1] - // line php5/php5.y:2186 - { - stmts := stmt.NewStmtList(yyDollar[5].list) - _elseIf := stmt.NewAltElseIf(yyDollar[3].node, stmts) - yyVAL.list = append(yyDollar[1].list, _elseIf) - - // save position - 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).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:2212 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 138: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:2218 - { - yyVAL.node = stmt.NewElse(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:2234 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 140: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2240 - { - stmts := stmt.NewStmtList(yyDollar[3].list) - yyVAL.node = stmt.NewAltElse(stmts) - - // save position - 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).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:2259 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 142: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:2265 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 143: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2274 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 144: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2280 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:2292 - { - 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 - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].node != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - } else if yyDollar[2].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) - } else if yyDollar[3].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) - } else { - 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).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) - } - if yyDollar[3].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 146: - yyDollar = yyS[yypt-6 : yypt+1] - // line php5/php5.y:2337 - { - 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 - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].node != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) - } else if yyDollar[2].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) - } else if yyDollar[3].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) - } else { - 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).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) - } - if yyDollar[3].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 147: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:2387 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 148: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2393 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2405 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2417 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 151: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:2427 - { - yyVAL.node = node.NewArgumentList(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:2440 - { - yyVAL.node = node.NewArgumentList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:2453 - { - arg := node.NewArgument(yyDollar[2].node, false, false) - yyVAL.node = node.NewArgumentList([]node.Node{arg}) - - // save position - 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).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:2472 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 155: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2478 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:2490 - { - yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) - - // save position - 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:2502 - { - yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) - - // save position - 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:2514 - { - yyVAL.node = node.NewArgument(yyDollar[2].node, false, true) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) - - // save comments - 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:2526 - { - yyVAL.node = node.NewArgument(yyDollar[2].node, true, false) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:2541 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:2550 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 162: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2560 - { - name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2575 - { - yyVAL.node = expr.NewVariable(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:2588 - { - yyVAL.node = expr.NewVariable(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:2607 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, nil) - yyVAL.list = append(yyDollar[1].list, staticVar) - - // save position - 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).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:2626 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, yyDollar[5].node) - yyVAL.list = append(yyDollar[1].list, staticVar) - - // save position - 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).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:2646 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, nil) - yyVAL.list = []node.Node{staticVar} - - // save position - 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).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:2664 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, yyDollar[3].node) - yyVAL.list = []node.Node{staticVar} - - // save position - 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).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:2687 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 170: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:2693 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 171: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2703 - { - yyVAL.node = stmt.NewPropertyList(yyDollar[1].list, nil, yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[3].token)) - - // save comments - 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:2717 - { - yyVAL.node = yyDollar[1].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:2730 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 174: - yyDollar = yyS[yypt-8 : yypt+1] - // line php5/php5.y:2736 - { - 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 - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].list == nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[8].node)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[8].node)) - } - - // save comments - 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[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:2770 - { - yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - - // save comments - 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:2785 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 177: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2791 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:2803 - { - yyVAL.node = stmt.NewNop() - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2815 - { - yyVAL.node = stmt.NewTraitAdaptationList(yyDollar[2].list) - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:2830 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 181: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2836 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 182: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2845 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 183: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:2851 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 184: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:2860 - { - yyVAL.node = yyDollar[1].node - - // save comments - 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:2870 - { - yyVAL.node = yyDollar[1].node - - // save comments - 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:2883 - { - yyVAL.node = stmt.NewTraitUsePrecedence(yyDollar[1].node, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) - - // save comments - 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:2899 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 188: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2905 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:2917 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewTraitMethodRef(nil, name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2931 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 191: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:2940 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewTraitMethodRef(yyDollar[1].node, target) - - // save position - 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).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:2959 - { - alias := node.NewIdentifier(yyDollar[4].token.Value) - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, alias) - - // save position - 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).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:2975 - { - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:2991 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 195: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:2997 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 196: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3006 - { - yyVAL.node = stmt.NewNop() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3019 - { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:3035 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 199: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3041 - { - modifier := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.list = []node.Node{modifier} - - // save position - modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3057 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 201: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3063 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 202: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3072 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 203: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:3078 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 204: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3087 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3099 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3111 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3123 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3135 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3147 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:3162 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, nil, "") - yyVAL.list = append(yyDollar[1].list, property) - - // save position - 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).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:3181 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, yyDollar[5].node, "") - yyVAL.list = append(yyDollar[1].list, property) - - // save position - 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).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:3201 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, nil, "") - yyVAL.list = []node.Node{property} - - // save position - 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).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:3219 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, yyDollar[3].node, "") - yyVAL.list = []node.Node{property} - - // save position - 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).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:3241 - { - 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 - 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).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:3262 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - constant := stmt.NewConstant(name, yyDollar[4].node, "") - yyVAL.node = stmt.NewClassConstList(nil, []node.Node{constant}) - - // save position - 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).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:3283 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:3292 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 218: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:3302 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 219: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3308 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 220: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:3317 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:3326 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 222: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:3335 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 223: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3341 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 224: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:3350 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) - yyVAL.list = append(yyDollar[1].list, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:3364 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[2].node) - yyVAL.list = []node.Node{fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[2].node)) - - // save comments - 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:3381 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 227: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3387 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 228: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3393 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 229: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:3402 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 230: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:3408 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 231: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:3417 - { - - if yyDollar[3].node != nil { - yyVAL.node = expr.NewNew(yyDollar[2].node, yyDollar[3].node.(*node.ArgumentList)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - } else { - yyVAL.node = expr.NewNew(yyDollar[2].node, nil) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - } - - // save comments - 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:3436 - { - listNode := expr.NewList(yyDollar[3].list) - yyVAL.node = assign.NewAssign(listNode, yyDollar[6].node) - - // save position - 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).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:3453 - { - yyVAL.node = assign.NewAssign(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3466 - { - yyVAL.node = assign.NewReference(yyDollar[1].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:3480 - { - var _new *expr.New - - if yyDollar[6].node != nil { - _new = expr.NewNew(yyDollar[5].node, yyDollar[6].node.(*node.ArgumentList)) - } else { - _new = expr.NewNew(yyDollar[5].node, nil) - } - yyVAL.node = assign.NewReference(yyDollar[1].node, _new) - - // save position - if yyDollar[6].node != nil { - _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[6].node)) - } else { - _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[4].token, yyDollar[5].node)) - } - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, _new)) - - // save comments - 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:3507 - { - yyVAL.node = expr.NewClone(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3519 - { - yyVAL.node = assign.NewPlus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - 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:3531 - { - yyVAL.node = assign.NewMinus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3544 - { - yyVAL.node = assign.NewMul(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3557 - { - yyVAL.node = assign.NewPow(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3570 - { - yyVAL.node = assign.NewDiv(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3583 - { - yyVAL.node = assign.NewConcat(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3596 - { - yyVAL.node = assign.NewMod(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3609 - { - yyVAL.node = assign.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3622 - { - yyVAL.node = assign.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3635 - { - yyVAL.node = assign.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3648 - { - yyVAL.node = assign.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3661 - { - yyVAL.node = assign.NewShiftRight(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3674 - { - yyVAL.node = expr.NewPostInc(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:3687 - { - yyVAL.node = expr.NewPreInc(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3699 - { - yyVAL.node = expr.NewPostDec(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:3712 - { - yyVAL.node = expr.NewPreDec(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3724 - { - yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3737 - { - yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3750 - { - yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3763 - { - yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3776 - { - yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3789 - { - yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3802 - { - yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3815 - { - yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3828 - { - yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3841 - { - yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3854 - { - yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3867 - { - yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3880 - { - yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3893 - { - yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3906 - { - yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3919 - { - yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3932 - { - yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3945 - { - yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3957 - { - yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3969 - { - yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3981 - { - yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3993 - { - yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4006 - { - yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4019 - { - yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4032 - { - yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4046 - { - yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4059 - { - yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4072 - { - yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4085 - { - yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4098 - { - yyVAL.node = expr.NewInstanceOf(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:4111 - { - 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:4120 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 285: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:4126 - { - 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 - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, n)) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 286: - yyDollar = yyS[yypt-5 : yypt+1] - // line php5/php5.y:4158 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) - - // save comments - 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:4172 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4186 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 289: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:4192 - { - yyVAL.node = cast.NewInt(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4205 - { - yyVAL.node = cast.NewDouble(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4218 - { - yyVAL.node = cast.NewString(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4231 - { - yyVAL.node = cast.NewArray(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4244 - { - yyVAL.node = cast.NewObject(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4257 - { - yyVAL.node = cast.NewBool(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4270 - { - yyVAL.node = cast.NewUnset(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4283 - { - e := yyDollar[2].node.(*expr.Exit) - yyVAL.node = yyDollar[2].node - - if strings.EqualFold(yyDollar[1].token.Value, "die") { - e.Die = true - } - - // save position - if yyDollar[2].node.GetPosition() == nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - } - - // save comments - 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:4304 - { - yyVAL.node = expr.NewErrorSuppress(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4316 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 299: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:4322 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 300: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:4328 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 301: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:4334 - { - yyVAL.node = expr.NewShellExec(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:4346 - { - yyVAL.node = expr.NewPrint(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4358 - { - yyVAL.node = expr.NewYield(nil, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4370 - { - yyVAL.node = expr.NewClosure(yyDollar[4].list, yyDollar[6].ClosureUse, nil, yyDollar[8].list, false, yyDollar[2].token != nil, "") - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[9].token)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 305: - yyDollar = yyS[yypt-10 : yypt+1] - // line php5/php5.y:4396 - { - yyVAL.node = expr.NewClosure(yyDollar[5].list, yyDollar[7].ClosureUse, nil, yyDollar[9].list, true, yyDollar[3].token != nil, "") - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[10].token)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 306: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:4426 - { - yyVAL.node = expr.NewYield(nil, yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4438 - { - yyVAL.node = expr.NewYield(nil, yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:4450 - { - yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) - - // save comments - 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:4463 - { - yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) - - // save comments - 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:4479 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:4493 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:4507 - { - str := scalar.NewString(yyDollar[1].token.Value) - yyVAL.node = expr.NewArrayDimFetch(str, yyDollar[3].node) - - // save position - str.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, yyDollar[4].token)) - - // save comments - 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:4523 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:4540 - { - yyVAL.node = expr.NewArray(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:4554 - { - yyVAL.node = expr.NewShortArray(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:4570 - { - yyVAL.token = yyDollar[1].token - } - case 317: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:4577 - { - yyVAL.ClosureUse = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 318: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:4583 - { - yyVAL.ClosureUse = expr.NewClosureUse(yyDollar[3].list) - - // 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:4600 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[3].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.list = append(yyDollar[1].list, variable) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - - // save comments - 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:4617 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[4].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - reference := expr.NewReference(variable) - yyVAL.list = append(yyDollar[1].list, reference) - - // save position - 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).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:4637 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.list = []node.Node{variable} - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4653 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - reference := expr.NewReference(variable) - yyVAL.list = []node.Node{reference} - - // save position - 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).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:4675 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = expr.NewFunctionCall(name, yyDollar[2].node.(*node.ArgumentList)) - - // save position - 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:4689 - { - funcName := name.NewRelative(yyDollar[3].list) - yyVAL.node = expr.NewFunctionCall(funcName, yyDollar[4].node.(*node.ArgumentList)) - - // save position - 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).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:4704 - { - funcName := name.NewFullyQualified(yyDollar[2].list) - yyVAL.node = expr.NewFunctionCall(funcName, yyDollar[3].node.(*node.ArgumentList)) - - // save position - 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).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:4718 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4731 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4744 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4757 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4770 - { - yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) - - // save position - 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:4785 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4797 - { - yyVAL.node = name.NewName(yyDollar[1].list) - - // save position - 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:4809 - { - yyVAL.node = name.NewRelative(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - - // save comments - 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:4822 - { - yyVAL.node = name.NewFullyQualified(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - 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:4837 - { - yyVAL.node = name.NewName(yyDollar[1].list) - - // save position - 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:4849 - { - yyVAL.node = name.NewRelative(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - - // save comments - 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:4862 - { - yyVAL.node = name.NewFullyQualified(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - 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:4877 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 339: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:4883 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 340: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:4892 - { - yyVAL.node = yyDollar[1].node - - // save comments - 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 - 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 - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) - yyVAL.node = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) - } - } - - for _, n := range yyDollar[4].list { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = yyVAL.node - 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 - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) - yyVAL.node = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) - } - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 341: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:4933 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 342: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:4943 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 343: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:4949 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 344: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:4959 - { - yyVAL.list = yyDollar[2].list - - // save comments - 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:4971 - { - yyVAL.node = expr.NewExit(nil) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 346: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:4977 - { - yyVAL.node = expr.NewExit(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:4990 - { - yyVAL.node = expr.NewExit(yyDollar[1].node) - - // save position - 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:5010 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 349: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5016 - { - 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:5026 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 351: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:5035 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 352: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5041 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 353: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5050 - { - yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5062 - { - yyVAL.node = scalar.NewDnumber(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5074 - { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5086 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5098 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5110 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5122 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5134 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5146 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5158 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5170 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, []node.Node{encapsed}) - - // save position - 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).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:5184 - { - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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:5199 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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:5218 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 367: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5227 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 368: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5233 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 369: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5239 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = expr.NewConstFetch(name) - - // save position - 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:5253 - { - name := name.NewRelative(yyDollar[3].list) - yyVAL.node = expr.NewConstFetch(name) - - // save position - 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).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:5268 - { - name := name.NewFullyQualified(yyDollar[2].list) - yyVAL.node = expr.NewConstFetch(name) - - // save position - 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).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:5282 - { - yyVAL.node = expr.NewArray(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:5296 - { - yyVAL.node = expr.NewShortArray(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:5309 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 375: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5315 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5327 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 377: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:5336 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:5350 - { - yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5363 - { - yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5376 - { - yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5389 - { - yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5402 - { - yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5415 - { - yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5428 - { - yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:5440 - { - yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:5452 - { - yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5465 - { - yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5478 - { - yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5491 - { - yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5504 - { - yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5517 - { - yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5530 - { - yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5543 - { - yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5556 - { - yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5569 - { - yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5582 - { - yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5595 - { - yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5608 - { - yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5621 - { - yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5634 - { - yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5648 - { - yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5661 - { - yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5674 - { - yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5687 - { - yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5700 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:5714 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) - - // save comments - 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:5728 - { - yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:5740 - { - yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:5752 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 410: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5765 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 411: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5771 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = expr.NewConstFetch(name) - - // save position - 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:5785 - { - name := name.NewRelative(yyDollar[3].list) - yyVAL.node = expr.NewConstFetch(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).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:5800 - { - name := name.NewFullyQualified(yyDollar[2].list) - yyVAL.node = expr.NewConstFetch(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) - - // save comments - 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:5817 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5831 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 416: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5837 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 417: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5843 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 418: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:5849 - { - yyVAL.node = scalar.NewEncapsed(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:5861 - { - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:5873 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5888 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 422: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:5894 - { - yyVAL.list = yyDollar[1].list - - // save comments - if yyDollar[2].token != nil { - 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:5908 - { - yyVAL.token = nil - } - case 424: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5912 - { - yyVAL.token = yyDollar[1].token - } - case 425: - yyDollar = yyS[yypt-5 : yypt+1] - // line php5/php5.y:5919 - { - arrayItem := expr.NewArrayItem(yyDollar[3].node, yyDollar[5].node, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) - - // save comments - 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:5934 - { - arrayItem := expr.NewArrayItem(nil, yyDollar[3].node, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:5948 - { - arrayItem := expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:5962 - { - arrayItem := expr.NewArrayItem(nil, yyDollar[1].node, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - 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:5978 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 430: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:5984 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 431: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:5993 - { - 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:6009 - { - 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:6029 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 434: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6039 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 435: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6048 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 436: - yyDollar = yyS[yypt-5 : yypt+1] - // line php5/php5.y:6057 - { - yyVAL.node = yyDollar[1].node - - if yyDollar[4].list != nil { - yyDollar[4].list[0].(*expr.MethodCall).Method = yyDollar[3].list[len(yyDollar[3].list)-1].(*expr.PropertyFetch).Property - yyDollar[3].list = append(yyDollar[3].list[:len(yyDollar[3].list)-1], yyDollar[4].list...) - } - - // save comments - 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 - 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 - 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 - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) - yyVAL.node = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) - } - } - - for _, n := range yyDollar[5].list { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = yyVAL.node - 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 - 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 - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyVAL.node, nn)) - yyVAL.node = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, yyVAL.node) - } - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 437: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6115 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 438: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6124 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].list...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 439: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:6130 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 440: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:6140 - { - if yyDollar[3].list != nil { - yyDollar[3].list[0].(*expr.MethodCall).Method = yyDollar[2].list[len(yyDollar[2].list)-1].(*expr.PropertyFetch).Property - yyDollar[2].list = append(yyDollar[2].list[:len(yyDollar[2].list)-1], yyDollar[3].list...) - } - - yyVAL.list = yyDollar[2].list - - // save comments - 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:6157 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) - yyVAL.list = append(yyDollar[1].list, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:6171 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) - yyVAL.list = []node.Node{yyDollar[1].node, fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:6188 - { - yyVAL.node = expr.NewMethodCall(nil, nil, yyDollar[1].node.(*node.ArgumentList)) - - // save position - 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:6200 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 445: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6206 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 446: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:6212 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 447: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6221 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 448: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6227 - { - yyDollar[1].simpleIndirectReference.last.SetVarName(yyDollar[2].node) - - for _, n := range yyDollar[1].simpleIndirectReference.all { - n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node)) - } - - yyVAL.node = yyDollar[1].simpleIndirectReference.all[0] - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 449: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:6242 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:6255 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:6271 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 452: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:6280 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:6294 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:6311 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 455: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6317 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 456: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6323 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 457: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6333 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 458: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6339 - { - yyDollar[1].simpleIndirectReference.last.SetVarName(yyDollar[2].node) - - for _, n := range yyDollar[1].simpleIndirectReference.all { - n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, yyDollar[2].node)) - } - - yyVAL.node = yyDollar[1].simpleIndirectReference.all[0] - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 459: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6351 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 460: - yyDollar = yyS[yypt-4 : yypt+1] - // line php5/php5.y:6360 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:6374 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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:6388 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 463: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6398 - { - name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6413 - { - yyVAL.node = expr.NewVariable(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:6431 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 466: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6437 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 467: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6447 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 468: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6453 - { - fetch := expr.NewPropertyFetch(nil, yyDollar[1].node) - yyVAL.list = []node.Node{fetch} - - // save position - 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:6466 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) - yyVAL.list = append(yyDollar[1].list, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:6480 - { - fetch := expr.NewArrayDimFetch(nil, yyDollar[3].node) - yyVAL.list = append(yyDollar[1].list, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:6494 - { - fetch := expr.NewPropertyFetch(nil, yyDollar[1].node) - yyVAL.list = []node.Node{fetch} - - // save position - 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:6507 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6519 - { - yyVAL.node = yyDollar[2].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 474: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6535 - { - n := expr.NewVariable(nil) - yyVAL.simpleIndirectReference = simpleIndirectReference{[]*expr.Variable{n}, n} - - // save position - n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6549 - { - n := expr.NewVariable(nil) - - yyDollar[1].simpleIndirectReference.last.SetVarName(n) - yyDollar[1].simpleIndirectReference.all = append(yyDollar[1].simpleIndirectReference.all, n) - yyDollar[1].simpleIndirectReference.last = n - yyVAL.simpleIndirectReference = yyDollar[1].simpleIndirectReference - - // save position - n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - - // save comments - 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:6570 - { - if len(yyDollar[1].list) == 0 { - yyDollar[1].list = []node.Node{expr.NewArrayItem(nil, nil, false)} - } - - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:6583 - { - 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 478: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:6597 - { - yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node, false) - - // save position - 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:6609 - { - listNode := expr.NewList(yyDollar[3].list) - yyVAL.node = expr.NewArrayItem(nil, listNode, false) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(listNode)) - - // save comments - 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:6625 - { - yyVAL.node = expr.NewArrayItem(nil, nil, false) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 481: - yyDollar = yyS[yypt-0 : yypt+1] - // line php5/php5.y:6635 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 482: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6641 - { - yyVAL.list = yyDollar[1].list - - if yyDollar[2].token != nil { - yyVAL.list = append(yyDollar[1].list, expr.NewArrayItem(nil, nil, false)) - } - - // save comments - if yyDollar[2].token != nil { - 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:6659 - { - arrayItem := expr.NewArrayItem(yyDollar[3].node, yyDollar[5].node, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[3].node, yyDollar[5].node)) - - // save comments - 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:6674 - { - arrayItem := expr.NewArrayItem(nil, yyDollar[3].node, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[3].node)) - - // save comments - 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:6688 - { - arrayItem := expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:6702 - { - arrayItem := expr.NewArrayItem(nil, yyDollar[1].node, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - 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:6715 - { - reference := expr.NewReference(yyDollar[6].node) - arrayItem := expr.NewArrayItem(yyDollar[3].node, reference, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - 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).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:6733 - { - reference := expr.NewReference(yyDollar[4].node) - arrayItem := expr.NewArrayItem(nil, reference, false) - yyVAL.list = append(yyDollar[1].list, arrayItem) - - // save position - 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).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:6749 - { - reference := expr.NewReference(yyDollar[4].node) - arrayItem := expr.NewArrayItem(yyDollar[1].node, reference, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - 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).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:6766 - { - reference := expr.NewReference(yyDollar[2].node) - arrayItem := expr.NewArrayItem(nil, reference, false) - yyVAL.list = []node.Node{arrayItem} - - // save position - 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).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:6784 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 492: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6790 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) - yyVAL.list = append(yyDollar[1].list, encapsed) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - - // save comments - 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:6803 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 494: - yyDollar = yyS[yypt-2 : yypt+1] - // line php5/php5.y:6809 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) - yyVAL.list = []node.Node{encapsed, yyDollar[2].node} - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6825 - { - name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6840 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) - - // save position - 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).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:6858 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - fetch := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewPropertyFetch(variable, fetch) - - // save position - 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).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:6878 - { - variable := expr.NewVariable(yyDollar[2].node) - - yyVAL.node = variable - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // 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 499: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:6893 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - variable := expr.NewVariable(name) - - yyVAL.node = variable - - // save position - 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).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:6910 - { - identifier := node.NewIdentifier(yyDollar[2].token.Value) - variable := expr.NewVariable(identifier) - yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[4].node) - - // save position - 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).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:6929 - { - 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:6942 - { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6954 - { - // TODO: add option to handle 64 bit integer - if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil { - yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) - } else { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - } - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6971 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:6989 - { - yyVAL.node = expr.NewIsset(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:7003 - { - yyVAL.node = expr.NewEmpty(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:7017 - { - yyVAL.node = expr.NewEmpty(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:7031 - { - yyVAL.node = expr.NewInclude(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:7043 - { - yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:7055 - { - yyVAL.node = expr.NewEval(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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:7069 - { - yyVAL.node = expr.NewRequire(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:7081 - { - yyVAL.node = expr.NewRequireOnce(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:7096 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 514: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:7102 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - 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:7114 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 516: - yyDollar = yyS[yypt-1 : yypt+1] - // line php5/php5.y:7120 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 517: - yyDollar = yyS[yypt-3 : yypt+1] - // line php5/php5.y:7129 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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:7145 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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:7164 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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:7183 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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) - } - } - goto yystack /* stack new state and value */ -} diff --git a/php5/php5.y b/php5/php5.y deleted file mode 100644 index 9102dd8..0000000 --- a/php5/php5.y +++ /dev/null @@ -1,7205 +0,0 @@ -%{ -package php5 - -import ( - "strings" - "strconv" - - "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" - "github.com/z7zmey/php-parser/node/name" - "github.com/z7zmey/php-parser/node/stmt" - "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" -) - -%} - -%union{ - node node.Node - token *scanner.Token - list []node.Node - simpleIndirectReference simpleIndirectReference - - ClassExtends *stmt.ClassExtends - ClassImplements *stmt.ClassImplements - InterfaceExtends *stmt.InterfaceExtends - ClosureUse *expr.ClosureUse -} - -%type $unk -%token T_INCLUDE -%token T_INCLUDE_ONCE -%token T_EXIT -%token T_IF -%token T_LNUMBER -%token T_DNUMBER -%token T_STRING -%token T_STRING_VARNAME -%token T_VARIABLE -%token T_NUM_STRING -%token T_INLINE_HTML -%token T_CHARACTER -%token T_BAD_CHARACTER -%token T_ENCAPSED_AND_WHITESPACE -%token T_CONSTANT_ENCAPSED_STRING -%token T_ECHO -%token T_DO -%token T_WHILE -%token T_ENDWHILE -%token T_FOR -%token T_ENDFOR -%token T_FOREACH -%token T_ENDFOREACH -%token T_DECLARE -%token T_ENDDECLARE -%token T_AS -%token T_SWITCH -%token T_ENDSWITCH -%token T_CASE -%token T_DEFAULT -%token T_BREAK -%token T_CONTINUE -%token T_GOTO -%token T_FUNCTION -%token T_FN -%token T_CONST -%token T_RETURN -%token T_TRY -%token T_CATCH -%token T_FINALLY -%token T_THROW -%token T_USE -%token T_INSTEADOF -%token T_GLOBAL -%token T_VAR -%token T_UNSET -%token T_ISSET -%token T_EMPTY -%token T_HALT_COMPILER -%token T_CLASS -%token T_TRAIT -%token T_INTERFACE -%token T_EXTENDS -%token T_IMPLEMENTS -%token T_OBJECT_OPERATOR -%token T_DOUBLE_ARROW -%token T_LIST -%token T_ARRAY -%token T_CALLABLE -%token T_CLASS_C -%token T_TRAIT_C -%token T_METHOD_C -%token T_FUNC_C -%token T_LINE -%token T_FILE -%token T_COMMENT -%token T_DOC_COMMENT -%token T_OPEN_TAG -%token T_OPEN_TAG_WITH_ECHO -%token T_CLOSE_TAG -%token T_WHITESPACE -%token T_START_HEREDOC -%token T_END_HEREDOC -%token T_DOLLAR_OPEN_CURLY_BRACES -%token T_CURLY_OPEN -%token T_PAAMAYIM_NEKUDOTAYIM -%token T_NAMESPACE -%token T_NS_C -%token T_DIR -%token T_NS_SEPARATOR -%token T_ELLIPSIS -%token T_EVAL -%token T_REQUIRE -%token T_REQUIRE_ONCE -%token T_LOGICAL_OR -%token T_LOGICAL_XOR -%token T_LOGICAL_AND -%token T_INSTANCEOF -%token T_NEW -%token T_CLONE -%token T_ELSEIF -%token T_ELSE -%token T_ENDIF -%token T_PRINT -%token T_YIELD -%token T_STATIC -%token T_ABSTRACT -%token T_FINAL -%token T_PRIVATE -%token T_PROTECTED -%token T_PUBLIC -%token T_INC -%token T_DEC -%token T_YIELD_FROM -%token T_INT_CAST -%token T_DOUBLE_CAST -%token T_STRING_CAST -%token T_ARRAY_CAST -%token T_OBJECT_CAST -%token T_BOOL_CAST -%token T_UNSET_CAST -%token T_COALESCE -%token T_SPACESHIP -%token T_NOELSE -%token T_PLUS_EQUAL -%token T_MINUS_EQUAL -%token T_MUL_EQUAL -%token T_POW_EQUAL -%token T_DIV_EQUAL -%token T_CONCAT_EQUAL -%token T_MOD_EQUAL -%token T_AND_EQUAL -%token T_OR_EQUAL -%token T_XOR_EQUAL -%token T_SL_EQUAL -%token T_SR_EQUAL -%token T_COALESCE_EQUAL -%token T_BOOLEAN_OR -%token T_BOOLEAN_AND -%token T_POW -%token T_SL -%token T_SR -%token T_IS_IDENTICAL -%token T_IS_NOT_IDENTICAL -%token T_IS_EQUAL -%token T_IS_NOT_EQUAL -%token T_IS_SMALLER_OR_EQUAL -%token T_IS_GREATER_OR_EQUAL -%token '"' -%token '`' -%token '{' -%token '}' -%token ';' -%token ':' -%token '(' -%token ')' -%token '[' -%token ']' -%token '?' -%token '&' -%token '-' -%token '+' -%token '!' -%token '~' -%token '@' -%token '$' -%token ',' -%token '|' -%token '=' -%token '^' -%token '*' -%token '/' -%token '%' -%token '<' -%token '>' -%token '.' - -%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE -%left ',' -%left T_LOGICAL_OR -%left T_LOGICAL_XOR -%left T_LOGICAL_AND -%right T_PRINT -%right T_YIELD -%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL -%left '?' ':' -%left T_BOOLEAN_OR -%left T_BOOLEAN_AND -%left '|' -%left '^' -%left '&' -%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL -%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL -%left T_SL T_SR -%left '+' '-' '.' -%left '*' '/' '%' -%right '!' -%nonassoc T_INSTANCEOF -%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' -%right T_POW -%right '[' -%nonassoc T_NEW T_CLONE -%left T_ELSEIF -%left T_ELSE -%left T_ENDIF -%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC - -%type function interface_entry -%type possible_comma -%type case_separator - -%type top_statement use_declaration use_function_declaration use_const_declaration common_scalar -%type static_class_constant compound_variable reference_variable class_name variable_class_name -%type dim_offset expr expr_without_variable r_variable w_variable rw_variable variable base_variable_with_function_calls -%type base_variable array_function_dereference function_call inner_statement statement unticked_statement -%type statement global_var static_scalar scalar class_constant static_class_name_scalar class_name_scalar -%type encaps_var encaps_var encaps_var_offset general_constant isset_variable internal_functions_in_yacc assignment_list_element -%type variable_name variable_without_objects dynamic_class_name_reference new_expr class_name_reference static_member -%type function_call fully_qualified_class_name combined_scalar combined_scalar_offset general_constant parenthesis_expr -%type exit_expr yield_expr function_declaration_statement class_declaration_statement constant_declaration -%type else_single new_else_single unset_variable declare_statement -%type finally_statement additional_catch unticked_function_declaration_statement unticked_class_declaration_statement -%type optional_class_type parameter class_entry_type class_statement class_constant_declaration -%type trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias -%type trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method -%type static_scalar_value static_operation -%type ctor_arguments function_call_parameter_list -%type trait_adaptations -%type switch_case_list -%type method_body -%type foreach_statement for_statement while_statement -%type foreach_variable foreach_optional_arg - -%type extends_from -%type implements_list -%type interface_extends_list -%type lexical_vars - -%type top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations -%type inner_statement_list global_var_list static_var_list encaps_list isset_variables non_empty_array_pair_list -%type array_pair_list assignment_list lexical_var_list elseif_list new_elseif_list non_empty_for_expr -%type for_expr case_list echo_expr_list unset_variables declare_list catch_statement additional_catches -%type non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list -%type class_statement_list variable_modifiers method_modifiers class_variable_declaration -%type interface_list non_empty_function_call_parameter_list trait_list trait_adaptation_list non_empty_trait_adaptation_list -%type trait_reference_list non_empty_member_modifiers backticks_expr static_array_pair_list non_empty_static_array_pair_list - -%type chaining_dereference chaining_instance_call chaining_method_or_property instance_call variable_property -%type method_or_not array_method_dereference object_property object_dim_list dynamic_class_name_variable_property -%type dynamic_class_name_variable_properties variable_properties - -%type simple_indirect_reference -%type is_reference is_variadic - -%% - -start: - top_statement_list - { - yylex.(*Parser).rootNode = node.NewRoot($1) - yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - - yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -namespace_name: - T_STRING - { - namePart := name.NewNamePart($1.Value) - $$ = []node.Node{namePart} - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | namespace_name T_NS_SEPARATOR T_STRING - { - namePart := name.NewNamePart($3.Value) - $$ = append($1, namePart) - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -top_statement: - error - { - // error - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_HALT_COMPILER '(' ')' ';' - { - $$ = stmt.NewHaltCompiler() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_NAMESPACE namespace_name ';' - { - name := name.NewName($2) - $$ = stmt.NewNamespace(name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_NAMESPACE namespace_name '{' top_statement_list '}' - { - name := name.NewName($2) - $$ = stmt.NewNamespace(name, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } - | T_NAMESPACE '{' top_statement_list '}' - { - $$ = stmt.NewNamespace(nil, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_USE use_declarations ';' - { - $$ = stmt.NewUseList(nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_USE T_FUNCTION use_function_declarations ';' - { - useType := node.NewIdentifier($2.Value) - $$ = stmt.NewUseList(useType, $3) - - // save position - useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_USE T_CONST use_const_declarations ';' - { - useType := node.NewIdentifier($2.Value) - $$ = stmt.NewUseList(useType, $3) - - // save position - useType.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | constant_declaration ';' - { - $$ = $1 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -use_declarations: - use_declarations ',' use_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | use_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -use_declaration: - namespace_name - { - name := name.NewName($1) - $$ = stmt.NewUse(nil, name, nil) - - // save position - 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) - } - | namespace_name T_AS T_STRING - { - name := name.NewName($1) - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).MoveFreeFloating($1[0], $$) - yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - name := name.NewName($2) - $$ = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - - // save comments - 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) - } - | T_NS_SEPARATOR namespace_name T_AS T_STRING - { - name := name.NewName($2) - alias := node.NewIdentifier($4.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).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) - } -; - -use_function_declarations: - use_function_declarations ',' use_function_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | use_function_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -use_function_declaration: - namespace_name - { - name := name.NewName($1) - $$ = stmt.NewUse(nil, name, nil) - - // save position - 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) - } - | namespace_name T_AS T_STRING - { - name := name.NewName($1) - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).MoveFreeFloating($1[0], $$) - yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - name := name.NewName($2) - $$ = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - - // save comments - 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) - } - | T_NS_SEPARATOR namespace_name T_AS T_STRING - { - name := name.NewName($2) - alias := node.NewIdentifier($4.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).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) - } -; - -use_const_declarations: - use_const_declarations ',' use_const_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | use_const_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -use_const_declaration: - namespace_name - { - name := name.NewName($1) - $$ = stmt.NewUse(nil, name, nil) - - // save position - 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) - } - | namespace_name T_AS T_STRING - { - name := name.NewName($1) - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).MoveFreeFloating($1[0], $$) - yylex.(*Parser).setFreeFloating(name, freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - name := name.NewName($2) - $$ = stmt.NewUse(nil, name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - - // save comments - 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) - } - | T_NS_SEPARATOR namespace_name T_AS T_STRING - { - name := name.NewName($2) - alias := node.NewIdentifier($4.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).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) - } -; - -constant_declaration: - constant_declaration ',' T_STRING '=' static_scalar - { - 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 - 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).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) - } - | T_CONST T_STRING '=' static_scalar - { - name := node.NewIdentifier($2.Value) - constant := stmt.NewConstant(name, $4, "") - constList := []node.Node{constant} - $$ = stmt.NewConstList(constList) - - // save position - 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).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) - } -; - -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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -inner_statement: - error - { - // error - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_HALT_COMPILER '(' ')' ';' - { - $$ = stmt.NewHaltCompiler() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - - -statement: - unticked_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STRING ':' - { - label := node.NewIdentifier($1.Value) - $$ = stmt.NewLabel(label) - - // save position - label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Label, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -unticked_statement: - '{' inner_statement_list '}' - { - $$ = stmt.NewStmtList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_IF parenthesis_expr statement elseif_list else_single - { - $$ = stmt.NewIf($2, $3, $4, $5) - - // save position - if $5 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - } else if len($4) > 0 { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $4)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - } - - // save comments - 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) - } - | T_IF parenthesis_expr ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';' - { - stmts := stmt.NewStmtList($4) - $$ = stmt.NewAltIf($2, stmts, $5, $6) - - // save position - stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) - - // save comments - 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) - } - | T_WHILE parenthesis_expr while_statement - { - switch n := $3.(type) { - case *stmt.While : - n.Cond = $2 - case *stmt.AltWhile : - n.Cond = $2 - } - - $$ = $3 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - 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) - } - | T_DO statement T_WHILE parenthesis_expr ';' - { - $$ = stmt.NewDo($2, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } - | T_FOR '(' for_expr ';' for_expr ';' for_expr ')' for_statement - { - switch n := $9.(type) { - case *stmt.For : - n.Init = $3 - n.Cond = $5 - n.Loop = $7 - case *stmt.AltFor : - n.Init = $3 - n.Cond = $5 - n.Loop = $7 - } - - $$ = $9 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) - - // save comments - 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) - } - | T_SWITCH parenthesis_expr switch_case_list - { - switch n := $3.(type) { - case *stmt.Switch: - n.Cond = $2 - case *stmt.AltSwitch: - n.Cond = $2 - default: - panic("unexpected node type") - } - - $$ = $3 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - 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) - } - | T_BREAK ';' - { - $$ = stmt.NewBreak(nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - 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) - } - | T_BREAK expr ';' - { - $$ = stmt.NewBreak($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_CONTINUE ';' - { - $$ = stmt.NewContinue(nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - 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) - } - | T_CONTINUE expr ';' - { - $$ = stmt.NewContinue($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_RETURN ';' - { - $$ = stmt.NewReturn(nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - 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) - } - | T_RETURN expr_without_variable ';' - { - $$ = stmt.NewReturn($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_RETURN variable ';' - { - $$ = stmt.NewReturn($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | yield_expr ';' - { - $$ = stmt.NewExpression($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - 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) - } - | T_GLOBAL global_var_list ';' - { - $$ = stmt.NewGlobal($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_STATIC static_var_list ';' - { - $$ = stmt.NewStatic($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_ECHO echo_expr_list ';' - { - $$ = stmt.NewEcho($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_INLINE_HTML - { - $$ = stmt.NewInlineHtml($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr ';' - { - $$ = stmt.NewExpression($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - 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) - } - | T_UNSET '(' unset_variables ')' ';' - { - $$ = stmt.NewUnset($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } - | T_FOREACH '(' variable T_AS foreach_variable foreach_optional_arg ')' foreach_statement - { - if $6 == nil { - switch n := $8.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Variable = $5 - case *stmt.AltForeach : - n.Expr = $3 - n.Variable = $5 - } - } else { - switch n := $8.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Key = $5 - n.Variable = $6 - case *stmt.AltForeach : - n.Expr = $3 - n.Key = $5 - n.Variable = $6 - } - } - - $$ = $8 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) - - // save comments - 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_FOREACH '(' expr_without_variable T_AS foreach_variable foreach_optional_arg ')' foreach_statement - { - if $6 == nil { - switch n := $8.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Variable = $5 - case *stmt.AltForeach : - n.Expr = $3 - n.Variable = $5 - } - } else { - switch n := $8.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Key = $5 - n.Variable = $6 - case *stmt.AltForeach : - n.Expr = $3 - n.Key = $5 - n.Variable = $6 - } - } - - // save position - $$ = $8 - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $8)) - - // save comments - 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 - { - $$ = $5 - $$.(*stmt.Declare).Consts = $3 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | ';' - { - $$ = stmt.NewNop() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_TRY '{' inner_statement_list '}' catch_statement finally_statement - { - $$ = stmt.NewTry($3, $5, $6) - - // save position - if $6 == nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) - } - - // save comments - 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) - } - | T_THROW expr ';' - { - $$ = stmt.NewThrow($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_GOTO T_STRING ';' - { - label := node.NewIdentifier($2.Value) - $$ = stmt.NewGoto(label) - - // save position - label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } -; - -catch_statement: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' additional_catches - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - catchNode := stmt.NewCatch([]node.Node{$3}, variable, $7) - $$ = append([]node.Node{catchNode}, $9...) - - // save position - 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).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) - } -; - -finally_statement: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINALLY '{' inner_statement_list '}' - { - $$ = stmt.NewFinally($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -additional_catches: - non_empty_additional_catches - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_additional_catches: - additional_catch - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_additional_catches additional_catch - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -additional_catch: - T_CATCH '(' fully_qualified_class_name T_VARIABLE ')' '{' inner_statement_list '}' - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = stmt.NewCatch([]node.Node{$3}, variable, $7) - - // save position - 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).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) - } -; - -unset_variables: - unset_variable - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | unset_variables ',' unset_variable - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -unset_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function_declaration_statement: - unticked_function_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_declaration_statement: - unticked_class_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -is_reference: - /* empty */ - { - $$ = nil - } - | '&' - { - $$ = $1 - } -; - -is_variadic: - /* empty */ - { - $$ = nil - } - | T_ELLIPSIS - { - $$ = $1 - } -; - -unticked_function_declaration_statement: - function is_reference T_STRING '(' parameter_list ')' '{' inner_statement_list '}' - { - name := node.NewIdentifier($3.Value) - $$ = stmt.NewFunction(name, $2 != nil, $5, nil, $8, "") - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - if $2 != nil { - 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, $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) - } -; - -unticked_class_declaration_statement: - class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}' - { - name := node.NewIdentifier($2.Value) - switch n := $1.(type) { - case *stmt.Class : - n.ClassName = name - n.Stmts = $6 - n.Extends = $3 - n.Implements = $4 - - case *stmt.Trait : - // TODO: is it possible that trait extend or implement - n.TraitName = name - n.Stmts = $6 - } - $$ = $1 - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $7)) - - // save comments - 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) - } - | interface_entry T_STRING interface_extends_list '{' class_statement_list '}' - { - name := node.NewIdentifier($2.Value) - $$ = stmt.NewInterface(name, $3, $5, "") - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) - - // save comments - 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) - } -; - - -class_entry_type: - T_CLASS - { - $$ = stmt.NewClass(nil, nil, nil, nil, nil, nil, "") - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ABSTRACT T_CLASS - { - classModifier := node.NewIdentifier($1.Value) - $$ = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") - - // save position - classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_TRAIT - { - $$ = stmt.NewTrait(nil, nil, "") - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINAL T_CLASS - { - classModifier := node.NewIdentifier($1.Value) - $$ = stmt.NewClass(nil, []node.Node{classModifier}, nil, nil, nil, nil, "") - - // save position - classModifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ModifierList, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -extends_from: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EXTENDS fully_qualified_class_name - { - $$ = stmt.NewClassExtends($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -interface_entry: - T_INTERFACE - { - $$ = $1 - } -; - -interface_extends_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EXTENDS interface_list - { - $$ = stmt.NewInterfaceExtends($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -implements_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_IMPLEMENTS interface_list - { - $$ = stmt.NewClassImplements($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -interface_list: - fully_qualified_class_name - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | interface_list ',' fully_qualified_class_name - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -foreach_optional_arg: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DOUBLE_ARROW foreach_variable - { - $$ = $2 - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Key, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -foreach_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' variable - { - $$ = expr.NewReference($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_LIST '(' assignment_list ')' - { - $$ = expr.NewList($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -for_statement: - statement - { - $$ = stmt.NewFor(nil, nil, nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDFOR ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltFor(nil, nil, nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -foreach_statement: - statement - { - $$ = stmt.NewForeach(nil, nil, nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDFOREACH ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltForeach(nil, nil, nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - - -declare_statement: - statement - { - $$ = stmt.NewDeclare(nil, $1, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDDECLARE ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewDeclare(nil, stmtList, true) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - - -declare_list: - T_STRING '=' static_scalar - { - name := node.NewIdentifier($1.Value) - constant := stmt.NewConstant(name, $3, "") - $$ = []node.Node{constant} - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating(constant, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(constant, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | declare_list ',' T_STRING '=' static_scalar - { - name := node.NewIdentifier($3.Value) - constant := stmt.NewConstant(name, $5, "") - $$ = append($1, constant) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - constant.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $5)) - - // save comments - 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) - } -; - - -switch_case_list: - '{' case_list '}' - { - caseList := stmt.NewCaseList($2) - $$ = stmt.NewSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' ';' case_list '}' - { - caseList := stmt.NewCaseList($3) - $$ = stmt.NewSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | ':' case_list T_ENDSWITCH ';' - { - caseList := stmt.NewCaseList($2) - $$ = stmt.NewAltSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | ':' ';' case_list T_ENDSWITCH ';' - { - - caseList := stmt.NewCaseList($3) - $$ = stmt.NewAltSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } -; - - -case_list: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | case_list T_CASE expr case_separator inner_statement_list - { - _case := stmt.NewCase($3, $5) - $$ = append($1, _case) - - // save position - _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) - - // save comments - 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) - } - | case_list T_DEFAULT case_separator inner_statement_list - { - _default := stmt.NewDefault($4) - $$ = append($1, _default) - - // save position - _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) - - // save comments - 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) - } -; - - -case_separator: - ':' - { - $$ = $1 - } - | ';' - { - $$ = $1 - } -; - - -while_statement: - statement - { - $$ = stmt.NewWhile(nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDWHILE ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltWhile(nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - - - -elseif_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | elseif_list T_ELSEIF parenthesis_expr statement - { - _elseIf := stmt.NewElseIf($3, $4) - $$ = append($1, _elseIf) - - // save position - _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $4)) - - // save comments - 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) - } -; - - -new_elseif_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | new_elseif_list T_ELSEIF parenthesis_expr ':' inner_statement_list - { - stmts := stmt.NewStmtList($5) - _elseIf := stmt.NewAltElseIf($3, stmts) - $$ = append($1, _elseIf) - - // save position - stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($5)) - _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) - - // save comments - 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) - } -; - - -else_single: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ELSE statement - { - $$ = stmt.NewElse($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -new_else_single: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ELSE ':' inner_statement_list - { - stmts := stmt.NewStmtList($3) - $$ = stmt.NewAltElse(stmts) - - // save position - stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Else, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -parameter_list: - non_empty_parameter_list - { - $$ = $1; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_parameter_list: - parameter - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_parameter_list ',' parameter - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -parameter: - optional_class_type is_reference is_variadic T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - } else if $2 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) - } else if $3 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - } - - // save comments - if $1 != nil { - yylex.(*Parser).MoveFreeFloating($1, $$) - } - if $2 != nil { - yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) - } - if $3 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - | optional_class_type is_reference is_variadic T_VARIABLE '=' static_scalar - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) - } else if $2 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) - } else if $3 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) - } - - // save comments - if $1 != nil { - yylex.(*Parser).MoveFreeFloating($1, $$) - } - if $2 != nil { - yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) - } - if $3 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -optional_class_type: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ARRAY - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CALLABLE - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | fully_qualified_class_name - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -function_call_parameter_list: - '(' ')' - { - $$ = node.NewArgumentList(nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' non_empty_function_call_parameter_list ')' - { - $$ = node.NewArgumentList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' yield_expr ')' - { - arg := node.NewArgument($2, false, false) - $$ = node.NewArgumentList([]node.Node{arg}) - - // save position - arg.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -non_empty_function_call_parameter_list: - function_call_parameter - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_function_call_parameter_list ',' function_call_parameter - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function_call_parameter: - expr_without_variable - { - $$ = node.NewArgument($1, false, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable - { - $$ = node.NewArgument($1, false, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' w_variable - { - $$ = node.NewArgument($2, false, true) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ELLIPSIS expr - { - $$ = node.NewArgument($2, true, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -global_var_list: - global_var_list ',' global_var - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | global_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -global_var: - T_VARIABLE - { - name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '$' r_variable - { - $$ = expr.NewVariable($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '$' '{' expr '}' - { - $$ = expr.NewVariable($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - - -static_var_list: - static_var_list ',' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, nil) - $$ = append($1, staticVar) - - // save position - 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).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(staticVar, freefloating.Start, $3.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_var_list ',' T_VARIABLE '=' static_scalar - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, $5) - $$ = append($1, staticVar) - - // save position - 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).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) - } - | T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, nil) - $$ = []node.Node{staticVar} - - // save position - 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).setFreeFloating(staticVar, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '=' static_scalar - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - staticVar := stmt.NewStaticVar(variable, $3) - $$ = []node.Node{staticVar} - - // save position - 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).setFreeFloating(staticVar, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - yylex.(*Parser).setFreeFloating(staticVar, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -class_statement_list: - class_statement_list class_statement - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -class_statement: - variable_modifiers class_variable_declaration ';' - { - $$ = stmt.NewPropertyList($1, nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $3)) - - // save comments - 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) - } - | class_constant_declaration ';' - { - $$ = $1 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.ConstList, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_use_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | method_modifiers function is_reference T_STRING '(' parameter_list ')' method_body - { - name := node.NewIdentifier($4.Value) - $$ = stmt.NewClassMethod(name, $1, $3 != nil, $6, nil, $8, "") - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 == nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $8)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $8)) - } - - // save comments - 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, $5.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ParameterList, $7.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_use_statement: - T_USE trait_list trait_adaptations - { - $$ = stmt.NewTraitUse($2, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_list: - fully_qualified_class_name - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_list ',' fully_qualified_class_name - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptations: - ';' - { - $$ = stmt.NewNop() - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' trait_adaptation_list '}' - { - $$ = stmt.NewTraitAdaptationList($2) - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptation_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_trait_adaptation_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_trait_adaptation_list: - trait_adaptation_statement - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_trait_adaptation_list trait_adaptation_statement - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptation_statement: - trait_precedence ';' - { - $$ = $1; - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.NameList, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_alias ';' - { - $$ = $1; - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Alias, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_precedence: - trait_method_reference_fully_qualified T_INSTEADOF trait_reference_list - { - $$ = stmt.NewTraitUsePrecedence($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_reference_list: - fully_qualified_class_name - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_reference_list ',' fully_qualified_class_name - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_method_reference: - T_STRING - { - name := node.NewIdentifier($1.Value) - $$ = stmt.NewTraitMethodRef(nil, name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_method_reference_fully_qualified - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_method_reference_fully_qualified: - fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING - { - target := node.NewIdentifier($3.Value) - $$ = stmt.NewTraitMethodRef($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_alias: - trait_method_reference T_AS trait_modifiers T_STRING - { - alias := node.NewIdentifier($4.Value) - $$ = stmt.NewTraitUseAlias($1, $3, alias) - - // save position - alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_method_reference T_AS member_modifier - { - $$ = stmt.NewTraitUseAlias($1, $3, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_modifiers: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | member_modifier - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -method_body: - ';' /* abstract method */ - { - $$ = stmt.NewNop() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' inner_statement_list '}' - { - $$ = stmt.NewStmtList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_modifiers: - non_empty_member_modifiers - { - $$ = $1; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VAR - { - modifier := node.NewIdentifier($1.Value) - $$ = []node.Node{modifier} - - // save position - modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -method_modifiers: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_member_modifiers - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_member_modifiers: - member_modifier - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_member_modifiers member_modifier - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -member_modifier: - T_PUBLIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PROTECTED - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PRIVATE - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STATIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ABSTRACT - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINAL - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_variable_declaration: - class_variable_declaration ',' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, nil, "") - $$ = append($1, property) - - // save position - 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).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(property, freefloating.Start, $3.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_variable_declaration ',' T_VARIABLE '=' static_scalar - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, $5, "") - $$ = append($1, property) - - // save position - 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).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) - } - | T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, nil, "") - $$ = []node.Node{property} - - // save position - 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).setFreeFloating(property, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '=' static_scalar - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - property := stmt.NewProperty(variable, $3, "") - $$ = []node.Node{property} - - // save position - 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).setFreeFloating(property, freefloating.Start, $2.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - yylex.(*Parser).setFreeFloating(property, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_constant_declaration: - class_constant_declaration ',' T_STRING '=' static_scalar - { - 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 - 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).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) - } - | T_CONST T_STRING '=' static_scalar - { - name := node.NewIdentifier($2.Value) - constant := stmt.NewConstant(name, $4, "") - $$ = stmt.NewClassConstList(nil, []node.Node{constant}) - - // save position - 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).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) - } -; - -echo_expr_list: - echo_expr_list ',' expr - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -for_expr: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_for_expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_for_expr: - non_empty_for_expr ',' expr - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -chaining_method_or_property: - chaining_method_or_property variable_property - { - $$ = append($1, $2...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_property - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -chaining_dereference: - chaining_dereference '[' dim_offset ']' - { - fetch := expr.NewArrayDimFetch(nil, $3) - $$ = append($1, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - 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) - } - | '[' dim_offset ']' - { - fetch := expr.NewArrayDimFetch(nil, $2) - $$ = []node.Node{fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($2)) - - // save comments - 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) - } -; - -chaining_instance_call: - chaining_dereference chaining_method_or_property - { - $$ = append($1, $2...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | chaining_dereference - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | chaining_method_or_property - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -instance_call: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | chaining_instance_call - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -new_expr: - T_NEW class_name_reference ctor_arguments - { - - if $3 != nil { - $$ = expr.NewNew($2, $3.(*node.ArgumentList)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - } else { - $$ = expr.NewNew($2, nil) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - } - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -expr_without_variable: - T_LIST '(' assignment_list ')' '=' expr - { - listNode := expr.NewList($3) - $$ = assign.NewAssign(listNode, $6) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) - - // save comments - 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) - } - | variable '=' expr - { - $$ = assign.NewAssign($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable '=' '&' variable - { - $$ = assign.NewReference($1, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Equal, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable '=' '&' T_NEW class_name_reference ctor_arguments - { - var _new *expr.New - - if $6 != nil { - _new = expr.NewNew($5, $6.(*node.ArgumentList)) - } else { - _new = expr.NewNew($5, nil) - } - $$ = assign.NewReference($1, _new) - - // save position - if $6 != nil { - _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) - } else { - _new.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $5)) - } - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, _new)) - - // save comments - 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) - } - | T_CLONE expr - { - $$ = expr.NewClone($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_PLUS_EQUAL expr - { - $$ = assign.NewPlus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MINUS_EQUAL expr - { - $$ = assign.NewMinus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MUL_EQUAL expr - { - $$ = assign.NewMul($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_POW_EQUAL expr - { - $$ = assign.NewPow($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_DIV_EQUAL expr - { - $$ = assign.NewDiv($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_CONCAT_EQUAL expr - { - $$ = assign.NewConcat($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MOD_EQUAL expr - { - $$ = assign.NewMod($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_AND_EQUAL expr - { - $$ = assign.NewBitwiseAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_OR_EQUAL expr - { - $$ = assign.NewBitwiseOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_XOR_EQUAL expr - { - $$ = assign.NewBitwiseXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_SL_EQUAL expr - { - $$ = assign.NewShiftLeft($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_SR_EQUAL expr - { - $$ = assign.NewShiftRight($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | rw_variable T_INC - { - $$ = expr.NewPostInc($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INC rw_variable - { - $$ = expr.NewPreInc($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | rw_variable T_DEC - { - $$ = expr.NewPostDec($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DEC rw_variable - { - $$ = expr.NewPreDec($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_BOOLEAN_OR expr - { - $$ = binary.NewBooleanOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_BOOLEAN_AND expr - { - $$ = binary.NewBooleanAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_OR expr - { - $$ = binary.NewLogicalOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_AND expr - { - $$ = binary.NewLogicalAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_XOR expr - { - $$ = binary.NewLogicalXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '|' expr - { - $$ = binary.NewBitwiseOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '&' expr - { - $$ = binary.NewBitwiseAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '^' expr - { - $$ = binary.NewBitwiseXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '.' expr - { - $$ = binary.NewConcat($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '+' expr - { - $$ = binary.NewPlus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '-' expr - { - $$ = binary.NewMinus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '*' expr - { - $$ = binary.NewMul($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_POW expr - { - $$ = binary.NewPow($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '/' expr - { - $$ = binary.NewDiv($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '%' expr - { - $$ = binary.NewMod($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_SL expr - { - $$ = binary.NewShiftLeft($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_SR expr - { - $$ = binary.NewShiftRight($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '+' expr %prec T_INC - { - $$ = expr.NewUnaryPlus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '-' expr %prec T_INC - { - $$ = expr.NewUnaryMinus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '!' expr - { - $$ = expr.NewBooleanNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '~' expr - { - $$ = expr.NewBitwiseNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_IDENTICAL expr - { - $$ = binary.NewIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_NOT_IDENTICAL expr - { - $$ = binary.NewNotIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_EQUAL expr - { - $$ = binary.NewEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_NOT_EQUAL expr - { - $$ = binary.NewNotEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - 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) - } - | expr '<' expr - { - $$ = binary.NewSmaller($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_SMALLER_OR_EQUAL expr - { - $$ = binary.NewSmallerOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '>' expr - { - $$ = binary.NewGreater($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_GREATER_OR_EQUAL expr - { - $$ = binary.NewGreaterOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_INSTANCEOF class_name_reference - { - $$ = expr.NewInstanceOf($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | parenthesis_expr - { - $$ = $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 - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' new_expr ')' instance_call - { - $$ = $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 - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, n)) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '?' expr ':' expr - { - $$ = expr.NewTernary($1, $3, $5) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '?' ':' expr - { - $$ = expr.NewTernary($1, nil, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | internal_functions_in_yacc - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INT_CAST expr - { - $$ = cast.NewInt($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DOUBLE_CAST expr - { - $$ = cast.NewDouble($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STRING_CAST expr - { - $$ = cast.NewString($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ARRAY_CAST expr - { - $$ = cast.NewArray($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_OBJECT_CAST expr - { - $$ = cast.NewObject($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_BOOL_CAST expr - { - $$ = cast.NewBool($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_UNSET_CAST expr - { - $$ = cast.NewUnset($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - 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")) { - e.Die = true - } - - // save position - if $2.GetPosition() == nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - } - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '@' expr - { - $$ = expr.NewErrorSuppress($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | combined_scalar_offset - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | combined_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '`' backticks_expr '`' - { - $$ = expr.NewShellExec($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PRINT expr - { - $$ = expr.NewPrint($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD - { - $$ = expr.NewYield(nil, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' - { - $$ = expr.NewClosure($4, $6, nil, $8, false, $2 != nil, "") - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $9)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' - { - $$ = expr.NewClosure($5, $7, nil, $9, true, $3 != nil, "") - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $10)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - -yield_expr: - T_YIELD expr_without_variable - { - $$ = expr.NewYield(nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD variable - { - $$ = expr.NewYield(nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD expr T_DOUBLE_ARROW expr_without_variable - { - $$ = expr.NewYield($2, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD expr T_DOUBLE_ARROW variable - { - $$ = expr.NewYield($2, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -combined_scalar_offset: - combined_scalar '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | combined_scalar_offset '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' - { - str := scalar.NewString($1.Value) - $$ = expr.NewArrayDimFetch(str, $3) - - // save position - str.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(str, $4)) - - // save comments - 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) - } - | general_constant '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } -; - -combined_scalar: - T_ARRAY '(' array_pair_list ')' - { - $$ = expr.NewArray($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | '[' array_pair_list ']' - { - $$ = expr.NewShortArray($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function: - T_FUNCTION - { - $$ = $1 - } -; - -lexical_vars: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_USE '(' lexical_var_list ')' - { - $$ = expr.NewClosureUse($3) - - // 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) - } -; - -lexical_var_list: - lexical_var_list ',' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($3.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = append($1, variable) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - - // save comments - 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) - } - | lexical_var_list ',' '&' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - reference := expr.NewReference(variable) - $$ = append($1, reference) - - // save position - 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).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) - } - | T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = []node.Node{variable} - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($2.Value, isDollar)) - variable := expr.NewVariable(identifier) - reference := expr.NewReference(variable) - $$ = []node.Node{reference} - - // save position - 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).setFreeFloating(reference, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $2.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function_call: - namespace_name function_call_parameter_list - { - name := name.NewName($1) - $$ = expr.NewFunctionCall(name, $2.(*node.ArgumentList)) - - // save position - 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) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list - { - funcName := name.NewRelative($3) - $$ = expr.NewFunctionCall(funcName, $4.(*node.ArgumentList)) - - // save position - funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $4)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(funcName, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name function_call_parameter_list - { - funcName := name.NewFullyQualified($2) - $$ = expr.NewFunctionCall(funcName, $3.(*node.ArgumentList)) - - // save position - funcName.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_without_objects function_call_parameter_list - { - $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_name: - T_STATIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | namespace_name - { - $$ = name.NewName($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1[0], $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name - { - $$ = name.NewRelative($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - $$ = name.NewFullyQualified($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -fully_qualified_class_name: - namespace_name - { - $$ = name.NewName($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1[0], $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name - { - $$ = name.NewRelative($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - $$ = name.NewFullyQualified($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_name_reference: - class_name - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dynamic_class_name_reference - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -dynamic_class_name_reference: - base_variable T_OBJECT_OPERATOR object_property dynamic_class_name_variable_properties - { - $$ = $1 - - // save comments - yylex.(*Parser).setFreeFloating($3[0], freefloating.Var, $2.FreeFloating) - - for _, n := range($3) { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = $$ - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.PropertyFetch: - nn.Variable = $$ - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - } - } - - for _, n := range($4) { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = $$ - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.PropertyFetch: - nn.Variable = $$ - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - } - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | base_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -dynamic_class_name_variable_properties: - dynamic_class_name_variable_properties dynamic_class_name_variable_property - { - $$ = append($1, $2...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -dynamic_class_name_variable_property: - T_OBJECT_OPERATOR object_property - { - $$ = $2 - - // save comments - yylex.(*Parser).setFreeFloating($2[0], freefloating.Var, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -exit_expr: - /* empty */ - { - $$ = expr.NewExit(nil); - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' ')' - { - $$ = expr.NewExit(nil); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - 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) - } - | parenthesis_expr - { - $$ = expr.NewExit($1); - - // save position - 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) - } -; - -backticks_expr: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ENCAPSED_AND_WHITESPACE - { - part := scalar.NewEncapsedStringPart($1.Value) - $$ = []node.Node{part} - - // save position - part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_list - { - $$ = $1; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -ctor_arguments: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_call_parameter_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -common_scalar: - T_LNUMBER - { - $$ = scalar.NewLnumber($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DNUMBER - { - $$ = scalar.NewDnumber($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CONSTANT_ENCAPSED_STRING - { - $$ = scalar.NewString($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_LINE - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FILE - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DIR - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_TRAIT_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_METHOD_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FUNC_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC - { - encapsed := scalar.NewEncapsedStringPart($2.Value) - $$ = scalar.NewHeredoc($1.Value, []node.Node{encapsed}) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC T_END_HEREDOC - { - $$ = scalar.NewHeredoc($1.Value, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_class_constant: - class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_scalar: - static_scalar_value - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_scalar_value: - common_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_class_name_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | namespace_name - { - name := name.NewName($1) - $$ = expr.NewConstFetch(name) - - // save position - 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) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name - { - name := name.NewRelative($3) - $$ = expr.NewConstFetch(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - name := name.NewFullyQualified($2) - $$ = expr.NewConstFetch(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ARRAY '(' static_array_pair_list ')' - { - $$ = expr.NewArray($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | '[' static_array_pair_list ']' - { - $$ = expr.NewShortArray($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_class_constant - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CLASS_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_operation - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_operation: - static_scalar_value '[' static_scalar_value ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | static_scalar_value '+' static_scalar_value - { - $$ = binary.NewPlus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '-' static_scalar_value - { - $$ = binary.NewMinus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '*' static_scalar_value - { - $$ = binary.NewMul($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_POW static_scalar_value - { - $$ = binary.NewPow($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '/' static_scalar_value - { - $$ = binary.NewDiv($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '%' static_scalar_value - { - $$ = binary.NewMod($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '!' static_scalar_value - { - $$ = expr.NewBooleanNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '~' static_scalar_value - { - $$ = expr.NewBitwiseNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '|' static_scalar_value - { - $$ = binary.NewBitwiseOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '&' static_scalar_value - { - $$ = binary.NewBitwiseAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '^' static_scalar_value - { - $$ = binary.NewBitwiseXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_SL static_scalar_value - { - $$ = binary.NewShiftLeft($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_SR static_scalar_value - { - $$ = binary.NewShiftRight($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '.' static_scalar_value - { - $$ = binary.NewConcat($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_LOGICAL_XOR static_scalar_value - { - $$ = binary.NewLogicalXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_LOGICAL_AND static_scalar_value - { - $$ = binary.NewLogicalAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_LOGICAL_OR static_scalar_value - { - $$ = binary.NewLogicalOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_BOOLEAN_AND static_scalar_value - { - $$ = binary.NewBooleanAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_BOOLEAN_OR static_scalar_value - { - $$ = binary.NewBooleanOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_IDENTICAL static_scalar_value - { - $$ = binary.NewIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_NOT_IDENTICAL static_scalar_value - { - $$ = binary.NewNotIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_EQUAL static_scalar_value - { - $$ = binary.NewEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_NOT_EQUAL static_scalar_value - { - $$ = binary.NewNotEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - 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) - } - | static_scalar_value '<' static_scalar_value - { - $$ = binary.NewSmaller($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '>' static_scalar_value - { - $$ = binary.NewGreater($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_SMALLER_OR_EQUAL static_scalar_value - { - $$ = binary.NewSmallerOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_IS_GREATER_OR_EQUAL static_scalar_value - { - $$ = binary.NewGreaterOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '?' ':' static_scalar_value - { - $$ = expr.NewTernary($1, nil, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value '?' static_scalar_value ':' static_scalar_value - { - $$ = expr.NewTernary($1, $3, $5) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '+' static_scalar_value - { - $$ = expr.NewUnaryPlus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '-' static_scalar_value - { - $$ = expr.NewUnaryMinus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' static_scalar_value ')' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -general_constant: - class_constant - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | namespace_name - { - name := name.NewName($1) - $$ = expr.NewConstFetch(name) - - // save position - 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) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name - { - name := name.NewRelative($3) - $$ = expr.NewConstFetch(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(name, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - name := name.NewFullyQualified($2) - $$ = expr.NewConstFetch(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(name)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -scalar: - T_STRING_VARNAME - { - name := node.NewIdentifier($1.Value) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | general_constant - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | common_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '"' encaps_list '"' - { - $$ = scalar.NewEncapsed($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC encaps_list T_END_HEREDOC - { - $$ = scalar.NewHeredoc($1.Value, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CLASS_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_array_pair_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_static_array_pair_list possible_comma - { - $$ = $1 - - // save comments - if $2 != nil { - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -possible_comma: - /* empty */ - { - $$ = nil - } - | ',' - { - $$ = $1 - } -; - -non_empty_static_array_pair_list: - non_empty_static_array_pair_list ',' static_scalar_value T_DOUBLE_ARROW static_scalar_value - { - arrayItem := expr.NewArrayItem($3, $5, false) - $$ = append($1, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) - - // save comments - 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) - } - | non_empty_static_array_pair_list ',' static_scalar_value - { - arrayItem := expr.NewArrayItem(nil, $3, false) - $$ = append($1, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).MoveFreeFloating($3, arrayItem) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value T_DOUBLE_ARROW static_scalar_value - { - arrayItem := expr.NewArrayItem($1, $3, false) - $$ = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, arrayItem) - yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_scalar_value - { - arrayItem := expr.NewArrayItem(nil, $1, false) - $$ = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, arrayItem) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -expr: - r_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr_without_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -parenthesis_expr: - '(' expr ')' - { - $$ = $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 - - // 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) - } -; - - -r_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -w_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -rw_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable: - base_variable_with_function_calls T_OBJECT_OPERATOR object_property method_or_not variable_properties - { - $$ = $1 - - if $4 != nil { - $4[0].(*expr.MethodCall).Method = $3[len($3)-1].(*expr.PropertyFetch).Property - $3 = append($3[:len($3)-1], $4...) - } - - // save comments - yylex.(*Parser).setFreeFloating($3[0], freefloating.Var, $2.FreeFloating) - - for _, n := range($3) { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.PropertyFetch: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.MethodCall: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - } - } - - for _, n := range($5) { - switch nn := n.(type) { - case *expr.ArrayDimFetch: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.PropertyFetch: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - - case *expr.MethodCall: - nn.Variable = $$ - nn.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($$, nn)) - $$ = nn - yylex.(*Parser).MoveFreeFloating(nn.Variable, $$) - } - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | base_variable_with_function_calls - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_properties: - variable_properties variable_property - { - $$ = append($1, $2...) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -variable_property: - T_OBJECT_OPERATOR object_property method_or_not - { - if $3 != nil { - $3[0].(*expr.MethodCall).Method = $2[len($2)-1].(*expr.PropertyFetch).Property - $2 = append($2[:len($2)-1], $3...) - } - - $$ = $2 - - // save comments - yylex.(*Parser).setFreeFloating($2[0], freefloating.Var, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -array_method_dereference: - array_method_dereference '[' dim_offset ']' - { - fetch := expr.NewArrayDimFetch(nil, $3) - $$ = append($1, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - 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) - } - | method '[' dim_offset ']' - { - fetch := expr.NewArrayDimFetch(nil, $3) - $$ = []node.Node{$1, fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - 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) - } -; - -method: - function_call_parameter_list - { - $$ = expr.NewMethodCall(nil, nil, $1.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -method_or_not: - method - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | array_method_dereference - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_without_objects: - reference_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | simple_indirect_reference reference_variable - { - $1.last.SetVarName($2) - - for _, n := range($1.all) { - n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2)) - } - - $$ = $1.all[0] - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_member: - class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_class_name: - reference_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -array_function_dereference: - array_function_dereference '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | function_call '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } -; - -base_variable_with_function_calls: - base_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | array_function_dereference - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_call - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -base_variable: - reference_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | simple_indirect_reference reference_variable - { - $1.last.SetVarName($2) - - for _, n := range($1.all) { - n.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(n, $2)) - } - - $$ = $1.all[0] - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_member - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -reference_variable: - reference_variable '[' dim_offset ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | reference_variable '{' expr '}' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | compound_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -compound_variable: - T_VARIABLE - { - name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '$' '{' expr '}' - { - $$ = expr.NewVariable($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -dim_offset: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -object_property: - object_dim_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_without_objects - { - fetch := expr.NewPropertyFetch(nil, $1) - $$ = []node.Node{fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -object_dim_list: - object_dim_list '[' dim_offset ']' - { - fetch := expr.NewArrayDimFetch(nil, $3) - $$ = append($1, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - 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) - } - | object_dim_list '{' expr '}' - { - fetch := expr.NewArrayDimFetch(nil, $3) - $$ = append($1, fetch) - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - 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) - } - | variable_name - { - fetch := expr.NewPropertyFetch(nil, $1) - $$ = []node.Node{fetch} - - // save position - fetch.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_name: - T_STRING - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' expr '}' - { - $$ = $2 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -simple_indirect_reference: - '$' - { - n := expr.NewVariable(nil) - $$ = simpleIndirectReference{[]*expr.Variable{n}, n} - - // save position - n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(n, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | simple_indirect_reference '$' - { - n := expr.NewVariable(nil) - - $1.last.SetVarName(n) - $1.all = append($1.all, n) - $1.last = n - $$ = $1 - - // save position - n.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - - // save comments - yylex.(*Parser).setFreeFloating(n, freefloating.Start, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(n, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -assignment_list: - assignment_list ',' assignment_list_element - { - if len($1) == 0 { - $1 = []node.Node{expr.NewArrayItem(nil, nil, false)} - } - - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | assignment_list_element - { - if $1.(*expr.ArrayItem).Key == nil && $1.(*expr.ArrayItem).Val == nil { - $$ = []node.Node{} - } else { - $$ = []node.Node{$1} - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -assignment_list_element: - variable - { - $$ = expr.NewArrayItem(nil, $1, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_LIST '(' assignment_list ')' - { - listNode := expr.NewList($3) - $$ = expr.NewArrayItem(nil, listNode, false) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(listNode)) - - // save comments - 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 */ - { - $$ = expr.NewArrayItem(nil, nil, false) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - - -array_pair_list: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_array_pair_list possible_comma - { - $$ = $1 - - if $2 != nil { - $$ = append($1, expr.NewArrayItem(nil, nil, false)) - } - - // save comments - if $2 != nil { - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_array_pair_list: - non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr - { - arrayItem := expr.NewArrayItem($3, $5, false) - $$ = append($1, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $5)) - - // save comments - 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) - } - | non_empty_array_pair_list ',' expr - { - arrayItem := expr.NewArrayItem(nil, $3, false) - $$ = append($1, arrayItem) - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($3)) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).MoveFreeFloating($3, arrayItem) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_DOUBLE_ARROW expr - { - arrayItem := expr.NewArrayItem($1, $3, false) - $$ = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, arrayItem) - yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - arrayItem := expr.NewArrayItem(nil, $1, false) - $$ = []node.Node{arrayItem} - - // save position - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, arrayItem) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable - { - reference := expr.NewReference($6) - arrayItem := expr.NewArrayItem($3, reference, false) - $$ = append($1, arrayItem) - - // save position - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($5, $6)) - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($3, $6)) - - // save comments - 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) - } - | non_empty_array_pair_list ',' '&' w_variable - { - reference := expr.NewReference($4) - arrayItem := expr.NewArrayItem(nil, reference, false) - $$ = append($1, arrayItem) - - // save position - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_DOUBLE_ARROW '&' w_variable - { - reference := expr.NewReference($4) - arrayItem := expr.NewArrayItem($1, reference, false) - $$ = []node.Node{arrayItem} - - // save position - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - 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) - } - | '&' w_variable - { - reference := expr.NewReference($2) - arrayItem := expr.NewArrayItem(nil, reference, false) - $$ = []node.Node{arrayItem} - - // save position - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - arrayItem.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating(arrayItem, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -encaps_list: - encaps_list encaps_var - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_list T_ENCAPSED_AND_WHITESPACE - { - encapsed := scalar.NewEncapsedStringPart($2.Value) - $$ = append($1, encapsed) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ENCAPSED_AND_WHITESPACE encaps_var - { - encapsed := scalar.NewEncapsedStringPart($1.Value) - $$ = []node.Node{encapsed, $2} - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -encaps_var: - T_VARIABLE - { - name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '[' encaps_var_offset ']' - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = expr.NewArrayDimFetch(variable, $3) - - // save position - 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).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) - } - | T_VARIABLE T_OBJECT_OPERATOR T_STRING - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - fetch := node.NewIdentifier($3.Value) - $$ = expr.NewPropertyFetch(variable, fetch) - - // save position - 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).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 '}' - { - variable := expr.NewVariable($2) - - $$ = variable - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // 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) - } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' - { - name := node.NewIdentifier($2.Value) - variable := expr.NewVariable(name) - - $$ = variable - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // 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) - } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { - identifier := node.NewIdentifier($2.Value) - variable := expr.NewVariable(identifier) - $$ = expr.NewArrayDimFetch(variable, $4) - - // save position - 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).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) - } - | T_CURLY_OPEN variable '}' - { - $$ = $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) - } -; - -encaps_var_offset: - T_STRING - { - $$ = scalar.NewString($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NUM_STRING - { - // TODO: add option to handle 64 bit integer - if _, err := strconv.Atoi($1.Value); err == nil { - $$ = scalar.NewLnumber($1.Value) - } else { - $$ = scalar.NewString($1.Value) - } - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -internal_functions_in_yacc: - T_ISSET '(' isset_variables ')' - { - $$ = expr.NewIsset($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_EMPTY '(' variable ')' - { - $$ = expr.NewEmpty($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_EMPTY '(' expr ')' - { - $$ = expr.NewEmpty($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_INCLUDE expr - { - $$ = expr.NewInclude($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INCLUDE_ONCE expr - { - $$ = expr.NewIncludeOnce($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EVAL '(' expr ')' - { - $$ = expr.NewEval($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_REQUIRE expr - { - $$ = expr.NewRequire($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_REQUIRE_ONCE expr - { - $$ = expr.NewRequireOnce($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -isset_variables: - isset_variable - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | isset_variables ',' isset_variable - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -isset_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr_without_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_constant: - class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_class_name_scalar: - class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_name_scalar: - class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -%% - -type simpleIndirectReference struct { - all []*expr.Variable - last *expr.Variable -} diff --git a/php5/php5_bench_test.go b/php5/php5_bench_test.go deleted file mode 100644 index 1cdd5aa..0000000 --- a/php5/php5_bench_test.go +++ /dev/null @@ -1,419 +0,0 @@ -package php5_test - -import ( - "testing" - - "github.com/z7zmey/php-parser/php5" -) - -func BenchmarkPhp5(b *testing.B) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - - function foo(bar $bar=null, baz &...$baz) {} - class foo {public function foo(bar $bar=null, baz &...$baz) {}} - function(bar $bar=null, baz &...$baz) {}; - static function(bar $bar=null, baz &...$baz) {}; - - "test"; - "\$test"; - " - test - "; - '$test'; - ' - $test - '; - <<bar()"; - "test ${foo}"; - "test ${foo[0]}"; - "test {$foo->bar()}"; - - if ($a) : - endif; - if ($a) : - elseif ($b): - endif; - if ($a) : - else: - endif; - if ($a) : - elseif ($b): - elseif ($c): - else: - endif; - - while (1) { break; } - while (1) { break 2; } - while (1) : break(3); endwhile; - class foo{ const FOO = 1, BAR = 2; } - class foo{ function bar() {} } - class foo{ public static function &bar() {} } - class foo{ final private function bar() {} protected function baz() {} } - abstract class foo{ abstract public function bar(); } - final class foo extends bar { } - final class foo implements bar { } - final class foo implements bar, baz { } - - const FOO = 1, BAR = 2; - while (1) { continue; } - while (1) { continue 2; } - while (1) { continue(3); } - declare(ticks=1); - declare(ticks=1, strict_types=1) {} - declare(ticks=1): enddeclare; - do {} while(1); - echo $a, 1; - echo($a); - for($i = 0; $i < 10; $i++, $i++) {} - for(; $i < 10; $i++) : endfor; - foreach ($a as $v) {} - foreach ([] as $v) {} - foreach ($a as $v) : endforeach; - foreach ($a as $k => $v) {} - foreach ([] as $k => $v) {} - foreach ($a as $k => &$v) {} - foreach ($a as $k => list($v)) {} - function foo() {} - - function foo() { - __halt_compiler(); - function bar() {} - class Baz {} - return $a; - } - - function foo(array $a, callable $b) {return;} - function &foo() {return 1;} - function &foo() {} - global $a, $b, $$c, ${foo()}; - a: - goto a; - __halt_compiler(); - if ($a) {} - if ($a) {} elseif ($b) {} - if ($a) {} else {} - if ($a) {} elseif ($b) {} elseif ($c) {} else {} - if ($a) {} elseif ($b) {} else if ($c) {} else {} - ?>
1, &$b,); - array(3 =>&$b); - array(&$b, 1=>1, 1, 3 =>&$b); - ~$a; - !$a; - - Foo::Bar; - clone($a); - clone $a; - function(){}; - function($a, $b) use ($c, &$d) {}; - function($a, $b) use (&$c, $d) {}; - function() {}; - foo; - namespace\foo; - \foo; - - empty($a); - empty(Foo); - @$a; - eval($a); - exit; - exit($a); - die(); - die($a); - foo(); - namespace\foo(&$a); - \foo([]); - $foo(yield $a); - - $a--; - $a++; - --$a; - ++$a; - - include $a; - include_once $a; - require $a; - require_once $a; - - $a instanceof Foo; - $a instanceof namespace\Foo; - $a instanceof \Foo; - - isset($a, $b); - isset(Foo); - list() = $b; - list($a, $b) = $b; - list($a[]) = $b; - list(list($a)) = $b; - - $a->foo(); - new Foo; - new namespace\Foo(); - new \Foo(); - print($a); - $a->foo; - $a->foo[1]; - $a->foo->bar->baz()->quux[0]; - $a->foo()[1][1]; - ` + "`cmd $a`;" + ` - ` + "`cmd`;" + ` - ` + "``;" + ` - []; - [1]; - [1=>1, &$b,]; - - Foo::bar(); - namespace\Foo::bar(); - \Foo::bar(); - Foo::$bar(); - $foo::$bar(); - Foo::$bar; - namespace\Foo::$bar; - \Foo::$bar; - $a ? $b : $c; - $a ? : $c; - $a ? $b ? $c : $d : $e; - $a ? $b : $c ? $d : $e; - -$a; - +$a; - $$a; - $$$a; - yield; - yield $a; - yield $a => $b; - yield Foo::class; - yield $a => Foo::class; - - (array)$a; - (boolean)$a; - (bool)$a; - (double)$a; - (float)$a; - (integer)$a; - (int)$a; - (object)$a; - (string)$a; - (unset)$a; - - $a & $b; - $a | $b; - $a ^ $b; - $a && $b; - $a || $b; - $a . $b; - $a / $b; - $a == $b; - $a >= $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 =& new Foo; - $a =& new Foo($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; - - - (new \Foo()); - (new \Foo())->bar()->baz; - (new \Foo())[0][0]; - (new \Foo())[0]->bar(); - - array([0])[0][0]; - "foo"[0]; - foo[0]; - static::foo; - - new $foo; - new $foo::$bar; - new $a->b[0]; - new $a->b{$b ?: null}->$c->d[0];static $a = [1][0]; - - static $a = !1; - static $a = ~1; - static $a = +1; - static $a = -1; - static $a = (1); - static $a = 1 ?: 2; - static $a = 1 ? 2 : 3; - static $a = 1 & 2; - static $a = 1 | 2; - static $a = 1 ^ 2; - static $a = 1 && 2; - static $a = 1 || 2; - static $a = 1 . 2; - static $a = 1 / 2; - static $a = 1 == 2; - static $a = 1 >= 2; - static $a = 1 > 2; - static $a = 1 === 2; - static $a = 1 and 2; - static $a = 1 or 2; - static $a = 1 xor 2; - static $a = 1 - 2; - static $a = 1 % 2; - static $a = 1 * 2; - static $a = 1 != 2; - static $a = 1 !== 2; - static $a = 1 + 2; - static $a = 1 ** 2; - static $a = 1 << 2; - static $a = 1 >> 2; - static $a = 1 <= 2; - static $a = 1 < 2; - static $a = Foo::bar; - static $a = Foo::class; - static $a = __CLASS__; - static $a = Foo; - static $a = namespace\Foo; - static $a = \Foo; - static $a = array(); - static $a = array(1 => 1, 2); - static $a = [1, 2 => 2][0]; - - if (yield 1) {} - Foo::$$bar; - - $foo(); - $foo()[0][0]; - $a{$b}; - ${$a}; - $foo::{$bar}(); - $foo::bar; - ` - - for n := 0; n < b.N; n++ { - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - } -} diff --git a/php5/php5_test.go b/php5/php5_test.go deleted file mode 100644 index 3cbb727..0000000 --- a/php5/php5_test.go +++ /dev/null @@ -1,18733 +0,0 @@ -package php5_test - -import ( - "testing" - - "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" -) - -func TestPhp5(t *testing.T) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - - function foo(bar $bar=null, baz &...$baz) {} - class foo {public function foo(bar $bar=null, baz &...$baz) {}} - function(bar $bar=null, baz &...$baz) {}; - static function(bar $bar=null, baz &...$baz) {}; - - 1234567890123456789; - 12345678901234567890; - 0.; - 0b0111111111111111111111111111111111111111111111111111111111111111; - 0b1111111111111111111111111111111111111111111111111111111111111111; - 0x007111111111111111; - 0x8111111111111111; - __CLASS__; - __DIR__; - __FILE__; - __FUNCTION__; - __LINE__; - __NAMESPACE__; - __METHOD__; - __TRAIT__; - - "test $var"; - "test $var[1]"; - "test $var[1234567890123456789012345678901234567890]"; - "test $var[bar]"; - "test $var[$bar]"; - "$foo $bar"; - "test $foo->bar()"; - "test ${foo}"; - "test ${foo[0]}"; - "test {$foo->bar()}"; - - if ($a) : - endif; - if ($a) : - elseif ($b): - endif; - if ($a) : - else: - endif; - if ($a) : - elseif ($b): - elseif ($c): - else: - endif; - - while (1) { break; } - while (1) { break 2; } - while (1) : break(3); endwhile; - class foo{ const FOO = 1, BAR = 2; } - class foo{ function bar() {} } - class foo{ public static function &bar() {} } - class foo{ final private function bar() {} protected function baz() {} } - abstract class foo{ abstract public function bar(); } - final class foo extends bar { } - final class foo implements bar { } - final class foo implements bar, baz { } - - const FOO = 1, BAR = 2; - while (1) { continue; } - while (1) { continue 2; } - while (1) { continue(3); } - declare(ticks=1); - declare(ticks=1, strict_types=1) {} - declare(ticks=1): enddeclare; - do {} while(1); - echo $a, 1; - echo($a); - for($i = 0; $i < 10; $i++, $i++) {} - for(; $i < 10; $i++) : endfor; - foreach ($a as $v) {} - foreach ([] as $v) {} - foreach ($a as $v) : endforeach; - foreach ($a as $k => $v) {} - foreach ([] as $k => $v) {} - foreach ($a as $k => &$v) {} - foreach ($a as $k => list($v)) {} - function foo() {} - - function foo() { - function bar() {} - class Baz {} - return $a; - } - - function foo(array $a, callable $b) {return;} - function &foo() {return 1;} - function &foo() {} - global $a, $b, $$c, ${foo()}; - a: - goto a; - if ($a) {} - if ($a) {} elseif ($b) {} - if ($a) {} else {} - if ($a) {} elseif ($b) {} elseif ($c) {} else {} - if ($a) {} elseif ($b) {} else if ($c) {} else {} - ?>
1, &$b,); - array(3 =>&$b); - array(&$b, 1=>1, 1, 3 =>&$b); - ~$a; - !$a; - - Foo::Bar; - clone($a); - clone $a; - function(){}; - function($a, $b) use ($c, &$d) {}; - function($a, $b) use (&$c, $d) {}; - function() {}; - foo; - namespace\foo; - \foo; - - empty($a); - empty(Foo); - @$a; - eval($a); - exit; - exit($a); - die(); - die($a); - foo(); - namespace\foo(&$a); - \foo([]); - $foo(yield $a); - - $a--; - $a++; - --$a; - ++$a; - - include $a; - include_once $a; - require $a; - require_once $a; - - $a instanceof Foo; - $a instanceof namespace\Foo; - $a instanceof \Foo; - - isset($a, $b); - isset(Foo); - list() = $b; - list($a, $b) = $b; - list($a[]) = $b; - list(list($a)) = $b; - - $a->foo(); - new Foo; - new namespace\Foo(); - new \Foo(); - print($a); - $a->foo; - $a->foo[1]; - $a->foo->bar->baz()->quux[0]; - $a->foo()[1][1]; - ` + "`cmd $a`;" + ` - ` + "`cmd`;" + ` - ` + "``;" + ` - []; - [1]; - [1=>1, &$b,]; - - Foo::bar(); - namespace\Foo::bar(); - \Foo::bar(); - Foo::$bar(); - $foo::$bar(); - Foo::$bar; - namespace\Foo::$bar; - \Foo::$bar; - $a ? $b : $c; - $a ? : $c; - $a ? $b ? $c : $d : $e; - $a ? $b : $c ? $d : $e; - -$a; - +$a; - $$a; - $$$a; - yield; - yield $a; - yield $a => $b; - yield Foo::class; - yield $a => Foo::class; - - (array)$a; - (boolean)$a; - (bool)$a; - (double)$a; - (float)$a; - (integer)$a; - (int)$a; - (object)$a; - (string)$a; - (unset)$a; - - $a & $b; - $a | $b; - $a ^ $b; - $a && $b; - $a || $b; - $a . $b; - $a / $b; - $a == $b; - $a >= $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 =& new Foo; - $a =& new Foo($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; - - - (new \Foo()); - (new \Foo())->bar()->baz; - (new \Foo())[0][0]; - (new \Foo())[0]->bar(); - - array([0])[0][0]; - "foo"[0]; - foo[0]; - static::foo; - - new $foo; - new $foo::$bar; - new $a->b[0]; - new $a->b{$b ?: null}->$c->d[0];static $a = [1][0]; - - static $a = !1; - static $a = ~1; - static $a = +1; - static $a = -1; - static $a = (1); - static $a = 1 ?: 2; - static $a = 1 ? 2 : 3; - static $a = 1 & 2; - static $a = 1 | 2; - static $a = 1 ^ 2; - static $a = 1 && 2; - static $a = 1 || 2; - static $a = 1 . 2; - static $a = 1 / 2; - static $a = 1 == 2; - static $a = 1 >= 2; - static $a = 1 > 2; - static $a = 1 === 2; - static $a = 1 and 2; - static $a = 1 or 2; - static $a = 1 xor 2; - static $a = 1 - 2; - static $a = 1 % 2; - static $a = 1 * 2; - static $a = 1 != 2; - static $a = 1 !== 2; - static $a = 1 + 2; - static $a = 1 ** 2; - static $a = 1 << 2; - static $a = 1 >> 2; - static $a = 1 <= 2; - static $a = 1 < 2; - static $a = Foo::bar; - static $a = Foo::class; - static $a = __CLASS__; - static $a = Foo; - static $a = namespace\Foo; - static $a = \Foo; - static $a = array(); - static $a = array(1 => 1, 2); - static $a = [1, 2 => 2][0]; - - if (yield 1) {} - Foo::$$bar; - - $foo(); - $foo()[0][0]; - $a{$b}; - ${$a}; - $foo::{$bar}(); - $foo::bar; - - __halt_compiler(); - - parsing process must be terminated - ` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 2, - EndLine: 379, - StartPos: 5, - EndPos: 6944, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 20, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 19, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 8, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 8, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 8, - EndPos: 19, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 13, - EndPos: 18, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 16, - EndPos: 18, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 16, - EndPos: 18, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 39, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 38, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 27, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 27, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 27, - EndPos: 38, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 32, - EndPos: 37, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 35, - EndPos: 37, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 35, - EndPos: 37, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 63, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 62, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 46, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 46, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 48, - EndPos: 51, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 51, - EndPos: 62, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 56, - EndPos: 61, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 59, - EndPos: 61, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 59, - EndPos: 61, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 86, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 85, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 69, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 69, - }, - Value: "foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 71, - EndPos: 74, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 74, - EndPos: 85, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 79, - EndPos: 84, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 82, - EndPos: 84, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 82, - EndPos: 84, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 110, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 109, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 93, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 93, - }, - Value: "foo", - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 95, - EndPos: 98, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 98, - EndPos: 109, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 103, - EndPos: 108, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 106, - EndPos: 108, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 106, - EndPos: 108, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 113, - EndPos: 132, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 113, - EndPos: 131, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 117, - EndPos: 120, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 117, - EndPos: 120, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 120, - EndPos: 131, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 125, - EndPos: 130, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 128, - EndPos: 130, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 128, - EndPos: 130, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 136, - EndPos: 180, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 145, - EndPos: 148, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 149, - EndPos: 162, - }, - ByRef: false, - Variadic: false, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 149, - EndPos: 152, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 149, - EndPos: 152, - }, - Value: "bar", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 153, - EndPos: 157, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 153, - EndPos: 157, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 158, - EndPos: 162, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 158, - EndPos: 162, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 158, - EndPos: 162, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 164, - EndPos: 176, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 164, - EndPos: 167, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 164, - EndPos: 167, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 172, - EndPos: 176, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 172, - EndPos: 176, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 183, - EndPos: 246, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 189, - EndPos: 192, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 194, - EndPos: 245, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 210, - EndPos: 213, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 194, - EndPos: 200, - }, - Value: "public", - }, - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 214, - EndPos: 227, - }, - ByRef: false, - Variadic: false, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 214, - EndPos: 217, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 214, - EndPos: 217, - }, - Value: "bar", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 218, - EndPos: 222, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 218, - EndPos: 222, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 223, - EndPos: 227, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 223, - EndPos: 227, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 223, - EndPos: 227, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 229, - EndPos: 241, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 229, - EndPos: 232, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 229, - EndPos: 232, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 237, - EndPos: 241, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 237, - EndPos: 241, - }, - Value: "baz", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 243, - EndPos: 245, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 249, - EndPos: 290, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 249, - EndPos: 289, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 258, - EndPos: 271, - }, - ByRef: false, - Variadic: false, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 258, - EndPos: 261, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 258, - EndPos: 261, - }, - Value: "bar", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 262, - EndPos: 266, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 262, - EndPos: 266, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 267, - EndPos: 271, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 267, - EndPos: 271, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 267, - EndPos: 271, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 273, - EndPos: 285, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 273, - EndPos: 276, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 273, - EndPos: 276, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 281, - EndPos: 285, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 281, - EndPos: 285, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 293, - EndPos: 341, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 293, - EndPos: 340, - }, - ReturnsRef: false, - Static: true, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 309, - EndPos: 322, - }, - ByRef: false, - Variadic: false, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 309, - EndPos: 312, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 309, - EndPos: 312, - }, - Value: "bar", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 313, - EndPos: 317, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 313, - EndPos: 317, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 318, - EndPos: 322, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 318, - EndPos: 322, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 318, - EndPos: 322, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 324, - EndPos: 336, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 324, - EndPos: 327, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 324, - EndPos: 327, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 332, - EndPos: 336, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 332, - EndPos: 336, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 345, - EndPos: 365, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 345, - EndPos: 364, - }, - Value: "1234567890123456789", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 368, - EndPos: 389, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 368, - EndPos: 388, - }, - Value: "12345678901234567890", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 392, - EndPos: 395, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 392, - EndPos: 394, - }, - Value: "0.", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 17, - EndLine: 17, - StartPos: 398, - EndPos: 465, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 17, - EndLine: 17, - StartPos: 398, - EndPos: 464, - }, - Value: "0b0111111111111111111111111111111111111111111111111111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 468, - EndPos: 535, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 468, - EndPos: 534, - }, - Value: "0b1111111111111111111111111111111111111111111111111111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 538, - EndPos: 559, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 538, - EndPos: 558, - }, - Value: "0x007111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 562, - EndPos: 581, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 562, - EndPos: 580, - }, - Value: "0x8111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 584, - EndPos: 594, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 584, - EndPos: 593, - }, - Value: "__CLASS__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 22, - EndLine: 22, - StartPos: 597, - EndPos: 605, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 22, - EndLine: 22, - StartPos: 597, - EndPos: 604, - }, - Value: "__DIR__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 23, - EndLine: 23, - StartPos: 608, - EndPos: 617, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 23, - EndLine: 23, - StartPos: 608, - EndPos: 616, - }, - Value: "__FILE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 24, - EndLine: 24, - StartPos: 620, - EndPos: 633, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 24, - EndLine: 24, - StartPos: 620, - EndPos: 632, - }, - Value: "__FUNCTION__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 25, - EndLine: 25, - StartPos: 636, - EndPos: 645, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 25, - EndLine: 25, - StartPos: 636, - EndPos: 644, - }, - Value: "__LINE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 26, - EndLine: 26, - StartPos: 648, - EndPos: 662, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 26, - EndLine: 26, - StartPos: 648, - EndPos: 661, - }, - Value: "__NAMESPACE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 27, - EndLine: 27, - StartPos: 665, - EndPos: 676, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 27, - EndLine: 27, - StartPos: 665, - EndPos: 675, - }, - Value: "__METHOD__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 28, - EndLine: 28, - StartPos: 679, - EndPos: 689, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 28, - EndLine: 28, - StartPos: 679, - EndPos: 688, - }, - Value: "__TRAIT__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 693, - EndPos: 705, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 693, - EndPos: 704, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 694, - EndPos: 699, - }, - Value: "test ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 699, - EndPos: 703, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 699, - EndPos: 703, - }, - Value: "var", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 708, - EndPos: 723, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 708, - EndPos: 722, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 709, - EndPos: 714, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 714, - EndPos: 721, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 714, - EndPos: 718, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 714, - EndPos: 718, - }, - Value: "var", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 719, - EndPos: 720, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 726, - EndPos: 780, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 726, - EndPos: 779, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 727, - EndPos: 732, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 732, - EndPos: 778, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 732, - EndPos: 736, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 732, - EndPos: 736, - }, - Value: "var", - }, - }, - Dim: &scalar.String{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 737, - EndPos: 777, - }, - Value: "1234567890123456789012345678901234567890", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 783, - EndPos: 800, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 783, - EndPos: 799, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 784, - EndPos: 789, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 789, - EndPos: 798, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 789, - EndPos: 793, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 789, - EndPos: 793, - }, - Value: "var", - }, - }, - Dim: &scalar.String{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 794, - EndPos: 797, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 803, - EndPos: 821, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 803, - EndPos: 820, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 804, - EndPos: 809, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 809, - EndPos: 819, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 809, - EndPos: 813, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 809, - EndPos: 813, - }, - Value: "var", - }, - }, - Dim: &expr.Variable{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 814, - EndPos: 818, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 814, - EndPos: 818, - }, - Value: "bar", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 824, - EndPos: 836, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 824, - EndPos: 835, - }, - Parts: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 825, - EndPos: 829, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 825, - EndPos: 829, - }, - Value: "foo", - }, - }, - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 829, - EndPos: 830, - }, - Value: " ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 830, - EndPos: 834, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 830, - EndPos: 834, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 839, - EndPos: 858, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 839, - EndPos: 857, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 840, - EndPos: 845, - }, - Value: "test ", - }, - &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 845, - EndPos: 854, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 845, - EndPos: 849, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 845, - EndPos: 849, - }, - Value: "foo", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 851, - EndPos: 854, - }, - Value: "bar", - }, - }, - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 854, - EndPos: 856, - }, - Value: "()", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 861, - EndPos: 875, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 861, - EndPos: 874, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 862, - EndPos: 867, - }, - Value: "test ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 867, - EndPos: 873, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 869, - EndPos: 872, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 878, - EndPos: 895, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 878, - EndPos: 894, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 879, - EndPos: 884, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 884, - EndPos: 893, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 886, - EndPos: 889, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 886, - EndPos: 889, - }, - Value: "foo", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 38, - EndLine: 38, - StartPos: 890, - EndPos: 891, - }, - Value: "0", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 898, - EndPos: 919, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 898, - EndPos: 918, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 899, - EndPos: 904, - }, - Value: "test ", - }, - &expr.MethodCall{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 905, - EndPos: 916, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 905, - EndPos: 909, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 905, - EndPos: 909, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 911, - EndPos: 914, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 914, - EndPos: 916, - }, - }, - }, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 41, - EndLine: 42, - StartPos: 923, - EndPos: 941, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 927, - EndPos: 929, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 927, - EndPos: 929, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 43, - EndLine: 45, - StartPos: 944, - EndPos: 977, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 948, - EndPos: 950, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 948, - EndPos: 950, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 44, - EndLine: -1, - StartPos: 956, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 964, - EndPos: 966, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 964, - EndPos: 966, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 46, - EndLine: 48, - StartPos: 980, - EndPos: 1006, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 984, - EndPos: 986, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 984, - EndPos: 986, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.AltElse{ - Position: &position.Position{ - StartLine: 47, - EndLine: -1, - StartPos: 992, - EndPos: -1, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 49, - EndLine: 53, - StartPos: 1009, - EndPos: 1065, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1013, - EndPos: 1015, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1013, - EndPos: 1015, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 50, - EndLine: -1, - StartPos: 1021, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1029, - EndPos: 1031, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1029, - EndPos: 1031, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 51, - EndLine: -1, - StartPos: 1036, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1044, - EndPos: 1046, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1044, - EndPos: 1046, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.AltElse{ - Position: &position.Position{ - StartLine: 52, - EndLine: -1, - StartPos: 1051, - EndPos: -1, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1069, - EndPos: 1089, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1076, - EndPos: 1077, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1079, - EndPos: 1089, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1081, - EndPos: 1087, - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1092, - EndPos: 1114, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1099, - EndPos: 1100, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1102, - EndPos: 1114, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1104, - EndPos: 1112, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1110, - EndPos: 1111, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.AltWhile{ - Position: &position.Position{ - StartLine: 57, - EndLine: 57, - StartPos: 1117, - EndPos: 1148, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 57, - EndLine: 57, - StartPos: 1124, - EndPos: 1125, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 57, - EndLine: 57, - StartPos: 1129, - EndPos: 1138, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 57, - EndLine: 57, - StartPos: 1129, - EndPos: 1138, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 57, - EndLine: 57, - StartPos: 1135, - EndPos: 1136, - }, - Value: "3", - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1151, - EndPos: 1187, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1157, - EndPos: 1160, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassConstList{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1162, - EndPos: 1185, - }, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1168, - EndPos: 1175, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1168, - EndPos: 1171, - }, - Value: "FOO", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1174, - EndPos: 1175, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1177, - EndPos: 1184, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1177, - EndPos: 1180, - }, - Value: "BAR", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1183, - EndPos: 1184, - }, - Value: "2", - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 59, - EndLine: 59, - StartPos: 1190, - EndPos: 1220, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 59, - EndLine: 59, - StartPos: 1196, - EndPos: 1199, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 59, - EndLine: 59, - StartPos: 1201, - EndPos: 1218, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 59, - EndLine: 59, - StartPos: 1210, - EndPos: 1213, - }, - Value: "bar", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 59, - EndLine: 59, - StartPos: 1216, - EndPos: 1218, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1223, - EndPos: 1268, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1229, - EndPos: 1232, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1234, - EndPos: 1266, - }, - ReturnsRef: true, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1258, - EndPos: 1261, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1234, - EndPos: 1240, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1241, - EndPos: 1247, - }, - Value: "static", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 60, - EndLine: 60, - StartPos: 1264, - EndPos: 1266, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1271, - EndPos: 1343, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1277, - EndPos: 1280, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1282, - EndPos: 1313, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1305, - EndPos: 1308, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1282, - EndPos: 1287, - }, - Value: "final", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1288, - EndPos: 1295, - }, - Value: "private", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1311, - EndPos: 1313, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1314, - EndPos: 1341, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1333, - EndPos: 1336, - }, - Value: "baz", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1314, - EndPos: 1323, - }, - Value: "protected", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1339, - EndPos: 1341, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1346, - EndPos: 1399, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1361, - EndPos: 1364, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1346, - EndPos: 1354, - }, - Value: "abstract", - }, - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1366, - EndPos: 1397, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1391, - EndPos: 1394, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1366, - EndPos: 1374, - }, - Value: "abstract", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1375, - EndPos: 1381, - }, - Value: "public", - }, - }, - Stmt: &stmt.Nop{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1396, - EndPos: 1397, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1402, - EndPos: 1433, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1414, - EndPos: 1417, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1402, - EndPos: 1407, - }, - Value: "final", - }, - }, - Extends: &stmt.ClassExtends{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1418, - EndPos: 1429, - }, - ClassName: &name.Name{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1426, - EndPos: 1429, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1426, - EndPos: 1429, - }, - Value: "bar", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1436, - EndPos: 1470, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1448, - EndPos: 1451, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1436, - EndPos: 1441, - }, - Value: "final", - }, - }, - Implements: &stmt.ClassImplements{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1452, - EndPos: 1466, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1463, - EndPos: 1466, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 64, - EndLine: 64, - StartPos: 1463, - EndPos: 1466, - }, - Value: "bar", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1473, - EndPos: 1512, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1485, - EndPos: 1488, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1473, - EndPos: 1478, - }, - Value: "final", - }, - }, - Implements: &stmt.ClassImplements{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1489, - EndPos: 1508, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1500, - EndPos: 1503, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1500, - EndPos: 1503, - }, - Value: "bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1505, - EndPos: 1508, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 65, - EndLine: 65, - StartPos: 1505, - EndPos: 1508, - }, - Value: "baz", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.ConstList{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1516, - EndPos: 1539, - }, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1522, - EndPos: 1529, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1522, - EndPos: 1525, - }, - Value: "FOO", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1528, - EndPos: 1529, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1531, - EndPos: 1538, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1531, - EndPos: 1534, - }, - Value: "BAR", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1537, - EndPos: 1538, - }, - Value: "2", - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1542, - EndPos: 1565, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1549, - EndPos: 1550, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1552, - EndPos: 1565, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1554, - EndPos: 1563, - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1568, - EndPos: 1593, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1575, - EndPos: 1576, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1578, - EndPos: 1593, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1580, - EndPos: 1591, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1589, - EndPos: 1590, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1596, - EndPos: 1622, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1603, - EndPos: 1604, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1606, - EndPos: 1622, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1608, - EndPos: 1620, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1617, - EndPos: 1618, - }, - Value: "3", - }, - }, - }, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1625, - EndPos: 1642, - }, - Alt: false, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1633, - EndPos: 1640, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1633, - EndPos: 1638, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1639, - EndPos: 1640, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.Nop{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1641, - EndPos: 1642, - }, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1645, - EndPos: 1680, - }, - Alt: false, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1653, - EndPos: 1660, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1653, - EndPos: 1658, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1659, - EndPos: 1660, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1662, - EndPos: 1676, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1662, - EndPos: 1674, - }, - Value: "strict_types", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1675, - EndPos: 1676, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1678, - EndPos: 1680, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1683, - EndPos: 1712, - }, - Alt: true, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1691, - EndPos: 1698, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1691, - EndPos: 1696, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1697, - EndPos: 1698, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Do{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1715, - EndPos: 1730, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1718, - EndPos: 1720, - }, - Stmts: []node.Node{}, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1727, - EndPos: 1728, - }, - Value: "1", - }, - }, - &stmt.Echo{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1733, - EndPos: 1744, - }, - Exprs: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1738, - EndPos: 1740, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1738, - EndPos: 1740, - }, - Value: "a", - }, - }, - &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1742, - EndPos: 1743, - }, - Value: "1", - }, - }, - }, - &stmt.Echo{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1747, - EndPos: 1756, - }, - Exprs: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1752, - EndPos: 1754, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1752, - EndPos: 1754, - }, - Value: "a", - }, - }, - }, - }, - &stmt.For{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1759, - EndPos: 1794, - }, - Init: []node.Node{ - &assign.Assign{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1763, - EndPos: 1769, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1763, - EndPos: 1765, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1763, - EndPos: 1765, - }, - Value: "i", - }, - }, - Expression: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1768, - EndPos: 1769, - }, - Value: "0", - }, - }, - }, - Cond: []node.Node{ - &binary.Smaller{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1771, - EndPos: 1778, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1771, - EndPos: 1773, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1771, - EndPos: 1773, - }, - Value: "i", - }, - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1776, - EndPos: 1778, - }, - Value: "10", - }, - }, - }, - Loop: []node.Node{ - &expr.PostInc{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1780, - EndPos: 1784, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1780, - EndPos: 1782, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1780, - EndPos: 1782, - }, - Value: "i", - }, - }, - }, - &expr.PostInc{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1786, - EndPos: 1790, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1786, - EndPos: 1788, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1786, - EndPos: 1788, - }, - Value: "i", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1792, - EndPos: 1794, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltFor{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1797, - EndPos: 1827, - }, - Cond: []node.Node{ - &binary.Smaller{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1803, - EndPos: 1810, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1803, - EndPos: 1805, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1803, - EndPos: 1805, - }, - Value: "i", - }, - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1808, - EndPos: 1810, - }, - Value: "10", - }, - }, - }, - Loop: []node.Node{ - &expr.PostInc{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1812, - EndPos: 1816, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1812, - EndPos: 1814, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1812, - EndPos: 1814, - }, - Value: "i", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1830, - EndPos: 1851, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1839, - EndPos: 1841, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1839, - EndPos: 1841, - }, - Value: "a", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1845, - EndPos: 1847, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1845, - EndPos: 1847, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1849, - EndPos: 1851, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 80, - EndLine: 80, - StartPos: 1854, - EndPos: 1875, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 80, - EndLine: 80, - StartPos: 1863, - EndPos: 1865, - }, - Items: []node.Node{}, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 80, - EndLine: 80, - StartPos: 1869, - EndPos: 1871, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 80, - EndLine: 80, - StartPos: 1869, - EndPos: 1871, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 80, - EndLine: 80, - StartPos: 1873, - EndPos: 1875, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltForeach{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1878, - EndPos: 1910, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1887, - EndPos: 1889, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1887, - EndPos: 1889, - }, - Value: "a", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1893, - EndPos: 1895, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1893, - EndPos: 1895, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1913, - EndPos: 1940, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1922, - EndPos: 1924, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1922, - EndPos: 1924, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1928, - EndPos: 1930, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1928, - EndPos: 1930, - }, - Value: "k", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1934, - EndPos: 1936, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1934, - EndPos: 1936, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1938, - EndPos: 1940, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1943, - EndPos: 1970, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1952, - EndPos: 1954, - }, - Items: []node.Node{}, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1958, - EndPos: 1960, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1958, - EndPos: 1960, - }, - Value: "k", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1964, - EndPos: 1966, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1964, - EndPos: 1966, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1968, - EndPos: 1970, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1973, - EndPos: 2001, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1982, - EndPos: 1984, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1982, - EndPos: 1984, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1988, - EndPos: 1990, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1988, - EndPos: 1990, - }, - Value: "k", - }, - }, - Variable: &expr.Reference{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1994, - EndPos: 1997, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1995, - EndPos: 1997, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1995, - EndPos: 1997, - }, - Value: "v", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1999, - EndPos: 2001, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2004, - EndPos: 2037, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2013, - EndPos: 2015, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2013, - EndPos: 2015, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2019, - EndPos: 2021, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2019, - EndPos: 2021, - }, - Value: "k", - }, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2025, - EndPos: 2033, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2030, - EndPos: 2032, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2030, - EndPos: 2032, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2030, - EndPos: 2032, - }, - Value: "v", - }, - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 2035, - EndPos: 2037, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 2040, - EndPos: 2057, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 2049, - EndPos: 2052, - }, - Value: "foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 88, - EndLine: 92, - StartPos: 2061, - EndPos: 2132, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 88, - EndLine: 88, - StartPos: 2070, - EndPos: 2073, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.Function{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2081, - EndPos: 2098, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2090, - EndPos: 2093, - }, - Value: "bar", - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 90, - EndLine: 90, - StartPos: 2102, - EndPos: 2114, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 90, - EndLine: 90, - StartPos: 2108, - EndPos: 2111, - }, - Value: "Baz", - }, - Stmts: []node.Node{}, - }, - &stmt.Return{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2118, - EndPos: 2128, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2125, - EndPos: 2127, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2125, - EndPos: 2127, - }, - Value: "a", - }, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2138, - EndPos: 2183, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2147, - EndPos: 2150, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2151, - EndPos: 2159, - }, - Variadic: false, - ByRef: false, - VariableType: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2151, - EndPos: 2156, - }, - Value: "array", - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2157, - EndPos: 2159, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2157, - EndPos: 2159, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2161, - EndPos: 2172, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2161, - EndPos: 2169, - }, - Value: "callable", - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2170, - EndPos: 2172, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2170, - EndPos: 2172, - }, - Value: "b", - }, - }, - }, - }, - Stmts: []node.Node{ - &stmt.Return{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2175, - EndPos: 2182, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2186, - EndPos: 2213, - }, - ReturnsRef: true, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2196, - EndPos: 2199, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.Return{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2203, - EndPos: 2212, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2210, - EndPos: 2211, - }, - Value: "1", - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2216, - EndPos: 2234, - }, - ReturnsRef: true, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2226, - EndPos: 2229, - }, - Value: "foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Global{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2237, - EndPos: 2266, - }, - Vars: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2244, - EndPos: 2246, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2244, - EndPos: 2246, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2248, - EndPos: 2250, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2248, - EndPos: 2250, - }, - Value: "b", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2252, - EndPos: 2255, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2253, - EndPos: 2255, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2253, - EndPos: 2255, - }, - Value: "c", - }, - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2257, - EndPos: 2265, - }, - VarName: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2259, - EndPos: 2264, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2259, - EndPos: 2262, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2259, - EndPos: 2262, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2262, - EndPos: 2264, - }, - }, - }, - }, - }, - }, - &stmt.Label{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2269, - EndPos: 2271, - }, - LabelName: &node.Identifier{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2269, - EndPos: 2270, - }, - Value: "a", - }, - }, - &stmt.Goto{ - Position: &position.Position{ - StartLine: 99, - EndLine: 99, - StartPos: 2275, - EndPos: 2282, - }, - Label: &node.Identifier{ - Position: &position.Position{ - StartLine: 99, - EndLine: 99, - StartPos: 2280, - EndPos: 2281, - }, - Value: "a", - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2285, - EndPos: 2295, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2289, - EndPos: 2291, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2289, - EndPos: 2291, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2293, - EndPos: 2295, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2298, - EndPos: 2323, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2302, - EndPos: 2304, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2302, - EndPos: 2304, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2306, - EndPos: 2308, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2309, - EndPos: 2323, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2317, - EndPos: 2319, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2317, - EndPos: 2319, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2321, - EndPos: 2323, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2326, - EndPos: 2344, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2330, - EndPos: 2332, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2330, - EndPos: 2332, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2334, - EndPos: 2336, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2337, - EndPos: 2344, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2342, - EndPos: 2344, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2347, - EndPos: 2395, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2351, - EndPos: 2353, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2351, - EndPos: 2353, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2355, - EndPos: 2357, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2358, - EndPos: 2372, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2366, - EndPos: 2368, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2366, - EndPos: 2368, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2370, - EndPos: 2372, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2373, - EndPos: 2387, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2381, - EndPos: 2383, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2381, - EndPos: 2383, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2385, - EndPos: 2387, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2388, - EndPos: 2395, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2393, - EndPos: 2395, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2398, - EndPos: 2447, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2402, - EndPos: 2404, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2402, - EndPos: 2404, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2406, - EndPos: 2408, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2409, - EndPos: 2423, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2417, - EndPos: 2419, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2417, - EndPos: 2419, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2421, - EndPos: 2423, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2424, - EndPos: 2447, - }, - Stmt: &stmt.If{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2429, - EndPos: 2447, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2433, - EndPos: 2435, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2433, - EndPos: 2435, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2437, - EndPos: 2439, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2440, - EndPos: 2447, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2445, - EndPos: 2447, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - }, - &stmt.Nop{ - Position: &position.Position{ - StartLine: 105, - EndLine: 105, - StartPos: 2450, - EndPos: 2452, - }, - }, - &stmt.InlineHtml{ - Position: &position.Position{ - StartLine: 105, - EndLine: 105, - StartPos: 2452, - EndPos: 2465, - }, - Value: "
", - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2470, - EndPos: 2486, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2480, - EndPos: 2483, - }, - Value: "Foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2489, - EndPos: 2517, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2499, - EndPos: 2502, - }, - Value: "Foo", - }, - Extends: &stmt.InterfaceExtends{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2503, - EndPos: 2514, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2511, - EndPos: 2514, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2511, - EndPos: 2514, - }, - Value: "Bar", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2520, - EndPos: 2553, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2530, - EndPos: 2533, - }, - Value: "Foo", - }, - Extends: &stmt.InterfaceExtends{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2534, - EndPos: 2550, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2542, - EndPos: 2545, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2542, - EndPos: 2545, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2547, - EndPos: 2550, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2547, - EndPos: 2550, - }, - Value: "Baz", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2556, - EndPos: 2570, - }, - NamespaceName: &name.Name{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2566, - EndPos: 2569, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2566, - EndPos: 2569, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2573, - EndPos: 2593, - }, - NamespaceName: &name.Name{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2583, - EndPos: 2590, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2583, - EndPos: 2586, - }, - Value: "Foo", - }, - &name.NamePart{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2587, - EndPos: 2590, - }, - Value: "Bar", - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 111, - EndLine: 111, - StartPos: 2596, - EndPos: 2608, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2611, - EndPos: 2630, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2617, - EndPos: 2620, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.PropertyList{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2622, - EndPos: 2629, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2622, - EndPos: 2625, - }, - Value: "var", - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2626, - EndPos: 2628, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2626, - EndPos: 2628, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2626, - EndPos: 2628, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2633, - EndPos: 2670, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2639, - EndPos: 2642, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.PropertyList{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2644, - EndPos: 2669, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2644, - EndPos: 2650, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2651, - EndPos: 2657, - }, - Value: "static", - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2658, - EndPos: 2660, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2658, - EndPos: 2660, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2658, - EndPos: 2660, - }, - Value: "a", - }, - }, - }, - &stmt.Property{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2662, - EndPos: 2668, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2662, - EndPos: 2664, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2662, - EndPos: 2664, - }, - Value: "b", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2667, - EndPos: 2668, - }, - Value: "1", - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2673, - EndPos: 2710, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2679, - EndPos: 2682, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.PropertyList{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2684, - EndPos: 2709, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2684, - EndPos: 2690, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2691, - EndPos: 2697, - }, - Value: "static", - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2698, - EndPos: 2704, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2698, - EndPos: 2700, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2698, - EndPos: 2700, - }, - Value: "a", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2703, - EndPos: 2704, - }, - Value: "1", - }, - }, - &stmt.Property{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2706, - EndPos: 2708, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2706, - EndPos: 2708, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2706, - EndPos: 2708, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2713, - EndPos: 2731, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2720, - EndPos: 2722, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2720, - EndPos: 2722, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2720, - EndPos: 2722, - }, - Value: "a", - }, - }, - }, - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2724, - EndPos: 2730, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2724, - EndPos: 2726, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2724, - EndPos: 2726, - }, - Value: "b", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2729, - EndPos: 2730, - }, - Value: "1", - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2734, - EndPos: 2752, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2741, - EndPos: 2747, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2741, - EndPos: 2743, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2741, - EndPos: 2743, - }, - Value: "a", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2746, - EndPos: 2747, - }, - Value: "1", - }, - }, - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2749, - EndPos: 2751, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2749, - EndPos: 2751, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2749, - EndPos: 2751, - }, - Value: "b", - }, - }, - }, - }, - }, - &stmt.AltSwitch{ - Position: &position.Position{ - StartLine: 118, - EndLine: 122, - StartPos: 2756, - EndPos: 2815, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2764, - EndPos: 2765, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 119, - EndLine: -1, - StartPos: 2772, - EndPos: -1, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 119, - EndLine: -1, - StartPos: 2772, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2777, - EndPos: 2778, - }, - Value: "1", - }, - Stmts: []node.Node{}, - }, - &stmt.Default{ - Position: &position.Position{ - StartLine: 120, - EndLine: -1, - StartPos: 2783, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 121, - EndLine: -1, - StartPos: 2795, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 121, - EndLine: 121, - StartPos: 2800, - EndPos: 2801, - }, - Value: "2", - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.AltSwitch{ - Position: &position.Position{ - StartLine: 124, - EndLine: 127, - StartPos: 2819, - EndPos: 2867, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 124, - EndLine: 124, - StartPos: 2827, - EndPos: 2828, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 125, - EndLine: -1, - StartPos: 2836, - EndPos: -1, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 125, - EndLine: -1, - StartPos: 2836, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 125, - EndLine: 125, - StartPos: 2841, - EndPos: 2842, - }, - Value: "1", - }, - Stmts: []node.Node{}, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 126, - EndLine: -1, - StartPos: 2847, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 126, - EndLine: 126, - StartPos: 2852, - EndPos: 2853, - }, - Value: "2", - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Switch{ - Position: &position.Position{ - StartLine: 129, - EndLine: 132, - StartPos: 2873, - EndPos: 2925, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 129, - EndLine: 129, - StartPos: 2881, - EndPos: 2882, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 129, - EndLine: 132, - StartPos: 2884, - EndPos: 2925, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 130, - EndLine: 130, - StartPos: 2889, - EndPos: 2903, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 130, - EndLine: 130, - StartPos: 2894, - EndPos: 2895, - }, - Value: "1", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 130, - EndLine: 130, - StartPos: 2897, - EndPos: 2903, - }, - }, - }, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 131, - EndLine: 131, - StartPos: 2907, - EndPos: 2921, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 131, - EndLine: 131, - StartPos: 2912, - EndPos: 2913, - }, - Value: "2", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 131, - EndLine: 131, - StartPos: 2915, - EndPos: 2921, - }, - }, - }, - }, - }, - }, - }, - &stmt.Switch{ - Position: &position.Position{ - StartLine: 134, - EndLine: 137, - StartPos: 2931, - EndPos: 2984, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 134, - EndLine: 134, - StartPos: 2939, - EndPos: 2940, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 134, - EndLine: 137, - StartPos: 2942, - EndPos: 2984, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 2948, - EndPos: 2962, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 2953, - EndPos: 2954, - }, - Value: "1", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 2956, - EndPos: 2962, - }, - }, - }, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 136, - EndLine: 136, - StartPos: 2966, - EndPos: 2980, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 136, - EndLine: 136, - StartPos: 2971, - EndPos: 2972, - }, - Value: "2", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 136, - EndLine: 136, - StartPos: 2974, - EndPos: 2980, - }, - }, - }, - }, - }, - }, - }, - &stmt.Throw{ - Position: &position.Position{ - StartLine: 138, - EndLine: 138, - StartPos: 2987, - EndPos: 2996, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 138, - EndLine: 138, - StartPos: 2993, - EndPos: 2995, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 138, - EndLine: 138, - StartPos: 2993, - EndPos: 2995, - }, - Value: "e", - }, - }, - }, - &stmt.Trait{ - Position: &position.Position{ - StartLine: 139, - EndLine: 139, - StartPos: 2999, - EndPos: 3011, - }, - PhpDocComment: "", - TraitName: &node.Identifier{ - Position: &position.Position{ - StartLine: 139, - EndLine: 139, - StartPos: 3005, - EndPos: 3008, - }, - Value: "Foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3014, - EndPos: 3036, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3020, - EndPos: 3023, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3026, - EndPos: 3034, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3030, - EndPos: 3033, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3030, - EndPos: 3033, - }, - Value: "Bar", - }, - }, - }, - }, - TraitAdaptationList: &stmt.Nop{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3033, - EndPos: 3034, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3039, - EndPos: 3068, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3045, - EndPos: 3048, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3051, - EndPos: 3066, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3055, - EndPos: 3058, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3055, - EndPos: 3058, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3060, - EndPos: 3063, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3060, - EndPos: 3063, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 141, - EndLine: 141, - StartPos: 3064, - EndPos: 3066, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3071, - EndPos: 3116, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3077, - EndPos: 3080, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3083, - EndPos: 3114, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3087, - EndPos: 3090, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3087, - EndPos: 3090, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3092, - EndPos: 3095, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3092, - EndPos: 3095, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3096, - EndPos: 3114, - }, - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3098, - EndPos: 3111, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3098, - EndPos: 3101, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3098, - EndPos: 3101, - }, - Value: "one", - }, - }, - Modifier: &node.Identifier{ - Position: &position.Position{ - StartLine: 142, - EndLine: 142, - StartPos: 3105, - EndPos: 3111, - }, - Value: "public", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3119, - EndPos: 3168, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3125, - EndPos: 3128, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3131, - EndPos: 3166, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3135, - EndPos: 3138, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3135, - EndPos: 3138, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3140, - EndPos: 3143, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3140, - EndPos: 3143, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3144, - EndPos: 3166, - }, - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3146, - EndPos: 3163, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3146, - EndPos: 3149, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3146, - EndPos: 3149, - }, - Value: "one", - }, - }, - Modifier: &node.Identifier{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3153, - EndPos: 3159, - }, - Value: "public", - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3160, - EndPos: 3163, - }, - Value: "two", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3171, - EndPos: 3248, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3177, - EndPos: 3180, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3183, - EndPos: 3246, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3187, - EndPos: 3190, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3187, - EndPos: 3190, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3192, - EndPos: 3195, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3192, - EndPos: 3195, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3196, - EndPos: 3246, - }, - Adaptations: []node.Node{ - &stmt.TraitUsePrecedence{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3198, - EndPos: 3226, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3198, - EndPos: 3206, - }, - Trait: &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3198, - EndPos: 3201, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3198, - EndPos: 3201, - }, - Value: "Bar", - }, - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3203, - EndPos: 3206, - }, - Value: "one", - }, - }, - Insteadof: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3217, - EndPos: 3220, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3217, - EndPos: 3220, - }, - Value: "Baz", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3222, - EndPos: 3226, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3222, - EndPos: 3226, - }, - Value: "Quux", - }, - }, - }, - }, - }, - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3228, - EndPos: 3243, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3228, - EndPos: 3236, - }, - Trait: &name.Name{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3228, - EndPos: 3231, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3228, - EndPos: 3231, - }, - Value: "Baz", - }, - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3233, - EndPos: 3236, - }, - Value: "one", - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 144, - EndLine: 144, - StartPos: 3240, - EndPos: 3243, - }, - Value: "two", - }, - }, - }, - }, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 146, - EndLine: -1, - StartPos: 3252, - EndPos: -1, - }, - Stmts: []node.Node{}, - Catches: []node.Node{}, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3261, - EndPos: 3291, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3268, - EndPos: 3291, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3275, - EndPos: 3284, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3275, - EndPos: 3284, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3285, - EndPos: 3287, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3285, - EndPos: 3287, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3294, - EndPos: 3355, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3301, - EndPos: 3324, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3308, - EndPos: 3317, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3308, - EndPos: 3317, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3318, - EndPos: 3320, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3318, - EndPos: 3320, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Catch{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3325, - EndPos: 3355, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3332, - EndPos: 3348, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3332, - EndPos: 3348, - }, - Value: "RuntimeException", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3349, - EndPos: 3351, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3349, - EndPos: 3351, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3358, - EndPos: 3462, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3365, - EndPos: 3388, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3372, - EndPos: 3381, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3372, - EndPos: 3381, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3382, - EndPos: 3384, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3382, - EndPos: 3384, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Catch{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3389, - EndPos: 3420, - }, - Types: []node.Node{ - &name.FullyQualified{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3396, - EndPos: 3413, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3397, - EndPos: 3413, - }, - Value: "RuntimeException", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3414, - EndPos: 3416, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3414, - EndPos: 3416, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Catch{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3421, - EndPos: 3462, - }, - Types: []node.Node{ - &name.Relative{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3428, - EndPos: 3455, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3438, - EndPos: 3455, - }, - Value: "AdditionException", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3456, - EndPos: 3458, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3456, - EndPos: 3458, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3465, - EndPos: 3506, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3472, - EndPos: 3495, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3479, - EndPos: 3488, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3479, - EndPos: 3488, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3489, - EndPos: 3491, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3489, - EndPos: 3491, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - Finally: &stmt.Finally{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3496, - EndPos: 3506, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Unset{ - Position: &position.Position{ - StartLine: 152, - EndLine: 152, - StartPos: 3510, - EndPos: 3524, - }, - Vars: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 152, - EndLine: 152, - StartPos: 3516, - EndPos: 3518, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 152, - EndLine: 152, - StartPos: 3516, - EndPos: 3518, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 152, - EndLine: 152, - StartPos: 3520, - EndPos: 3522, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 152, - EndLine: 152, - StartPos: 3520, - EndPos: 3522, - }, - Value: "b", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3528, - EndPos: 3536, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3532, - EndPos: 3535, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3532, - EndPos: 3535, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3532, - EndPos: 3535, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3539, - EndPos: 3548, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3544, - EndPos: 3547, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3544, - EndPos: 3547, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3544, - EndPos: 3547, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3551, - EndPos: 3567, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3556, - EndPos: 3566, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3556, - EndPos: 3559, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3556, - EndPos: 3559, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3563, - EndPos: 3566, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3570, - EndPos: 3583, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3574, - EndPos: 3577, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3574, - EndPos: 3577, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3574, - EndPos: 3577, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3579, - EndPos: 3582, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3579, - EndPos: 3582, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3579, - EndPos: 3582, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3586, - EndPos: 3606, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3590, - EndPos: 3593, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3590, - EndPos: 3593, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3590, - EndPos: 3593, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3595, - EndPos: 3605, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3595, - EndPos: 3598, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3595, - EndPos: 3598, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 158, - EndLine: 158, - StartPos: 3602, - EndPos: 3605, - }, - Value: "Baz", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3609, - EndPos: 3632, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3613, - EndPos: 3621, - }, - Value: "function", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3622, - EndPos: 3625, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3622, - EndPos: 3625, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3622, - EndPos: 3625, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3628, - EndPos: 3631, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3628, - EndPos: 3631, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3628, - EndPos: 3631, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3635, - EndPos: 3672, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3639, - EndPos: 3647, - }, - Value: "function", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3648, - EndPos: 3658, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3648, - EndPos: 3651, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3648, - EndPos: 3651, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3655, - EndPos: 3658, - }, - Value: "foo", - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3661, - EndPos: 3671, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3661, - EndPos: 3664, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3661, - EndPos: 3664, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 160, - EndLine: 160, - StartPos: 3668, - EndPos: 3671, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3675, - EndPos: 3695, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3679, - EndPos: 3684, - }, - Value: "const", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3685, - EndPos: 3688, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3685, - EndPos: 3688, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3685, - EndPos: 3688, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3691, - EndPos: 3694, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3691, - EndPos: 3694, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3691, - EndPos: 3694, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3698, - EndPos: 3732, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3702, - EndPos: 3707, - }, - Value: "const", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3708, - EndPos: 3718, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3708, - EndPos: 3711, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3708, - EndPos: 3711, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3715, - EndPos: 3718, - }, - Value: "foo", - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3721, - EndPos: 3731, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3721, - EndPos: 3724, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3721, - EndPos: 3724, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3728, - EndPos: 3731, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3736, - EndPos: 3742, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3736, - EndPos: 3741, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3736, - EndPos: 3738, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3736, - EndPos: 3738, - }, - Value: "a", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3739, - EndPos: 3740, - }, - Value: "1", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3745, - EndPos: 3754, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3745, - EndPos: 3753, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3745, - EndPos: 3750, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3745, - EndPos: 3747, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3745, - EndPos: 3747, - }, - Value: "a", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3748, - EndPos: 3749, - }, - Value: "1", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3751, - EndPos: 3752, - }, - Value: "2", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3757, - EndPos: 3765, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3757, - EndPos: 3764, - }, - Items: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3768, - EndPos: 3777, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3768, - EndPos: 3776, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3774, - EndPos: 3775, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3774, - EndPos: 3775, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3780, - EndPos: 3798, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3780, - EndPos: 3797, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3786, - EndPos: 3790, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3786, - EndPos: 3787, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3789, - EndPos: 3790, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3792, - EndPos: 3795, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3792, - EndPos: 3795, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3793, - EndPos: 3795, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3793, - EndPos: 3795, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3801, - EndPos: 3816, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3801, - EndPos: 3815, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3807, - EndPos: 3814, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3807, - EndPos: 3808, - }, - Value: "3", - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3811, - EndPos: 3814, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3812, - EndPos: 3814, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3812, - EndPos: 3814, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3819, - EndPos: 3848, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3819, - EndPos: 3847, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3825, - EndPos: 3828, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3825, - EndPos: 3828, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3826, - EndPos: 3828, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3826, - EndPos: 3828, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3830, - EndPos: 3834, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3830, - EndPos: 3831, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3833, - EndPos: 3834, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3836, - EndPos: 3837, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3836, - EndPos: 3837, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3839, - EndPos: 3846, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3839, - EndPos: 3840, - }, - Value: "3", - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3843, - EndPos: 3846, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3844, - EndPos: 3846, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 170, - EndLine: 170, - StartPos: 3844, - EndPos: 3846, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3851, - EndPos: 3855, - }, - Expr: &expr.BitwiseNot{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3851, - EndPos: 3854, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3852, - EndPos: 3854, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3852, - EndPos: 3854, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3858, - EndPos: 3862, - }, - Expr: &expr.BooleanNot{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3858, - EndPos: 3861, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3859, - EndPos: 3861, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3859, - EndPos: 3861, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3866, - EndPos: 3875, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3866, - EndPos: 3874, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3866, - EndPos: 3869, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3866, - EndPos: 3869, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3871, - EndPos: 3874, - }, - Value: "Bar", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3878, - EndPos: 3888, - }, - Expr: &expr.Clone{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3878, - EndPos: 3886, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3884, - EndPos: 3886, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3884, - EndPos: 3886, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 176, - EndLine: 176, - StartPos: 3891, - EndPos: 3900, - }, - Expr: &expr.Clone{ - Position: &position.Position{ - StartLine: 176, - EndLine: 176, - StartPos: 3891, - EndPos: 3899, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 176, - EndLine: 176, - StartPos: 3897, - EndPos: 3899, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 176, - EndLine: 176, - StartPos: 3897, - EndPos: 3899, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3903, - EndPos: 3916, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3903, - EndPos: 3915, - }, - Static: false, - PhpDocComment: "", - ReturnsRef: false, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3919, - EndPos: 3953, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3919, - EndPos: 3952, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3928, - EndPos: 3930, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3928, - EndPos: 3930, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3928, - EndPos: 3930, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3932, - EndPos: 3934, - }, - Variadic: false, - ByRef: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3932, - EndPos: 3934, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3932, - EndPos: 3934, - }, - Value: "b", - }, - }, - }, - }, - ClosureUse: &expr.ClosureUse{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3936, - EndPos: 3949, - }, - Uses: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3941, - EndPos: 3943, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3941, - EndPos: 3943, - }, - Value: "c", - }, - }, - &expr.Reference{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3945, - EndPos: 3948, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3946, - EndPos: 3948, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3946, - EndPos: 3948, - }, - Value: "d", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3956, - EndPos: 3990, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3956, - EndPos: 3989, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3965, - EndPos: 3967, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3965, - EndPos: 3967, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3965, - EndPos: 3967, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3969, - EndPos: 3971, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3969, - EndPos: 3971, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3969, - EndPos: 3971, - }, - Value: "b", - }, - }, - }, - }, - ClosureUse: &expr.ClosureUse{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3973, - EndPos: 3986, - }, - Uses: []node.Node{ - &expr.Reference{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3978, - EndPos: 3981, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3979, - EndPos: 3981, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3979, - EndPos: 3981, - }, - Value: "c", - }, - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3983, - EndPos: 3985, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 3983, - EndPos: 3985, - }, - Value: "d", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 3993, - EndPos: 4007, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 3993, - EndPos: 4006, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4010, - EndPos: 4014, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4010, - EndPos: 4013, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4010, - EndPos: 4013, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4010, - EndPos: 4013, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4017, - EndPos: 4031, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4017, - EndPos: 4030, - }, - Constant: &name.Relative{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4017, - EndPos: 4030, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4027, - EndPos: 4030, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4034, - EndPos: 4039, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4034, - EndPos: 4038, - }, - Constant: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4034, - EndPos: 4038, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4035, - EndPos: 4038, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4043, - EndPos: 4053, - }, - Expr: &expr.Empty{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4043, - EndPos: 4052, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4049, - EndPos: 4051, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4049, - EndPos: 4051, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4056, - EndPos: 4067, - }, - Expr: &expr.Empty{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4056, - EndPos: 4066, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4062, - EndPos: 4065, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4062, - EndPos: 4065, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4062, - EndPos: 4065, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4070, - EndPos: 4074, - }, - Expr: &expr.ErrorSuppress{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4070, - EndPos: 4073, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4071, - EndPos: 4073, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4071, - EndPos: 4073, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4077, - EndPos: 4086, - }, - Expr: &expr.Eval{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4077, - EndPos: 4085, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4082, - EndPos: 4084, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4082, - EndPos: 4084, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 189, - EndLine: 189, - StartPos: 4089, - EndPos: 4094, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 189, - EndLine: 189, - StartPos: 4089, - EndPos: 4093, - }, - Die: false, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4097, - EndPos: 4106, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4097, - EndPos: 4105, - }, - Die: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4102, - EndPos: 4104, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4102, - EndPos: 4104, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4109, - EndPos: 4115, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4109, - EndPos: 4114, - }, - Die: true, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4118, - EndPos: 4126, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4118, - EndPos: 4125, - }, - Die: true, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4122, - EndPos: 4124, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4122, - EndPos: 4124, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4129, - EndPos: 4135, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4129, - EndPos: 4134, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4129, - EndPos: 4132, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4129, - EndPos: 4132, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4132, - EndPos: 4134, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4138, - EndPos: 4157, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4138, - EndPos: 4156, - }, - Function: &name.Relative{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4138, - EndPos: 4151, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4148, - EndPos: 4151, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4151, - EndPos: 4156, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4153, - EndPos: 4155, - }, - Variadic: false, - IsReference: true, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4153, - EndPos: 4155, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4153, - EndPos: 4155, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4160, - EndPos: 4169, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4160, - EndPos: 4168, - }, - Function: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4160, - EndPos: 4164, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4161, - EndPos: 4164, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4164, - EndPos: 4168, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4165, - EndPos: 4167, - }, - Variadic: false, - IsReference: false, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 195, - EndLine: 195, - StartPos: 4165, - EndPos: 4167, - }, - Items: []node.Node{}, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4172, - EndPos: 4187, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4172, - EndPos: 4186, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4172, - EndPos: 4176, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4172, - EndPos: 4176, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4176, - EndPos: 4186, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4177, - EndPos: 4185, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4177, - EndPos: 4185, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4183, - EndPos: 4185, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4183, - EndPos: 4185, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4191, - EndPos: 4196, - }, - Expr: &expr.PostDec{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4191, - EndPos: 4195, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4191, - EndPos: 4193, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4191, - EndPos: 4193, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4199, - EndPos: 4204, - }, - Expr: &expr.PostInc{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4199, - EndPos: 4203, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4199, - EndPos: 4201, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4199, - EndPos: 4201, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4207, - EndPos: 4212, - }, - Expr: &expr.PreDec{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4207, - EndPos: 4211, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4209, - EndPos: 4211, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4209, - EndPos: 4211, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4215, - EndPos: 4220, - }, - Expr: &expr.PreInc{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4215, - EndPos: 4219, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4217, - EndPos: 4219, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4217, - EndPos: 4219, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4224, - EndPos: 4235, - }, - Expr: &expr.Include{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4224, - EndPos: 4234, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4232, - EndPos: 4234, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4232, - EndPos: 4234, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4238, - EndPos: 4254, - }, - Expr: &expr.IncludeOnce{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4238, - EndPos: 4253, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4251, - EndPos: 4253, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4251, - EndPos: 4253, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4257, - EndPos: 4268, - }, - Expr: &expr.Require{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4257, - EndPos: 4267, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4265, - EndPos: 4267, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4265, - EndPos: 4267, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4271, - EndPos: 4287, - }, - Expr: &expr.RequireOnce{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4271, - EndPos: 4286, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4284, - EndPos: 4286, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4284, - EndPos: 4286, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4291, - EndPos: 4309, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4291, - EndPos: 4308, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4291, - EndPos: 4293, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4291, - EndPos: 4293, - }, - Value: "a", - }, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4305, - EndPos: 4308, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4305, - EndPos: 4308, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4312, - EndPos: 4340, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4312, - EndPos: 4339, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4312, - EndPos: 4314, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4312, - EndPos: 4314, - }, - Value: "a", - }, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4326, - EndPos: 4339, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4336, - EndPos: 4339, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4343, - EndPos: 4362, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4343, - EndPos: 4361, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4343, - EndPos: 4345, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4343, - EndPos: 4345, - }, - Value: "a", - }, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4357, - EndPos: 4361, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4358, - EndPos: 4361, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4366, - EndPos: 4380, - }, - Expr: &expr.Isset{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4366, - EndPos: 4379, - }, - Variables: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4372, - EndPos: 4374, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4372, - EndPos: 4374, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4376, - EndPos: 4378, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 212, - EndLine: 212, - StartPos: 4376, - EndPos: 4378, - }, - Value: "b", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4383, - EndPos: 4394, - }, - Expr: &expr.Isset{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4383, - EndPos: 4393, - }, - Variables: []node.Node{ - &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4389, - EndPos: 4392, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4389, - EndPos: 4392, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4389, - EndPos: 4392, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4397, - EndPos: 4409, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4397, - EndPos: 4408, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4397, - EndPos: 4403, - }, - Items: []node.Node{}, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4406, - EndPos: 4408, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4406, - EndPos: 4408, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4412, - EndPos: 4430, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4412, - EndPos: 4429, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4412, - EndPos: 4424, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4417, - EndPos: 4419, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4417, - EndPos: 4419, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4417, - EndPos: 4419, - }, - Value: "a", - }, - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4421, - EndPos: 4423, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4421, - EndPos: 4423, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4421, - EndPos: 4423, - }, - Value: "b", - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4427, - EndPos: 4429, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4427, - EndPos: 4429, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4433, - EndPos: 4449, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4433, - EndPos: 4448, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4433, - EndPos: 4443, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4438, - EndPos: 4442, - }, - Val: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4438, - EndPos: 4442, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4438, - EndPos: 4440, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4438, - EndPos: 4440, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4446, - EndPos: 4448, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4446, - EndPos: 4448, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4452, - EndPos: 4472, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4452, - EndPos: 4471, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4452, - EndPos: 4466, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4457, - EndPos: 4465, - }, - Val: &expr.List{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4457, - EndPos: 4465, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4462, - EndPos: 4464, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4462, - EndPos: 4464, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4462, - EndPos: 4464, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4469, - EndPos: 4471, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 217, - EndLine: 217, - StartPos: 4469, - EndPos: 4471, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4476, - EndPos: 4486, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4476, - EndPos: 4485, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4476, - EndPos: 4478, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4476, - EndPos: 4478, - }, - Value: "a", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4480, - EndPos: 4483, - }, - Value: "foo", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4483, - EndPos: 4485, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4489, - EndPos: 4497, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4489, - EndPos: 4496, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4493, - EndPos: 4496, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4493, - EndPos: 4496, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 221, - EndLine: 221, - StartPos: 4500, - EndPos: 4520, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 221, - EndLine: 221, - StartPos: 4500, - EndPos: 4519, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 221, - EndLine: 221, - StartPos: 4504, - EndPos: 4517, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 221, - EndLine: 221, - StartPos: 4514, - EndPos: 4517, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 221, - EndLine: 221, - StartPos: 4517, - EndPos: 4519, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4523, - EndPos: 4534, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4523, - EndPos: 4533, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4527, - EndPos: 4531, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4528, - EndPos: 4531, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4531, - EndPos: 4533, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4537, - EndPos: 4547, - }, - Expr: &expr.Print{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4537, - EndPos: 4545, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4543, - EndPos: 4545, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4543, - EndPos: 4545, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4550, - EndPos: 4558, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4550, - EndPos: 4557, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4550, - EndPos: 4552, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4550, - EndPos: 4552, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4554, - EndPos: 4557, - }, - Value: "foo", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4561, - EndPos: 4572, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4561, - EndPos: 4570, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4561, - EndPos: 4568, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4561, - EndPos: 4563, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4561, - EndPos: 4563, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4565, - EndPos: 4568, - }, - Value: "foo", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4569, - EndPos: 4570, - }, - Value: "1", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4604, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4602, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4600, - }, - Variable: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4594, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4587, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4582, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4577, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4575, - EndPos: 4577, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4579, - EndPos: 4582, - }, - Value: "foo", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4584, - EndPos: 4587, - }, - Value: "bar", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4589, - EndPos: 4592, - }, - Value: "baz", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4592, - EndPos: 4594, - }, - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4596, - EndPos: 4600, - }, - Value: "quux", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 226, - EndLine: 226, - StartPos: 4601, - EndPos: 4602, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4623, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4621, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4618, - }, - Variable: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4616, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4609, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4607, - EndPos: 4609, - }, - Value: "a", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4611, - EndPos: 4614, - }, - Value: "foo", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4614, - EndPos: 4616, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4617, - EndPos: 4618, - }, - Value: "1", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4620, - EndPos: 4621, - }, - Value: "1", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4626, - EndPos: 4635, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4626, - EndPos: 4634, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4627, - EndPos: 4631, - }, - Value: "cmd ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4631, - EndPos: 4633, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4631, - EndPos: 4633, - }, - Value: "a", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4638, - EndPos: 4644, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4638, - EndPos: 4643, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4639, - EndPos: 4642, - }, - Value: "cmd", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4647, - EndPos: 4650, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4647, - EndPos: 4649, - }, - Parts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4653, - EndPos: 4656, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4653, - EndPos: 4655, - }, - Items: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4659, - EndPos: 4663, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4659, - EndPos: 4662, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4660, - EndPos: 4661, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4660, - EndPos: 4661, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4666, - EndPos: 4679, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4666, - EndPos: 4678, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4667, - EndPos: 4671, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4667, - EndPos: 4668, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4670, - EndPos: 4671, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4673, - EndPos: 4676, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4673, - EndPos: 4676, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4674, - EndPos: 4676, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4674, - EndPos: 4676, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4683, - EndPos: 4694, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4683, - EndPos: 4693, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4683, - EndPos: 4686, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4683, - EndPos: 4686, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4688, - EndPos: 4691, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4691, - EndPos: 4693, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4697, - EndPos: 4718, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4697, - EndPos: 4717, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4697, - EndPos: 4710, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4707, - EndPos: 4710, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4712, - EndPos: 4715, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4715, - EndPos: 4717, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4721, - EndPos: 4733, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4721, - EndPos: 4732, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4721, - EndPos: 4725, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4722, - EndPos: 4725, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4727, - EndPos: 4730, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4730, - EndPos: 4732, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4736, - EndPos: 4748, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4736, - EndPos: 4747, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4736, - EndPos: 4739, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4736, - EndPos: 4739, - }, - Value: "Foo", - }, - }, - }, - Call: &expr.Variable{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4741, - EndPos: 4745, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4741, - EndPos: 4745, - }, - Value: "bar", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4745, - EndPos: 4747, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4751, - EndPos: 4764, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4751, - EndPos: 4763, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4751, - EndPos: 4755, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4751, - EndPos: 4755, - }, - Value: "foo", - }, - }, - Call: &expr.Variable{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4757, - EndPos: 4761, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4757, - EndPos: 4761, - }, - Value: "bar", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4761, - EndPos: 4763, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4767, - EndPos: 4777, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4767, - EndPos: 4776, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4767, - EndPos: 4770, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4767, - EndPos: 4770, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4772, - EndPos: 4776, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 240, - EndLine: 240, - StartPos: 4772, - EndPos: 4776, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4780, - EndPos: 4800, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4780, - EndPos: 4799, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4780, - EndPos: 4793, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4790, - EndPos: 4793, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4795, - EndPos: 4799, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4795, - EndPos: 4799, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4803, - EndPos: 4814, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4803, - EndPos: 4813, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4803, - EndPos: 4807, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4804, - EndPos: 4807, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4809, - EndPos: 4813, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4809, - EndPos: 4813, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4817, - EndPos: 4830, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4817, - EndPos: 4829, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4817, - EndPos: 4819, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4817, - EndPos: 4819, - }, - Value: "a", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4822, - EndPos: 4824, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4822, - EndPos: 4824, - }, - Value: "b", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4827, - EndPos: 4829, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4827, - EndPos: 4829, - }, - Value: "c", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4833, - EndPos: 4843, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4833, - EndPos: 4842, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4833, - EndPos: 4835, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4833, - EndPos: 4835, - }, - Value: "a", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4840, - EndPos: 4842, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4840, - EndPos: 4842, - }, - Value: "c", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4846, - EndPos: 4869, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4846, - EndPos: 4868, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4846, - EndPos: 4848, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4846, - EndPos: 4848, - }, - Value: "a", - }, - }, - IfTrue: &expr.Ternary{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4851, - EndPos: 4863, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4851, - EndPos: 4853, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4851, - EndPos: 4853, - }, - Value: "b", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4856, - EndPos: 4858, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4856, - EndPos: 4858, - }, - Value: "c", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4861, - EndPos: 4863, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4861, - EndPos: 4863, - }, - Value: "d", - }, - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4866, - EndPos: 4868, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4866, - EndPos: 4868, - }, - Value: "e", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4872, - EndPos: 4895, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4872, - EndPos: 4894, - }, - Condition: &expr.Ternary{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4872, - EndPos: 4884, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4872, - EndPos: 4874, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4872, - EndPos: 4874, - }, - Value: "a", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4877, - EndPos: 4879, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4877, - EndPos: 4879, - }, - Value: "b", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4882, - EndPos: 4884, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4882, - EndPos: 4884, - }, - Value: "c", - }, - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4887, - EndPos: 4889, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4887, - EndPos: 4889, - }, - Value: "d", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4892, - EndPos: 4894, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4892, - EndPos: 4894, - }, - Value: "e", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4898, - EndPos: 4902, - }, - Expr: &expr.UnaryMinus{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4898, - EndPos: 4901, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4899, - EndPos: 4901, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4899, - EndPos: 4901, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4905, - EndPos: 4909, - }, - Expr: &expr.UnaryPlus{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4905, - EndPos: 4908, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4906, - EndPos: 4908, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4906, - EndPos: 4908, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4912, - EndPos: 4916, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4912, - EndPos: 4915, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4913, - EndPos: 4915, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4913, - EndPos: 4915, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4919, - EndPos: 4924, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4919, - EndPos: 4923, - }, - VarName: &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: &node.Identifier{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4921, - EndPos: 4923, - }, - Value: "a", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4927, - EndPos: 4933, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4927, - EndPos: 4932, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4936, - EndPos: 4945, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4936, - EndPos: 4944, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4942, - EndPos: 4944, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4942, - EndPos: 4944, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4948, - EndPos: 4963, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4948, - EndPos: 4962, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4954, - EndPos: 4956, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4954, - EndPos: 4956, - }, - Value: "a", - }, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4960, - EndPos: 4962, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4960, - EndPos: 4962, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4966, - EndPos: 4983, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4966, - EndPos: 4982, - }, - Value: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4972, - EndPos: 4982, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4972, - EndPos: 4975, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4972, - EndPos: 4975, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4977, - EndPos: 4982, - }, - Value: "class", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4986, - EndPos: 5009, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4986, - EndPos: 5008, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4992, - EndPos: 4994, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4992, - EndPos: 4994, - }, - Value: "a", - }, - }, - Value: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4998, - EndPos: 5008, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4998, - EndPos: 5001, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 4998, - EndPos: 5001, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 5003, - EndPos: 5008, - }, - Value: "class", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5015, - EndPos: 5025, - }, - Expr: &cast.Array{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5015, - EndPos: 5024, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5022, - EndPos: 5024, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5022, - EndPos: 5024, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5028, - EndPos: 5040, - }, - Expr: &cast.Bool{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5028, - EndPos: 5039, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5037, - EndPos: 5039, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5037, - EndPos: 5039, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5043, - EndPos: 5052, - }, - Expr: &cast.Bool{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5043, - EndPos: 5051, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5049, - EndPos: 5051, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5049, - EndPos: 5051, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5055, - EndPos: 5066, - }, - Expr: &cast.Double{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5055, - EndPos: 5065, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5063, - EndPos: 5065, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5063, - EndPos: 5065, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5069, - EndPos: 5079, - }, - Expr: &cast.Double{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5069, - EndPos: 5078, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5076, - EndPos: 5078, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5076, - EndPos: 5078, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 262, - EndLine: 262, - StartPos: 5082, - EndPos: 5094, - }, - Expr: &cast.Int{ - Position: &position.Position{ - StartLine: 262, - EndLine: 262, - StartPos: 5082, - EndPos: 5093, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 262, - EndLine: 262, - StartPos: 5091, - EndPos: 5093, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 262, - EndLine: 262, - StartPos: 5091, - EndPos: 5093, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5097, - EndPos: 5105, - }, - Expr: &cast.Int{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5097, - EndPos: 5104, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5102, - EndPos: 5104, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5102, - EndPos: 5104, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5108, - EndPos: 5119, - }, - Expr: &cast.Object{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5108, - EndPos: 5118, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5116, - EndPos: 5118, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5116, - EndPos: 5118, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5122, - EndPos: 5133, - }, - Expr: &cast.String{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5122, - EndPos: 5132, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5130, - EndPos: 5132, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5130, - EndPos: 5132, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5136, - EndPos: 5146, - }, - Expr: &cast.Unset{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5136, - EndPos: 5145, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5143, - EndPos: 5145, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5143, - EndPos: 5145, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5150, - EndPos: 5158, - }, - Expr: &binary.BitwiseAnd{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5150, - EndPos: 5157, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5150, - EndPos: 5152, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5150, - EndPos: 5152, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5155, - EndPos: 5157, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5155, - EndPos: 5157, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5161, - EndPos: 5169, - }, - Expr: &binary.BitwiseOr{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5161, - EndPos: 5168, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5161, - EndPos: 5163, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5161, - EndPos: 5163, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5166, - EndPos: 5168, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5166, - EndPos: 5168, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5172, - EndPos: 5180, - }, - Expr: &binary.BitwiseXor{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5172, - EndPos: 5179, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5172, - EndPos: 5174, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5172, - EndPos: 5174, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5177, - EndPos: 5179, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5177, - EndPos: 5179, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5183, - EndPos: 5192, - }, - Expr: &binary.BooleanAnd{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5183, - EndPos: 5191, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5183, - EndPos: 5185, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5183, - EndPos: 5185, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5189, - EndPos: 5191, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5189, - EndPos: 5191, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5195, - EndPos: 5204, - }, - Expr: &binary.BooleanOr{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5195, - EndPos: 5203, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5195, - EndPos: 5197, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5195, - EndPos: 5197, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5201, - EndPos: 5203, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5201, - EndPos: 5203, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5207, - EndPos: 5215, - }, - Expr: &binary.Concat{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5207, - EndPos: 5214, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5207, - EndPos: 5209, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5207, - EndPos: 5209, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5212, - EndPos: 5214, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 273, - EndLine: 273, - StartPos: 5212, - EndPos: 5214, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5218, - EndPos: 5226, - }, - Expr: &binary.Div{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5218, - EndPos: 5225, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5218, - EndPos: 5220, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5218, - EndPos: 5220, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5223, - EndPos: 5225, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5223, - EndPos: 5225, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5229, - EndPos: 5238, - }, - Expr: &binary.Equal{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5229, - EndPos: 5237, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5229, - EndPos: 5231, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5229, - EndPos: 5231, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5235, - EndPos: 5237, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5235, - EndPos: 5237, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5241, - EndPos: 5250, - }, - Expr: &binary.GreaterOrEqual{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5241, - EndPos: 5249, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5241, - EndPos: 5243, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5241, - EndPos: 5243, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5247, - EndPos: 5249, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5247, - EndPos: 5249, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5253, - EndPos: 5261, - }, - Expr: &binary.Greater{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5253, - EndPos: 5260, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5253, - EndPos: 5255, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5253, - EndPos: 5255, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5258, - EndPos: 5260, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5258, - EndPos: 5260, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5264, - EndPos: 5274, - }, - Expr: &binary.Identical{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5264, - EndPos: 5273, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5264, - EndPos: 5266, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5264, - EndPos: 5266, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5271, - EndPos: 5273, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5271, - EndPos: 5273, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5277, - EndPos: 5287, - }, - Expr: &binary.LogicalAnd{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5277, - EndPos: 5286, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5277, - EndPos: 5279, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5277, - EndPos: 5279, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5284, - EndPos: 5286, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5284, - EndPos: 5286, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5290, - EndPos: 5299, - }, - Expr: &binary.LogicalOr{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5290, - EndPos: 5298, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5290, - EndPos: 5292, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5290, - EndPos: 5292, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5296, - EndPos: 5298, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5296, - EndPos: 5298, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5302, - EndPos: 5312, - }, - Expr: &binary.LogicalXor{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5302, - EndPos: 5311, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5302, - EndPos: 5304, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5302, - EndPos: 5304, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5309, - EndPos: 5311, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5309, - EndPos: 5311, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5315, - EndPos: 5323, - }, - Expr: &binary.Minus{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5315, - EndPos: 5322, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5315, - EndPos: 5317, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5315, - EndPos: 5317, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5320, - EndPos: 5322, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5320, - EndPos: 5322, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5326, - EndPos: 5334, - }, - Expr: &binary.Mod{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5326, - EndPos: 5333, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5326, - EndPos: 5328, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5326, - EndPos: 5328, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5331, - EndPos: 5333, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5331, - EndPos: 5333, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5337, - EndPos: 5345, - }, - Expr: &binary.Mul{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5337, - EndPos: 5344, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5337, - EndPos: 5339, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5337, - EndPos: 5339, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5342, - EndPos: 5344, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5342, - EndPos: 5344, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5348, - EndPos: 5357, - }, - Expr: &binary.NotEqual{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5348, - EndPos: 5356, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5348, - EndPos: 5350, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5348, - EndPos: 5350, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5354, - EndPos: 5356, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5354, - EndPos: 5356, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5360, - EndPos: 5370, - }, - Expr: &binary.NotIdentical{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5360, - EndPos: 5369, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5360, - EndPos: 5362, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5360, - EndPos: 5362, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5367, - EndPos: 5369, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5367, - EndPos: 5369, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5373, - EndPos: 5381, - }, - Expr: &binary.Plus{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5373, - EndPos: 5380, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5373, - EndPos: 5375, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5373, - EndPos: 5375, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5378, - EndPos: 5380, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5378, - EndPos: 5380, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5384, - EndPos: 5393, - }, - Expr: &binary.Pow{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5384, - EndPos: 5392, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5384, - EndPos: 5386, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5384, - EndPos: 5386, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5390, - EndPos: 5392, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5390, - EndPos: 5392, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5396, - EndPos: 5405, - }, - Expr: &binary.ShiftLeft{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5396, - EndPos: 5404, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5396, - EndPos: 5398, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5396, - EndPos: 5398, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5402, - EndPos: 5404, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5402, - EndPos: 5404, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5408, - EndPos: 5417, - }, - Expr: &binary.ShiftRight{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5408, - EndPos: 5416, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5408, - EndPos: 5410, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5408, - EndPos: 5410, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5414, - EndPos: 5416, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5414, - EndPos: 5416, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5420, - EndPos: 5429, - }, - Expr: &binary.SmallerOrEqual{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5420, - EndPos: 5428, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5420, - EndPos: 5422, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5420, - EndPos: 5422, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5426, - EndPos: 5428, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5426, - EndPos: 5428, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5432, - EndPos: 5440, - }, - Expr: &binary.Smaller{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5432, - EndPos: 5439, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5432, - EndPos: 5434, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5432, - EndPos: 5434, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5437, - EndPos: 5439, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5437, - EndPos: 5439, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5444, - EndPos: 5453, - }, - Expr: &assign.Reference{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5444, - EndPos: 5452, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5444, - EndPos: 5446, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5444, - EndPos: 5446, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5450, - EndPos: 5452, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5450, - EndPos: 5452, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5456, - EndPos: 5470, - }, - Expr: &assign.Reference{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5456, - EndPos: 5469, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5456, - EndPos: 5458, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5456, - EndPos: 5458, - }, - Value: "a", - }, - }, - Expression: &expr.New{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5462, - EndPos: 5469, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5466, - EndPos: 5469, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5466, - EndPos: 5469, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5473, - EndPos: 5491, - }, - Expr: &assign.Reference{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5473, - EndPos: 5490, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5473, - EndPos: 5475, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5473, - EndPos: 5475, - }, - Value: "a", - }, - }, - Expression: &expr.New{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5479, - EndPos: 5490, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5483, - EndPos: 5486, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5483, - EndPos: 5486, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5486, - EndPos: 5490, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5487, - EndPos: 5489, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5487, - EndPos: 5489, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5487, - EndPos: 5489, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5494, - EndPos: 5502, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5494, - EndPos: 5501, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5494, - EndPos: 5496, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5494, - EndPos: 5496, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5499, - EndPos: 5501, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5499, - EndPos: 5501, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5505, - EndPos: 5514, - }, - Expr: &assign.BitwiseAnd{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5505, - EndPos: 5513, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5505, - EndPos: 5507, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5505, - EndPos: 5507, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5511, - EndPos: 5513, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5511, - EndPos: 5513, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5517, - EndPos: 5526, - }, - Expr: &assign.BitwiseOr{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5517, - EndPos: 5525, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5517, - EndPos: 5519, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5517, - EndPos: 5519, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5523, - EndPos: 5525, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5523, - EndPos: 5525, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5529, - EndPos: 5538, - }, - Expr: &assign.BitwiseXor{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5529, - EndPos: 5537, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5529, - EndPos: 5531, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5529, - EndPos: 5531, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5535, - EndPos: 5537, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5535, - EndPos: 5537, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5541, - EndPos: 5550, - }, - Expr: &assign.Concat{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5541, - EndPos: 5549, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5541, - EndPos: 5543, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5541, - EndPos: 5543, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5547, - EndPos: 5549, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 301, - EndLine: 301, - StartPos: 5547, - EndPos: 5549, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5553, - EndPos: 5562, - }, - Expr: &assign.Div{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5553, - EndPos: 5561, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5553, - EndPos: 5555, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5553, - EndPos: 5555, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5559, - EndPos: 5561, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5559, - EndPos: 5561, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5565, - EndPos: 5574, - }, - Expr: &assign.Minus{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5565, - EndPos: 5573, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5565, - EndPos: 5567, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5565, - EndPos: 5567, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5571, - EndPos: 5573, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5571, - EndPos: 5573, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5577, - EndPos: 5586, - }, - Expr: &assign.Mod{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5577, - EndPos: 5585, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5577, - EndPos: 5579, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5577, - EndPos: 5579, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5583, - EndPos: 5585, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5583, - EndPos: 5585, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5589, - EndPos: 5598, - }, - Expr: &assign.Mul{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5589, - EndPos: 5597, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5589, - EndPos: 5591, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5589, - EndPos: 5591, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5595, - EndPos: 5597, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5595, - EndPos: 5597, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5601, - EndPos: 5610, - }, - Expr: &assign.Plus{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5601, - EndPos: 5609, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5601, - EndPos: 5603, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5601, - EndPos: 5603, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5607, - EndPos: 5609, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5607, - EndPos: 5609, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5613, - EndPos: 5623, - }, - Expr: &assign.Pow{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5613, - EndPos: 5622, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5613, - EndPos: 5615, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5613, - EndPos: 5615, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5620, - EndPos: 5622, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5620, - EndPos: 5622, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5626, - EndPos: 5636, - }, - Expr: &assign.ShiftLeft{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5626, - EndPos: 5635, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5626, - EndPos: 5628, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5626, - EndPos: 5628, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5633, - EndPos: 5635, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5633, - EndPos: 5635, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5649, - }, - Expr: &assign.ShiftRight{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5648, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5641, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5641, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5646, - EndPos: 5648, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5646, - EndPos: 5648, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5655, - EndPos: 5667, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5655, - EndPos: 5665, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5659, - EndPos: 5663, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5660, - EndPos: 5663, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5663, - EndPos: 5665, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5691, - EndPos: 5695, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5691, - EndPos: 5694, - }, - Variable: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5687, - EndPos: 5689, - }, - Variable: &expr.New{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5671, - EndPos: 5681, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5675, - EndPos: 5679, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5676, - EndPos: 5679, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5679, - EndPos: 5681, - }, - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5684, - EndPos: 5687, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5687, - EndPos: 5689, - }, - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5691, - EndPos: 5694, - }, - Value: "baz", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5714, - EndPos: 5717, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5714, - EndPos: 5715, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5711, - EndPos: 5712, - }, - Variable: &expr.New{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5699, - EndPos: 5709, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5703, - EndPos: 5707, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5704, - EndPos: 5707, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5707, - EndPos: 5709, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5711, - EndPos: 5712, - }, - Value: "0", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5714, - EndPos: 5715, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5740, - EndPos: 5743, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5740, - EndPos: 5742, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5733, - EndPos: 5734, - }, - Variable: &expr.New{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5721, - EndPos: 5731, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5725, - EndPos: 5729, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5726, - EndPos: 5729, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5729, - EndPos: 5731, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5733, - EndPos: 5734, - }, - Value: "0", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5737, - EndPos: 5740, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5740, - EndPos: 5742, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5747, - EndPos: 5764, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5747, - EndPos: 5763, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5747, - EndPos: 5760, - }, - Variable: &expr.Array{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5747, - EndPos: 5757, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5753, - EndPos: 5756, - }, - Val: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5753, - EndPos: 5756, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5754, - EndPos: 5755, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5754, - EndPos: 5755, - }, - Value: "0", - }, - }, - }, - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5758, - EndPos: 5759, - }, - Value: "0", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5761, - EndPos: 5762, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5767, - EndPos: 5776, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5767, - EndPos: 5775, - }, - Variable: &scalar.String{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5767, - EndPos: 5772, - }, - Value: "\"foo\"", - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5773, - EndPos: 5774, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5779, - EndPos: 5786, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5779, - EndPos: 5785, - }, - Variable: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5779, - EndPos: 5782, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5779, - EndPos: 5782, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5779, - EndPos: 5782, - }, - Value: "foo", - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 319, - EndLine: 319, - StartPos: 5783, - EndPos: 5784, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5789, - EndPos: 5801, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5789, - EndPos: 5800, - }, - Class: &node.Identifier{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5789, - EndPos: 5795, - }, - Value: "static", - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5797, - EndPos: 5800, - }, - Value: "foo", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5805, - EndPos: 5814, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5805, - EndPos: 5813, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5809, - EndPos: 5813, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5809, - EndPos: 5813, - }, - Value: "foo", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5817, - EndPos: 5832, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5817, - EndPos: 5831, - }, - Class: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5821, - EndPos: 5831, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5821, - EndPos: 5825, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5821, - EndPos: 5825, - }, - Value: "foo", - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5827, - EndPos: 5831, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5827, - EndPos: 5831, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5835, - EndPos: 5848, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5835, - EndPos: 5846, - }, - Class: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5845, - EndPos: 5846, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5843, - EndPos: 5846, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5839, - EndPos: 5844, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5839, - EndPos: 5841, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5843, - EndPos: 5844, - }, - Value: "b", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5845, - EndPos: 5846, - }, - Value: "0", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5851, - EndPos: 5883, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5851, - EndPos: 5881, - }, - Class: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5880, - EndPos: 5881, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5878, - EndPos: 5881, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5874, - EndPos: 5879, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5861, - EndPos: 5876, - }, - Variable: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5859, - EndPos: 5871, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5855, - EndPos: 5860, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5855, - EndPos: 5857, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5859, - EndPos: 5860, - }, - Value: "b", - }, - }, - Dim: &expr.Ternary{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5861, - EndPos: 5871, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5861, - EndPos: 5863, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5861, - EndPos: 5863, - }, - Value: "b", - }, - }, - IfFalse: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5867, - EndPos: 5871, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5867, - EndPos: 5871, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5867, - EndPos: 5871, - }, - Value: "null", - }, - }, - }, - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5874, - EndPos: 5876, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5874, - EndPos: 5876, - }, - Value: "c", - }, - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5878, - EndPos: 5879, - }, - Value: "d", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5880, - EndPos: 5881, - }, - Value: "0", - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5883, - EndPos: 5902, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5890, - EndPos: 5901, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5890, - EndPos: 5892, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5890, - EndPos: 5892, - }, - Value: "a", - }, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5895, - EndPos: 5901, - }, - Variable: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5895, - EndPos: 5898, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5896, - EndPos: 5897, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5896, - EndPos: 5897, - }, - Value: "1", - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5899, - EndPos: 5900, - }, - Value: "0", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5906, - EndPos: 5921, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5913, - EndPos: 5920, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5913, - EndPos: 5915, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5913, - EndPos: 5915, - }, - Value: "a", - }, - }, - Expr: &expr.BooleanNot{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5918, - EndPos: 5920, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 327, - EndLine: 327, - StartPos: 5919, - EndPos: 5920, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5924, - EndPos: 5939, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5931, - EndPos: 5938, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5931, - EndPos: 5933, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5931, - EndPos: 5933, - }, - Value: "a", - }, - }, - Expr: &expr.BitwiseNot{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5936, - EndPos: 5938, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5937, - EndPos: 5938, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5942, - EndPos: 5957, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5949, - EndPos: 5956, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5949, - EndPos: 5951, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5949, - EndPos: 5951, - }, - Value: "a", - }, - }, - Expr: &expr.UnaryPlus{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5954, - EndPos: 5956, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5955, - EndPos: 5956, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5960, - EndPos: 5975, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5967, - EndPos: 5974, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5967, - EndPos: 5969, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5967, - EndPos: 5969, - }, - Value: "a", - }, - }, - Expr: &expr.UnaryMinus{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5972, - EndPos: 5974, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5973, - EndPos: 5974, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 331, - EndLine: 331, - StartPos: 5978, - EndPos: 5994, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 331, - EndLine: 331, - StartPos: 5985, - EndPos: 5992, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 331, - EndLine: 331, - StartPos: 5985, - EndPos: 5987, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 331, - EndLine: 331, - StartPos: 5985, - EndPos: 5987, - }, - Value: "a", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 331, - EndLine: 331, - StartPos: 5991, - EndPos: 5992, - }, - Value: "1", - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 5997, - EndPos: 6016, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6004, - EndPos: 6015, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6004, - EndPos: 6006, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6004, - EndPos: 6006, - }, - Value: "a", - }, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6009, - EndPos: 6015, - }, - Condition: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6009, - EndPos: 6010, - }, - Value: "1", - }, - IfFalse: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6014, - EndPos: 6015, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6019, - EndPos: 6041, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6026, - EndPos: 6040, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6026, - EndPos: 6028, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6026, - EndPos: 6028, - }, - Value: "a", - }, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6031, - EndPos: 6040, - }, - Condition: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6031, - EndPos: 6032, - }, - Value: "1", - }, - IfTrue: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6035, - EndPos: 6036, - }, - Value: "2", - }, - IfFalse: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6039, - EndPos: 6040, - }, - Value: "3", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6044, - EndPos: 6062, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6051, - EndPos: 6061, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6051, - EndPos: 6053, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6051, - EndPos: 6053, - }, - Value: "a", - }, - }, - Expr: &binary.BitwiseAnd{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6056, - EndPos: 6061, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6056, - EndPos: 6057, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6060, - EndPos: 6061, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6065, - EndPos: 6083, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6072, - EndPos: 6082, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6072, - EndPos: 6074, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6072, - EndPos: 6074, - }, - Value: "a", - }, - }, - Expr: &binary.BitwiseOr{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6077, - EndPos: 6082, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6077, - EndPos: 6078, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6081, - EndPos: 6082, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6086, - EndPos: 6104, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6093, - EndPos: 6103, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6093, - EndPos: 6095, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6093, - EndPos: 6095, - }, - Value: "a", - }, - }, - Expr: &binary.BitwiseXor{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6098, - EndPos: 6103, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6098, - EndPos: 6099, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6102, - EndPos: 6103, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6107, - EndPos: 6126, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6114, - EndPos: 6125, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6114, - EndPos: 6116, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6114, - EndPos: 6116, - }, - Value: "a", - }, - }, - Expr: &binary.BooleanAnd{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6119, - EndPos: 6125, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6119, - EndPos: 6120, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6124, - EndPos: 6125, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6129, - EndPos: 6148, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6136, - EndPos: 6147, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6136, - EndPos: 6138, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6136, - EndPos: 6138, - }, - Value: "a", - }, - }, - Expr: &binary.BooleanOr{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6141, - EndPos: 6147, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6141, - EndPos: 6142, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6146, - EndPos: 6147, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6151, - EndPos: 6169, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6158, - EndPos: 6168, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6158, - EndPos: 6160, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6158, - EndPos: 6160, - }, - Value: "a", - }, - }, - Expr: &binary.Concat{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6163, - EndPos: 6168, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6163, - EndPos: 6164, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 339, - EndLine: 339, - StartPos: 6167, - EndPos: 6168, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6172, - EndPos: 6190, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6179, - EndPos: 6189, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6179, - EndPos: 6181, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6179, - EndPos: 6181, - }, - Value: "a", - }, - }, - Expr: &binary.Div{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6184, - EndPos: 6189, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6184, - EndPos: 6185, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6188, - EndPos: 6189, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6193, - EndPos: 6212, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6200, - EndPos: 6211, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6200, - EndPos: 6202, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6200, - EndPos: 6202, - }, - Value: "a", - }, - }, - Expr: &binary.Equal{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6205, - EndPos: 6211, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6205, - EndPos: 6206, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6210, - EndPos: 6211, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6215, - EndPos: 6234, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6222, - EndPos: 6233, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6222, - EndPos: 6224, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6222, - EndPos: 6224, - }, - Value: "a", - }, - }, - Expr: &binary.GreaterOrEqual{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6227, - EndPos: 6233, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6227, - EndPos: 6228, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 342, - EndLine: 342, - StartPos: 6232, - EndPos: 6233, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6237, - EndPos: 6255, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6244, - EndPos: 6254, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6244, - EndPos: 6246, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6244, - EndPos: 6246, - }, - Value: "a", - }, - }, - Expr: &binary.Greater{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6249, - EndPos: 6254, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6249, - EndPos: 6250, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6253, - EndPos: 6254, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6258, - EndPos: 6278, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6265, - EndPos: 6277, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6265, - EndPos: 6267, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6265, - EndPos: 6267, - }, - Value: "a", - }, - }, - Expr: &binary.Identical{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6270, - EndPos: 6277, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6270, - EndPos: 6271, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6276, - EndPos: 6277, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6281, - EndPos: 6301, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6288, - EndPos: 6300, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6288, - EndPos: 6290, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6288, - EndPos: 6290, - }, - Value: "a", - }, - }, - Expr: &binary.LogicalAnd{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6293, - EndPos: 6300, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6293, - EndPos: 6294, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 345, - EndLine: 345, - StartPos: 6299, - EndPos: 6300, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6304, - EndPos: 6323, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6311, - EndPos: 6322, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6311, - EndPos: 6313, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6311, - EndPos: 6313, - }, - Value: "a", - }, - }, - Expr: &binary.LogicalOr{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6316, - EndPos: 6322, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6316, - EndPos: 6317, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6321, - EndPos: 6322, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6326, - EndPos: 6346, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6333, - EndPos: 6345, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6333, - EndPos: 6335, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6333, - EndPos: 6335, - }, - Value: "a", - }, - }, - Expr: &binary.LogicalXor{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6338, - EndPos: 6345, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6338, - EndPos: 6339, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 347, - EndLine: 347, - StartPos: 6344, - EndPos: 6345, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6349, - EndPos: 6367, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6356, - EndPos: 6366, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6356, - EndPos: 6358, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6356, - EndPos: 6358, - }, - Value: "a", - }, - }, - Expr: &binary.Minus{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6361, - EndPos: 6366, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6361, - EndPos: 6362, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6365, - EndPos: 6366, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6370, - EndPos: 6388, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6377, - EndPos: 6387, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6377, - EndPos: 6379, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6377, - EndPos: 6379, - }, - Value: "a", - }, - }, - Expr: &binary.Mod{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6382, - EndPos: 6387, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6382, - EndPos: 6383, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 349, - EndLine: 349, - StartPos: 6386, - EndPos: 6387, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6391, - EndPos: 6409, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6398, - EndPos: 6408, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6398, - EndPos: 6400, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6398, - EndPos: 6400, - }, - Value: "a", - }, - }, - Expr: &binary.Mul{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6403, - EndPos: 6408, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6403, - EndPos: 6404, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 350, - EndLine: 350, - StartPos: 6407, - EndPos: 6408, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6412, - EndPos: 6431, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6419, - EndPos: 6430, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6419, - EndPos: 6421, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6419, - EndPos: 6421, - }, - Value: "a", - }, - }, - Expr: &binary.NotEqual{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6424, - EndPos: 6430, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6424, - EndPos: 6425, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 351, - EndLine: 351, - StartPos: 6429, - EndPos: 6430, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6434, - EndPos: 6454, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6441, - EndPos: 6453, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6441, - EndPos: 6443, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6441, - EndPos: 6443, - }, - Value: "a", - }, - }, - Expr: &binary.NotIdentical{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6446, - EndPos: 6453, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6446, - EndPos: 6447, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 352, - EndLine: 352, - StartPos: 6452, - EndPos: 6453, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6457, - EndPos: 6475, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6464, - EndPos: 6474, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6464, - EndPos: 6466, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6464, - EndPos: 6466, - }, - Value: "a", - }, - }, - Expr: &binary.Plus{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6469, - EndPos: 6474, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6469, - EndPos: 6470, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 353, - EndLine: 353, - StartPos: 6473, - EndPos: 6474, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6478, - EndPos: 6497, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6485, - EndPos: 6496, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6485, - EndPos: 6487, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6485, - EndPos: 6487, - }, - Value: "a", - }, - }, - Expr: &binary.Pow{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6490, - EndPos: 6496, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6490, - EndPos: 6491, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 354, - EndLine: 354, - StartPos: 6495, - EndPos: 6496, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6500, - EndPos: 6519, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6507, - EndPos: 6518, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6507, - EndPos: 6509, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6507, - EndPos: 6509, - }, - Value: "a", - }, - }, - Expr: &binary.ShiftLeft{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6512, - EndPos: 6518, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6512, - EndPos: 6513, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 355, - EndLine: 355, - StartPos: 6517, - EndPos: 6518, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6522, - EndPos: 6541, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6529, - EndPos: 6540, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6529, - EndPos: 6531, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6529, - EndPos: 6531, - }, - Value: "a", - }, - }, - Expr: &binary.ShiftRight{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6534, - EndPos: 6540, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6534, - EndPos: 6535, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 356, - EndLine: 356, - StartPos: 6539, - EndPos: 6540, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6544, - EndPos: 6563, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6551, - EndPos: 6562, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6551, - EndPos: 6553, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6551, - EndPos: 6553, - }, - Value: "a", - }, - }, - Expr: &binary.SmallerOrEqual{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6556, - EndPos: 6562, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6556, - EndPos: 6557, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 357, - EndLine: 357, - StartPos: 6561, - EndPos: 6562, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6566, - EndPos: 6584, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6573, - EndPos: 6583, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6573, - EndPos: 6575, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6573, - EndPos: 6575, - }, - Value: "a", - }, - }, - Expr: &binary.Smaller{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6578, - EndPos: 6583, - }, - Left: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6578, - EndPos: 6579, - }, - Value: "1", - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 358, - EndLine: 358, - StartPos: 6582, - EndPos: 6583, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6587, - EndPos: 6608, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6594, - EndPos: 6607, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6594, - EndPos: 6596, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6594, - EndPos: 6596, - }, - Value: "a", - }, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6599, - EndPos: 6607, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6599, - EndPos: 6602, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6599, - EndPos: 6602, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 359, - EndLine: 359, - StartPos: 6604, - EndPos: 6607, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6611, - EndPos: 6634, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6618, - EndPos: 6633, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6618, - EndPos: 6620, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6618, - EndPos: 6620, - }, - Value: "a", - }, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6623, - EndPos: 6633, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6623, - EndPos: 6626, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6623, - EndPos: 6626, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 360, - EndLine: 360, - StartPos: 6628, - EndPos: 6633, - }, - Value: "class", - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 361, - EndLine: 361, - StartPos: 6637, - EndPos: 6659, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 361, - EndLine: 361, - StartPos: 6644, - EndPos: 6658, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 361, - EndLine: 361, - StartPos: 6644, - EndPos: 6646, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 361, - EndLine: 361, - StartPos: 6644, - EndPos: 6646, - }, - Value: "a", - }, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 361, - EndLine: 361, - StartPos: 6649, - EndPos: 6658, - }, - Value: "__CLASS__", - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6662, - EndPos: 6678, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6669, - EndPos: 6677, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6669, - EndPos: 6671, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6669, - EndPos: 6671, - }, - Value: "a", - }, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6674, - EndPos: 6677, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6674, - EndPos: 6677, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 362, - EndLine: 362, - StartPos: 6674, - EndPos: 6677, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6681, - EndPos: 6707, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6688, - EndPos: 6706, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6688, - EndPos: 6690, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6688, - EndPos: 6690, - }, - Value: "a", - }, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6693, - EndPos: 6706, - }, - Constant: &name.Relative{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6693, - EndPos: 6706, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 363, - EndLine: 363, - StartPos: 6703, - EndPos: 6706, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6710, - EndPos: 6727, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6717, - EndPos: 6726, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6717, - EndPos: 6719, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6717, - EndPos: 6719, - }, - Value: "a", - }, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6722, - EndPos: 6726, - }, - Constant: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6722, - EndPos: 6726, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 364, - EndLine: 364, - StartPos: 6723, - EndPos: 6726, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 365, - EndLine: 365, - StartPos: 6730, - EndPos: 6750, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 365, - EndLine: 365, - StartPos: 6737, - EndPos: 6749, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 365, - EndLine: 365, - StartPos: 6737, - EndPos: 6739, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 365, - EndLine: 365, - StartPos: 6737, - EndPos: 6739, - }, - Value: "a", - }, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 365, - EndLine: 365, - StartPos: 6742, - EndPos: 6749, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6753, - EndPos: 6782, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6760, - EndPos: 6781, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6760, - EndPos: 6762, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6760, - EndPos: 6762, - }, - Value: "a", - }, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6765, - EndPos: 6781, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6771, - EndPos: 6777, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6771, - EndPos: 6772, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6776, - EndPos: 6777, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6779, - EndPos: 6780, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 366, - EndLine: 366, - StartPos: 6779, - EndPos: 6780, - }, - Value: "2", - }, - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6785, - EndPos: 6812, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6792, - EndPos: 6811, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6792, - EndPos: 6794, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6792, - EndPos: 6794, - }, - Value: "a", - }, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6797, - EndPos: 6811, - }, - Variable: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6797, - EndPos: 6808, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6798, - EndPos: 6799, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6798, - EndPos: 6799, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6801, - EndPos: 6807, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6801, - EndPos: 6802, - }, - Value: "2", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6806, - EndPos: 6807, - }, - Value: "2", - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 367, - EndLine: 367, - StartPos: 6809, - EndPos: 6810, - }, - Value: "0", - }, - }, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 369, - EndLine: 369, - StartPos: 6816, - EndPos: 6831, - }, - Cond: &expr.Yield{ - Position: &position.Position{ - StartLine: 369, - EndLine: 369, - StartPos: 6820, - EndPos: 6827, - }, - Value: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 369, - EndLine: 369, - StartPos: 6826, - EndPos: 6827, - }, - Value: "1", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 369, - EndLine: 369, - StartPos: 6829, - EndPos: 6831, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6834, - EndPos: 6845, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6834, - EndPos: 6844, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6834, - EndPos: 6837, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6834, - EndPos: 6837, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6839, - EndPos: 6844, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6840, - EndPos: 6844, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 370, - EndLine: 370, - StartPos: 6840, - EndPos: 6844, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 372, - EndLine: 372, - StartPos: 6849, - EndPos: 6856, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 372, - EndLine: 372, - StartPos: 6849, - EndPos: 6855, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 372, - EndLine: 372, - StartPos: 6849, - EndPos: 6853, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 372, - EndLine: 372, - StartPos: 6849, - EndPos: 6853, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 372, - EndLine: 372, - StartPos: 6853, - EndPos: 6855, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6872, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6871, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6868, - }, - Variable: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6865, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6863, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6859, - EndPos: 6863, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6863, - EndPos: 6865, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6866, - EndPos: 6867, - }, - Value: "0", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 373, - EndLine: 373, - StartPos: 6869, - EndPos: 6870, - }, - Value: "0", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6875, - EndPos: 6882, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6875, - EndPos: 6881, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6875, - EndPos: 6877, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6875, - EndPos: 6877, - }, - Value: "a", - }, - }, - Dim: &expr.Variable{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6878, - EndPos: 6880, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 374, - EndLine: 374, - StartPos: 6878, - EndPos: 6880, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 375, - EndLine: 375, - StartPos: 6885, - EndPos: 6891, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 375, - EndLine: 375, - StartPos: 6885, - EndPos: 6890, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 375, - EndLine: 375, - StartPos: 6887, - EndPos: 6889, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 375, - EndLine: 375, - StartPos: 6887, - EndPos: 6889, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6894, - EndPos: 6909, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6894, - EndPos: 6908, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6894, - EndPos: 6898, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6894, - EndPos: 6898, - }, - Value: "foo", - }, - }, - Call: &expr.Variable{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6900, - EndPos: 6906, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6901, - EndPos: 6905, - }, - Value: "bar", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 376, - EndLine: 376, - StartPos: 6906, - EndPos: 6908, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 377, - EndLine: 377, - StartPos: 6912, - EndPos: 6922, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 377, - EndLine: 377, - StartPos: 6912, - EndPos: 6921, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 377, - EndLine: 377, - StartPos: 6912, - EndPos: 6916, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 377, - EndLine: 377, - StartPos: 6912, - EndPos: 6916, - }, - Value: "foo", - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 377, - EndLine: 377, - StartPos: 6918, - EndPos: 6921, - }, - Value: "bar", - }, - }, - }, - &stmt.HaltCompiler{ - Position: &position.Position{ - StartLine: 379, - EndLine: 379, - StartPos: 6926, - EndPos: 6944, - }, - }, - }, - } - - php5parser := php5.NewParser([]byte(src), "5.6") - php5parser.Parse() - actual := php5parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestPhp5Strings(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.Lexer.ReturnTokenToPool(yyDollar[i].token) - } - yyDollar[i].token = nil - } - yyVAL.token = nil -} diff --git a/php7/php7.go b/php7/php7.go deleted file mode 100644 index 5e35ac0..0000000 --- a/php7/php7.go +++ /dev/null @@ -1,8390 +0,0 @@ -// line php7/php7.y:2 -package php7 - -import __yyfmt__ "fmt" - -// line php7/php7.y:2 -import ( - "strconv" - "strings" - - "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" - "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/scanner" -) - -// line php7/php7.y:22 -type yySymType struct { - yys int - node node.Node - token *scanner.Token - list []node.Node - str string - - ClassExtends *stmt.ClassExtends - ClassImplements *stmt.ClassImplements - InterfaceExtends *stmt.InterfaceExtends - ClosureUse *expr.ClosureUse -} - -const T_INCLUDE = 57346 -const T_INCLUDE_ONCE = 57347 -const T_EXIT = 57348 -const T_IF = 57349 -const T_LNUMBER = 57350 -const T_DNUMBER = 57351 -const T_STRING = 57352 -const T_STRING_VARNAME = 57353 -const T_VARIABLE = 57354 -const T_NUM_STRING = 57355 -const T_INLINE_HTML = 57356 -const T_CHARACTER = 57357 -const T_BAD_CHARACTER = 57358 -const T_ENCAPSED_AND_WHITESPACE = 57359 -const T_CONSTANT_ENCAPSED_STRING = 57360 -const T_ECHO = 57361 -const T_DO = 57362 -const T_WHILE = 57363 -const T_ENDWHILE = 57364 -const T_FOR = 57365 -const T_ENDFOR = 57366 -const T_FOREACH = 57367 -const T_ENDFOREACH = 57368 -const T_DECLARE = 57369 -const T_ENDDECLARE = 57370 -const T_AS = 57371 -const T_SWITCH = 57372 -const T_ENDSWITCH = 57373 -const T_CASE = 57374 -const T_DEFAULT = 57375 -const T_BREAK = 57376 -const T_CONTINUE = 57377 -const T_GOTO = 57378 -const T_FUNCTION = 57379 -const T_FN = 57380 -const T_CONST = 57381 -const T_RETURN = 57382 -const T_TRY = 57383 -const T_CATCH = 57384 -const T_FINALLY = 57385 -const T_THROW = 57386 -const T_USE = 57387 -const T_INSTEADOF = 57388 -const T_GLOBAL = 57389 -const T_VAR = 57390 -const T_UNSET = 57391 -const T_ISSET = 57392 -const T_EMPTY = 57393 -const T_HALT_COMPILER = 57394 -const T_CLASS = 57395 -const T_TRAIT = 57396 -const T_INTERFACE = 57397 -const T_EXTENDS = 57398 -const T_IMPLEMENTS = 57399 -const T_OBJECT_OPERATOR = 57400 -const T_DOUBLE_ARROW = 57401 -const T_LIST = 57402 -const T_ARRAY = 57403 -const T_CALLABLE = 57404 -const T_CLASS_C = 57405 -const T_TRAIT_C = 57406 -const T_METHOD_C = 57407 -const T_FUNC_C = 57408 -const T_LINE = 57409 -const T_FILE = 57410 -const T_COMMENT = 57411 -const T_DOC_COMMENT = 57412 -const T_OPEN_TAG = 57413 -const T_OPEN_TAG_WITH_ECHO = 57414 -const T_CLOSE_TAG = 57415 -const T_WHITESPACE = 57416 -const T_START_HEREDOC = 57417 -const T_END_HEREDOC = 57418 -const T_DOLLAR_OPEN_CURLY_BRACES = 57419 -const T_CURLY_OPEN = 57420 -const T_PAAMAYIM_NEKUDOTAYIM = 57421 -const T_NAMESPACE = 57422 -const T_NS_C = 57423 -const T_DIR = 57424 -const T_NS_SEPARATOR = 57425 -const T_ELLIPSIS = 57426 -const T_EVAL = 57427 -const T_REQUIRE = 57428 -const T_REQUIRE_ONCE = 57429 -const T_LOGICAL_OR = 57430 -const T_LOGICAL_XOR = 57431 -const T_LOGICAL_AND = 57432 -const T_INSTANCEOF = 57433 -const T_NEW = 57434 -const T_CLONE = 57435 -const T_ELSEIF = 57436 -const T_ELSE = 57437 -const T_ENDIF = 57438 -const T_PRINT = 57439 -const T_YIELD = 57440 -const T_STATIC = 57441 -const T_ABSTRACT = 57442 -const T_FINAL = 57443 -const T_PRIVATE = 57444 -const T_PROTECTED = 57445 -const T_PUBLIC = 57446 -const T_INC = 57447 -const T_DEC = 57448 -const T_YIELD_FROM = 57449 -const T_INT_CAST = 57450 -const T_DOUBLE_CAST = 57451 -const T_STRING_CAST = 57452 -const T_ARRAY_CAST = 57453 -const T_OBJECT_CAST = 57454 -const T_BOOL_CAST = 57455 -const T_UNSET_CAST = 57456 -const T_COALESCE = 57457 -const T_SPACESHIP = 57458 -const T_NOELSE = 57459 -const T_PLUS_EQUAL = 57460 -const T_MINUS_EQUAL = 57461 -const T_MUL_EQUAL = 57462 -const T_POW_EQUAL = 57463 -const T_DIV_EQUAL = 57464 -const T_CONCAT_EQUAL = 57465 -const T_MOD_EQUAL = 57466 -const T_AND_EQUAL = 57467 -const T_OR_EQUAL = 57468 -const T_XOR_EQUAL = 57469 -const T_SL_EQUAL = 57470 -const T_SR_EQUAL = 57471 -const T_COALESCE_EQUAL = 57472 -const T_BOOLEAN_OR = 57473 -const T_BOOLEAN_AND = 57474 -const T_POW = 57475 -const T_SL = 57476 -const T_SR = 57477 -const T_IS_IDENTICAL = 57478 -const T_IS_NOT_IDENTICAL = 57479 -const T_IS_EQUAL = 57480 -const T_IS_NOT_EQUAL = 57481 -const T_IS_SMALLER_OR_EQUAL = 57482 -const T_IS_GREATER_OR_EQUAL = 57483 - -var yyToknames = [...]string{ - "$end", - "error", - "$unk", - "T_INCLUDE", - "T_INCLUDE_ONCE", - "T_EXIT", - "T_IF", - "T_LNUMBER", - "T_DNUMBER", - "T_STRING", - "T_STRING_VARNAME", - "T_VARIABLE", - "T_NUM_STRING", - "T_INLINE_HTML", - "T_CHARACTER", - "T_BAD_CHARACTER", - "T_ENCAPSED_AND_WHITESPACE", - "T_CONSTANT_ENCAPSED_STRING", - "T_ECHO", - "T_DO", - "T_WHILE", - "T_ENDWHILE", - "T_FOR", - "T_ENDFOR", - "T_FOREACH", - "T_ENDFOREACH", - "T_DECLARE", - "T_ENDDECLARE", - "T_AS", - "T_SWITCH", - "T_ENDSWITCH", - "T_CASE", - "T_DEFAULT", - "T_BREAK", - "T_CONTINUE", - "T_GOTO", - "T_FUNCTION", - "T_FN", - "T_CONST", - "T_RETURN", - "T_TRY", - "T_CATCH", - "T_FINALLY", - "T_THROW", - "T_USE", - "T_INSTEADOF", - "T_GLOBAL", - "T_VAR", - "T_UNSET", - "T_ISSET", - "T_EMPTY", - "T_HALT_COMPILER", - "T_CLASS", - "T_TRAIT", - "T_INTERFACE", - "T_EXTENDS", - "T_IMPLEMENTS", - "T_OBJECT_OPERATOR", - "T_DOUBLE_ARROW", - "T_LIST", - "T_ARRAY", - "T_CALLABLE", - "T_CLASS_C", - "T_TRAIT_C", - "T_METHOD_C", - "T_FUNC_C", - "T_LINE", - "T_FILE", - "T_COMMENT", - "T_DOC_COMMENT", - "T_OPEN_TAG", - "T_OPEN_TAG_WITH_ECHO", - "T_CLOSE_TAG", - "T_WHITESPACE", - "T_START_HEREDOC", - "T_END_HEREDOC", - "T_DOLLAR_OPEN_CURLY_BRACES", - "T_CURLY_OPEN", - "T_PAAMAYIM_NEKUDOTAYIM", - "T_NAMESPACE", - "T_NS_C", - "T_DIR", - "T_NS_SEPARATOR", - "T_ELLIPSIS", - "T_EVAL", - "T_REQUIRE", - "T_REQUIRE_ONCE", - "T_LOGICAL_OR", - "T_LOGICAL_XOR", - "T_LOGICAL_AND", - "T_INSTANCEOF", - "T_NEW", - "T_CLONE", - "T_ELSEIF", - "T_ELSE", - "T_ENDIF", - "T_PRINT", - "T_YIELD", - "T_STATIC", - "T_ABSTRACT", - "T_FINAL", - "T_PRIVATE", - "T_PROTECTED", - "T_PUBLIC", - "T_INC", - "T_DEC", - "T_YIELD_FROM", - "T_INT_CAST", - "T_DOUBLE_CAST", - "T_STRING_CAST", - "T_ARRAY_CAST", - "T_OBJECT_CAST", - "T_BOOL_CAST", - "T_UNSET_CAST", - "T_COALESCE", - "T_SPACESHIP", - "T_NOELSE", - "T_PLUS_EQUAL", - "T_MINUS_EQUAL", - "T_MUL_EQUAL", - "T_POW_EQUAL", - "T_DIV_EQUAL", - "T_CONCAT_EQUAL", - "T_MOD_EQUAL", - "T_AND_EQUAL", - "T_OR_EQUAL", - "T_XOR_EQUAL", - "T_SL_EQUAL", - "T_SR_EQUAL", - "T_COALESCE_EQUAL", - "T_BOOLEAN_OR", - "T_BOOLEAN_AND", - "T_POW", - "T_SL", - "T_SR", - "T_IS_IDENTICAL", - "T_IS_NOT_IDENTICAL", - "T_IS_EQUAL", - "T_IS_NOT_EQUAL", - "T_IS_SMALLER_OR_EQUAL", - "T_IS_GREATER_OR_EQUAL", - "'\"'", - "'`'", - "'{'", - "'}'", - "';'", - "':'", - "'('", - "')'", - "'['", - "']'", - "'?'", - "'&'", - "'-'", - "'+'", - "'!'", - "'~'", - "'@'", - "'$'", - "','", - "'|'", - "'='", - "'^'", - "'*'", - "'/'", - "'%'", - "'<'", - "'>'", - "'.'", -} -var yyStatenames = [...]string{} - -const yyEofCode = 1 -const yyErrCode = 2 -const yyInitialStackSize = 16 - -// line php7/php7.y:5666 - -// line yacctab:1 -var yyExca = [...]int{ - -1, 1, - 1, -1, - -2, 0, - -1, 2, - 1, 1, - -2, 0, - -1, 44, - 58, 426, - 79, 426, - 144, 426, - 150, 426, - -2, 421, - -1, 48, - 148, 429, - -2, 438, - -1, 85, - 58, 428, - 79, 428, - 144, 428, - 148, 431, - 150, 428, - -2, 416, - -1, 109, - 79, 389, - -2, 418, - -1, 233, - 58, 426, - 79, 426, - 144, 426, - 150, 426, - -2, 315, - -1, 236, - 148, 431, - -2, 428, - -1, 239, - 58, 426, - 79, 426, - 144, 426, - 150, 426, - -2, 317, - -1, 358, - 116, 0, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 339, - -1, 359, - 116, 0, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 340, - -1, 360, - 116, 0, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 341, - -1, 361, - 116, 0, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 342, - -1, 362, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 343, - -1, 363, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 344, - -1, 364, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 345, - -1, 365, - 140, 0, - 141, 0, - 167, 0, - 168, 0, - -2, 346, - -1, 366, - 116, 0, - 136, 0, - 137, 0, - 138, 0, - 139, 0, - -2, 347, - -1, 373, - 149, 164, - 160, 164, - -2, 426, - -1, 418, - 149, 466, - 151, 466, - 160, 466, - -2, 426, - -1, 423, - 58, 427, - 79, 427, - 144, 427, - 148, 430, - 150, 427, - -2, 349, - -1, 437, - 148, 452, - -2, 419, - -1, 438, - 148, 454, - -2, 444, - -1, 518, - 148, 452, - -2, 420, - -1, 519, - 148, 454, - -2, 445, - -1, 536, - 149, 214, - -2, 219, - -1, 578, - 149, 214, - -2, 219, - -1, 603, - 148, 430, - -2, 427, - -1, 669, - 149, 184, - -2, 426, - -1, 677, - 149, 214, - -2, 219, - -1, 693, - 149, 465, - 151, 465, - 160, 465, - -2, 426, - -1, 730, - 149, 185, - -2, 426, - -1, 746, - 37, 269, - 39, 269, - -2, 266, - -1, 760, - 94, 209, - 95, 209, - 96, 209, - -2, 0, - -1, 789, - 149, 184, - -2, 426, - -1, 791, - 149, 187, - -2, 400, - -1, 806, - 94, 210, - 95, 210, - 96, 210, - -2, 0, - -1, 856, - 31, 200, - 32, 200, - 33, 200, - 145, 200, - -2, 0, - -1, 888, - 29, 77, - -2, 81, - -1, 893, - 31, 199, - 32, 199, - 33, 199, - 145, 199, - -2, 0, - -1, 921, - 149, 214, - -2, 219, -} - -const yyPrivate = 57344 - -const yyLast = 7766 - -var yyAct = [...]int{ - - 28, 132, 765, 631, 843, 880, 866, 585, 442, 748, - 842, 109, 785, 820, 191, 839, 635, 682, 113, 634, - 668, 128, 140, 140, 140, 712, 650, 153, 380, 572, - 117, 123, 633, 649, 224, 188, 327, 580, 540, 529, - 636, 410, 372, 521, 318, 723, 226, 5, 322, 81, - 382, 9, 321, 228, 232, 8, 85, 240, 241, 242, - 243, 244, 152, 134, 245, 246, 247, 248, 249, 250, - 251, 320, 254, 149, 7, 262, 263, 264, 319, 145, - 2, 6, 130, 127, 139, 520, 436, 268, 129, 876, - 277, 278, 873, 280, 281, 850, 691, 597, 273, 258, - 83, 860, 338, 314, 234, 234, 899, 142, 143, 874, - 870, 236, 236, 847, 411, 846, 107, 900, 549, 575, - 684, 287, 339, 875, 871, 771, 716, 336, 334, 684, - 313, 312, 307, 295, 324, 297, 340, 306, 329, 330, - 304, 337, 335, 310, 706, 313, 311, 643, 628, 573, - 326, 307, 564, 290, 292, 181, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 416, 368, 370, 192, 374, 270, 708, 376, - 44, 791, 222, 273, 119, 107, 107, 167, 700, 300, - 607, 696, 610, 608, 392, 394, 395, 396, 397, 398, - 399, 400, 401, 402, 403, 404, 405, 406, 165, 164, - 407, 140, 409, 181, 228, 384, 867, 107, 166, 168, - 169, 419, 617, 163, 234, 604, 421, 272, 613, 228, - 119, 236, 107, 614, 388, 233, 239, 592, 412, 415, - 861, 265, 932, 921, 140, 895, 430, 828, 414, 181, - 827, 431, 818, 108, 136, 167, 140, 114, 807, 367, - 795, 437, 518, 422, 80, 375, 530, 531, 221, 234, - 532, 835, 270, 237, 220, 525, 236, 738, 728, 537, - 710, 705, 541, 703, 228, 119, 166, 168, 169, 146, - 695, 167, 170, 171, 666, 408, 526, 655, 177, 179, - 136, 234, 645, 114, 605, 559, 596, 793, 236, 296, - 822, 821, 165, 164, 551, 731, 554, 311, 543, 237, - 694, 927, 166, 168, 169, 176, 178, 163, 424, 568, - 677, 153, 108, 108, 609, 5, 638, 639, 429, 9, - 435, 291, 663, 8, 517, 664, 426, 427, 527, 288, - 578, 274, 425, 910, 562, 136, 560, 868, 114, 536, - 571, 524, 7, 420, 108, 373, 389, 523, 294, 6, - 546, 387, 426, 289, 427, 427, 426, 293, 587, 108, - 588, 552, 279, 589, 590, 582, 558, 276, 586, 275, - 253, 223, 219, 569, 186, 185, 184, 138, 577, 137, - 133, 567, 115, 595, 584, 566, 766, 228, 599, 758, - 418, 228, 391, 157, 159, 158, 181, 936, 190, 935, - 909, 851, 579, 780, 781, 616, 894, 637, 857, 299, - 619, 298, 181, 780, 781, 829, 824, 817, 777, 759, - 183, 180, 433, 727, 594, 602, 274, 726, 724, 722, - 719, 563, 548, 598, 545, 390, 155, 156, 167, 170, - 171, 172, 173, 174, 175, 177, 179, 378, 333, 332, - 618, 822, 821, 331, 167, 170, 171, 182, 161, 165, - 164, 301, 816, 119, 813, 808, 160, 413, 162, 166, - 168, 169, 176, 178, 163, 165, 164, 773, 615, 544, - 915, 544, 544, 217, 218, 166, 168, 169, 864, 863, - 163, 544, 809, 798, 140, 623, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 794, - 740, 438, 519, 644, 683, 167, 823, 583, 640, 187, - 198, 199, 181, 257, 122, 77, 779, 193, 627, 769, - 116, 620, 119, 659, 329, 661, 116, 624, 309, 642, - 203, 665, 554, 294, 554, 311, 913, 651, 626, 309, - 309, 148, 678, 745, 522, 267, 747, 259, 654, 681, - 640, 5, 428, 586, 167, 9, 266, 119, 692, 8, - 660, 200, 202, 201, 78, 79, 657, 119, 622, 680, - 146, 309, 119, 638, 639, 698, 667, 679, 7, 849, - 674, 729, 294, 234, 234, 6, 581, 118, 259, 530, - 236, 236, 136, 648, 557, 114, 688, 752, 753, 754, - 751, 750, 749, 714, 541, 653, 647, 383, 309, 640, - 234, 386, 260, 261, 911, 555, 797, 236, 284, 285, - 720, 119, 735, 736, 702, 550, 554, 136, 704, 713, - 114, 554, 554, 228, 717, 651, 303, 733, 709, 715, - 553, 737, 711, 889, 802, 305, 801, 718, 125, 640, - 126, 760, 761, 260, 261, 228, 756, 148, 119, 119, - 107, 755, 308, 135, 106, 46, 112, 732, 739, 912, - 725, 752, 753, 754, 751, 750, 749, 535, 640, 259, - 234, 325, 697, 329, 428, 840, 125, 236, 126, 762, - 757, 764, 228, 554, 124, 554, 713, 901, 651, 767, - 772, 812, 770, 774, 194, 150, 259, 119, 775, 111, - 788, 428, 1, 803, 259, 640, 804, 586, 799, 778, - 806, 611, 652, 800, 373, 669, 790, 38, 136, 259, - 782, 114, 784, 786, 286, 121, 131, 259, 640, 234, - 556, 819, 282, 811, 260, 261, 236, 237, 150, 826, - 554, 693, 544, 814, 810, 381, 832, 621, 833, 834, - 413, 625, 815, 746, 379, 831, 825, 780, 781, 197, - 534, 260, 261, 135, 106, 196, 836, 844, 533, 260, - 261, 743, 856, 259, 783, 780, 781, 848, 256, 195, - 189, 744, 632, 855, 260, 261, 235, 539, 238, 225, - 859, 283, 260, 261, 528, 865, 371, 108, 879, 877, - 890, 891, 886, 147, 838, 144, 892, 893, 328, 885, - 151, 730, 841, 853, 676, 897, 898, 830, 255, 872, - 796, 385, 786, 896, 903, 656, 852, 905, 934, 662, - 845, 227, 43, 42, 886, 908, 904, 902, 260, 261, - 16, 885, 15, 606, 271, 49, 48, 110, 50, 84, - 82, 72, 252, 62, 269, 61, 906, 918, 884, 883, - 882, 881, 742, 45, 734, 673, 315, 928, 926, 922, - 789, 924, 925, 586, 120, 929, 302, 3, 441, 768, - 930, 707, 919, 640, 920, 933, 0, 4, 937, 89, - 90, 70, 47, 94, 95, 36, 0, 107, 0, 27, - 0, 0, 0, 112, 26, 18, 17, 0, 19, 0, - 30, 0, 31, 0, 0, 20, 0, 0, 0, 21, - 22, 35, 37, 106, 13, 23, 33, 0, 0, 34, - 12, 0, 24, 0, 29, 87, 88, 10, 39, 40, - 41, 0, 0, 0, 0, 51, 111, 0, 103, 99, - 100, 101, 96, 97, 745, 0, 0, 747, 0, 0, - 104, 0, 0, 0, 0, 11, 102, 98, 114, 0, - 91, 92, 93, 0, 0, 0, 0, 86, 53, 0, - 0, 0, 74, 75, 25, 78, 79, 0, 0, 0, - 54, 55, 76, 63, 64, 65, 66, 67, 68, 69, - 0, 0, 0, 0, 0, 0, 0, 0, 752, 753, - 754, 751, 750, 749, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 105, 73, 14, - 646, 32, 0, 60, 0, 52, 0, 0, 0, 57, - 56, 58, 59, 71, 108, 4, 0, 89, 90, 70, - 47, 94, 95, 36, 869, 107, 0, 27, 0, 0, - 0, 112, 26, 18, 17, 0, 19, 0, 30, 0, - 31, 0, 0, 20, 0, 0, 0, 21, 22, 35, - 37, 106, 13, 23, 33, 0, 0, 34, 12, 0, - 24, 0, 29, 87, 88, 10, 39, 40, 41, 0, - 0, 0, 0, 51, 111, 0, 103, 99, 100, 101, - 96, 97, 745, 0, 0, 747, 0, 0, 104, 0, - 0, 0, 0, 11, 102, 98, 114, 0, 91, 92, - 93, 0, 0, 0, 0, 86, 53, 0, 0, 0, - 74, 75, 25, 78, 79, 0, 0, 0, 54, 55, - 76, 63, 64, 65, 66, 67, 68, 69, 0, 0, - 0, 0, 0, 0, 0, 0, 752, 753, 754, 751, - 750, 749, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 105, 73, 14, 547, 32, - 0, 60, 0, 52, 0, 0, 0, 57, 56, 58, - 59, 71, 108, 4, 0, 89, 90, 70, 47, 94, - 95, 36, 837, 107, 0, 27, 0, 0, 0, 112, - 26, 18, 17, 0, 19, 0, 30, 0, 31, 0, - 0, 20, 0, 0, 0, 21, 22, 35, 37, 106, - 13, 23, 33, 0, 0, 34, 12, 0, 24, 0, - 29, 87, 88, 10, 39, 40, 41, 0, 0, 0, - 0, 51, 111, 0, 103, 99, 100, 101, 96, 97, - 745, 0, 0, 747, 0, 0, 104, 0, 0, 0, - 0, 11, 102, 98, 114, 0, 91, 92, 93, 0, - 0, 0, 0, 86, 53, 0, 0, 0, 74, 75, - 25, 78, 79, 0, 0, 0, 54, 55, 76, 63, - 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, - 0, 0, 0, 0, 752, 753, 754, 751, 750, 749, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 105, 73, 14, 0, 32, 0, 60, - 0, 52, 0, 0, 0, 57, 56, 58, 59, 71, - 108, 317, 0, 89, 90, 70, 47, 94, 95, 36, - 805, 107, 0, 27, 0, 0, 0, 112, 26, 18, - 17, 0, 19, 0, 30, 0, 31, 0, 0, 20, - 0, 0, 0, 21, 22, 35, 37, 106, 0, 23, - 33, 0, 0, 34, 0, 0, 24, 0, 29, 87, - 88, 323, 39, 40, 41, 0, 0, 0, 0, 51, - 111, 0, 103, 99, 100, 101, 96, 97, 745, 0, - 0, 747, 0, 0, 104, 0, 0, 0, 0, 136, - 102, 98, 114, 0, 91, 92, 93, 0, 0, 0, - 0, 86, 53, 0, 0, 0, 74, 75, 25, 78, - 79, 0, 0, 0, 54, 55, 76, 63, 64, 65, - 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, - 0, 0, 752, 753, 754, 751, 750, 749, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 105, 73, 14, 938, 32, 0, 60, 0, 52, - 0, 0, 0, 57, 56, 58, 59, 71, 108, 317, - 0, 89, 90, 70, 47, 94, 95, 36, 741, 107, - 0, 27, 0, 0, 0, 112, 26, 18, 17, 0, - 19, 0, 30, 0, 31, 0, 0, 20, 0, 0, - 0, 21, 22, 35, 37, 106, 0, 23, 33, 0, - 0, 34, 0, 0, 24, 0, 29, 87, 88, 323, - 39, 40, 41, 0, 0, 0, 0, 51, 111, 0, - 103, 99, 100, 101, 96, 97, 0, 0, 0, 0, - 0, 0, 104, 0, 0, 0, 0, 136, 102, 98, - 114, 0, 91, 92, 93, 0, 0, 0, 0, 86, - 53, 0, 0, 0, 74, 75, 25, 78, 79, 0, - 0, 0, 54, 55, 76, 63, 64, 65, 66, 67, - 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, - 73, 14, 931, 32, 0, 60, 0, 52, 0, 0, - 0, 57, 56, 58, 59, 71, 108, 317, 0, 89, - 90, 70, 47, 94, 95, 36, 0, 107, 0, 27, - 0, 0, 0, 112, 26, 18, 17, 0, 19, 0, - 30, 0, 31, 0, 0, 20, 0, 0, 0, 21, - 22, 35, 37, 106, 0, 23, 33, 0, 0, 34, - 0, 0, 24, 0, 29, 87, 88, 323, 39, 40, - 41, 0, 0, 0, 0, 51, 111, 0, 103, 99, - 100, 101, 96, 97, 0, 0, 0, 0, 0, 0, - 104, 0, 0, 0, 0, 136, 102, 98, 114, 0, - 91, 92, 93, 0, 0, 0, 0, 86, 53, 0, - 0, 0, 74, 75, 25, 78, 79, 0, 0, 0, - 54, 55, 76, 63, 64, 65, 66, 67, 68, 69, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 105, 73, 14, - 917, 32, 0, 60, 0, 52, 0, 0, 0, 57, - 56, 58, 59, 71, 108, 317, 0, 89, 90, 70, - 47, 94, 95, 36, 0, 107, 0, 27, 0, 0, - 0, 112, 26, 18, 17, 0, 19, 0, 30, 0, - 31, 0, 0, 20, 0, 0, 0, 21, 22, 35, - 37, 106, 0, 23, 33, 0, 0, 34, 0, 0, - 24, 0, 29, 87, 88, 323, 39, 40, 41, 0, - 0, 0, 0, 51, 111, 0, 103, 99, 100, 101, - 96, 97, 0, 0, 0, 0, 0, 0, 104, 0, - 0, 0, 0, 136, 102, 98, 114, 0, 91, 92, - 93, 0, 0, 0, 0, 86, 53, 0, 0, 0, - 74, 75, 25, 78, 79, 0, 0, 0, 54, 55, - 76, 63, 64, 65, 66, 67, 68, 69, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 105, 73, 14, 916, 32, - 0, 60, 0, 52, 0, 0, 0, 57, 56, 58, - 59, 71, 108, 317, 0, 89, 90, 70, 47, 94, - 95, 36, 0, 107, 0, 27, 0, 0, 0, 112, - 26, 18, 17, 0, 19, 914, 30, 0, 31, 0, - 0, 20, 0, 0, 0, 21, 22, 35, 37, 106, - 0, 23, 33, 0, 0, 34, 0, 0, 24, 0, - 29, 87, 88, 323, 39, 40, 41, 0, 0, 0, - 0, 51, 111, 0, 103, 99, 100, 101, 96, 97, - 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, - 0, 136, 102, 98, 114, 0, 91, 92, 93, 0, - 0, 0, 0, 86, 53, 0, 0, 0, 74, 75, - 25, 78, 79, 0, 0, 0, 54, 55, 76, 63, - 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 105, 73, 14, 0, 32, 0, 60, - 0, 52, 0, 0, 0, 57, 56, 58, 59, 71, - 108, 317, 0, 89, 90, 70, 47, 94, 95, 36, - 0, 107, 0, 27, 0, 0, 0, 112, 26, 18, - 17, 0, 19, 0, 30, 0, 31, 0, 0, 20, - 0, 0, 0, 21, 22, 35, 37, 106, 0, 23, - 33, 0, 0, 34, 0, 0, 24, 0, 29, 87, - 88, 323, 39, 40, 41, 0, 0, 0, 0, 51, - 111, 0, 103, 99, 100, 101, 96, 97, 0, 0, - 0, 0, 0, 0, 104, 0, 0, 0, 0, 136, - 102, 98, 114, 0, 91, 92, 93, 0, 0, 0, - 0, 86, 53, 0, 0, 0, 74, 75, 25, 78, - 79, 0, 0, 0, 54, 55, 76, 63, 64, 65, - 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 105, 73, 14, 862, 32, 0, 60, 0, 52, - 0, 0, 0, 57, 56, 58, 59, 71, 108, 317, - 0, 89, 90, 70, 47, 94, 95, 36, 0, 107, - 0, 27, 0, 0, 0, 112, 26, 18, 17, 0, - 19, 0, 30, 858, 31, 0, 0, 20, 0, 0, - 0, 21, 22, 35, 37, 106, 0, 23, 33, 0, - 0, 34, 0, 0, 24, 0, 29, 87, 88, 323, - 39, 40, 41, 0, 0, 0, 0, 51, 111, 0, - 103, 99, 100, 101, 96, 97, 0, 0, 0, 0, - 0, 0, 104, 0, 0, 0, 0, 136, 102, 98, - 114, 0, 91, 92, 93, 0, 0, 0, 0, 86, - 53, 0, 0, 0, 74, 75, 25, 78, 79, 0, - 0, 0, 54, 55, 76, 63, 64, 65, 66, 67, - 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, - 73, 14, 0, 32, 0, 60, 0, 52, 0, 0, - 0, 57, 56, 58, 59, 71, 108, 317, 0, 89, - 90, 70, 47, 94, 95, 36, 0, 107, 0, 27, - 0, 0, 0, 112, 26, 18, 17, 0, 19, 0, - 30, 0, 31, 792, 0, 20, 0, 0, 0, 21, - 22, 35, 37, 106, 0, 23, 33, 0, 0, 34, - 0, 0, 24, 0, 29, 87, 88, 323, 39, 40, - 41, 0, 0, 0, 0, 51, 111, 0, 103, 99, - 100, 101, 96, 97, 0, 0, 0, 0, 0, 0, - 104, 0, 0, 0, 0, 136, 102, 98, 114, 0, - 91, 92, 93, 0, 0, 0, 0, 86, 53, 0, - 0, 0, 74, 75, 25, 78, 79, 0, 0, 0, - 54, 55, 76, 63, 64, 65, 66, 67, 68, 69, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 105, 73, 14, - 0, 32, 0, 60, 0, 52, 0, 0, 0, 57, - 56, 58, 59, 71, 108, 317, 0, 89, 90, 70, - 47, 94, 95, 36, 0, 107, 0, 27, 0, 0, - 0, 112, 26, 18, 17, 776, 19, 0, 30, 0, - 31, 0, 0, 20, 0, 0, 0, 21, 22, 35, - 37, 106, 0, 23, 33, 0, 0, 34, 0, 0, - 24, 0, 29, 87, 88, 323, 39, 40, 41, 0, - 0, 0, 0, 51, 111, 0, 103, 99, 100, 101, - 96, 97, 0, 0, 0, 0, 0, 0, 104, 0, - 0, 0, 0, 136, 102, 98, 114, 0, 91, 92, - 93, 0, 0, 0, 0, 86, 53, 0, 0, 0, - 74, 75, 25, 78, 79, 0, 0, 0, 54, 55, - 76, 63, 64, 65, 66, 67, 68, 69, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 105, 73, 14, 0, 32, - 0, 60, 0, 52, 0, 0, 0, 57, 56, 58, - 59, 71, 108, 317, 0, 89, 90, 70, 47, 94, - 95, 36, 0, 107, 0, 27, 0, 0, 0, 112, - 26, 18, 17, 0, 19, 0, 30, 0, 31, 0, - 0, 20, 0, 0, 0, 21, 22, 35, 37, 106, - 0, 23, 33, 0, 0, 34, 0, 0, 24, 0, - 29, 87, 88, 323, 39, 40, 41, 0, 0, 0, - 0, 51, 111, 0, 103, 99, 100, 101, 96, 97, - 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, - 0, 136, 102, 98, 114, 0, 91, 92, 93, 0, - 0, 0, 0, 86, 53, 0, 0, 687, 74, 75, - 25, 78, 79, 0, 0, 0, 54, 55, 76, 63, - 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 105, 73, 14, 0, 32, 0, 60, - 0, 52, 0, 0, 0, 57, 56, 58, 59, 71, - 108, 317, 0, 89, 90, 70, 47, 94, 95, 36, - 0, 107, 0, 27, 0, 0, 0, 112, 26, 18, - 17, 0, 19, 0, 30, 0, 31, 0, 0, 20, - 0, 0, 0, 21, 22, 35, 37, 106, 0, 23, - 33, 0, 0, 34, 0, 0, 24, 0, 29, 87, - 88, 323, 39, 40, 41, 0, 0, 0, 0, 51, - 111, 0, 103, 99, 100, 101, 96, 97, 0, 0, - 0, 0, 0, 0, 104, 0, 0, 0, 0, 136, - 102, 98, 114, 0, 91, 92, 93, 0, 0, 0, - 0, 86, 53, 0, 0, 0, 74, 75, 25, 78, - 79, 0, 0, 0, 54, 55, 76, 63, 64, 65, - 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 105, 73, 14, 576, 32, 0, 60, 0, 52, - 0, 0, 0, 57, 56, 58, 59, 71, 108, 317, - 0, 89, 90, 70, 47, 94, 95, 36, 0, 107, - 0, 27, 0, 0, 0, 112, 26, 18, 17, 0, - 19, 0, 30, 0, 31, 0, 0, 20, 0, 0, - 0, 21, 22, 35, 37, 106, 0, 23, 33, 0, - 0, 34, 0, 0, 24, 0, 29, 87, 88, 323, - 39, 40, 41, 0, 0, 0, 0, 51, 111, 0, - 103, 99, 100, 101, 96, 97, 0, 0, 0, 0, - 0, 0, 104, 0, 0, 0, 0, 136, 102, 98, - 114, 0, 91, 92, 93, 0, 0, 0, 0, 86, - 53, 0, 0, 0, 74, 75, 25, 78, 79, 0, - 0, 0, 54, 55, 76, 63, 64, 65, 66, 67, - 68, 69, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, - 73, 14, 316, 32, 0, 60, 0, 52, 0, 0, - 0, 57, 56, 58, 59, 71, 108, 317, 0, 89, - 90, 70, 47, 94, 95, 36, 0, 107, 0, 27, - 0, 0, 0, 112, 26, 18, 17, 0, 19, 0, - 30, 0, 31, 0, 0, 20, 0, 0, 0, 21, - 22, 35, 37, 106, 0, 23, 33, 0, 0, 34, - 0, 0, 24, 0, 29, 87, 88, 323, 39, 40, - 41, 0, 0, 0, 0, 51, 111, 0, 103, 99, - 100, 101, 96, 97, 0, 0, 0, 0, 0, 0, - 104, 0, 0, 0, 0, 136, 102, 98, 114, 0, - 91, 92, 93, 0, 0, 0, 0, 86, 53, 0, - 0, 0, 74, 75, 25, 78, 79, 0, 0, 0, - 54, 55, 76, 63, 64, 65, 66, 67, 68, 69, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 105, 73, 14, - 0, 32, 0, 60, 0, 52, 0, 0, 0, 57, - 56, 58, 59, 71, 108, 449, 450, 460, 461, 0, - 0, 440, 0, 107, 0, 0, 0, 0, 0, 0, - 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, - 475, 495, 496, 497, 498, 499, 487, 488, 489, 516, - 490, 491, 476, 477, 478, 479, 480, 481, 482, 483, - 484, 485, 486, 0, 507, 505, 506, 502, 503, 0, - 0, 494, 500, 501, 508, 509, 511, 510, 512, 513, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 504, 515, 514, 0, 0, 451, 452, 453, 454, - 455, 456, 457, 458, 459, 462, 463, 464, 492, 493, - 443, 444, 445, 446, 447, 448, 89, 90, 70, 47, - 94, 95, 36, 0, 107, 0, 27, 0, 0, 0, - 112, 26, 18, 17, 0, 19, 0, 30, 0, 31, - 0, 0, 20, 0, 0, 0, 21, 22, 35, 135, - 106, 0, 23, 33, 0, 439, 34, 0, 0, 24, - 0, 29, 87, 88, 0, 0, 0, 0, 0, 0, - 108, 0, 51, 111, 0, 103, 99, 100, 101, 96, - 97, 0, 0, 0, 0, 0, 0, 104, 0, 0, - 0, 0, 136, 102, 98, 114, 0, 91, 92, 93, - 0, 0, 0, 0, 86, 53, 0, 0, 0, 74, - 75, 25, 0, 0, 0, 0, 0, 54, 55, 76, - 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 105, 73, 14, 0, 32, 787, - 60, 0, 52, 0, 0, 0, 57, 56, 58, 59, - 71, 108, 89, 90, 70, 47, 94, 95, 36, 0, - 107, 0, 27, 0, 0, 0, 112, 26, 18, 17, - 0, 19, 0, 30, 0, 31, 0, 0, 20, 0, - 0, 0, 21, 22, 35, 135, 106, 0, 23, 33, - 0, 0, 34, 0, 0, 24, 0, 29, 87, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 51, 111, - 0, 103, 99, 100, 101, 96, 97, 0, 0, 0, - 0, 0, 0, 104, 0, 0, 0, 0, 136, 102, - 98, 114, 0, 91, 92, 93, 0, 0, 0, 0, - 86, 53, 0, 0, 0, 74, 75, 25, 0, 0, - 0, 0, 0, 54, 55, 76, 63, 64, 65, 66, - 67, 68, 69, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 105, 73, 14, 0, 32, 854, 60, 0, 52, 0, - 0, 0, 57, 56, 58, 59, 71, 108, 89, 90, - 70, 47, 94, 95, 36, 0, 107, 0, 27, 0, - 0, 0, 112, 26, 18, 17, 0, 19, 0, 30, - 0, 31, 0, 0, 20, 0, 0, 0, 21, 22, - 35, 135, 106, 0, 23, 33, 0, 0, 34, 0, - 0, 24, 0, 29, 87, 88, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 111, 0, 103, 99, 100, - 101, 96, 97, 0, 0, 0, 0, 0, 0, 104, - 0, 0, 0, 0, 136, 102, 98, 114, 0, 91, - 92, 93, 0, 0, 0, 0, 86, 53, 0, 0, - 0, 74, 75, 25, 0, 0, 0, 0, 0, 54, - 55, 76, 63, 64, 65, 66, 67, 68, 69, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 105, 73, 14, 0, - 32, 689, 60, 0, 52, 0, 0, 0, 57, 56, - 58, 59, 71, 108, 89, 90, 70, 47, 94, 95, - 36, 0, 107, 0, 27, 0, 0, 0, 112, 26, - 18, 17, 0, 19, 0, 30, 0, 31, 0, 0, - 20, 0, 0, 0, 21, 22, 35, 135, 106, 0, - 23, 33, 0, 0, 34, 0, 0, 24, 0, 29, - 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 111, 0, 103, 99, 100, 101, 96, 97, 0, - 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, - 136, 102, 98, 114, 0, 91, 92, 93, 0, 0, - 0, 0, 86, 53, 0, 0, 0, 74, 75, 25, - 0, 0, 0, 0, 0, 54, 55, 76, 63, 64, - 65, 66, 67, 68, 69, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 105, 73, 14, 0, 32, 675, 60, 0, - 52, 0, 0, 0, 57, 56, 58, 59, 71, 108, - 89, 90, 70, 47, 94, 95, 36, 0, 107, 0, - 27, 0, 0, 0, 112, 26, 18, 17, 0, 19, - 0, 30, 0, 31, 0, 0, 20, 0, 0, 0, - 21, 22, 35, 135, 106, 0, 23, 33, 0, 0, - 34, 0, 0, 24, 0, 29, 87, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 111, 0, 103, - 99, 100, 101, 96, 97, 0, 0, 0, 0, 0, - 0, 104, 0, 0, 0, 0, 136, 102, 98, 114, - 0, 91, 92, 93, 0, 0, 0, 0, 86, 53, - 0, 0, 0, 74, 75, 25, 0, 0, 0, 0, - 0, 54, 55, 76, 63, 64, 65, 66, 67, 68, - 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 105, 73, - 14, 0, 32, 658, 60, 0, 52, 0, 0, 0, - 57, 56, 58, 59, 71, 108, 89, 90, 70, 47, - 94, 95, 36, 0, 107, 0, 27, 0, 0, 0, - 112, 26, 18, 17, 0, 19, 0, 30, 0, 31, - 0, 0, 20, 0, 0, 0, 21, 22, 35, 135, - 106, 0, 23, 33, 0, 0, 34, 0, 0, 24, - 0, 29, 87, 88, 0, 0, 0, 0, 0, 0, - 0, 0, 51, 111, 0, 103, 99, 100, 101, 96, - 97, 0, 0, 0, 0, 0, 0, 104, 0, 0, - 0, 0, 136, 102, 98, 114, 0, 91, 92, 93, - 0, 0, 0, 0, 86, 53, 0, 0, 0, 74, - 75, 25, 0, 0, 0, 0, 0, 54, 55, 76, - 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 105, 73, 14, 0, 32, 0, - 60, 0, 52, 0, 0, 0, 57, 56, 58, 59, - 71, 108, 449, 450, 460, 461, 0, 0, 888, 0, - 0, 0, 0, 0, 0, 0, 0, 465, 466, 467, - 468, 469, 470, 471, 472, 473, 474, 475, 495, 496, - 497, 498, 499, 487, 488, 489, 516, 490, 491, 476, - 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, - 0, 507, 505, 506, 502, 503, 0, 0, 494, 500, - 501, 508, 509, 511, 510, 512, 513, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 887, 515, - 514, 114, 0, 451, 452, 453, 454, 455, 456, 457, - 458, 459, 462, 463, 464, 492, 493, 443, 444, 445, - 446, 447, 448, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 449, - 450, 460, 461, 0, 0, 888, 0, 0, 0, 0, - 0, 0, 0, 907, 465, 466, 467, 468, 469, 470, - 471, 472, 473, 474, 475, 495, 496, 497, 498, 499, - 487, 488, 489, 516, 490, 491, 476, 477, 478, 479, - 480, 481, 482, 483, 484, 485, 486, 0, 507, 505, - 506, 502, 503, 0, 0, 494, 500, 501, 508, 509, - 511, 510, 512, 513, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 887, 515, 514, 114, 0, - 451, 452, 453, 454, 455, 456, 457, 458, 459, 462, - 463, 464, 492, 493, 443, 444, 445, 446, 447, 448, - 89, 90, 70, 0, 94, 95, 119, 0, 107, 0, - 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 135, 106, 0, 0, 0, 0, 0, - 878, 0, 0, 0, 0, 0, 87, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 231, 111, 0, 103, - 99, 100, 101, 96, 97, 0, 0, 0, 0, 0, - 0, 104, 0, 0, 0, 0, 136, 102, 98, 114, - 230, 91, 92, 93, 0, 0, 0, 0, 86, 53, - 0, 0, 0, 74, 75, 141, 0, 0, 0, 0, - 0, 54, 55, 76, 63, 64, 65, 66, 67, 68, - 69, 0, 0, 0, 89, 90, 70, 0, 94, 95, - 119, 0, 107, 0, 0, 0, 0, 0, 112, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 105, 73, - 0, 0, 0, 0, 60, 0, 52, 135, 106, 229, - 57, 56, 58, 59, 71, 108, 0, 0, 0, 0, - 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 111, 0, 103, 99, 100, 101, 96, 97, 0, - 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, - 136, 102, 98, 114, 542, 91, 92, 93, 0, 0, - 0, 0, 86, 53, 0, 0, 0, 74, 75, 141, - 0, 0, 0, 0, 0, 54, 55, 76, 63, 64, - 65, 66, 67, 68, 69, 0, 0, 0, 89, 90, - 70, 0, 94, 95, 119, 0, 107, 0, 0, 0, - 0, 0, 112, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 105, 73, 0, 0, 0, 0, 60, 538, - 52, 135, 106, 0, 57, 56, 58, 59, 71, 108, - 0, 0, 0, 0, 87, 88, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 111, 0, 103, 99, 100, - 101, 96, 97, 0, 0, 0, 0, 0, 0, 104, - 0, 0, 0, 0, 136, 102, 98, 114, 542, 91, - 92, 93, 0, 0, 0, 0, 86, 53, 0, 0, - 0, 74, 75, 141, 0, 0, 0, 0, 0, 54, - 55, 76, 63, 64, 65, 66, 67, 68, 69, 0, - 0, 0, 89, 90, 70, 0, 94, 95, 119, 0, - 107, 0, 0, 0, 0, 0, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 105, 73, 0, 0, - 0, 0, 60, 0, 52, 135, 106, 0, 57, 56, - 58, 59, 71, 108, 0, 0, 0, 0, 87, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 601, 111, - 0, 103, 99, 100, 101, 96, 97, 0, 0, 0, - 0, 0, 0, 104, 0, 0, 0, 0, 136, 102, - 98, 114, 0, 91, 92, 93, 0, 0, 0, 0, - 86, 53, 0, 0, 0, 74, 75, 141, 0, 0, - 0, 0, 0, 54, 55, 76, 63, 64, 65, 66, - 67, 68, 69, 0, 0, 0, 89, 90, 70, 0, - 94, 95, 119, 432, 107, 0, 0, 0, 0, 0, - 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 105, 73, 0, 0, 0, 0, 60, 0, 52, 135, - 106, 600, 57, 56, 58, 59, 71, 108, 0, 0, - 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, - 0, 0, 51, 111, 0, 103, 99, 100, 101, 96, - 97, 0, 0, 0, 0, 0, 0, 104, 0, 0, - 0, 0, 136, 102, 98, 114, 0, 91, 92, 93, - 0, 0, 0, 0, 86, 53, 0, 0, 0, 74, - 75, 141, 0, 0, 0, 0, 0, 54, 55, 76, - 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, - 89, 90, 70, 0, 94, 95, 119, 0, 107, 0, - 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 105, 73, 0, 0, 0, 0, - 60, 0, 52, 135, 106, 0, 57, 56, 58, 59, - 71, 108, 0, 0, 0, 0, 87, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 111, 0, 103, - 99, 100, 101, 96, 97, 0, 0, 0, 0, 0, - 0, 104, 0, 0, 0, 0, 136, 102, 98, 114, - 0, 91, 92, 93, 0, 0, 0, 0, 86, 53, - 0, 0, 0, 74, 75, 141, 0, 0, 0, 0, - 0, 54, 55, 76, 63, 64, 65, 66, 67, 68, - 69, 0, 0, 0, 89, 90, 70, 0, 94, 95, - 119, 0, 107, 0, 0, 0, 0, 0, 112, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 105, 73, - 0, 0, 0, 0, 60, 0, 52, 135, 106, 393, - 57, 56, 58, 59, 71, 108, 0, 0, 0, 0, - 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 111, 0, 103, 99, 100, 101, 96, 97, 0, - 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, - 136, 102, 98, 114, 0, 91, 92, 93, 0, 0, - 0, 0, 86, 53, 0, 0, 0, 74, 75, 141, - 0, 0, 0, 0, 0, 54, 55, 76, 63, 64, - 65, 66, 67, 68, 69, 0, 0, 0, 89, 90, - 70, 0, 94, 95, 119, 0, 107, 0, 0, 0, - 0, 0, 112, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 105, 73, 0, 0, 0, 369, 60, 0, - 52, 135, 106, 0, 57, 56, 58, 59, 71, 108, - 0, 0, 0, 0, 87, 88, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 111, 0, 103, 99, 100, - 101, 96, 97, 0, 0, 0, 0, 0, 0, 104, - 0, 0, 0, 0, 136, 102, 98, 114, 0, 91, - 92, 93, 0, 0, 0, 0, 86, 53, 0, 0, - 0, 74, 75, 141, 0, 0, 0, 0, 0, 54, - 55, 76, 63, 64, 65, 66, 67, 68, 69, 0, - 0, 157, 159, 158, 181, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 105, 73, 183, 180, - 0, 0, 60, 0, 52, 0, 0, 0, 57, 56, - 58, 59, 71, 108, 155, 156, 167, 170, 171, 172, - 173, 174, 175, 177, 179, 0, 157, 159, 158, 181, - 0, 0, 0, 0, 763, 182, 161, 165, 164, 0, - 0, 0, 0, 0, 160, 0, 162, 166, 168, 169, - 176, 178, 163, 183, 180, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, - 156, 167, 170, 171, 172, 173, 174, 175, 177, 179, - 0, 157, 159, 158, 181, 0, 0, 721, 0, 0, - 182, 161, 165, 164, 0, 0, 0, 0, 0, 160, - 0, 162, 166, 168, 169, 176, 178, 163, 183, 180, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 167, 170, 171, 172, - 173, 174, 175, 177, 179, 0, 0, 0, 701, 157, - 159, 158, 181, 0, 0, 182, 161, 165, 164, 0, - 0, 0, 0, 0, 160, 0, 162, 166, 168, 169, - 176, 178, 163, 0, 0, 0, 183, 180, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 155, 156, 167, 170, 171, 172, 173, 174, - 175, 177, 179, 0, 0, 0, 699, 157, 159, 158, - 181, 0, 0, 182, 161, 165, 164, 0, 0, 0, - 0, 0, 160, 0, 162, 166, 168, 169, 176, 178, - 163, 0, 0, 0, 183, 180, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 155, 156, 167, 170, 171, 172, 173, 174, 175, 177, - 179, 0, 0, 0, 690, 157, 159, 158, 181, 0, - 0, 182, 161, 165, 164, 0, 0, 0, 0, 0, - 160, 0, 162, 166, 168, 169, 176, 178, 163, 0, - 0, 0, 183, 180, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 155, 156, - 167, 170, 171, 172, 173, 174, 175, 177, 179, 0, - 157, 159, 158, 181, 0, 0, 686, 0, 0, 182, - 161, 165, 164, 0, 0, 0, 0, 0, 160, 0, - 162, 166, 168, 169, 176, 178, 163, 183, 180, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 155, 156, 167, 170, 171, 172, 173, - 174, 175, 177, 179, 0, 157, 159, 158, 181, 0, - 0, 685, 0, 0, 182, 161, 165, 164, 0, 0, - 0, 0, 0, 160, 0, 162, 166, 168, 169, 176, - 178, 163, 183, 180, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 155, 156, - 167, 170, 171, 172, 173, 174, 175, 177, 179, 0, - 0, 0, 641, 157, 159, 158, 181, 0, 0, 182, - 161, 165, 164, 0, 0, 0, 0, 0, 160, 0, - 162, 166, 168, 169, 176, 178, 163, 0, 0, 0, - 183, 180, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 155, 156, 167, 170, - 171, 172, 173, 174, 175, 177, 179, 0, 157, 159, - 158, 181, 0, 0, 630, 0, 0, 182, 161, 165, - 164, 0, 0, 0, 0, 0, 160, 0, 162, 166, - 168, 169, 176, 178, 163, 183, 180, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 155, 156, 167, 170, 171, 172, 173, 174, 175, - 177, 179, 0, 157, 159, 158, 181, 0, 0, 629, - 0, 0, 182, 161, 165, 164, 0, 0, 0, 0, - 0, 160, 0, 162, 166, 168, 169, 176, 178, 163, - 183, 180, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 155, 156, 167, 170, - 171, 172, 173, 174, 175, 177, 179, 0, 0, 0, - 612, 157, 159, 158, 181, 0, 0, 182, 161, 165, - 164, 0, 0, 0, 0, 0, 160, 0, 162, 166, - 168, 169, 176, 178, 163, 0, 0, 0, 183, 180, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 167, 170, 171, 172, - 173, 174, 175, 177, 179, 0, 157, 159, 158, 181, - 0, 0, 603, 0, 0, 182, 161, 165, 164, 0, - 0, 0, 0, 0, 160, 0, 162, 166, 168, 169, - 176, 178, 163, 183, 180, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, - 156, 167, 170, 171, 172, 173, 174, 175, 177, 179, - 574, 0, 0, 593, 157, 159, 158, 181, 0, 0, - 182, 161, 165, 164, 0, 0, 0, 0, 0, 160, - 0, 162, 166, 168, 169, 176, 178, 163, 0, 0, - 0, 183, 180, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 155, 156, 167, - 170, 171, 172, 173, 174, 175, 177, 179, 0, 157, - 159, 158, 181, 0, 0, 591, 0, 0, 182, 161, - 165, 164, 0, 0, 0, 0, 0, 160, 0, 162, - 166, 168, 169, 176, 178, 163, 183, 180, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 155, 156, 167, 170, 171, 172, 173, 174, - 175, 177, 179, 0, 157, 159, 158, 181, 0, 0, - 0, 0, 0, 182, 161, 165, 164, 0, 0, 0, - 0, 0, 160, 0, 162, 166, 168, 169, 176, 178, - 163, 183, 180, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 155, 156, 167, - 170, 171, 172, 173, 174, 175, 177, 179, 0, 157, - 159, 158, 181, 570, 0, 0, 0, 0, 182, 161, - 165, 164, 0, 0, 0, 0, 0, 160, 0, 162, - 166, 168, 169, 176, 178, 163, 183, 180, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 155, 156, 167, 170, 171, 172, 173, 174, - 175, 177, 179, 0, 157, 159, 158, 181, 0, 0, - 565, 0, 0, 182, 161, 165, 164, 0, 0, 0, - 0, 0, 160, 0, 162, 166, 168, 169, 176, 178, - 163, 183, 180, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 155, 156, 167, - 170, 171, 172, 173, 174, 175, 177, 179, 0, 157, - 159, 158, 181, 0, 0, 561, 0, 0, 182, 161, - 165, 164, 0, 0, 0, 0, 0, 160, 0, 162, - 166, 168, 169, 176, 178, 163, 183, 180, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 417, 0, - 0, 0, 155, 156, 167, 170, 171, 172, 173, 174, - 175, 177, 179, 0, 0, 0, 0, 0, 0, 0, - 423, 0, 0, 182, 161, 165, 164, 157, 159, 158, - 181, 0, 160, 0, 162, 166, 168, 169, 176, 178, - 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 183, 180, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 155, 156, 167, 170, 171, 172, 173, 174, 175, 177, - 179, 0, 157, 159, 158, 181, 0, 0, 0, 0, - 0, 182, 161, 165, 164, 0, 0, 0, 0, 0, - 160, 0, 162, 166, 168, 169, 176, 178, 163, 183, - 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 155, 156, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 377, 157, 159, 158, 181, 0, 182, 161, 165, 164, - 0, 0, 0, 0, 0, 160, 0, 162, 166, 168, - 169, 176, 178, 163, 0, 0, 0, 0, 183, 180, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 167, 170, 171, 172, - 173, 174, 175, 177, 179, 0, 0, 0, 0, 154, - 157, 159, 158, 181, 0, 182, 161, 165, 164, 0, - 0, 0, 0, 0, 160, 0, 162, 166, 168, 169, - 176, 178, 163, 0, 0, 0, 0, 183, 180, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 155, 156, 167, 170, 171, 172, 173, - 174, 175, 177, 179, 0, 0, 159, 158, 181, 0, - 0, 0, 0, 0, 182, 161, 165, 164, 0, 0, - 0, 0, 0, 160, 0, 162, 166, 168, 169, 176, - 178, 163, 183, 180, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 155, 156, - 167, 170, 171, 172, 173, 174, 175, 177, 179, 0, - 0, 0, 158, 181, 0, 0, 0, 0, 0, 182, - 161, 165, 164, 0, 0, 0, 0, 0, 160, 0, - 162, 166, 168, 169, 176, 178, 163, 183, 180, 434, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 155, 156, 167, 170, 171, 172, 173, - 174, 175, 177, 179, 0, 0, 0, 0, 0, 0, - 0, 181, 0, 0, 182, 161, 165, 164, 0, 0, - 0, 0, 0, 160, 0, 162, 166, 168, 169, 176, - 178, 163, 0, 0, 0, 183, 180, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 155, 156, 167, 170, 171, 172, 173, 174, 175, - 177, 179, 0, 0, 0, 0, 181, 0, 0, 0, - 0, 0, 182, 161, 165, 164, 0, 0, 0, 0, - 0, 160, 0, 162, 166, 168, 169, 176, 178, 163, - 183, 180, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 155, 156, 167, 170, - 171, 172, 173, 174, 175, 177, 179, 0, 0, 0, - 0, 181, 0, 0, 0, 0, 0, 182, 161, 165, - 164, 0, 0, 0, 0, 0, 160, 0, 162, 166, - 168, 169, 176, 178, 163, 183, 180, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 155, 156, 167, 170, 171, 172, 173, 174, 175, - 177, 179, 0, 0, 0, 181, 0, 0, 0, 0, - 0, 0, 0, 161, 165, 164, 0, 0, 0, 0, - 0, 160, 0, 162, 166, 168, 169, 176, 178, 163, - 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 181, 156, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 161, 165, 164, - 180, 0, 0, 0, 0, 160, 0, 162, 166, 168, - 169, 176, 178, 163, 0, 181, 0, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 161, 165, 164, - 180, 0, 0, 0, 0, 160, 0, 162, 166, 168, - 169, 176, 178, 163, 0, 181, 0, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 161, 165, 164, - 180, 0, 0, 0, 0, 0, 0, 162, 166, 168, - 169, 176, 178, 163, 0, 181, 0, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 161, 165, 164, - 180, 0, 0, 0, 0, 0, 0, 0, 166, 168, - 169, 176, 178, 163, 0, 0, 0, 167, 170, 171, - 172, 173, 174, 175, 177, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 165, 164, - 449, 450, 460, 461, 0, 0, 440, 0, 166, 168, - 169, 176, 178, 163, 0, 465, 466, 467, 468, 469, - 470, 471, 472, 473, 474, 475, 495, 496, 497, 498, - 499, 487, 488, 489, 516, 490, 491, 476, 477, 478, - 479, 480, 481, 482, 483, 484, 485, 486, 0, 507, - 505, 506, 502, 503, 0, 0, 494, 500, 501, 508, - 509, 511, 510, 512, 513, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 504, 515, 514, 0, - 0, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 462, 463, 464, 492, 493, 443, 444, 445, 446, 447, - 448, 449, 450, 460, 461, 0, 0, 923, 0, 0, - 0, 0, 0, 0, 0, 0, 465, 466, 467, 468, - 469, 470, 471, 472, 473, 474, 475, 495, 496, 497, - 498, 499, 487, 488, 489, 516, 490, 491, 476, 477, - 478, 479, 480, 481, 482, 483, 484, 485, 486, 0, - 507, 505, 506, 502, 503, 0, 0, 494, 500, 501, - 508, 509, 511, 510, 512, 513, 119, 0, 107, 0, - 0, 0, 0, 0, 112, 0, 0, 504, 515, 514, - 0, 0, 451, 452, 453, 454, 455, 456, 457, 458, - 459, 462, 463, 464, 492, 493, 752, 753, 754, 751, - 750, 749, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 671, 111, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 136, 0, 0, 114, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 237, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 235, 0, 672, 0, 0, 670, - 0, 0, 0, 0, 0, 108, -} -var yyPact = [...]int{ - - -1000, -1000, 1251, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 264, 483, 651, 766, -1000, -1000, -1000, 262, 4342, 261, - 259, 5524, 5524, 5524, 183, 776, 5524, -1000, 6743, 258, - 257, 256, -1000, 405, 5524, 820, 281, 32, 504, 819, - 805, 799, 456, 507, 408, -1000, -1000, 254, -1000, -1000, - 134, 253, 4726, 5524, 688, 688, 5524, 5524, 5524, 5524, - 5524, -1000, -1000, 5524, 5524, 5524, 5524, 5524, 5524, 5524, - 252, 5524, -1000, 811, 5524, 5524, 5524, -1000, -1000, -1000, - -1000, 101, -1000, 517, 506, -1000, 184, 251, 249, 5524, - 5524, 244, 5524, 5524, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 765, 757, 32, -1000, 215, 203, - 203, 239, -1000, 490, 737, 170, 737, 295, -1000, -1000, - 345, 602, -9, 619, 737, -1000, -1000, -1000, -1000, -15, - -1000, -59, 3147, 5524, 700, 32, 477, 5524, 5524, 337, - 6802, 666, 333, 332, -18, -1000, -1000, -19, -1000, -1000, - -60, -24, -1000, 6802, -1000, 5524, 5524, 5524, 5524, 5524, - 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, - 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, 5524, - 5524, 230, 5410, 5524, 688, 5524, 766, -1000, 6684, 331, - -1000, 794, -1000, 785, -1000, 591, -1000, 595, 233, 4342, - 228, 319, 275, 5296, 5524, 5524, 5524, 5524, 5524, 5524, - 5524, 5524, 5524, 5524, 5524, 5524, 5524, -1000, -1000, 5524, - 5524, 5524, 104, 4726, 98, 22, -1000, -1000, 6629, 688, - 5524, 225, -1000, -1000, 101, 5524, -1000, -1000, 4726, -1000, - 412, 412, 461, 412, 6561, 412, 412, 412, 412, 412, - 412, 412, -1000, 5524, 412, 219, 616, 707, -1000, 198, - 5182, 688, 7025, 6970, 7025, 5524, 3461, 3461, 203, -1000, - 505, 227, 203, -1000, -1000, 5524, 5524, 6802, 6802, 5524, - 6802, 6802, 742, -1000, 734, 575, 616, 221, 5524, -1000, - -1000, 4840, -1000, 4726, 782, 490, 318, 490, -1000, -1000, - 1093, -1000, 316, -28, 582, 737, -1000, 597, 511, 770, - 551, -1000, -1000, 766, 5524, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 218, 6506, 216, -1000, 315, -8, 6802, - 6451, -1000, -1000, -1000, -1000, 183, -1000, 733, 5524, -1000, - 5524, 7134, 7174, 6857, 7025, 6912, 7214, 7294, 7254, 132, - 132, 132, 461, 412, 461, 461, 64, 64, 168, 168, - 168, 168, 351, 351, 351, 351, 168, -1000, 6396, 5524, - 7080, -11, -1000, -1000, 6341, -30, 2989, -1000, -1000, -1000, - 212, 591, 569, 587, 403, -1000, 587, 5524, -1000, 5524, - -1000, -1000, 7025, 5524, 7025, 7025, 7025, 7025, 7025, 7025, - 7025, 7025, 7025, 7025, 7025, 7025, 7025, 6286, 96, 6228, - 203, -1000, 5524, -1000, 167, -65, 4726, 5068, -1000, 6802, - 4726, 6173, 84, -1000, 165, -1000, -1000, -1000, -1000, 190, - 751, 6115, 93, 363, 5524, 81, 203, -1000, -1000, 5524, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, 203, -1000, -1000, - -1000, -1000, 183, 5524, 5524, 104, 183, 591, -12, -1000, - 6802, 6060, 6005, -1000, -1000, -1000, 285, 5947, -1000, -13, - -1000, 6802, 5524, 163, -1000, -1000, 935, -1000, -1000, -1000, - 502, 550, -1000, 737, 539, 689, -1000, 501, -1000, 6802, - 158, 4186, 5524, 5524, 5524, 208, -1000, -1000, 6802, -1000, - 5524, 7080, 155, 688, 7606, 4030, -1000, 192, 285, 569, - -1000, 587, -1000, -1000, 400, -40, -1000, 5892, 5837, 2831, - 7294, 3874, -1000, -1000, -1000, 5779, -66, 5524, -1000, 6802, - 688, 182, 151, -1000, -1000, -1000, 50, -1000, -1000, 709, - -1000, -1000, -1000, -1000, 5524, -1000, 7025, -1000, -1000, 5721, - -1000, -1000, 47, 5663, -1000, -1000, 569, 144, 5524, -1000, - -1000, 142, -16, -1000, 35, -1000, -1000, 552, -1000, -1000, - -1000, -1000, 141, 4954, 6802, -1000, -1000, 737, 499, -34, - -1000, -1000, 737, 689, -1000, 314, -1000, -1000, -1000, 5608, - 313, 6802, -1000, 312, 311, 7080, 307, -1000, 139, 562, - 688, 177, 4726, -1000, -1000, -1000, 620, 285, 138, -1000, - 396, -40, 1433, -1000, 587, 4342, 272, 303, -1000, -1000, - -1000, 5524, 7025, -1000, 4726, -66, -1000, -1000, 5553, -1000, - -1000, -1000, -1000, -1000, -1000, 269, 285, 475, -1000, -1000, - -1000, -1000, -35, -1000, 737, 362, 689, -1000, -34, -1000, - 2673, 302, 5524, 411, -1000, 793, -1000, -1000, 3562, 7606, - -1000, 4726, 40, 2515, -1000, 169, 395, 121, 611, 379, - -1000, -1000, -1000, 285, 647, 587, 612, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, 1275, -1000, -1000, -1000, -1000, - 3305, 7025, 119, 350, 378, -1000, 285, -1000, 729, -1000, - 349, 737, -35, -1000, -1000, 347, 301, -1000, 113, -1000, - 5524, 174, 401, 300, 775, -1000, -1000, -1000, 111, -1000, - 108, -1000, 299, 587, -1000, 269, 269, 133, -1000, 1117, - 713, 7446, 32, -31, -1000, -1000, 3305, -66, -1000, -1000, - 560, -1000, -67, -1000, -1000, 286, -1000, -1000, 3718, 335, - -1000, -1000, -1000, -1000, -1000, 292, 2357, 3562, -1000, -1000, - 89, -1000, 2199, 375, 374, 214, 959, -1000, -36, -1000, - -70, -37, -1000, -73, 7446, -1000, -1000, 4625, 538, 5524, - 5524, -1000, -1000, -1000, -1000, -1000, 3305, -1000, 290, -1000, - 106, 587, -1000, -1000, -1000, -43, -1000, -1000, 725, -1000, - -1000, 713, -1000, 5524, -1000, 7446, 5524, -1000, -1000, 4498, - -1000, 284, 217, 608, 680, 497, -1000, 477, -1000, -1000, - 7025, 6802, 2041, 3305, -1000, 366, -1000, 1883, 1725, -1000, - 214, -1000, -1000, 6802, -1000, 6802, 105, -1000, -1000, -1000, - -1000, 587, 7547, 7446, 185, -1000, -1000, -1000, -1000, -1000, - -1000, 285, -40, -1000, -1000, 7446, -1000, -1000, 1567, 103, - -1000, -1000, 269, 283, -1000, -1000, -1000, 1409, -1000, -} -var yyPgo = [...]int{ - - 0, 931, 929, 14, 8, 928, 4, 29, 13, 927, - 11, 44, 78, 71, 52, 48, 926, 26, 924, 83, - 21, 82, 916, 0, 84, 915, 914, 42, 190, 32, - 19, 38, 913, 79, 73, 912, 5, 911, 910, 909, - 908, 15, 62, 905, 904, 100, 87, 274, 903, 902, - 901, 6, 900, 86, 41, 899, 56, 49, 898, 897, - 896, 895, 894, 99, 893, 892, 890, 883, 10, 882, - 881, 46, 39, 40, 2, 16, 705, 43, 85, 880, - 879, 878, 12, 876, 875, 555, 50, 37, 871, 870, - 9, 762, 20, 553, 868, 18, 867, 864, 862, 88, - 860, 36, 858, 855, 25, 33, 854, 853, 45, 848, - 846, 554, 845, 844, 839, 34, 837, 80, 1, 3, - 832, 17, 831, 821, 803, 7, 767, 28, 752, -} -var yyR1 = [...]int{ - - 0, 128, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 6, 6, 117, - 117, 95, 95, 10, 10, 10, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 91, 91, 16, 16, 18, 18, 7, 7, 105, - 105, 104, 104, 111, 111, 17, 17, 20, 20, 19, - 19, 99, 99, 118, 118, 22, 22, 22, 22, 22, - 22, 22, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 97, 97, 96, 96, - 26, 26, 110, 110, 27, 12, 1, 1, 2, 2, - 13, 13, 126, 126, 76, 76, 14, 15, 86, 86, - 88, 88, 87, 87, 92, 92, 92, 92, 83, 83, - 82, 82, 25, 25, 80, 80, 80, 80, 108, 108, - 108, 8, 8, 84, 84, 67, 67, 65, 65, 69, - 69, 66, 66, 119, 119, 120, 120, 29, 29, 30, - 30, 75, 75, 73, 73, 73, 74, 74, 77, 77, - 116, 116, 31, 31, 103, 103, 33, 107, 107, 34, - 34, 121, 121, 35, 35, 35, 35, 125, 125, 79, - 79, 79, 109, 109, 36, 36, 37, 38, 38, 38, - 38, 40, 40, 39, 81, 81, 123, 123, 122, 122, - 124, 124, 90, 90, 90, 90, 90, 90, 106, 106, - 41, 41, 98, 98, 68, 21, 100, 100, 42, 101, - 101, 102, 102, 44, 43, 43, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 85, 85, 127, 3, 3, 89, 89, - 112, 112, 51, 51, 52, 52, 52, 52, 45, 45, - 46, 46, 49, 49, 94, 94, 94, 78, 78, 56, - 56, 56, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 57, 57, - 57, 23, 23, 24, 24, 55, 58, 58, 58, 59, - 59, 59, 60, 60, 60, 60, 60, 60, 28, 28, - 28, 47, 47, 47, 61, 61, 62, 62, 62, 62, - 62, 62, 53, 53, 53, 54, 54, 54, 115, 71, - 71, 114, 114, 70, 70, 70, 70, 70, 70, 70, - 93, 93, 93, 93, 63, 63, 63, 63, 63, 63, - 63, 64, 64, 64, 64, 48, 48, 48, 48, 48, - 48, 48, 113, 113, 72, -} -var yyR2 = [...]int{ - - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 0, 1, 3, 1, 3, 2, 1, 1, 1, 1, - 1, 1, 4, 3, 5, 4, 3, 4, 3, 4, - 3, 1, 1, 6, 7, 6, 7, 0, 1, 3, - 1, 3, 1, 3, 1, 1, 2, 1, 3, 1, - 2, 3, 1, 2, 0, 1, 1, 1, 1, 1, - 1, 4, 3, 1, 1, 5, 7, 9, 5, 3, - 3, 3, 3, 3, 3, 1, 2, 6, 7, 9, - 5, 1, 6, 3, 3, 2, 0, 9, 1, 3, - 0, 4, 1, 3, 1, 11, 0, 1, 0, 1, - 9, 8, 1, 2, 1, 1, 6, 7, 0, 2, - 0, 2, 0, 2, 1, 2, 4, 3, 1, 4, - 1, 4, 1, 4, 3, 4, 4, 5, 0, 5, - 4, 1, 1, 1, 4, 5, 6, 1, 3, 6, - 7, 3, 6, 1, 0, 1, 3, 4, 6, 0, - 1, 1, 2, 1, 1, 1, 0, 2, 2, 4, - 1, 3, 1, 2, 3, 1, 1, 3, 1, 1, - 3, 2, 0, 4, 4, 3, 10, 1, 3, 1, - 2, 3, 1, 2, 2, 2, 3, 3, 3, 4, - 3, 1, 1, 3, 1, 3, 1, 1, 0, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, - 2, 4, 3, 1, 4, 4, 3, 1, 1, 0, - 1, 3, 1, 8, 3, 2, 6, 5, 3, 4, - 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 1, 5, 4, 3, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 1, 3, 2, 1, 2, 4, - 2, 1, 2, 11, 9, 0, 0, 1, 0, 4, - 3, 1, 1, 2, 2, 4, 4, 2, 1, 1, - 1, 1, 0, 3, 0, 1, 1, 0, 1, 4, - 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 2, 3, 3, 1, 1, 1, 3, - 3, 1, 1, 0, 1, 1, 1, 3, 1, 1, - 3, 1, 1, 4, 4, 4, 4, 1, 1, 1, - 3, 1, 4, 2, 3, 3, 1, 4, 4, 3, - 3, 3, 1, 3, 1, 1, 3, 1, 1, 0, - 1, 3, 1, 3, 1, 4, 2, 2, 6, 4, - 2, 2, 1, 2, 1, 4, 3, 3, 3, 6, - 3, 1, 1, 2, 1, 5, 4, 2, 2, 4, - 2, 2, 1, 3, 1, -} -var yyChk = [...]int{ - - -1000, -128, -117, -9, 2, -11, -12, -13, -14, -15, - 52, 80, 45, 39, 144, -65, -66, 21, 20, 23, - 30, 34, 35, 40, 47, 99, 19, 14, -23, 49, - 25, 27, 146, 41, 44, 36, 10, 37, -126, 53, - 54, 55, -67, -69, -28, -32, -76, 7, -60, -61, - -58, 60, 150, 93, 105, 106, 155, 154, 156, 157, - 148, -43, -48, 108, 109, 110, 111, 112, 113, 114, - 6, 158, -50, 143, 97, 98, 107, -85, 100, 101, - -47, -57, -52, -45, -55, -56, 92, 50, 51, 4, - 5, 85, 86, 87, 8, 9, 67, 68, 82, 64, - 65, 66, 81, 63, 75, 142, 38, 12, 159, -10, - -59, 61, 18, -95, 83, 148, 83, -95, 144, 10, - -18, -91, -111, -95, 83, 37, 39, -19, -20, -99, - -21, 10, -118, 148, -11, 37, 80, 148, 148, -24, - -23, 99, -24, -24, -103, -33, -47, -107, -85, -34, - 12, -100, -42, -23, 146, 131, 132, 88, 90, 89, - 161, 153, 163, 169, 155, 154, 164, 133, 165, 166, - 134, 135, 136, 137, 138, 139, 167, 140, 168, 141, - 116, 91, 152, 115, 148, 148, 148, 144, -23, 10, - 147, -3, 153, 53, -76, 10, 10, 10, 94, 95, - 94, 96, 95, 162, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, 128, 129, 130, 105, 106, 148, - 150, 144, 58, 148, -115, -114, -71, -70, -23, 153, - 84, 60, -23, -28, -57, 148, -56, 99, 150, -28, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -49, 148, -23, -94, 17, -93, -63, 12, - 77, 78, -23, -23, -23, 150, 79, 79, -46, -44, - -45, -62, 53, -10, -47, 148, 148, -23, -23, 148, - -23, -23, 17, 76, -93, -93, 17, -3, 144, -47, - -77, 148, -77, 148, 83, -95, 149, -95, 146, 144, - -117, 146, -16, -111, -95, 83, 146, 160, 83, 29, - -95, -20, 146, 160, 162, -22, 145, 2, -11, -12, - -13, -14, -15, 52, -23, 21, -3, -101, -102, -23, - -23, 146, 146, 146, 146, 160, 146, 160, 162, 146, - 160, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -46, -23, 147, - -23, -110, -27, -28, -23, -99, -118, 146, 146, 10, - -127, 10, -86, 56, -127, -88, 56, 148, -11, 148, - 146, 147, -23, 153, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, -24, -23, - -54, 10, 144, -47, -115, 151, 160, 59, -28, -23, - 148, -23, -115, 149, -24, 143, -63, -63, 17, 150, - 58, -23, 11, -28, 59, -24, -53, -6, -47, 144, - 10, -5, -4, 99, 100, 101, 102, 103, 104, 4, - 5, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 6, 7, 94, 95, 96, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 35, 36, 37, - 39, 40, 97, 98, 60, 30, 31, 32, 33, 34, - 61, 62, 56, 57, 80, 54, 55, 53, 63, 64, - 66, 65, 67, 68, 82, 81, 38, -53, -6, -47, - -78, -77, 79, 150, 144, 58, 79, -78, -113, -72, - -23, -23, -23, 76, 76, 142, 148, -23, 149, -116, - -31, -23, 84, -115, 10, 146, -117, 145, 146, 146, - 83, -95, -19, 83, -95, 144, 10, 83, -21, -23, - 148, 149, 148, 146, 160, 149, -33, -34, -23, -42, - 147, -23, -7, 160, 29, 149, 145, -127, 148, -86, - -87, 57, -10, 144, -127, -125, -10, -23, -23, -118, - -23, 149, 151, 145, -77, -23, 149, 162, -71, -23, - 153, 60, -115, 149, 151, 149, -64, 10, 13, 154, - 12, 10, 145, 145, 150, 145, -23, 151, -77, -23, - -77, -47, -24, -23, -54, -47, -86, -7, 160, 149, - 149, -119, -120, -29, -30, -75, -73, 152, 61, 62, - -10, 145, -7, 160, -23, 149, 145, 144, 83, -105, - -17, -20, -91, 144, -127, 149, -84, -11, 147, -23, - -101, -23, -80, 144, 147, -23, 149, -27, -92, -28, - 153, 60, 150, -25, -11, 147, -97, 148, -119, -87, - -127, -125, -121, 144, 160, 149, 149, 96, -11, 147, - 145, 162, -23, -28, 148, 149, 151, 13, -23, 145, - 151, 145, -87, 149, -72, 149, 160, -1, 153, -73, - 149, -31, -104, -20, 144, -7, 160, -20, -105, 146, - -118, 149, 146, -108, 146, -108, 146, 146, 149, 59, - -28, 148, -115, -118, -26, 42, 43, -119, 149, -127, - 144, 145, -35, -123, -122, 45, -124, 48, -90, 104, - 103, 102, 99, 100, 101, -121, -10, -11, 147, 146, - -118, -23, -115, 151, -127, -74, 147, -29, -2, 84, - -7, 160, -104, 145, -17, -7, 22, 146, -101, 145, - 32, 33, -108, 31, -108, -82, -11, 147, -92, -28, - -115, 151, 28, 148, 144, 149, -89, 45, 144, -121, - -30, 39, 37, -125, -90, 145, -118, 149, 145, 144, - -127, -75, 12, 145, -20, -7, 145, 146, 149, -23, - -8, 147, 146, 145, 146, 31, -118, 149, 149, 146, - -96, -10, -118, -74, -74, 148, -121, 145, -106, -41, - 12, -98, -68, -6, -3, -79, 146, 144, -121, 59, - 162, 145, -83, -11, 147, -8, -118, 146, 26, -82, - 12, 161, 145, 144, 144, -112, -51, 12, 153, 145, - 146, 160, -127, 162, 146, 160, 162, -6, 145, -109, - -36, -37, -38, -39, -40, -10, -6, 80, 10, 145, - -23, -23, -118, -118, 146, 149, -10, -118, -118, 149, - 160, 12, -41, -23, -68, -23, -127, 145, -36, 146, - 146, 46, 29, 79, 24, 144, 145, 145, -51, -127, - -127, 148, -125, 10, -4, -90, -6, 146, -118, -119, - -6, 145, 149, -74, -81, 146, 144, -118, 145, -} -var yyDef = [...]int{ - - 80, -2, -2, 79, 86, 87, 88, 89, 90, 91, - 0, 0, 0, 0, 124, 133, 134, 0, 0, 0, - 0, 423, 423, 423, 0, 388, 0, 145, 0, 0, - 0, 0, 151, 0, 0, 0, 81, 376, 0, 0, - 0, 0, 207, 0, -2, 422, 172, 0, -2, 439, - 425, 0, 459, 0, 0, 0, 0, 0, 0, 0, - 0, 350, 354, 0, 0, 0, 0, 0, 0, 0, - 392, 0, 364, 394, 0, 367, 0, 371, 174, 175, - 432, 417, 437, 0, 0, -2, 0, 0, 0, 0, - 0, 0, 0, 0, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 0, 0, 376, 441, 0, -2, - 0, 0, 401, 83, 0, 0, 0, 0, 80, 81, - 0, 0, 0, 117, 0, 101, 102, 114, 119, 0, - 122, 0, 0, 0, 0, 376, 0, 289, 0, 0, - 424, 388, 0, 0, 0, 235, 236, 0, 372, 238, - 239, 0, 287, 288, 146, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 124, 0, 0, - 155, 375, 377, 0, 173, 178, 375, 180, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 314, 316, 0, - 423, 0, 0, 459, 0, 458, 462, 460, 464, 0, - 0, 0, 300, -2, 0, 0, -2, 388, 459, -2, - 335, 336, 337, 338, 0, 355, 356, 357, 358, 359, - 360, 361, 362, 423, 363, 0, 395, 396, 472, 474, - 0, 0, 366, 368, 370, 423, 0, 0, 397, 295, - 390, 391, 397, 389, 446, 0, 0, 487, 488, 0, - 490, 491, 0, 413, 0, 0, 0, 0, 0, 443, - 384, 0, 387, 459, 0, 85, 0, 84, 93, 80, - 0, 96, 0, 0, 117, 0, 98, 0, 0, 0, - 117, 120, 100, 0, 0, 123, 132, 125, 126, 127, - 128, 129, 130, 0, 0, 0, 375, 0, 290, 292, - 0, 139, 140, 141, 142, 0, 143, 0, 0, 144, - 0, 318, 319, 320, 321, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, 332, 333, 334, -2, -2, - -2, -2, -2, -2, -2, -2, -2, 348, 0, 0, - 353, 107, 162, -2, 0, 0, 0, 153, 154, 375, - 0, 178, 182, 0, 0, 375, 0, 0, 208, 0, - 211, 124, 298, 0, 301, 302, 303, 304, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 0, 0, 0, - 440, 455, 0, 457, 0, 400, 459, 0, -2, 467, - 459, 0, 0, -2, 0, 365, 473, 470, 471, 0, - 0, 0, 0, 426, 0, 0, 0, -2, -2, 0, - 77, 78, 70, 71, 72, 73, 74, 75, 76, 2, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 0, -2, -2, - 294, 398, 0, 423, 0, 0, 0, 178, 107, 492, - 494, 0, 0, 412, 415, 414, -2, 0, 228, 107, - 230, 232, 0, 0, 82, 92, 0, 95, 97, 99, - 0, 117, 113, 0, 117, 0, 118, 0, 121, 375, - 0, 0, 0, 289, 0, 0, 234, 237, 240, 286, - 0, 352, 0, 108, 0, 0, 156, 0, -2, 182, - 375, 0, 179, 242, 0, 181, 247, 0, 0, 0, - 299, 0, 433, 435, 436, 0, 0, 0, 461, 463, - 0, 0, 0, -2, 400, 393, 0, 481, 482, 0, - 484, 476, 477, 478, 0, 480, 369, 434, 385, 0, - 386, 450, 0, 0, 449, 451, 182, 0, 108, 486, - 489, 0, 213, 215, 166, 220, 221, 0, 223, 224, - 225, 442, 0, 108, 233, 399, 94, 0, 0, 107, - 110, 115, 0, 0, 285, 0, 135, 203, 124, 0, - 0, 291, 138, 198, 198, 351, 0, 163, 0, -2, - 0, 0, 459, 150, 192, 124, 160, -2, 0, 375, - 0, 183, 268, 242, 0, 0, 0, 0, 205, 124, - 456, 0, 297, -2, 459, 469, 475, 483, 0, 453, - 447, 448, 375, 485, 493, 226, 219, 168, 167, 222, - 229, 231, 107, 112, 0, 0, 108, 116, 107, 131, - 0, 0, 289, 0, 198, 0, 198, 147, 0, 0, - -2, 459, 0, 0, 152, 0, 0, 0, 378, 0, - 242, 176, 241, 219, 0, 0, -2, 267, 270, 272, - 273, 274, 275, 276, 277, 268, 248, 206, 124, 212, - -2, 296, 0, 0, 0, 375, 0, 216, 0, 169, - 0, 108, 107, 105, 109, 0, 0, 136, 0, 194, - 0, 0, 0, 0, 0, 148, 190, 124, 0, -2, - 0, -2, 0, 0, 124, 226, 226, 0, 242, 268, - 0, 0, 376, 0, 271, 177, -2, 468, 479, 242, - 0, 227, 217, 103, 111, 0, 106, 204, 0, 0, - 124, 201, 202, 195, 196, 0, 0, 0, 186, 193, - 0, 158, 0, 0, 0, 0, 268, 171, 0, 279, - 375, 0, 283, 0, 0, 245, 249, 0, 268, 0, - 0, 104, 137, 188, 124, 124, -2, 197, 0, 149, - 0, 0, 161, 124, 124, 0, 381, 382, 0, 170, - 243, 0, 280, 0, 244, 0, 0, 375, 250, 0, - 252, 0, 0, 262, 0, 0, 261, 57, -2, 293, - 374, 218, 0, -2, 191, 0, 159, 0, 0, 379, - 0, 383, 278, 375, 282, 375, 0, 251, 253, 254, - 255, 0, 0, 0, 0, 124, 165, 373, 380, 281, - 284, -2, 256, 257, 258, 260, 263, 189, 0, 0, - 259, 157, 226, 0, 246, 264, 124, 0, 265, -} -var yyTok1 = [...]int{ - - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 156, 142, 3, 159, 166, 153, 3, - 148, 149, 164, 155, 160, 154, 169, 165, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 147, 146, - 167, 162, 168, 152, 158, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 150, 3, 151, 163, 3, 143, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 144, 161, 145, 157, -} -var yyTok2 = [...]int{ - - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, -} -var yyTok3 = [...]int{ - 0, -} - -var yyErrorMessages = [...]struct { - state int - token int - msg string -}{} - -// line yaccpar:1 - -/* parser for yacc output */ - -var ( - yyDebug = 0 - yyErrorVerbose = true -) - -type yyLexer interface { - Lex(lval *yySymType) int - Error(s string) -} - -type yyParser interface { - Parse(yyLexer) int - Lookahead() int -} - -type yyParserImpl struct { - lval yySymType - stack [yyInitialStackSize]yySymType - char int -} - -func (p *yyParserImpl) Lookahead() int { - return p.char -} - -func yyNewParser() yyParser { - return &yyParserImpl{} -} - -const yyFlag = -1000 - -func yyTokname(c int) string { - if c >= 1 && c-1 < len(yyToknames) { - if yyToknames[c-1] != "" { - return yyToknames[c-1] - } - } - return __yyfmt__.Sprintf("tok-%v", c) -} - -func yyStatname(s int) string { - if s >= 0 && s < len(yyStatenames) { - if yyStatenames[s] != "" { - return yyStatenames[s] - } - } - return __yyfmt__.Sprintf("state-%v", s) -} - -func yyErrorMessage(state, lookAhead int) string { - const TOKSTART = 4 - - if !yyErrorVerbose { - return "syntax error" - } - - for _, e := range yyErrorMessages { - if e.state == state && e.token == lookAhead { - return "syntax error: " + e.msg - } - } - - res := "syntax error: unexpected " + yyTokname(lookAhead) - - // To match Bison, suggest at most four expected tokens. - expected := make([]int, 0, 4) - - // Look for shiftable tokens. - base := yyPact[state] - for tok := TOKSTART; tok-1 < len(yyToknames); tok++ { - if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok { - if len(expected) == cap(expected) { - return res - } - expected = append(expected, tok) - } - } - - if yyDef[state] == -2 { - i := 0 - for yyExca[i] != -1 || yyExca[i+1] != state { - i += 2 - } - - // Look for tokens that we accept or reduce. - for i += 2; yyExca[i] >= 0; i += 2 { - tok := yyExca[i] - if tok < TOKSTART || yyExca[i+1] == 0 { - continue - } - if len(expected) == cap(expected) { - return res - } - expected = append(expected, tok) - } - - // If the default action is to accept or reduce, give up. - if yyExca[i+1] != 0 { - return res - } - } - - for i, tok := range expected { - if i == 0 { - res += ", expecting " - } else { - res += " or " - } - res += yyTokname(tok) - } - return res -} - -func yylex1(lex yyLexer, lval *yySymType) (char, token int) { - token = 0 - char = lex.Lex(lval) - if char <= 0 { - token = yyTok1[0] - goto out - } - if char < len(yyTok1) { - token = yyTok1[char] - goto out - } - if char >= yyPrivate { - if char < yyPrivate+len(yyTok2) { - token = yyTok2[char-yyPrivate] - goto out - } - } - for i := 0; i < len(yyTok3); i += 2 { - token = yyTok3[i+0] - if token == char { - token = yyTok3[i+1] - goto out - } - } - -out: - if token == 0 { - token = yyTok2[1] /* unknown char */ - } - if yyDebug >= 3 { - __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char)) - } - return char, token -} - -func yyParse(yylex yyLexer) int { - return yyNewParser().Parse(yylex) -} - -func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int { - var yyn int - var yyVAL yySymType - var yyDollar []yySymType - _ = yyDollar // silence set and not used - yyS := yyrcvr.stack[:] - - Nerrs := 0 /* number of errors */ - Errflag := 0 /* error recovery flag */ - yystate := 0 - yyrcvr.char = -1 - yytoken := -1 // yyrcvr.char translated into internal numbering - defer func() { - // Make sure we report no lookahead when not parsing. - yystate = -1 - yyrcvr.char = -1 - yytoken = -1 - }() - yyp := -1 - goto yystack - -ret0: - return 0 - -ret1: - return 1 - -yystack: - /* put a state and value onto the stack */ - if yyDebug >= 4 { - __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate)) - } - - yyp++ - if yyp >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyS[yyp] = yyVAL - yyS[yyp].yys = yystate - -yynewstate: - yyn = yyPact[yystate] - if yyn <= yyFlag { - goto yydefault /* simple state */ - } - if yyrcvr.char < 0 { - yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) - } - yyn += yytoken - if yyn < 0 || yyn >= yyLast { - goto yydefault - } - yyn = yyAct[yyn] - if yyChk[yyn] == yytoken { /* valid shift */ - yyrcvr.char = -1 - yytoken = -1 - yyVAL = yyrcvr.lval - yystate = yyn - if Errflag > 0 { - Errflag-- - } - goto yystack - } - -yydefault: - /* default state action */ - yyn = yyDef[yystate] - if yyn == -2 { - if yyrcvr.char < 0 { - yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) - } - - /* look through exception table */ - xi := 0 - for { - if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate { - break - } - xi += 2 - } - for xi += 2; ; xi += 2 { - yyn = yyExca[xi+0] - if yyn < 0 || yyn == yytoken { - break - } - } - yyn = yyExca[xi+1] - if yyn < 0 { - goto ret0 - } - } - if yyn == 0 { - /* error ... attempt to resume parsing */ - switch Errflag { - case 0: /* brand new error */ - yylex.Error(yyErrorMessage(yystate, yytoken)) - Nerrs++ - if yyDebug >= 1 { - __yyfmt__.Printf("%s", yyStatname(yystate)) - __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken)) - } - fallthrough - - case 1, 2: /* incompletely recovered error ... try again */ - Errflag = 3 - - /* find a state where "error" is a legal shift action */ - for yyp >= 0 { - yyn = yyPact[yyS[yyp].yys] + yyErrCode - if yyn >= 0 && yyn < yyLast { - yystate = yyAct[yyn] /* simulate a shift of "error" */ - if yyChk[yystate] == yyErrCode { - goto yystack - } - } - - /* the current p has no shift on "error", pop stack */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) - } - yyp-- - } - /* there is no state on the stack with an error shift ... abort */ - goto ret1 - - case 3: /* no shift yet; clobber input char */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken)) - } - if yytoken == yyEofCode { - goto ret1 - } - yyrcvr.char = -1 - yytoken = -1 - goto yynewstate /* try again in the same state */ - } - } - - /* reduction by production yyn */ - if yyDebug >= 2 { - __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate)) - } - - yynt := yyn - yypt := yyp - _ = yypt // guard against "declared and not used" - - yyp -= yyR2[yyn] - // yyp is now the index of $0. Perform the default action. Iff the - // reduced production is ε, $1 is possibly out of range. - if yyp+1 >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyVAL = yyS[yyp+1] - - /* consult goto table to find next state */ - yyn = yyR1[yyn] - yyg := yyPgo[yyn] - yyj := yyg + yyS[yyp].yys + 1 - - if yyj >= yyLast { - yystate = yyAct[yyg] - } else { - yystate = yyAct[yyj] - if yyChk[yystate] != -yyn { - yystate = yyAct[yyg] - } - } - // dummy call; replaced with literal code - switch yynt { - - case 1: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:303 - { - yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) - - // save position - yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) - - yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 2: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 3: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 4: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 5: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 6: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 7: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 8: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 9: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:316 - { - yyVAL.token = yyDollar[1].token - } - case 10: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 11: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 12: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 13: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 14: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 15: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 16: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 17: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 18: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 19: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 20: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 21: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:317 - { - yyVAL.token = yyDollar[1].token - } - case 22: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 23: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 24: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 25: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 26: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 27: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 28: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 29: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 30: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 31: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:318 - { - yyVAL.token = yyDollar[1].token - } - case 32: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 33: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 34: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 35: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 36: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 37: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 38: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 39: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 40: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 41: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:319 - { - yyVAL.token = yyDollar[1].token - } - case 42: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 43: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 44: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 45: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 46: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 47: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 48: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 49: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 50: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 51: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 52: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:320 - { - yyVAL.token = yyDollar[1].token - } - case 53: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 54: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 55: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 56: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 57: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 58: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 59: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 60: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:321 - { - yyVAL.token = yyDollar[1].token - } - case 61: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 62: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 63: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 64: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 65: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 66: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 67: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 68: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 69: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:322 - { - yyVAL.token = yyDollar[1].token - } - case 70: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:327 - { - yyVAL.token = yyDollar[1].token - } - case 71: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 72: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 73: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 74: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 75: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 76: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:330 - { - yyVAL.token = yyDollar[1].token - } - case 77: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:335 - { - yyVAL.token = yyDollar[1].token - } - case 78: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:339 - { - yyVAL.token = yyDollar[1].token - } - case 79: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:346 - { - 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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 80: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:359 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 81: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:368 - { - namePart := name.NewNamePart(yyDollar[1].token.Value) - yyVAL.list = []node.Node{namePart} - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 82: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:381 - { - namePart := name.NewNamePart(yyDollar[3].token.Value) - yyVAL.list = append(yyDollar[1].list, namePart) - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[3].token)) - - // save comments - 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 83: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:398 - { - yyVAL.node = name.NewName(yyDollar[1].list) - - // save position - 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 84: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:410 - { - yyVAL.node = name.NewRelative(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[3].list)) - - // save comments - 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 85: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:423 - { - yyVAL.node = name.NewFullyQualified(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 86: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:438 - { - // error - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 87: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:445 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 88: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:451 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 89: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:457 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 90: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:463 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 91: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:469 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 92: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:475 - { - yyVAL.node = stmt.NewHaltCompiler() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 93: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:491 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewNamespace(name, nil) - - // save position - 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).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 94: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:508 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewNamespace(name, yyDollar[4].list) - - // save position - 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).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 95: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:525 - { - yyVAL.node = stmt.NewNamespace(nil, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 96: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:539 - { - yyVAL.node = yyDollar[2].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 97: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:553 - { - yyVAL.node = yyDollar[3].node.(*stmt.GroupUse).SetUseType(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 98: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:567 - { - yyVAL.node = stmt.NewUseList(nil, yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 99: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:581 - { - yyVAL.node = stmt.NewUseList(yyDollar[2].node, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 100: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:595 - { - yyVAL.node = stmt.NewConstList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 101: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:612 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 102: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:624 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 103: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:639 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[4].list) - - // save position - 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).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).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).returnTokenToPool(yyDollar, &yyVAL) - } - case 104: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:660 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[5].list) - - // save position - 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).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).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).returnTokenToPool(yyDollar, &yyVAL) - } - case 105: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:685 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[4].list) - - // save position - 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).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).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).returnTokenToPool(yyDollar, &yyVAL) - } - case 106: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:706 - { - name := name.NewName(yyDollar[2].list) - yyVAL.node = stmt.NewGroupUse(nil, name, yyDollar[5].list) - - // save position - 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).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).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).returnTokenToPool(yyDollar, &yyVAL) - } - case 107: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:731 - { - yyVAL.token = nil - } - case 108: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:735 - { - yyVAL.token = yyDollar[1].token - } - case 109: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:742 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 110: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:751 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 111: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:760 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 112: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:769 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 113: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:778 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 114: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:787 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 115: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:796 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 116: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:802 - { - yyVAL.node = yyDollar[2].node.(*stmt.Use).SetUseType(yyDollar[1].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 117: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:811 - { - name := name.NewName(yyDollar[1].list) - yyVAL.node = stmt.NewUse(nil, name, nil) - - // save position - 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 118: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:825 - { - name := name.NewName(yyDollar[1].list) - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewUse(nil, name, alias) - - // save position - 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).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 119: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:846 - { - yyVAL.node = yyDollar[1].node - - // save coments - yylex.(*Parser).MoveFreeFloating(yyDollar[1].node.(*stmt.Use).Use, yyVAL.node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 120: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:855 - { - yyVAL.node = yyDollar[2].node - - // save comments - 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 121: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:871 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 122: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:880 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 123: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:889 - { - 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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 124: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:902 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 125: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:911 - { - // error - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 126: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:918 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 127: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:924 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 128: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:930 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 129: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:936 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 130: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:942 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 131: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:948 - { - yyVAL.node = stmt.NewHaltCompiler() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 132: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:966 - { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 133: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:979 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 134: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:985 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 135: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:991 - { - switch n := yyDollar[5].node.(type) { - case *stmt.While: - n.Cond = yyDollar[3].node - case *stmt.AltWhile: - n.Cond = yyDollar[3].node - } - - yyVAL.node = yyDollar[5].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - - // save comments - 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 136: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:1012 - { - yyVAL.node = stmt.NewDo(yyDollar[2].node, yyDollar[5].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[7].token)) - - // save comments - 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 137: - yyDollar = yyS[yypt-9 : yypt+1] - // line php7/php7.y:1029 - { - switch n := yyDollar[9].node.(type) { - case *stmt.For: - n.Init = yyDollar[3].list - n.Cond = yyDollar[5].list - n.Loop = yyDollar[7].list - case *stmt.AltFor: - n.Init = yyDollar[3].list - n.Cond = yyDollar[5].list - n.Loop = yyDollar[7].list - } - - yyVAL.node = yyDollar[9].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) - - // save comments - 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 138: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:1056 - { - switch n := yyDollar[5].node.(type) { - case *stmt.Switch: - n.Cond = yyDollar[3].node - case *stmt.AltSwitch: - n.Cond = yyDollar[3].node - default: - panic("unexpected node type") - } - - yyVAL.node = yyDollar[5].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - - // save comments - 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 139: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1079 - { - yyVAL.node = stmt.NewBreak(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1093 - { - yyVAL.node = stmt.NewContinue(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1107 - { - yyVAL.node = stmt.NewReturn(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 142: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1121 - { - yyVAL.node = stmt.NewGlobal(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:1135 - { - yyVAL.node = stmt.NewStatic(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 144: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1149 - { - yyVAL.node = stmt.NewEcho(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 145: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1164 - { - yyVAL.node = stmt.NewInlineHtml(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 146: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1176 - { - yyVAL.node = stmt.NewExpression(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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 147: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:1190 - { - yyVAL.node = stmt.NewUnset(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[6].token)) - - // save comments - 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).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).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 148: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:1210 - { - switch n := yyDollar[7].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Variable = yyDollar[5].node - } - - yyVAL.node = yyDollar[7].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[7].node)) - - // save comments - 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 149: - yyDollar = yyS[yypt-9 : yypt+1] - // line php7/php7.y:1235 - { - switch n := yyDollar[9].node.(type) { - case *stmt.Foreach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[7].node - case *stmt.AltForeach: - n.Expr = yyDollar[3].node - n.Key = yyDollar[5].node - n.Variable = yyDollar[7].node - } - - yyVAL.node = yyDollar[9].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) - - // save comments - 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 150: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:1262 - { - yyVAL.node = yyDollar[5].node - yyVAL.node.(*stmt.Declare).Consts = yyDollar[3].list - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - - // save comments - 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 151: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1277 - { - yyVAL.node = stmt.NewNop() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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 152: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:1290 - { - if yyDollar[6].node == nil { - yyVAL.node = stmt.NewTry(yyDollar[3].list, yyDollar[5].list, yyDollar[6].node) - 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) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[6].node)) - } - - // save comments - 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 153: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1307 - { - yyVAL.node = stmt.NewThrow(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 154: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1321 - { - label := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewGoto(label) - - // save position - 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).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 155: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1338 - { - label := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewLabel(label) - - // save position - 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).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 156: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1355 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 157: - yyDollar = yyS[yypt-9 : yypt+1] - // line php7/php7.y:1361 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[5].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - catch := stmt.NewCatch(yyDollar[4].list, variable, yyDollar[8].list) - yyVAL.list = append(yyDollar[1].list, catch) - - // save position - 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).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 158: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1386 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 159: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1392 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 160: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1404 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 161: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1410 - { - yyVAL.node = stmt.NewFinally(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 162: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1427 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 163: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1433 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 164: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1445 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 165: - yyDollar = yyS[yypt-11 : yypt+1] - // line php7/php7.y:1454 - { - 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 - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - if yyDollar[2].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 166: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1490 - { - yyVAL.token = nil - } - case 167: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1494 - { - yyVAL.token = yyDollar[1].token - } - case 168: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1501 - { - yyVAL.token = nil - } - case 169: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1505 - { - yyVAL.token = yyDollar[1].token - } - case 170: - yyDollar = yyS[yypt-9 : yypt+1] - // line php7/php7.y:1512 - { - 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 - 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).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 171: - yyDollar = yyS[yypt-8 : yypt+1] - // line php7/php7.y:1530 - { - 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 - 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).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 172: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1550 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 173: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1556 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 174: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1565 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 175: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1577 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 176: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:1592 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewTrait(name, yyDollar[5].list, yyDollar[3].str) - - // save position - 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).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 177: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:1612 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - yyVAL.node = stmt.NewInterface(name, yyDollar[3].InterfaceExtends, yyDollar[6].list, yyDollar[4].str) - - // save position - 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).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 178: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1632 - { - yyVAL.ClassExtends = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 179: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1638 - { - yyVAL.ClassExtends = stmt.NewClassExtends(yyDollar[2].node) - - // save position - yyVAL.ClassExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.ClassExtends, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 180: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1653 - { - yyVAL.InterfaceExtends = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 181: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1659 - { - yyVAL.InterfaceExtends = stmt.NewInterfaceExtends(yyDollar[2].list) - - // save position - yyVAL.InterfaceExtends.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.InterfaceExtends, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 182: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1674 - { - yyVAL.ClassImplements = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 183: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1680 - { - yyVAL.ClassImplements = stmt.NewClassImplements(yyDollar[2].list) - - // save position - yyVAL.ClassImplements.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[1].token, yyDollar[2].list)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.ClassImplements, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 184: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1695 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 185: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:1701 - { - yyVAL.node = expr.NewReference(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 186: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1713 - { - yyVAL.node = expr.NewList(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 187: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1727 - { - yyVAL.node = expr.NewShortList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // 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 188: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1743 - { - yyVAL.node = stmt.NewFor(nil, nil, nil, yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 189: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1752 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltFor(nil, nil, nil, stmtList) - - // save position - 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).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 190: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1772 - { - yyVAL.node = stmt.NewForeach(nil, nil, nil, yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 191: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1781 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltForeach(nil, nil, nil, stmtList) - - // save position - 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).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 192: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1801 - { - 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 193: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1810 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewDeclare(nil, stmtList, true) - - // save position - 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).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 194: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:1830 - { - caseList := stmt.NewCaseList(yyDollar[2].list) - yyVAL.node = stmt.NewSwitch(nil, caseList) - - // save position - 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).setFreeFloating(caseList, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, yyDollar[3].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 195: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1845 - { - caseList := stmt.NewCaseList(yyDollar[3].list) - yyVAL.node = stmt.NewSwitch(nil, caseList) - - // save position - 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).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 196: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1861 - { - caseList := stmt.NewCaseList(yyDollar[2].list) - yyVAL.node = stmt.NewAltSwitch(nil, caseList) - - // save position - 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).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 197: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:1878 - { - - caseList := stmt.NewCaseList(yyDollar[3].list) - yyVAL.node = stmt.NewAltSwitch(nil, caseList) - - // save position - 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).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 198: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:1900 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 199: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:1906 - { - _case := stmt.NewCase(yyDollar[3].node, yyDollar[5].list) - yyVAL.list = append(yyDollar[1].list, _case) - - // save position - _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[5].list)) - - // save comments - 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 200: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1921 - { - _default := stmt.NewDefault(yyDollar[4].list) - yyVAL.list = append(yyDollar[1].list, _default) - - // save position - _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition(yyDollar[2].token, yyDollar[4].list)) - - // save comments - 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 201: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1939 - { - yyVAL.token = yyDollar[1].token - } - case 202: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1943 - { - yyVAL.token = yyDollar[1].token - } - case 203: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:1950 - { - yyVAL.node = stmt.NewWhile(nil, yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition(yyDollar[1].node)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 204: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:1959 - { - stmtList := stmt.NewStmtList(yyDollar[2].list) - yyVAL.node = stmt.NewAltWhile(nil, stmtList) - - // save position - 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).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 205: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:1979 - { - yyVAL.node = stmt.NewIf(yyDollar[3].node, yyDollar[5].node, nil, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[5].node)) - - // save comments - 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 206: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:1993 - { - _elseIf := stmt.NewElseIf(yyDollar[4].node, yyDollar[6].node) - yyVAL.node = yyDollar[1].node.(*stmt.If).AddElseIf(_elseIf) - - // save position - _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).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 207: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2012 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 208: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2018 - { - _else := stmt.NewElse(yyDollar[3].node) - yyVAL.node = yyDollar[1].node.(*stmt.If).SetElse(_else) - - // save position - _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).setFreeFloating(_else, freefloating.Start, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 209: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:2035 - { - stmts := stmt.NewStmtList(yyDollar[6].list) - yyVAL.node = stmt.NewAltIf(yyDollar[3].node, stmts, nil, nil) - - // save position - 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).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 210: - yyDollar = yyS[yypt-7 : yypt+1] - // line php7/php7.y:2052 - { - stmts := stmt.NewStmtList(yyDollar[7].list) - _elseIf := stmt.NewAltElseIf(yyDollar[4].node, stmts) - yyVAL.node = yyDollar[1].node.(*stmt.AltIf).AddElseIf(_elseIf) - - // save position - 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).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 211: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2073 - { - yyVAL.node = yyDollar[1].node - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[3].token)) - - // save comments - 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 212: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:2087 - { - stmts := stmt.NewStmtList(yyDollar[4].list) - _else := stmt.NewAltElse(stmts) - yyVAL.node = yyDollar[1].node.(*stmt.AltIf).SetElse(_else) - - // save position - 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).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 213: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2110 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 214: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:2116 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 215: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2125 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 216: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2131 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 217: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:2143 - { - 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 - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].node != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - } else if yyDollar[2].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[2].token, yyDollar[4].token)) - } else if yyDollar[3].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[3].token, yyDollar[4].token)) - } else { - 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).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) - } - if yyDollar[3].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 218: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:2188 - { - 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 - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].node != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[6].node)) - } else if yyDollar[2].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[6].node)) - } else if yyDollar[3].token != nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[3].token, yyDollar[6].node)) - } else { - 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).setFreeFloating(yyVAL.node, freefloating.OptionalType, yyDollar[2].token.FreeFloating) - } - if yyDollar[3].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 219: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:2237 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 220: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2243 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 221: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2252 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 222: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2258 - { - yyVAL.node = node.NewNullable(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:2273 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2285 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 225: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2297 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 226: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:2306 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 227: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2312 - { - yyVAL.node = yyDollar[2].node - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Colon, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 228: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2324 - { - yyVAL.node = node.NewArgumentList(nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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 229: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:2337 - { - yyVAL.node = node.NewArgumentList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - if yyDollar[3].token != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 230: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2357 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 231: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2363 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 232: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2375 - { - yyVAL.node = node.NewArgument(yyDollar[1].node, false, false) - - // save position - 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 233: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2387 - { - yyVAL.node = node.NewArgument(yyDollar[2].node, true, false) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 234: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2402 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 235: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2411 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 236: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2420 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 237: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2429 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 238: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2438 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 239: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2447 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.node = stmt.NewStaticVar(variable, nil) - - // save position - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 240: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2464 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.node = stmt.NewStaticVar(variable, yyDollar[3].node) - - // save position - 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).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 241: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2485 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 242: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:2491 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 243: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:2500 - { - yyVAL.node = stmt.NewPropertyList(yyDollar[1].list, yyDollar[2].node, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition(yyDollar[1].list, yyDollar[4].token)) - - // save comments - yylex.(*Parser).MoveFreeFloating(yyDollar[1].list[0], yyVAL.node) - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.PropertyList, 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-4 : yypt+1] - // line php7/php7.y:2514 - { - yyVAL.node = stmt.NewClassConstList(yyDollar[1].list, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition(yyDollar[1].list, yyDollar[2].token, yyDollar[4].token)) - - // save comments - 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 245: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2533 - { - yyVAL.node = stmt.NewTraitUse(yyDollar[2].list, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 246: - yyDollar = yyS[yypt-10 : yypt+1] - // line php7/php7.y:2545 - { - 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 - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[4].token)) - if yyDollar[1].list == nil { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[2].token, yyDollar[10].node)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition(yyDollar[1].list, yyDollar[10].node)) - } - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 247: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2582 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 248: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2588 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 249: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2600 - { - yyVAL.node = stmt.NewNop() - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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 250: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2613 - { - yyVAL.node = stmt.NewTraitAdaptationList(nil) - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - 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 251: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2625 - { - yyVAL.node = stmt.NewTraitAdaptationList(yyDollar[2].list) - - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 252: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2640 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 253: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2646 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 254: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2655 - { - yyVAL.node = yyDollar[1].node - - // save comments - 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 255: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2665 - { - yyVAL.node = yyDollar[1].node - - // save comments - 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 256: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2678 - { - yyVAL.node = stmt.NewTraitUsePrecedence(yyDollar[1].node, yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition(yyDollar[1].node, yyDollar[3].list)) - - // save comments - 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 257: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2694 - { - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, nil, alias) - - // save position - 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).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-3 : yypt+1] - // line php7/php7.y:2710 - { - alias := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, nil, alias) - - // save position - 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).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 259: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:2726 - { - alias := node.NewIdentifier(yyDollar[4].token.Value) - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, alias) - - // save position - 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).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 260: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2742 - { - yyVAL.node = stmt.NewTraitUseAlias(yyDollar[1].node, yyDollar[3].node, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 261: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2758 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewTraitMethodRef(nil, name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 262: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2772 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 263: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2781 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = stmt.NewTraitMethodRef(yyDollar[1].node, target) - - // save position - 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).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 264: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2800 - { - yyVAL.node = stmt.NewNop() - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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 265: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2813 - { - yyVAL.node = stmt.NewStmtList(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 266: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2829 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 267: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2835 - { - modifier := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.list = []node.Node{modifier} - - // save position - modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 268: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:2851 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 269: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2857 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 270: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2866 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 271: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2872 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 272: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2881 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2893 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2905 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2917 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:2929 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 277: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2941 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 278: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:2956 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 279: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:2965 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 280: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:2974 - { - 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 - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 281: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:2991 - { - 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 - 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).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 282: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3012 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 283: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3021 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 284: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:3030 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewConstant(name, yyDollar[3].node, yyDollar[4].str) - - // save position - 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).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-4 : yypt+1] - // line php7/php7.y:3048 - { - name := node.NewIdentifier(yyDollar[1].token.Value) - yyVAL.node = stmt.NewConstant(name, yyDollar[3].node, yyDollar[4].str) - - // save position - 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).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 286: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3066 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 287: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3075 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 288: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3084 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 289: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:3093 - { - yyVAL.list = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 290: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3099 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 291: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3108 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 292: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3117 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 293: - yyDollar = yyS[yypt-8 : yypt+1] - // line php7/php7.y:3126 - { - 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) - } else { - yyVAL.node = stmt.NewClass(nil, nil, nil, yyDollar[3].ClassExtends, yyDollar[4].ClassImplements, yyDollar[7].list, yyDollar[5].str) - } - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[8].token)) - - // save comments - 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 294: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3147 - { - if yyDollar[3].node != nil { - yyVAL.node = expr.NewNew(yyDollar[2].node, yyDollar[3].node.(*node.ArgumentList)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[3].node)) - } else { - yyVAL.node = expr.NewNew(yyDollar[2].node, nil) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - } - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 295: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3162 - { - yyVAL.node = expr.NewNew(yyDollar[2].node, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 296: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:3177 - { - listNode := expr.NewList(yyDollar[3].list) - yyVAL.node = assign.NewAssign(listNode, yyDollar[6].node) - - // save position - 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).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 297: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:3194 - { - shortList := expr.NewShortList(yyDollar[2].list) - yyVAL.node = assign.NewAssign(shortList, yyDollar[5].node) - - // save position - 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).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 298: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3210 - { - yyVAL.node = assign.NewAssign(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 299: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:3223 - { - yyVAL.node = assign.NewReference(yyDollar[1].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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 300: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3237 - { - yyVAL.node = expr.NewClone(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 301: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3249 - { - yyVAL.node = assign.NewPlus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3262 - { - yyVAL.node = assign.NewMinus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3275 - { - yyVAL.node = assign.NewMul(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3288 - { - yyVAL.node = assign.NewPow(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3301 - { - yyVAL.node = assign.NewDiv(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3314 - { - yyVAL.node = assign.NewConcat(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3327 - { - yyVAL.node = assign.NewMod(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3340 - { - yyVAL.node = assign.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3353 - { - yyVAL.node = assign.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3366 - { - yyVAL.node = assign.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3379 - { - yyVAL.node = assign.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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-3 : yypt+1] - // line php7/php7.y:3392 - { - yyVAL.node = assign.NewShiftRight(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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-3 : yypt+1] - // line php7/php7.y:3405 - { - yyVAL.node = assign.NewCoalesce(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 314: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3418 - { - yyVAL.node = expr.NewPostInc(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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:3431 - { - yyVAL.node = expr.NewPreInc(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 316: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3443 - { - yyVAL.node = expr.NewPostDec(yyDollar[1].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[2].token)) - - // save comments - 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 317: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3456 - { - yyVAL.node = expr.NewPreDec(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 318: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3468 - { - yyVAL.node = binary.NewBooleanOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3481 - { - yyVAL.node = binary.NewBooleanAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3494 - { - yyVAL.node = binary.NewLogicalOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3507 - { - yyVAL.node = binary.NewLogicalAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3520 - { - yyVAL.node = binary.NewLogicalXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3533 - { - yyVAL.node = binary.NewBitwiseOr(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3546 - { - yyVAL.node = binary.NewBitwiseAnd(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3559 - { - yyVAL.node = binary.NewBitwiseXor(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3572 - { - yyVAL.node = binary.NewConcat(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3585 - { - yyVAL.node = binary.NewPlus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3598 - { - yyVAL.node = binary.NewMinus(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3611 - { - yyVAL.node = binary.NewMul(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3624 - { - yyVAL.node = binary.NewPow(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3637 - { - yyVAL.node = binary.NewDiv(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3650 - { - yyVAL.node = binary.NewMod(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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-3 : yypt+1] - // line php7/php7.y:3663 - { - yyVAL.node = binary.NewShiftLeft(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 334: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3676 - { - yyVAL.node = binary.NewShiftRight(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 335: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3689 - { - yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3701 - { - yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 337: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3713 - { - yyVAL.node = expr.NewBooleanNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 338: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3725 - { - yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 339: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3737 - { - yyVAL.node = binary.NewIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3750 - { - yyVAL.node = binary.NewNotIdentical(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 341: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3763 - { - yyVAL.node = binary.NewEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3776 - { - yyVAL.node = binary.NewNotEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 343: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3790 - { - yyVAL.node = binary.NewSmaller(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3803 - { - yyVAL.node = binary.NewSmallerOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3816 - { - yyVAL.node = binary.NewGreater(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3829 - { - yyVAL.node = binary.NewGreaterOrEqual(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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:3842 - { - yyVAL.node = binary.NewSpaceship(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 348: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3855 - { - yyVAL.node = expr.NewInstanceOf(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 349: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3868 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 350: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3878 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 351: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:3884 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[5].node)) - - // save comments - 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 352: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:3898 - { - yyVAL.node = expr.NewTernary(yyDollar[1].node, nil, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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 353: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:3912 - { - yyVAL.node = binary.NewCoalesce(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 354: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:3925 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 355: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:3931 - { - yyVAL.node = cast.NewInt(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3944 - { - yyVAL.node = cast.NewDouble(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3957 - { - yyVAL.node = cast.NewString(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3970 - { - yyVAL.node = cast.NewArray(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3983 - { - yyVAL.node = cast.NewObject(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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:3996 - { - yyVAL.node = cast.NewBool(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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 361: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4009 - { - yyVAL.node = cast.NewUnset(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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 362: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4022 - { - var e *expr.Exit - if yyDollar[2].node != nil { - e = yyDollar[2].node.(*expr.Exit) - } else { - 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 { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - } else { - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - } - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 363: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4049 - { - yyVAL.node = expr.NewErrorSuppress(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 364: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4061 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 365: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4067 - { - yyVAL.node = expr.NewShellExec(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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:4079 - { - yyVAL.node = expr.NewPrint(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 367: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4091 - { - yyVAL.node = expr.NewYield(nil, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 368: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4103 - { - yyVAL.node = expr.NewYield(nil, yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 369: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4115 - { - yyVAL.node = expr.NewYield(yyDollar[2].node, yyDollar[4].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[4].node)) - - // save comments - 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 370: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4128 - { - yyVAL.node = expr.NewYieldFrom(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 371: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4140 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 372: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4146 - { - yyVAL.node = yyDollar[2].node - - switch n := yyVAL.node.(type) { - case *expr.Closure: - n.Static = true - case *expr.ArrowFunction: - n.Static = true - } - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Static, (*yyVAL.node.GetFreeFloating())[freefloating.Start]) - delete((*yyVAL.node.GetFreeFloating()), freefloating.Start) - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 373: - yyDollar = yyS[yypt-11 : yypt+1] - // line php7/php7.y:4169 - { - 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 - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[11].token)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 374: - yyDollar = yyS[yypt-9 : yypt+1] - // line php7/php7.y:4201 - { - yyVAL.node = expr.NewArrowFunction(yyDollar[4].list, yyDollar[6].node, yyDollar[9].node, false, yyDollar[2].token != nil, yyDollar[7].str) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[9].node)) - - // save comments - 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) - if yyDollar[6].node != nil { - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyDollar[6].node.GetFreeFloating())[freefloating.Colon]) - delete((*yyDollar[6].node.GetFreeFloating()), freefloating.Colon) - } - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.ReturnType, yyDollar[8].token.FreeFloating) - - // normalize - if yyDollar[6].node == nil { - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Params, (*yyVAL.node.GetFreeFloating())[freefloating.ReturnType]) - delete((*yyVAL.node.GetFreeFloating()), freefloating.ReturnType) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 375: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4232 - { - yyVAL.str = yylex.(*Parser).Lexer.GetPhpDocComment() - yylex.(*Parser).Lexer.SetPhpDocComment("") - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 376: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4242 - { - yyVAL.token = nil - } - case 377: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4246 - { - yyVAL.token = yyDollar[1].token - } - case 378: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4253 - { - yyVAL.ClosureUse = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 379: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4259 - { - yyVAL.ClosureUse = expr.NewClosureUse(yyDollar[3].list) - - // 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 380: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4276 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 381: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4285 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 382: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4294 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(yyVAL.node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 383: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4309 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[2].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.node = expr.NewReference(variable) - - // save position - 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).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 384: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4330 - { - yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) - - // save position - 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 385: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4342 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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 386: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4355 - { - yyVAL.node = expr.NewStaticCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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 387: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4368 - { - yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(*node.ArgumentList)) - - // save position - 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 388: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4383 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 389: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4395 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 390: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4404 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 391: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4410 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 392: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4419 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 393: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4425 - { - yyVAL.node = expr.NewExit(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 394: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4441 - { - yyVAL.list = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 395: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4447 - { - 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 396: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4457 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 397: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4466 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 398: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4472 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 399: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4481 - { - yyVAL.node = expr.NewArray(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 400: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4495 - { - yyVAL.node = expr.NewShortArray(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - 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 401: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4508 - { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4523 - { - yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4535 - { - yyVAL.node = scalar.NewDnumber(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4547 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4559 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4571 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:4583 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 408: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4595 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 409: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4607 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 410: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4619 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 411: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4631 - { - yyVAL.node = scalar.NewMagicConstant(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 412: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4643 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, []node.Node{encapsed}) - - // save position - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 413: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4657 - { - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, nil) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[2].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 414: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4669 - { - yyVAL.node = scalar.NewEncapsed(yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 415: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4681 - { - yyVAL.node = scalar.NewHeredoc(yyDollar[1].token.Value, yyDollar[2].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 416: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4693 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 417: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4699 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 418: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4708 - { - yyVAL.node = expr.NewConstFetch(yyDollar[1].node) - - // save position - 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 419: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4720 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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 420: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4736 - { - target := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target) - - // save position - 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).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 421: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4755 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 422: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4761 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 423: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:4770 - { - yyVAL.node = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 424: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4776 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 425: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4785 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 426: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4794 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 427: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4800 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 428: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4810 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 429: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4819 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 430: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4825 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 431: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4835 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 432: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4844 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 433: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4850 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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 434: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4864 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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 435: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4878 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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 436: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4892 - { - yyVAL.node = expr.NewMethodCall(yyDollar[1].node, yyDollar[3].node, yyDollar[4].node.(*node.ArgumentList)) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[4].node)) - - // save comments - 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:4905 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 438: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4914 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 439: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4920 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 440: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4926 - { - yyVAL.node = expr.NewPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 441: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:4942 - { - name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(yyVAL.node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 442: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:4957 - { - yyVAL.node = expr.NewVariable(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 443: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:4972 - { - yyVAL.node = expr.NewVariable(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - 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 444: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:4988 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 445: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5001 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 446: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5017 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 447: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5023 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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 448: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5037 - { - yyVAL.node = expr.NewArrayDimFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition(yyDollar[1].node, yyDollar[4].token)) - - // save comments - 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 449: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5051 - { - yyVAL.node = expr.NewPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 450: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5064 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 451: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5077 - { - yyVAL.node = expr.NewStaticPropertyFetch(yyDollar[1].node, yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 452: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5093 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 453: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5105 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 454: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5115 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 455: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5124 - { - yyVAL.node = node.NewIdentifier(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 456: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5136 - { - 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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 457: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5146 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 458: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5155 - { - yyVAL.list = yyDollar[1].list - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 459: - yyDollar = yyS[yypt-0 : yypt+1] - // line php7/php7.y:5164 - { - yyVAL.node = expr.NewArrayItem(nil, nil, false) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 460: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5170 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 461: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5179 - { - if len(yyDollar[1].list) == 0 { - yyDollar[1].list = []node.Node{expr.NewArrayItem(nil, nil, false)} - } - - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 462: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5192 - { - 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 463: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5205 - { - yyVAL.node = expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node, false) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)) - - // save comments - 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 464: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5218 - { - yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node, false) - - // save position - 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 465: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5230 - { - reference := expr.NewReference(yyDollar[4].node) - yyVAL.node = expr.NewArrayItem(yyDollar[1].node, reference, false) - - // save position - 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).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 466: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5246 - { - reference := expr.NewReference(yyDollar[2].node) - yyVAL.node = expr.NewArrayItem(nil, reference, false) - - // save position - 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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 467: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5260 - { - yyVAL.node = expr.NewArrayItem(nil, yyDollar[2].node, true) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 468: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:5272 - { - // TODO: Cannot use list() as standalone expression - listNode := expr.NewList(yyDollar[5].list) - yyVAL.node = expr.NewArrayItem(yyDollar[1].node, listNode, false) - - // save position - 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).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 469: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5291 - { - // TODO: Cannot use list() as standalone expression - listNode := expr.NewList(yyDollar[3].list) - yyVAL.node = expr.NewArrayItem(nil, listNode, false) - - // save position - 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).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 470: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5311 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[2].node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 471: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5317 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value) - yyVAL.list = append(yyDollar[1].list, encapsed) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[2].token)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 472: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5330 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 473: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5336 - { - encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value) - yyVAL.list = []node.Node{encapsed, yyDollar[2].node} - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 474: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5352 - { - name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(yyVAL.node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 475: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5367 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[3].node) - - // save position - 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).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 476: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5385 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - variable := expr.NewVariable(identifier) - fetch := node.NewIdentifier(yyDollar[3].token.Value) - yyVAL.node = expr.NewPropertyFetch(variable, fetch) - - // save position - 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).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 477: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5405 - { - variable := expr.NewVariable(yyDollar[2].node) - - yyVAL.node = variable - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token)) - - // 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 478: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5420 - { - name := node.NewIdentifier(yyDollar[2].token.Value) - variable := expr.NewVariable(name) - - yyVAL.node = variable - - // save position - 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).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 479: - yyDollar = yyS[yypt-6 : yypt+1] - // line php7/php7.y:5437 - { - identifier := node.NewIdentifier(yyDollar[2].token.Value) - variable := expr.NewVariable(identifier) - yyVAL.node = expr.NewArrayDimFetch(variable, yyDollar[4].node) - - // save position - 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).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 480: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5456 - { - 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 481: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5469 - { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 482: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5481 - { - // TODO: add option to handle 64 bit integer - if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil { - yyVAL.node = scalar.NewLnumber(yyDollar[1].token.Value) - } else { - yyVAL.node = scalar.NewString(yyDollar[1].token.Value) - } - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - 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:5498 - { - var lnumber *scalar.Lnumber - // TODO: add option to handle 64 bit integer - _, err := strconv.Atoi(yyDollar[2].token.Value) - isInt := err == nil - - if isInt { - lnumber = scalar.NewLnumber(yyDollar[2].token.Value) - yyVAL.node = expr.NewUnaryMinus(lnumber) - } else { - yyDollar[2].token.Value = "-" + yyDollar[2].token.Value - yyVAL.node = scalar.NewString(yyDollar[2].token.Value) - } - - // save position - if isInt { - lnumber.SetPosition(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).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 484: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5524 - { - identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar)) - yyVAL.node = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - yylex.(*Parser).addDollarToken(yyVAL.node) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 485: - yyDollar = yyS[yypt-5 : yypt+1] - // line php7/php7.y:5542 - { - yyVAL.node = expr.NewIsset(yyDollar[3].list) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[5].token)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - case 486: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5560 - { - yyVAL.node = expr.NewEmpty(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 487: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5574 - { - yyVAL.node = expr.NewInclude(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 488: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5586 - { - yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 489: - yyDollar = yyS[yypt-4 : yypt+1] - // line php7/php7.y:5598 - { - yyVAL.node = expr.NewEval(yyDollar[3].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)) - - // save comments - 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 490: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5612 - { - yyVAL.node = expr.NewRequire(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 491: - yyDollar = yyS[yypt-2 : yypt+1] - // line php7/php7.y:5624 - { - yyVAL.node = expr.NewRequireOnce(yyDollar[2].node) - - // save position - yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node)) - - // save comments - yylex.(*Parser).setFreeFloating(yyVAL.node, freefloating.Start, yyDollar[1].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 492: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5639 - { - yyVAL.list = []node.Node{yyDollar[1].node} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 493: - yyDollar = yyS[yypt-3 : yypt+1] - // line php7/php7.y:5645 - { - yyVAL.list = append(yyDollar[1].list, yyDollar[3].node) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), freefloating.End, yyDollar[2].token.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - case 494: - yyDollar = yyS[yypt-1 : yypt+1] - // line php7/php7.y:5657 - { - yyVAL.node = yyDollar[1].node - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - } - goto yystack /* stack new state and value */ -} diff --git a/php7/php7.y b/php7/php7.y deleted file mode 100644 index e6634ff..0000000 --- a/php7/php7.y +++ /dev/null @@ -1,5666 +0,0 @@ -%{ -package php7 - -import ( - "strings" - "strconv" - - "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" - "github.com/z7zmey/php-parser/node/name" - "github.com/z7zmey/php-parser/node/stmt" - "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" -) - -%} - -%union{ - node node.Node - token *scanner.Token - list []node.Node - str string - - ClassExtends *stmt.ClassExtends - ClassImplements *stmt.ClassImplements - InterfaceExtends *stmt.InterfaceExtends - ClosureUse *expr.ClosureUse -} - -%type $unk -%token T_INCLUDE -%token T_INCLUDE_ONCE -%token T_EXIT -%token T_IF -%token T_LNUMBER -%token T_DNUMBER -%token T_STRING -%token T_STRING_VARNAME -%token T_VARIABLE -%token T_NUM_STRING -%token T_INLINE_HTML -%token T_CHARACTER -%token T_BAD_CHARACTER -%token T_ENCAPSED_AND_WHITESPACE -%token T_CONSTANT_ENCAPSED_STRING -%token T_ECHO -%token T_DO -%token T_WHILE -%token T_ENDWHILE -%token T_FOR -%token T_ENDFOR -%token T_FOREACH -%token T_ENDFOREACH -%token T_DECLARE -%token T_ENDDECLARE -%token T_AS -%token T_SWITCH -%token T_ENDSWITCH -%token T_CASE -%token T_DEFAULT -%token T_BREAK -%token T_CONTINUE -%token T_GOTO -%token T_FUNCTION -%token T_FN -%token T_CONST -%token T_RETURN -%token T_TRY -%token T_CATCH -%token T_FINALLY -%token T_THROW -%token T_USE -%token T_INSTEADOF -%token T_GLOBAL -%token T_VAR -%token T_UNSET -%token T_ISSET -%token T_EMPTY -%token T_HALT_COMPILER -%token T_CLASS -%token T_TRAIT -%token T_INTERFACE -%token T_EXTENDS -%token T_IMPLEMENTS -%token T_OBJECT_OPERATOR -%token T_DOUBLE_ARROW -%token T_LIST -%token T_ARRAY -%token T_CALLABLE -%token T_CLASS_C -%token T_TRAIT_C -%token T_METHOD_C -%token T_FUNC_C -%token T_LINE -%token T_FILE -%token T_COMMENT -%token T_DOC_COMMENT -%token T_OPEN_TAG -%token T_OPEN_TAG_WITH_ECHO -%token T_CLOSE_TAG -%token T_WHITESPACE -%token T_START_HEREDOC -%token T_END_HEREDOC -%token T_DOLLAR_OPEN_CURLY_BRACES -%token T_CURLY_OPEN -%token T_PAAMAYIM_NEKUDOTAYIM -%token T_NAMESPACE -%token T_NS_C -%token T_DIR -%token T_NS_SEPARATOR -%token T_ELLIPSIS -%token T_EVAL -%token T_REQUIRE -%token T_REQUIRE_ONCE -%token T_LOGICAL_OR -%token T_LOGICAL_XOR -%token T_LOGICAL_AND -%token T_INSTANCEOF -%token T_NEW -%token T_CLONE -%token T_ELSEIF -%token T_ELSE -%token T_ENDIF -%token T_PRINT -%token T_YIELD -%token T_STATIC -%token T_ABSTRACT -%token T_FINAL -%token T_PRIVATE -%token T_PROTECTED -%token T_PUBLIC -%token T_INC -%token T_DEC -%token T_YIELD_FROM -%token T_INT_CAST -%token T_DOUBLE_CAST -%token T_STRING_CAST -%token T_ARRAY_CAST -%token T_OBJECT_CAST -%token T_BOOL_CAST -%token T_UNSET_CAST -%token T_COALESCE -%token T_SPACESHIP -%token T_NOELSE -%token T_PLUS_EQUAL -%token T_MINUS_EQUAL -%token T_MUL_EQUAL -%token T_POW_EQUAL -%token T_DIV_EQUAL -%token T_CONCAT_EQUAL -%token T_MOD_EQUAL -%token T_AND_EQUAL -%token T_OR_EQUAL -%token T_XOR_EQUAL -%token T_SL_EQUAL -%token T_SR_EQUAL -%token T_COALESCE_EQUAL -%token T_BOOLEAN_OR -%token T_BOOLEAN_AND -%token T_POW -%token T_SL -%token T_SR -%token T_IS_IDENTICAL -%token T_IS_NOT_IDENTICAL -%token T_IS_EQUAL -%token T_IS_NOT_EQUAL -%token T_IS_SMALLER_OR_EQUAL -%token T_IS_GREATER_OR_EQUAL -%token '"' -%token '`' -%token '{' -%token '}' -%token ';' -%token ':' -%token '(' -%token ')' -%token '[' -%token ']' -%token '?' -%token '&' -%token '-' -%token '+' -%token '!' -%token '~' -%token '@' -%token '$' -%token ',' -%token '|' -%token '=' -%token '^' -%token '*' -%token '/' -%token '%' -%token '<' -%token '>' -%token '.' - -%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE -%left ',' -%left T_LOGICAL_OR -%left T_LOGICAL_XOR -%left T_LOGICAL_AND -%right T_PRINT -%right T_YIELD -%right T_DOUBLE_ARROW -%right T_YIELD_FROM -%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL T_COALESCE_EQUAL -%left '?' ':' -%right T_COALESCE -%left T_BOOLEAN_OR -%left T_BOOLEAN_AND -%left '|' -%left '^' -%left '&' -%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP -%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL -%left T_SL T_SR -%left '+' '-' '.' -%left '*' '/' '%' -%right '!' -%nonassoc T_INSTANCEOF -%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' -%right T_POW -%right '[' -%nonassoc T_NEW T_CLONE -%left T_NOELSE -%left T_ELSEIF -%left T_ELSE -%left T_ENDIF -%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC - -%type is_reference is_variadic returns_ref - -%type reserved_non_modifiers -%type semi_reserved -%type identifier -%type possible_comma -%type case_separator - -%type top_statement name statement function_declaration_statement -%type class_declaration_statement trait_declaration_statement -%type interface_declaration_statement -%type group_use_declaration inline_use_declaration -%type mixed_group_use_declaration use_declaration unprefixed_use_declaration -%type const_decl inner_statement -%type expr optional_expr -%type declare_statement finally_statement unset_variable variable -%type parameter optional_type argument expr_without_variable global_var -%type static_var class_statement trait_adaptation trait_precedence trait_alias -%type absolute_trait_method_reference trait_method_reference property echo_expr -%type new_expr anonymous_class class_name class_name_reference simple_variable -%type internal_functions_in_yacc -%type exit_expr scalar lexical_var function_call member_name property_name -%type variable_class_name dereferencable_scalar constant dereferencable -%type callable_expr callable_variable static_member new_variable -%type encaps_var encaps_var_offset -%type if_stmt -%type alt_if_stmt -%type if_stmt_without_else -%type class_const_decl -%type alt_if_stmt_without_else -%type array_pair possible_array_pair -%type isset_variable type return_type type_expr -%type class_modifier -%type argument_list ctor_arguments -%type trait_adaptations -%type switch_case_list -%type method_body -%type foreach_statement for_statement while_statement -%type inline_function -%type extends_from -%type implements_list -%type interface_extends_list -%type lexical_vars - -%type member_modifier -%type use_type -%type foreach_variable - - -%type encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list -%type const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list -%type unprefixed_use_declarations inline_use_declarations property_list static_var_list -%type case_list trait_adaptation_list unset_variables -%type use_declarations lexical_var_list isset_variables non_empty_array_pair_list -%type array_pair_list non_empty_argument_list top_statement_list -%type inner_statement_list parameter_list non_empty_parameter_list class_statement_list -%type method_modifiers variable_modifiers -%type non_empty_member_modifiers name_list class_modifiers - -%type backup_doc_comment - -%% - -///////////////////////////////////////////////////////////////////////// - -start: - top_statement_list - { - yylex.(*Parser).rootNode = node.NewRoot($1) - - // save position - yylex.(*Parser).rootNode.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - - yylex.(*Parser).setFreeFloating(yylex.(*Parser).rootNode, freefloating.End, yylex.(*Parser).currentToken.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -reserved_non_modifiers: - T_INCLUDE {$$=$1} | T_INCLUDE_ONCE {$$=$1} | T_EVAL {$$=$1} | T_REQUIRE {$$=$1} | T_REQUIRE_ONCE {$$=$1} | T_LOGICAL_OR {$$=$1} | T_LOGICAL_XOR {$$=$1} | T_LOGICAL_AND {$$=$1} - | T_INSTANCEOF {$$=$1} | T_NEW {$$=$1} | T_CLONE {$$=$1} | T_EXIT {$$=$1} | T_IF {$$=$1} | T_ELSEIF {$$=$1} | T_ELSE {$$=$1} | T_ENDIF {$$=$1} | T_ECHO {$$=$1} | T_DO {$$=$1} | T_WHILE {$$=$1} | T_ENDWHILE {$$=$1} - | T_FOR {$$=$1} | T_ENDFOR {$$=$1} | T_FOREACH {$$=$1} | T_ENDFOREACH {$$=$1} | T_DECLARE {$$=$1} | T_ENDDECLARE {$$=$1} | T_AS {$$=$1} | T_TRY {$$=$1} | T_CATCH {$$=$1} | T_FINALLY {$$=$1} - | T_THROW {$$=$1} | T_USE {$$=$1} | T_INSTEADOF {$$=$1} | T_GLOBAL {$$=$1} | T_VAR {$$=$1} | T_UNSET {$$=$1} | T_ISSET {$$=$1} | T_EMPTY {$$=$1} | T_CONTINUE {$$=$1} | T_GOTO {$$=$1} - | T_FUNCTION {$$=$1} | T_CONST {$$=$1} | T_RETURN {$$=$1} | T_PRINT {$$=$1} | T_YIELD {$$=$1} | T_LIST {$$=$1} | T_SWITCH {$$=$1} | T_ENDSWITCH {$$=$1} | T_CASE {$$=$1} | T_DEFAULT {$$=$1} | T_BREAK {$$=$1} - | T_ARRAY {$$=$1} | T_CALLABLE {$$=$1} | T_EXTENDS {$$=$1} | T_IMPLEMENTS {$$=$1} | T_NAMESPACE {$$=$1} | T_TRAIT {$$=$1} | T_INTERFACE {$$=$1} | T_CLASS {$$=$1} - | T_CLASS_C {$$=$1} | T_TRAIT_C {$$=$1} | T_FUNC_C {$$=$1} | T_METHOD_C {$$=$1} | T_LINE {$$=$1} | T_FILE {$$=$1} | T_DIR {$$=$1} | T_NS_C {$$=$1} | T_FN {$$=$1} -; - -semi_reserved: - reserved_non_modifiers - { - $$ = $1 - } - | T_STATIC {$$=$1} | T_ABSTRACT {$$=$1} | T_FINAL {$$=$1} | T_PRIVATE {$$=$1} | T_PROTECTED {$$=$1} | T_PUBLIC {$$=$1} -; - -identifier: - T_STRING - { - $$ = $1 - } - | semi_reserved - { - $$ = $1 - } -; - -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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -namespace_name: - T_STRING - { - namePart := name.NewNamePart($1.Value) - $$ = []node.Node{namePart} - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | namespace_name T_NS_SEPARATOR T_STRING - { - namePart := name.NewNamePart($3.Value) - $$ = append($1, namePart) - - // save position - namePart.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(namePart, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -name: - namespace_name - { - $$ = name.NewName($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1[0], $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NAMESPACE T_NS_SEPARATOR namespace_name - { - $$ = name.NewRelative($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Namespace, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name - { - $$ = name.NewFullyQualified($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -top_statement: - error - { - // error - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | interface_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_HALT_COMPILER '(' ')' ';' - { - $$ = stmt.NewHaltCompiler() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_NAMESPACE namespace_name ';' - { - name := name.NewName($2) - $$ = stmt.NewNamespace(name, nil) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_NAMESPACE namespace_name '{' top_statement_list '}' - { - name := name.NewName($2) - $$ = stmt.NewNamespace(name, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } - | T_NAMESPACE '{' top_statement_list '}' - { - $$ = stmt.NewNamespace(nil, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_USE mixed_group_use_declaration ';' - { - $$ = $2 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_USE use_type group_use_declaration ';' - { - $$ = $3.(*stmt.GroupUse).SetUseType($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_USE use_declarations ';' - { - $$ = stmt.NewUseList(nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_USE use_type use_declarations ';' - { - $$ = stmt.NewUseList($2, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_CONST const_list ';' - { - $$ = stmt.NewConstList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } -; - -use_type: - T_FUNCTION - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CONST - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -group_use_declaration: - namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' - { - name := name.NewName($1) - $$ = stmt.NewGroupUse(nil, name, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) - - // save comments - 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).setFreeFloating($$, freefloating.Stmts, append($5.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($5), $6.FreeFloating...)...)) - } else { - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' - { - name := name.NewName($2) - $$ = stmt.NewGroupUse(nil, name, $5) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) - - // save comments - 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).setFreeFloating($$, freefloating.Stmts, append($6.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($6), $7.FreeFloating...)...)) - } else { - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -mixed_group_use_declaration: - namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' - { - name := name.NewName($1) - $$ = stmt.NewGroupUse(nil, name, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $6)) - - // save comments - 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).setFreeFloating($$, freefloating.Stmts, append($5.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($5), $6.FreeFloating...)...)) - } else { - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $6.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' - { - name := name.NewName($2) - $$ = stmt.NewGroupUse(nil, name, $5) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) - - // save comments - 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).setFreeFloating($$, freefloating.Stmts, append($6.FreeFloating, append(yylex.(*Parser).GetFreeFloatingToken($6), $7.FreeFloating...)...)) - } else { - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $7.FreeFloating) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -possible_comma: - /* empty */ - { - $$ = nil - } - | ',' - { - $$ = $1 - } -; - -inline_use_declarations: - inline_use_declarations ',' inline_use_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | inline_use_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -unprefixed_use_declarations: - unprefixed_use_declarations ',' unprefixed_use_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | unprefixed_use_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -use_declarations: - use_declarations ',' use_declaration - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | use_declaration - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -inline_use_declaration: - unprefixed_use_declaration - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | use_type unprefixed_use_declaration - { - $$ = $2.(*stmt.Use).SetUseType($1) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -unprefixed_use_declaration: - namespace_name - { - name := name.NewName($1) - $$ = stmt.NewUse(nil, name, nil) - - // save position - 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) - } - | namespace_name T_AS T_STRING - { - name := name.NewName($1) - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewUse(nil, name, alias) - - // save position - 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).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) - } -; - -use_declaration: - unprefixed_use_declaration - { - $$ = $1 - - // save coments - yylex.(*Parser).MoveFreeFloating($1.(*stmt.Use).Use, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_SEPARATOR unprefixed_use_declaration - { - $$ = $2; - - // save comments - 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) - } -; - -const_list: - const_list ',' const_decl - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | const_decl - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -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) - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -inner_statement: - error - { - // error - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | interface_declaration_statement - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_HALT_COMPILER '(' ')' ';' - { - $$ = stmt.NewHaltCompiler() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - -statement: - '{' inner_statement_list '}' - { - $$ = stmt.NewStmtList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | if_stmt - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | alt_if_stmt - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_WHILE '(' expr ')' while_statement - { - switch n := $5.(type) { - case *stmt.While : - n.Cond = $3 - case *stmt.AltWhile : - n.Cond = $3 - } - - $$ = $5 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | T_DO statement T_WHILE '(' expr ')' ';' - { - $$ = stmt.NewDo($2, $5) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) - - // save comments - 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) - } - | T_FOR '(' for_exprs ';' for_exprs ';' for_exprs ')' for_statement - { - switch n := $9.(type) { - case *stmt.For : - n.Init = $3 - n.Cond = $5 - n.Loop = $7 - case *stmt.AltFor : - n.Init = $3 - n.Cond = $5 - n.Loop = $7 - } - - $$ = $9 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) - - // save comments - 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) - } - | T_SWITCH '(' expr ')' switch_case_list - { - switch n := $5.(type) { - case *stmt.Switch: - n.Cond = $3 - case *stmt.AltSwitch: - n.Cond = $3 - default: - panic("unexpected node type") - } - - $$ = $5 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | T_BREAK optional_expr ';' - { - $$ = stmt.NewBreak($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_CONTINUE optional_expr ';' - { - $$ = stmt.NewContinue($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_RETURN optional_expr ';' - { - $$ = stmt.NewReturn($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_GLOBAL global_var_list ';' - { - $$ = stmt.NewGlobal($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_STATIC static_var_list ';' - { - $$ = stmt.NewStatic($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_ECHO echo_expr_list ';' - { - $$ = stmt.NewEcho($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_INLINE_HTML - { - $$ = stmt.NewInlineHtml($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr ';' - { - $$ = stmt.NewExpression($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - 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) - } - | T_UNSET '(' unset_variables possible_comma ')' ';' - { - $$ = stmt.NewUnset($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Unset, $2.FreeFloating) - if $4 != nil { - 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).setFreeFloating($$, freefloating.CloseParenthesisToken, $6.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($6)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement - { - switch n := $7.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Variable = $5 - case *stmt.AltForeach : - n.Expr = $3 - n.Variable = $5 - } - - $$ = $7 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $7)) - - // save comments - 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) - } - | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement - { - switch n := $9.(type) { - case *stmt.Foreach : - n.Expr = $3 - n.Key = $5 - n.Variable = $7 - case *stmt.AltForeach : - n.Expr = $3 - n.Key = $5 - n.Variable = $7 - } - - $$ = $9 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) - - // save comments - 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 - { - $$ = $5 - $$.(*stmt.Declare).Consts = $3 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | ';' - { - $$ = stmt.NewNop() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_TRY '{' inner_statement_list '}' catch_list finally_statement - { - if $6 == nil { - $$ = stmt.NewTry($3, $5, $6) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $5)) - } else { - $$ = stmt.NewTry($3, $5, $6) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) - } - - // save comments - 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) - } - | T_THROW expr ';' - { - $$ = stmt.NewThrow($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_GOTO T_STRING ';' - { - label := node.NewIdentifier($2.Value) - $$ = stmt.NewGoto(label) - - // save position - label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } - | T_STRING ':' - { - label := node.NewIdentifier($1.Value) - $$ = stmt.NewLabel(label) - - // save position - label.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Label, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - -catch_list: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}' - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($5.Value, isDollar)) - variable := expr.NewVariable(identifier) - catch := stmt.NewCatch($4, variable, $8) - $$ = append($1, catch) - - // save position - 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).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) - } -; -catch_name_list: - name - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | catch_name_list '|' name - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -finally_statement: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINALLY '{' inner_statement_list '}' - { - $$ = stmt.NewFinally($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -unset_variables: - unset_variable - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | unset_variables ',' unset_variable - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -unset_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function_declaration_statement: - T_FUNCTION returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type '{' inner_statement_list '}' - { - name := node.NewIdentifier($3.Value) - $$ = stmt.NewFunction(name, $2 != nil, $6, $8, $10, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) - - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - if $2 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - -is_reference: - /* empty */ - { - $$ = nil - } - | '&' - { - $$ = $1 - } -; - -is_variadic: - /* empty */ - { - $$ = nil - } - | T_ELLIPSIS - { - $$ = $1 - } -; - -class_declaration_statement: - class_modifiers T_CLASS T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' - { - name := node.NewIdentifier($3.Value) - $$ = stmt.NewClass(name, $1, nil, $4, $5, $8, $6) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $9)) - - // save comments - 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) - } - | T_CLASS T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' - { - name := node.NewIdentifier($2.Value) - $$ = stmt.NewClass(name, nil, nil, $3, $4, $7, $5) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) - - // save comments - 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) - } -; - -class_modifiers: - class_modifier - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_modifiers class_modifier - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_modifier: - T_ABSTRACT - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINAL - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_declaration_statement: - T_TRAIT T_STRING backup_doc_comment '{' class_statement_list '}' - { - name := node.NewIdentifier($2.Value) - $$ = stmt.NewTrait(name, $5, $3) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $6)) - - // save comments - 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) - } -; - -interface_declaration_statement: - T_INTERFACE T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}' - { - name := node.NewIdentifier($2.Value) - $$ = stmt.NewInterface(name, $3, $6, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $7)) - - // save comments - 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) - } -; - -extends_from: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EXTENDS name - { - $$ = stmt.NewClassExtends($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -interface_extends_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EXTENDS name_list - { - $$ = stmt.NewInterfaceExtends($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -implements_list: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_IMPLEMENTS name_list - { - $$ = stmt.NewClassImplements($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -foreach_variable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' variable - { - $$ = expr.NewReference($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_LIST '(' array_pair_list ')' - { - $$ = expr.NewList($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | '[' array_pair_list ']' - { - $$ = expr.NewShortList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save commentsc - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -for_statement: - statement - { - $$ = stmt.NewFor(nil, nil, nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDFOR ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltFor(nil, nil, nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -foreach_statement: - statement - { - $$ = stmt.NewForeach(nil, nil, nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDFOREACH ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltForeach(nil, nil, nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -declare_statement: - statement - { - $$ = stmt.NewDeclare(nil, $1, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDDECLARE ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewDeclare(nil, stmtList, true) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -switch_case_list: - '{' case_list '}' - { - caseList := stmt.NewCaseList($2) - $$ = stmt.NewSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating(caseList, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(caseList, freefloating.CaseListEnd, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' ';' case_list '}' - { - caseList := stmt.NewCaseList($3) - $$ = stmt.NewSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | ':' case_list T_ENDSWITCH ';' - { - caseList := stmt.NewCaseList($2) - $$ = stmt.NewAltSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | ':' ';' case_list T_ENDSWITCH ';' - { - - caseList := stmt.NewCaseList($3) - $$ = stmt.NewAltSwitch(nil, caseList) - - // save position - caseList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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) - } -; - -case_list: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | case_list T_CASE expr case_separator inner_statement_list - { - _case := stmt.NewCase($3, $5) - $$ = append($1, _case) - - // save position - _case.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $5)) - - // save comments - 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) - } - | case_list T_DEFAULT case_separator inner_statement_list - { - _default := stmt.NewDefault($4) - $$ = append($1, _default) - - // save position - _default.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $4)) - - // save comments - 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) - } -; - -case_separator: - ':' - { - $$ = $1 - } - | ';' - { - $$ = $1 - } -; - -while_statement: - statement - { - $$ = stmt.NewWhile(nil, $1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' inner_statement_list T_ENDWHILE ';' - { - stmtList := stmt.NewStmtList($2) - $$ = stmt.NewAltWhile(nil, stmtList) - - // save position - stmtList.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -if_stmt_without_else: - T_IF '(' expr ')' statement - { - $$ = stmt.NewIf($3, $5, nil, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | if_stmt_without_else T_ELSEIF '(' expr ')' statement - { - _elseIf := stmt.NewElseIf($4, $6) - $$ = $1.(*stmt.If).AddElseIf(_elseIf) - - // save position - _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) - - // save comments - 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) - } -; - -if_stmt: - if_stmt_without_else %prec T_NOELSE - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | if_stmt_without_else T_ELSE statement - { - _else := stmt.NewElse($3) - $$ = $1.(*stmt.If).SetElse(_else) - - // save position - _else.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating(_else, freefloating.Start, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -alt_if_stmt_without_else: - T_IF '(' expr ')' ':' inner_statement_list - { - stmts := stmt.NewStmtList($6) - $$ = stmt.NewAltIf($3, stmts, nil, nil) - - // save position - stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($6)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $6)) - - // save comments - 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) - } - | alt_if_stmt_without_else T_ELSEIF '(' expr ')' ':' inner_statement_list - { - stmts := stmt.NewStmtList($7) - _elseIf := stmt.NewAltElseIf($4, stmts) - $$ = $1.(*stmt.AltIf).AddElseIf(_elseIf) - - // save position - stmts.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListPosition($7)) - _elseIf.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($2, $7)) - - // save comments - 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) - } -; - -alt_if_stmt: - alt_if_stmt_without_else T_ENDIF ';' - { - $$ = $1 - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - 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) - } - | alt_if_stmt_without_else T_ELSE ':' inner_statement_list T_ENDIF ';' - { - stmts := stmt.NewStmtList($4) - _else := stmt.NewAltElse(stmts) - $$ = $1.(*stmt.AltIf).SetElse(_else) - - // save position - 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).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) - } -; - -parameter_list: - non_empty_parameter_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_parameter_list: - parameter - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_parameter_list ',' parameter - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -parameter: - optional_type is_reference is_variadic T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - } else if $2 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($2, $4)) - } else if $3 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $4)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - } - - // save comments - if $1 != nil { - yylex.(*Parser).MoveFreeFloating($1, $$) - } - if $2 != nil { - yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) - } - if $3 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } - | optional_type is_reference is_variadic T_VARIABLE '=' expr - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($4.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $6)) - } else if $2 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $6)) - } else if $3 != nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $6)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6)) - } - - // save comments - if $1 != nil { - yylex.(*Parser).MoveFreeFloating($1, $$) - } - if $2 != nil { - yylex.(*Parser).setFreeFloating($$, freefloating.OptionalType, $2.FreeFloating) - } - if $3 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - -optional_type: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | type_expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -type_expr: - type - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '?' type - { - $$ = node.NewNullable($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -type: - T_ARRAY - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CALLABLE - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | name - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -return_type: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | ':' type_expr - { - $$ = $2; - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Colon, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -argument_list: - '(' ')' - { - $$ = node.NewArgumentList(nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArgumentList, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' non_empty_argument_list possible_comma ')' - { - $$ = node.NewArgumentList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - if $3 != nil { - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_argument_list: - argument - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_argument_list ',' argument - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -argument: - expr - { - $$ = node.NewArgument($1, false, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ELLIPSIS expr - { - $$ = node.NewArgument($2, true, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -global_var_list: - global_var_list ',' global_var - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | global_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -global_var: - simple_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_var_list: - static_var_list ',' static_var - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_var: - T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = stmt.NewStaticVar(variable, nil) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '=' expr - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = stmt.NewStaticVar(variable, $3) - - // save position - 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).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_statement_list: - class_statement_list class_statement - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_statement: - variable_modifiers optional_type property_list ';' - { - $$ = stmt.NewPropertyList($1, $2, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1[0], $$) - yylex.(*Parser).setFreeFloating($$, freefloating.PropertyList, $4.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($4)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | method_modifiers T_CONST class_const_list ';' - { - $$ = stmt.NewClassConstList($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $4)) - - // save comments - 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 - { - $$ = stmt.NewTraitUse($2, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body - { - name := node.NewIdentifier($4.Value) - $$ = stmt.NewClassMethod(name, $1, $3 != nil, $7, $9, $10, $5) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - if $1 == nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($2, $10)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeListNodePosition($1, $10)) - } - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } -; - -name_list: - name - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | name_list ',' name - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptations: - ';' - { - $$ = stmt.NewNop() - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' '}' - { - $$ = stmt.NewTraitAdaptationList(nil) - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' trait_adaptation_list '}' - { - $$ = stmt.NewTraitAdaptationList($2) - - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.AdaptationList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptation_list: - trait_adaptation - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_adaptation_list trait_adaptation - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_adaptation: - trait_precedence ';' - { - $$ = $1; - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.NameList, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_alias ';' - { - $$ = $1; - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Alias, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($2)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_precedence: - absolute_trait_method_reference T_INSTEADOF name_list - { - $$ = stmt.NewTraitUsePrecedence($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeNodeListPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_alias: - trait_method_reference T_AS T_STRING - { - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewTraitUseAlias($1, nil, alias) - - // save position - alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_method_reference T_AS reserved_non_modifiers - { - alias := node.NewIdentifier($3.Value) - $$ = stmt.NewTraitUseAlias($1, nil, alias) - - // save position - alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_method_reference T_AS member_modifier identifier - { - alias := node.NewIdentifier($4.Value) - $$ = stmt.NewTraitUseAlias($1, $3, alias) - - // save position - alias.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(alias, freefloating.Start, $4.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | trait_method_reference T_AS member_modifier - { - $$ = stmt.NewTraitUseAlias($1, $3, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Ref, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -trait_method_reference: - identifier - { - name := node.NewIdentifier($1.Value) - $$ = stmt.NewTraitMethodRef(nil, name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | absolute_trait_method_reference - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -absolute_trait_method_reference: - name T_PAAMAYIM_NEKUDOTAYIM identifier - { - target := node.NewIdentifier($3.Value) - $$ = stmt.NewTraitMethodRef($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -method_body: - ';' /* abstract method */ - { - $$ = stmt.NewNop() - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.SemiColon, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' inner_statement_list '}' - { - $$ = stmt.NewStmtList($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Stmts, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_modifiers: - non_empty_member_modifiers - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VAR - { - modifier := node.NewIdentifier($1.Value) - $$ = []node.Node{modifier} - - // save position - modifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(modifier, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -method_modifiers: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_member_modifiers - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_member_modifiers: - member_modifier - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_member_modifiers member_modifier - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -member_modifier: - T_PUBLIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PROTECTED - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PRIVATE - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STATIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ABSTRACT - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FINAL - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -property_list: - property_list ',' property - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | property - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -property: - T_VARIABLE backup_doc_comment - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = stmt.NewProperty(variable, nil, $2) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - variable.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '=' expr backup_doc_comment - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = stmt.NewProperty(variable, $3, $4) - - // save position - 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).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_const_list: - class_const_list ',' class_const_decl - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_const_decl - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_const_decl: - identifier '=' expr backup_doc_comment - { - name := node.NewIdentifier($1.Value) - $$ = stmt.NewConstant(name, $3, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -const_decl: - T_STRING '=' expr backup_doc_comment - { - name := node.NewIdentifier($1.Value) - $$ = stmt.NewConstant(name, $3, $4) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -echo_expr_list: - echo_expr_list ',' echo_expr - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | echo_expr - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -echo_expr: - expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -for_exprs: - /* empty */ - { - $$ = nil; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | non_empty_for_exprs - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_for_exprs: - non_empty_for_exprs ',' expr - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -anonymous_class: - T_CLASS ctor_arguments extends_from implements_list backup_doc_comment '{' class_statement_list '}' - { - if $2 != nil { - $$ = stmt.NewClass(nil, nil, $2.(*node.ArgumentList), $3, $4, $7, $5) - } else { - $$ = stmt.NewClass(nil, nil, nil, $3, $4, $7, $5) - } - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $8)) - - // save comments - 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) - } -; - -new_expr: - T_NEW class_name_reference ctor_arguments - { - if $3 != nil { - $$ = expr.NewNew($2, $3.(*node.ArgumentList)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3)) - } else { - $$ = expr.NewNew($2, nil) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - } - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NEW anonymous_class - { - $$ = expr.NewNew($2, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -expr_without_variable: - T_LIST '(' array_pair_list ')' '=' expr - { - listNode := expr.NewList($3) - $$ = assign.NewAssign(listNode, $6) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $6)) - - // save comments - 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) - } - | '[' array_pair_list ']' '=' expr - { - shortList := expr.NewShortList($2) - $$ = assign.NewAssign(shortList, $5) - - // save position - shortList.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $5)) - - // save comments - 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) - } - | variable '=' expr - { - $$ = assign.NewAssign($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable '=' '&' expr - { - $$ = assign.NewReference($1, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Equal, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CLONE expr - { - $$ = expr.NewClone($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_PLUS_EQUAL expr - { - $$ = assign.NewPlus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MINUS_EQUAL expr - { - $$ = assign.NewMinus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MUL_EQUAL expr - { - $$ = assign.NewMul($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_POW_EQUAL expr - { - $$ = assign.NewPow($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_DIV_EQUAL expr - { - $$ = assign.NewDiv($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_CONCAT_EQUAL expr - { - $$ = assign.NewConcat($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_MOD_EQUAL expr - { - $$ = assign.NewMod($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_AND_EQUAL expr - { - $$ = assign.NewBitwiseAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_OR_EQUAL expr - { - $$ = assign.NewBitwiseOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_XOR_EQUAL expr - { - $$ = assign.NewBitwiseXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_SL_EQUAL expr - { - $$ = assign.NewShiftLeft($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_SR_EQUAL expr - { - $$ = assign.NewShiftRight($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_COALESCE_EQUAL expr - { - $$ = assign.NewCoalesce($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_INC - { - $$ = expr.NewPostInc($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INC variable - { - $$ = expr.NewPreInc($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable T_DEC - { - $$ = expr.NewPostDec($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DEC variable - { - $$ = expr.NewPreDec($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_BOOLEAN_OR expr - { - $$ = binary.NewBooleanOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_BOOLEAN_AND expr - { - $$ = binary.NewBooleanAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_OR expr - { - $$ = binary.NewLogicalOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_AND expr - { - $$ = binary.NewLogicalAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_LOGICAL_XOR expr - { - $$ = binary.NewLogicalXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '|' expr - { - $$ = binary.NewBitwiseOr($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '&' expr - { - $$ = binary.NewBitwiseAnd($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '^' expr - { - $$ = binary.NewBitwiseXor($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '.' expr - { - $$ = binary.NewConcat($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '+' expr - { - $$ = binary.NewPlus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '-' expr - { - $$ = binary.NewMinus($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '*' expr - { - $$ = binary.NewMul($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_POW expr - { - $$ = binary.NewPow($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '/' expr - { - $$ = binary.NewDiv($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '%' expr - { - $$ = binary.NewMod($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_SL expr - { - $$ = binary.NewShiftLeft($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_SR expr - { - $$ = binary.NewShiftRight($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '+' expr %prec T_INC - { - $$ = expr.NewUnaryPlus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '-' expr %prec T_INC - { - $$ = expr.NewUnaryMinus($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '!' expr - { - $$ = expr.NewBooleanNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '~' expr - { - $$ = expr.NewBitwiseNot($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_IDENTICAL expr - { - $$ = binary.NewIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_NOT_IDENTICAL expr - { - $$ = binary.NewNotIdentical($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_EQUAL expr - { - $$ = binary.NewEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_NOT_EQUAL expr - { - $$ = binary.NewNotEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - 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) - } - | expr '<' expr - { - $$ = binary.NewSmaller($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_SMALLER_OR_EQUAL expr - { - $$ = binary.NewSmallerOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '>' expr - { - $$ = binary.NewGreater($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_IS_GREATER_OR_EQUAL expr - { - $$ = binary.NewGreaterOrEqual($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_SPACESHIP expr - { - $$ = binary.NewSpaceship($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_INSTANCEOF class_name_reference - { - $$ = expr.NewInstanceOf($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' expr ')' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | new_expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '?' expr ':' expr - { - $$ = expr.NewTernary($1, $3, $5) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $5)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $4.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr '?' ':' expr - { - $$ = expr.NewTernary($1, nil, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Cond, $2.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.True, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_COALESCE expr - { - $$ = binary.NewCoalesce($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | internal_functions_in_yacc - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INT_CAST expr - { - $$ = cast.NewInt($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DOUBLE_CAST expr - { - $$ = cast.NewDouble($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STRING_CAST expr - { - $$ = cast.NewString($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ARRAY_CAST expr - { - $$ = cast.NewArray($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_OBJECT_CAST expr - { - $$ = cast.NewObject($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_BOOL_CAST expr - { - $$ = cast.NewBool($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Cast, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_UNSET_CAST expr - { - $$ = cast.NewUnset($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - 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 - { - var e *expr.Exit; - if $2 != nil { - e = $2.(*expr.Exit) - } else { - e = expr.NewExit(nil) - } - - $$ = e - - if (strings.EqualFold($1.Value, "die")) { - e.Die = true - } - - // save position - if $2 == nil { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - } else { - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - } - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '@' expr - { - $$ = expr.NewErrorSuppress($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '`' backticks_expr '`' - { - $$ = expr.NewShellExec($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_PRINT expr - { - $$ = expr.NewPrint($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD - { - $$ = expr.NewYield(nil, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD expr - { - $$ = expr.NewYield(nil, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD expr T_DOUBLE_ARROW expr - { - $$ = expr.NewYield($2, $4) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $4)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_YIELD_FROM expr - { - $$ = expr.NewYieldFrom($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | inline_function - { - $$ = $1; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_STATIC inline_function - { - $$ = $2; - - switch n := $$.(type) { - case *expr.Closure : - n.Static = true; - case *expr.ArrowFunction : - n.Static = true; - }; - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Static, (*$$.GetFreeFloating())[freefloating.Start]); delete((*$$.GetFreeFloating()), freefloating.Start) - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating); - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -inline_function: - T_FUNCTION returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type '{' inner_statement_list '}' - { - $$ = expr.NewClosure($5, $7, $8, $10, false, $2 != nil, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $11)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FN returns_ref '(' parameter_list ')' return_type backup_doc_comment T_DOUBLE_ARROW expr - { - $$ = expr.NewArrowFunction($4, $6, $9, false, $2 != nil, $7) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $9)) - - // save comments - 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) - if $6 != nil { - yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$6.GetFreeFloating())[freefloating.Colon]); delete((*$6.GetFreeFloating()), freefloating.Colon) - }; - yylex.(*Parser).setFreeFloating($$, freefloating.ReturnType, $8.FreeFloating) - - // normalize - if $6 == nil { - yylex.(*Parser).setFreeFloating($$, freefloating.Params, (*$$.GetFreeFloating())[freefloating.ReturnType]); delete((*$$.GetFreeFloating()), freefloating.ReturnType) - }; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -backup_doc_comment: - /* empty */ - { - $$ = yylex.(*Parser).Lexer.GetPhpDocComment() - yylex.(*Parser).Lexer.SetPhpDocComment("") - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -returns_ref: - /* empty */ - { - $$ = nil - } - | '&' - { - $$ = $1 - } -; - -lexical_vars: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_USE '(' lexical_var_list ')' - { - $$ = expr.NewClosureUse($3) - - // 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) - } -; - -lexical_var_list: - lexical_var_list ',' lexical_var - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | lexical_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -lexical_var: - T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($2.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = expr.NewReference(variable) - - // save position - 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).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating(variable, freefloating.Start, $2.FreeFloating) - yylex.(*Parser).addDollarToken(variable) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -function_call: - name argument_list - { - $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list - { - $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | callable_expr argument_list - { - $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_name: - T_STATIC - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | name - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -class_name_reference: - class_name - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | new_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -exit_expr: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' optional_expr ')' - { - $$ = expr.NewExit($2); - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - 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) - } -; - -backticks_expr: - /* empty */ - { - $$ = []node.Node{} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ENCAPSED_AND_WHITESPACE - { - part := scalar.NewEncapsedStringPart($1.Value) - $$ = []node.Node{part} - - // save position - part.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -ctor_arguments: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | argument_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -dereferencable_scalar: - T_ARRAY '(' array_pair_list ')' - { - $$ = expr.NewArray($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | '[' array_pair_list ']' - { - $$ = expr.NewShortArray($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.ArrayPairList, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CONSTANT_ENCAPSED_STRING - { - $$ = scalar.NewString($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -scalar: - T_LNUMBER - { - $$ = scalar.NewLnumber($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DNUMBER - { - $$ = scalar.NewDnumber($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_LINE - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FILE - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_DIR - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_TRAIT_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_METHOD_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_FUNC_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NS_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_CLASS_C - { - $$ = scalar.NewMagicConstant($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC - { - encapsed := scalar.NewEncapsedStringPart($2.Value) - $$ = scalar.NewHeredoc($1.Value, []node.Node{encapsed}) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC T_END_HEREDOC - { - $$ = scalar.NewHeredoc($1.Value, nil) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '"' encaps_list '"' - { - $$ = scalar.NewEncapsed($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_START_HEREDOC encaps_list T_END_HEREDOC - { - $$ = scalar.NewHeredoc($1.Value, $2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dereferencable_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | constant - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -constant: - name - { - $$ = expr.NewConstFetch($1) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name T_PAAMAYIM_NEKUDOTAYIM identifier - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier - { - target := node.NewIdentifier($3.Value) - $$ = expr.NewClassConstFetch($1, target) - - // save position - target.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($3)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(target, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -expr: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr_without_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -optional_expr: - /* empty */ - { - $$ = nil - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable_class_name: - dereferencable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -dereferencable: - variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' expr ')' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dereferencable_scalar - { - $$ = $1; - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -callable_expr: - callable_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '(' expr ')' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dereferencable_scalar - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -callable_variable: - simple_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dereferencable '[' optional_expr ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | constant '[' optional_expr ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | dereferencable '{' expr '}' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | dereferencable T_OBJECT_OPERATOR property_name argument_list - { - $$ = expr.NewMethodCall($1, $3, $4.(*node.ArgumentList)) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | function_call - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -variable: - callable_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | static_member - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | dereferencable T_OBJECT_OPERATOR property_name - { - $$ = expr.NewPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -simple_variable: - T_VARIABLE - { - name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '$' '{' expr '}' - { - $$ = expr.NewVariable($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | '$' simple_variable - { - $$ = expr.NewVariable($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).setFreeFloating($$, freefloating.Dollar, yylex.(*Parser).GetFreeFloatingToken($1)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -static_member: - class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Name, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -new_variable: - simple_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | new_variable '[' optional_expr ']' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | new_variable '{' expr '}' - { - $$ = expr.NewArrayDimFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4)) - - // save comments - 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) - } - | new_variable T_OBJECT_OPERATOR property_name - { - $$ = expr.NewPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable - { - $$ = expr.NewStaticPropertyFetch($1, $3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Var, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -member_name: - identifier - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' expr '}' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | simple_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -property_name: - T_STRING - { - $$ = node.NewIdentifier($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '{' expr '}' - { - $$ = $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)...)...)) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | simple_variable - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -array_pair_list: - non_empty_array_pair_list - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -possible_array_pair: - /* empty */ - { - $$ = expr.NewArrayItem(nil, nil, false) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | array_pair - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -non_empty_array_pair_list: - non_empty_array_pair_list ',' possible_array_pair - { - if len($1) == 0 { - $1 = []node.Node{expr.NewArrayItem(nil, nil, false)} - } - - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | possible_array_pair - { - if $1.(*expr.ArrayItem).Key == nil && $1.(*expr.ArrayItem).Val == nil { - $$ = []node.Node{} - } else { - $$ = []node.Node{$1} - } - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -array_pair: - expr T_DOUBLE_ARROW expr - { - $$ = expr.NewArrayItem($1, $3, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $3)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr - { - $$ = expr.NewArrayItem(nil, $1, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodePosition($1)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | expr T_DOUBLE_ARROW '&' variable - { - reference := expr.NewReference($4) - $$ = expr.NewArrayItem($1, reference, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4)) - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($3, $4)) - - // save comments - yylex.(*Parser).MoveFreeFloating($1, $$) - yylex.(*Parser).setFreeFloating($$, freefloating.Expr, $2.FreeFloating) - yylex.(*Parser).setFreeFloating(reference, freefloating.Start, $3.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '&' variable - { - reference := expr.NewReference($2) - $$ = expr.NewArrayItem(nil, reference, false) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - reference.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ELLIPSIS expr - { - $$ = expr.NewArrayItem(nil, $2, true) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - 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 - listNode := expr.NewList($5) - $$ = expr.NewArrayItem($1, listNode, false) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($3, $6)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $6)) - - // save comments - 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 - listNode := expr.NewList($3) - $$ = expr.NewArrayItem(nil, listNode, false) - - // save position - listNode.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } -; - -encaps_list: - encaps_list encaps_var - { - $$ = append($1, $2) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_list T_ENCAPSED_AND_WHITESPACE - { - encapsed := scalar.NewEncapsedStringPart($2.Value) - $$ = append($1, encapsed) - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | encaps_var - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_ENCAPSED_AND_WHITESPACE encaps_var - { - encapsed := scalar.NewEncapsedStringPart($1.Value) - $$ = []node.Node{encapsed, $2} - - // save position - encapsed.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating(encapsed, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -encaps_var: - T_VARIABLE - { - name := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(name) - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE '[' encaps_var_offset ']' - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - $$ = expr.NewArrayDimFetch(variable, $3) - - // save position - 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).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) - } - | T_VARIABLE T_OBJECT_OPERATOR T_STRING - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - variable := expr.NewVariable(identifier) - fetch := node.NewIdentifier($3.Value) - $$ = expr.NewPropertyFetch(variable, fetch) - - // save position - 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).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 '}' - { - variable := expr.NewVariable($2) - - $$ = variable - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // 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) - } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' - { - name := node.NewIdentifier($2.Value) - variable := expr.NewVariable(name) - - $$ = variable - - // save position - name.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($2)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3)) - - // 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) - } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { - identifier := node.NewIdentifier($2.Value) - variable := expr.NewVariable(identifier) - $$ = expr.NewArrayDimFetch(variable, $4) - - // save position - 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).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) - } - | T_CURLY_OPEN variable '}' - { - $$ = $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) - } -; - -encaps_var_offset: - T_STRING - { - $$ = scalar.NewString($1.Value) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_NUM_STRING - { - // TODO: add option to handle 64 bit integer - if _, err := strconv.Atoi($1.Value); err == nil { - $$ = scalar.NewLnumber($1.Value) - } else { - $$ = scalar.NewString($1.Value) - } - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | '-' T_NUM_STRING - { - var lnumber *scalar.Lnumber - // TODO: add option to handle 64 bit integer - _, err := strconv.Atoi($2.Value); - isInt := err == nil - - if isInt { - lnumber = scalar.NewLnumber($2.Value) - $$ = expr.NewUnaryMinus(lnumber) - } else { - $2.Value = "-"+$2.Value - $$ = scalar.NewString($2.Value) - } - - // save position - if isInt { - lnumber.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - } - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_VARIABLE - { - identifier := node.NewIdentifier(strings.TrimLeftFunc($1.Value, isDollar)) - $$ = expr.NewVariable(identifier) - - // save position - identifier.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - yylex.(*Parser).addDollarToken($$) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -internal_functions_in_yacc: - T_ISSET '(' isset_variables possible_comma ')' - { - $$ = expr.NewIsset($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $5)) - - // save comments - 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).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EMPTY '(' expr ')' - { - $$ = expr.NewEmpty($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_INCLUDE expr - { - $$ = expr.NewInclude($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_INCLUDE_ONCE expr - { - $$ = expr.NewIncludeOnce($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_EVAL '(' expr ')' - { - $$ = expr.NewEval($3) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) - - // save comments - 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) - } - | T_REQUIRE expr - { - $$ = expr.NewRequire($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | T_REQUIRE_ONCE expr - { - $$ = expr.NewRequireOnce($2) - - // save position - $$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) - - // save comments - yylex.(*Parser).setFreeFloating($$, freefloating.Start, $1.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -isset_variables: - isset_variable - { - $$ = []node.Node{$1} - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } - | isset_variables ',' isset_variable - { - $$ = append($1, $3) - - // save comments - yylex.(*Parser).setFreeFloating(lastNode($1), freefloating.End, $2.FreeFloating) - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -isset_variable: - expr - { - $$ = $1 - - yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) - } -; - -///////////////////////////////////////////////////////////////////////// - -%% diff --git a/php7/php7_bench_test.go b/php7/php7_bench_test.go deleted file mode 100644 index c7acc29..0000000 --- a/php7/php7_bench_test.go +++ /dev/null @@ -1,387 +0,0 @@ -package php7_test - -import ( - "testing" - - "github.com/z7zmey/php-parser/php7" -) - -func BenchmarkPhp7(b *testing.B) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - /** anonymous class */ - new class ($a, ...$b) {}; - new class {}; - new $foo; - new $foo[1]; - new $foo{$bar}; - new $foo->bar; - new $foo::$bar; - new static::$bar; - - function foo(?bar $bar=null, baz &...$baz) {} - class foo {public function foo(?bar $bar=null, baz &...$baz) {}} - function(?bar $bar=null, baz &...$baz) {}; - static function(?bar $bar=null, baz &...$baz) {}; - - "test"; - "\$test"; - " - test - "; - '$test'; - ' - $test - '; - <<bar()"; - "test ${foo}"; - "test ${foo[0]}"; - "test ${$foo}"; - "test {$foo->bar()}"; - - if ($a) : - endif; - if ($a) : - elseif ($b): - endif; - if ($a) : - else: - endif; - if ($a) : - elseif ($b): - elseif ($c): - else: - endif; - - while (1) { break; } - while (1) { break 2; } - while (1) : break(3); endwhile; - class foo{ public const FOO = 1, BAR = 2; } - class foo{ const FOO = 1, BAR = 2; } - class foo{ function bar() {} } - class foo{ public static function &bar() {} } - class foo{ public static function &bar(): void {} } - abstract class foo{ } - final class foo extends bar { } - final class foo implements bar { } - final class foo implements bar, baz { } - new class() extends foo implements bar, baz { }; - - const FOO = 1, BAR = 2; - while (1) { continue; } - while (1) { continue 2; } - while (1) { continue(3); } - declare(ticks=1); - declare(ticks=1) {} - declare(ticks=1): enddeclare; - do {} while(1); - echo $a, 1; - echo($a); - for($i = 0; $i < 10; $i++, $i++) {} - for(; $i < 10; $i++, $i++) : endfor; - foreach ($a as $v) {} - foreach ($a as $v) : endforeach; - foreach ($a as $k => $v) {} - foreach ($a as $k => &$v) {} - foreach ($a as $k => list($v)) {} - foreach ($a as $k => [$v]) {} - function foo() {} - function foo() {return;} - function &foo() {return 1;} - function &foo(): void {} - global $a, $b; - a: - goto a; - __halt_compiler(); - if ($a) {} - if ($a) {} elseif ($b) {} - if ($a) {} else {} - if ($a) {} elseif ($b) {} elseif ($c) {} else {} - if ($a) {} elseif ($b) {} else if ($c) {} else {} - ?>
1, &$b,); - ~$a; - !$a; - - Foo::Bar; - $foo::Bar; - clone($a); - clone $a; - function(){}; - function($a, $b) use ($c, &$d) {}; - function(): void {}; - foo; - namespace\foo; - \foo; - - empty($a); - @$a; - eval($a); - exit; - exit($a); - die; - die($a); - foo(); - namespace\foo(); - \foo(); - $foo(); - - $a--; - $a++; - --$a; - ++$a; - - include $a; - include_once $a; - require $a; - require_once $a; - - $a instanceof Foo; - $a instanceof namespace\Foo; - $a instanceof \Foo; - - isset($a, $b); - list($a) = $b; - list($a[]) = $b; - list(list($a)) = $b; - - $a->foo(); - new Foo(); - new namespace\Foo(); - new \Foo(); - new class ($a, ...$b) {}; - print($a); - $a->foo; - ` + "`cmd $a`;" + ` - ` + "`cmd`;" + ` - ` + "``;" + ` - []; - [1]; - [1=>1, &$b,]; - - [$a] = $b; - [$a[]] = $b; - [list($a)] = $b; - Foo::bar(); - namespace\Foo::bar(); - \Foo::bar(); - Foo::$bar; - $foo::$bar; - namespace\Foo::$bar; - \Foo::$bar; - $a ? $b : $c; - $a ? : $c; - $a ? $b ? $c : $d : $e; - $a ? $b : $c ? $d : $e; - -$a; - +$a; - $$a; - yield; - yield $a; - yield $a => $b; - yield from $a; - - (array)$a; - (boolean)$a; - (bool)$a; - (double)$a; - (float)$a; - (integer)$a; - (int)$a; - (object)$a; - (string)$a; - (unset)$a; - - $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 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; - $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; - - class foo {public function class() {} } - \foo\bar(); - - function foo(&$a, ...$b) { - __halt_compiler(); - function bar() {} - class Baz {} - trait Quux{} - interface Quuux {} - } - - function foo(&$a = 1, ...$b = 1, $c = 1) {} - function foo(array $a, callable $b) {} - abstract final class foo { abstract protected static function bar(); final private function baz() {} } - - (new Foo)->bar; - (new Foo)(); - [$foo][0](); - foo[1](); - "foo"(); - [1]{$foo}(); - ${foo()}; - - Foo::$bar(); - Foo::{$bar[0]}(); - - $foo->$bar; - $foo->{$bar[0]}; - - [1=>&$a, 2=>list($b)]; - ` - - for n := 0; n < b.N; n++ { - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - } -} diff --git a/php7/php7_test.go b/php7/php7_test.go deleted file mode 100644 index 32b79c7..0000000 --- a/php7/php7_test.go +++ /dev/null @@ -1,16450 +0,0 @@ -package php7_test - -import ( - "testing" - - "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/php7" - "github.com/z7zmey/php-parser/position" -) - -func TestPhp7(t *testing.T) { - src := `bar($a, ...$b); - foo::bar($a, ...$b); - $foo::bar($a, ...$b); - new foo($a, ...$b); - /** anonymous class */ - new class ($a, ...$b) {}; - new class {}; - new $foo; - new $foo[1]; - new $foo{$bar}; - new $foo->bar; - new $foo::$bar; - new static::$bar; - - function foo(?bar $bar=null, baz &...$baz) {} - class foo {public function foo(?bar $bar=null, baz &...$baz) {}} - function(?bar $bar=null, baz &...$baz) {}; - static function(?bar $bar=null, baz &...$baz) {}; - - 1234567890123456789; - 12345678901234567890; - 0.; - 0b0111111111111111111111111111111111111111111111111111111111111111; - 0b1111111111111111111111111111111111111111111111111111111111111111; - 0x007111111111111111; - 0x8111111111111111; - __CLASS__; - __DIR__; - __FILE__; - __FUNCTION__; - __LINE__; - __NAMESPACE__; - __METHOD__; - __TRAIT__; - - "test $var"; - "test $var[1]"; - "test $var[-1]"; - "test $var[1234567890123456789012345678901234567890]"; - "test $var[-1234567890123456789012345678901234567890]"; - "test $var[bar]"; - "test $var[$bar]"; - "$foo $bar"; - "test $foo->bar()"; - "test ${foo}"; - "test ${foo[0]}"; - "test ${$foo}"; - "test {$foo->bar()}"; - - if ($a) : - endif; - if ($a) : - elseif ($b): - endif; - if ($a) : - else: - endif; - if ($a) : - elseif ($b): - elseif ($c): - else: - endif; - - while (1) { break; } - while (1) { break 2; } - while (1) : break(3); endwhile; - class foo{ public const FOO = 1, BAR = 2; } - class foo{ const FOO = 1, BAR = 2; } - class foo{ function bar() {} } - class foo{ public static function &bar() {} } - class foo{ public static function &bar(): void {} } - abstract class foo{ } - final class foo extends bar { } - final class foo implements bar { } - final class foo implements bar, baz { } - new class() extends foo implements bar, baz { }; - - const FOO = 1, BAR = 2; - while (1) { continue; } - while (1) { continue 2; } - while (1) { continue(3); } - declare(ticks=1); - declare(ticks=1) {} - declare(ticks=1): enddeclare; - do {} while(1); - echo $a, 1; - echo($a); - for($i = 0; $i < 10; $i++, $i++) {} - for(; $i < 10; $i++, $i++) : endfor; - foreach ($a as $v) {} - foreach ($a as $v) : endforeach; - foreach ($a as $k => $v) {} - foreach ($a as $k => &$v) {} - foreach ($a as $k => list($v)) {} - foreach ($a as $k => [$v]) {} - function foo() {} - function foo() {return;} - function &foo() {return 1;} - function &foo(): void {} - global $a, $b; - a: - goto a; - if ($a) {} - if ($a) {} elseif ($b) {} - if ($a) {} else {} - if ($a) {} elseif ($b) {} elseif ($c) {} else {} - if ($a) {} elseif ($b) {} else if ($c) {} else {} - ?>
1, &$b,); - ~$a; - !$a; - - Foo::Bar; - $foo::Bar; - clone($a); - clone $a; - function(){}; - function($a, $b) use ($c, &$d) {}; - function(): void {}; - foo; - namespace\foo; - \foo; - - empty($a); - @$a; - eval($a); - exit; - exit($a); - die; - die($a); - foo(); - namespace\foo(); - \foo(); - $foo(); - - $a--; - $a++; - --$a; - ++$a; - - include $a; - include_once $a; - require $a; - require_once $a; - - $a instanceof Foo; - $a instanceof namespace\Foo; - $a instanceof \Foo; - - isset($a, $b); - list($a) = $b; - list($a[]) = $b; - list(list($a)) = $b; - - $a->foo(); - new Foo(); - new namespace\Foo(); - new \Foo(); - new class ($a, ...$b) {}; - print($a); - $a->foo; - ` + "`cmd $a`;" + ` - ` + "`cmd`;" + ` - ` + "``;" + ` - []; - [1]; - [1=>1, &$b,]; - - [$a] = $b; - [$a[]] = $b; - [list($a)] = $b; - Foo::bar(); - namespace\Foo::bar(); - \Foo::bar(); - Foo::$bar; - $foo::$bar; - namespace\Foo::$bar; - \Foo::$bar; - $a ? $b : $c; - $a ? : $c; - $a ? $b ? $c : $d : $e; - $a ? $b : $c ? $d : $e; - -$a; - +$a; - $$a; - yield; - yield $a; - yield $a => $b; - yield from $a; - - (array)$a; - (boolean)$a; - (bool)$a; - (double)$a; - (float)$a; - (integer)$a; - (int)$a; - (object)$a; - (string)$a; - (unset)$a; - - $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 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; - $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; - - class foo {public function class() {} } - \foo\bar(); - - function foo(&$a, ...$b) { - - function bar() {} - class Baz {} - trait Quux{} - interface Quuux {} - } - - function foo(&$a = 1, ...$b = 1, $c = 1) {} - function foo(array $a, callable $b) {} - abstract final class foo { abstract protected static function bar(); final private function baz() {} } - - (new Foo)->bar; - (new Foo)(); - [$foo][0](); - foo[1](); - "foo"(); - [1]{$foo}(); - ${foo()}; - - Foo::$bar(); - Foo::{$bar[0]}(); - - $foo->$bar; - $foo->{$bar[0]}; - - [1=>&$a, 2=>list($b)]; - - __halt_compiler(); - - parsing process must be terminated - ` - - expected := &node.Root{ - Position: &position.Position{ - StartLine: 2, - EndLine: 348, - StartPos: 5, - EndPos: 6319, - }, - Stmts: []node.Node{ - &stmt.Expression{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 20, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 19, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 8, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 5, - EndPos: 8, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 8, - EndPos: 19, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 11, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 13, - EndPos: 18, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 16, - EndPos: 18, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 16, - EndPos: 18, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 39, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 38, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 27, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 23, - EndPos: 27, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 27, - EndPos: 38, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 28, - EndPos: 30, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 32, - EndPos: 37, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 35, - EndPos: 37, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 35, - EndPos: 37, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 63, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 62, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 46, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 42, - EndPos: 46, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 48, - EndPos: 51, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 51, - EndPos: 62, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 52, - EndPos: 54, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 56, - EndPos: 61, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 59, - EndPos: 61, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 4, - EndLine: 4, - StartPos: 59, - EndPos: 61, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 86, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 85, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 69, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 66, - EndPos: 69, - }, - Value: "foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 71, - EndPos: 74, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 74, - EndPos: 85, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 75, - EndPos: 77, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 79, - EndPos: 84, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 82, - EndPos: 84, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 5, - EndLine: 5, - StartPos: 82, - EndPos: 84, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 110, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 109, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 93, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 89, - EndPos: 93, - }, - Value: "foo", - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 95, - EndPos: 98, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 98, - EndPos: 109, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 99, - EndPos: 101, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 103, - EndPos: 108, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 106, - EndPos: 108, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 6, - EndLine: 6, - StartPos: 106, - EndPos: 108, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 113, - EndPos: 132, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 113, - EndPos: 131, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 117, - EndPos: 120, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 117, - EndPos: 120, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 120, - EndPos: 131, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 121, - EndPos: 123, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 125, - EndPos: 130, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 128, - EndPos: 130, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 7, - EndLine: 7, - StartPos: 128, - EndPos: 130, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 160, - EndPos: 185, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 160, - EndPos: 184, - }, - Class: &stmt.Class{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 164, - EndPos: 184, - }, - PhpDocComment: "/** anonymous class */", - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 170, - EndPos: 181, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 171, - EndPos: 173, - }, - Variadic: false, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 171, - EndPos: 173, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 171, - EndPos: 173, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 175, - EndPos: 180, - }, - Variadic: true, - IsReference: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 178, - EndPos: 180, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 9, - EndLine: 9, - StartPos: 178, - EndPos: 180, - }, - Value: "b", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 188, - EndPos: 201, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 188, - EndPos: 200, - }, - Class: &stmt.Class{ - Position: &position.Position{ - StartLine: 10, - EndLine: 10, - StartPos: 192, - EndPos: 200, - }, - PhpDocComment: "", - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 204, - EndPos: 213, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 204, - EndPos: 212, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 208, - EndPos: 212, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 11, - EndLine: 11, - StartPos: 208, - EndPos: 212, - }, - Value: "foo", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 216, - EndPos: 228, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 216, - EndPos: 227, - }, - Class: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 220, - EndPos: 227, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 220, - EndPos: 224, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 220, - EndPos: 224, - }, - Value: "foo", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 12, - EndLine: 12, - StartPos: 225, - EndPos: 226, - }, - Value: "1", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 231, - EndPos: 246, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 231, - EndPos: 245, - }, - Class: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 235, - EndPos: 245, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 235, - EndPos: 239, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 235, - EndPos: 239, - }, - Value: "foo", - }, - }, - Dim: &expr.Variable{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 240, - EndPos: 244, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 13, - EndLine: 13, - StartPos: 240, - EndPos: 244, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 249, - EndPos: 263, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 249, - EndPos: 262, - }, - Class: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 253, - EndPos: 262, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 253, - EndPos: 257, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 253, - EndPos: 257, - }, - Value: "foo", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 14, - EndLine: 14, - StartPos: 259, - EndPos: 262, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 266, - EndPos: 281, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 266, - EndPos: 280, - }, - Class: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 270, - EndPos: 280, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 270, - EndPos: 274, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 270, - EndPos: 274, - }, - Value: "foo", - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 276, - EndPos: 280, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 15, - EndLine: 15, - StartPos: 276, - EndPos: 280, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 284, - EndPos: 301, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 284, - EndPos: 300, - }, - Class: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 288, - EndPos: 300, - }, - Class: &node.Identifier{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 288, - EndPos: 294, - }, - Value: "static", - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 296, - EndPos: 300, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 16, - EndLine: 16, - StartPos: 296, - EndPos: 300, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 305, - EndPos: 350, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 314, - EndPos: 317, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 318, - EndPos: 332, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Nullable{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 318, - EndPos: 322, - }, - Expr: &name.Name{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 319, - EndPos: 322, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 319, - EndPos: 322, - }, - Value: "bar", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 323, - EndPos: 327, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 323, - EndPos: 327, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 328, - EndPos: 332, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 328, - EndPos: 332, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 328, - EndPos: 332, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 334, - EndPos: 346, - }, - Variadic: true, - ByRef: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 334, - EndPos: 337, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 334, - EndPos: 337, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 342, - EndPos: 346, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 18, - EndLine: 18, - StartPos: 342, - EndPos: 346, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 353, - EndPos: 417, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 359, - EndPos: 362, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 364, - EndPos: 416, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 380, - EndPos: 383, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 364, - EndPos: 370, - }, - Value: "public", - }, - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 384, - EndPos: 398, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Nullable{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 384, - EndPos: 388, - }, - Expr: &name.Name{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 385, - EndPos: 388, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 385, - EndPos: 388, - }, - Value: "bar", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 389, - EndPos: 393, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 389, - EndPos: 393, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 394, - EndPos: 398, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 394, - EndPos: 398, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 394, - EndPos: 398, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 400, - EndPos: 412, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 400, - EndPos: 403, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 400, - EndPos: 403, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 408, - EndPos: 412, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 408, - EndPos: 412, - }, - Value: "baz", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 19, - EndLine: 19, - StartPos: 414, - EndPos: 416, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 420, - EndPos: 462, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 420, - EndPos: 461, - }, - PhpDocComment: "", - ReturnsRef: false, - Static: false, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 429, - EndPos: 443, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Nullable{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 429, - EndPos: 433, - }, - Expr: &name.Name{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 430, - EndPos: 433, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 430, - EndPos: 433, - }, - Value: "bar", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 434, - EndPos: 438, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 434, - EndPos: 438, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 439, - EndPos: 443, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 439, - EndPos: 443, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 439, - EndPos: 443, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 445, - EndPos: 457, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 445, - EndPos: 448, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 445, - EndPos: 448, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 453, - EndPos: 457, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 20, - EndLine: 20, - StartPos: 453, - EndPos: 457, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 465, - EndPos: 514, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 465, - EndPos: 513, - }, - PhpDocComment: "", - ReturnsRef: false, - Static: true, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 481, - EndPos: 495, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Nullable{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 481, - EndPos: 485, - }, - Expr: &name.Name{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 482, - EndPos: 485, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 482, - EndPos: 485, - }, - Value: "bar", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 486, - EndPos: 490, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 486, - EndPos: 490, - }, - Value: "bar", - }, - }, - DefaultValue: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 491, - EndPos: 495, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 491, - EndPos: 495, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 491, - EndPos: 495, - }, - Value: "null", - }, - }, - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 497, - EndPos: 509, - }, - ByRef: true, - Variadic: true, - VariableType: &name.Name{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 497, - EndPos: 500, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 497, - EndPos: 500, - }, - Value: "baz", - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 505, - EndPos: 509, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 21, - EndLine: 21, - StartPos: 505, - EndPos: 509, - }, - Value: "baz", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 23, - EndLine: 23, - StartPos: 518, - EndPos: 538, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 23, - EndLine: 23, - StartPos: 518, - EndPos: 537, - }, - Value: "1234567890123456789", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 24, - EndLine: 24, - StartPos: 541, - EndPos: 562, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 24, - EndLine: 24, - StartPos: 541, - EndPos: 561, - }, - Value: "12345678901234567890", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 25, - EndLine: 25, - StartPos: 565, - EndPos: 568, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 25, - EndLine: 25, - StartPos: 565, - EndPos: 567, - }, - Value: "0.", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 26, - EndLine: 26, - StartPos: 571, - EndPos: 638, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 26, - EndLine: 26, - StartPos: 571, - EndPos: 637, - }, - Value: "0b0111111111111111111111111111111111111111111111111111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 27, - EndLine: 27, - StartPos: 641, - EndPos: 708, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 27, - EndLine: 27, - StartPos: 641, - EndPos: 707, - }, - Value: "0b1111111111111111111111111111111111111111111111111111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 28, - EndLine: 28, - StartPos: 711, - EndPos: 732, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 28, - EndLine: 28, - StartPos: 711, - EndPos: 731, - }, - Value: "0x007111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 29, - EndLine: 29, - StartPos: 735, - EndPos: 754, - }, - Expr: &scalar.Dnumber{ - Position: &position.Position{ - StartLine: 29, - EndLine: 29, - StartPos: 735, - EndPos: 753, - }, - Value: "0x8111111111111111", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 757, - EndPos: 767, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 30, - EndLine: 30, - StartPos: 757, - EndPos: 766, - }, - Value: "__CLASS__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 770, - EndPos: 778, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 31, - EndLine: 31, - StartPos: 770, - EndPos: 777, - }, - Value: "__DIR__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 781, - EndPos: 790, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 32, - EndLine: 32, - StartPos: 781, - EndPos: 789, - }, - Value: "__FILE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 793, - EndPos: 806, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 33, - EndLine: 33, - StartPos: 793, - EndPos: 805, - }, - Value: "__FUNCTION__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 809, - EndPos: 818, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 34, - EndLine: 34, - StartPos: 809, - EndPos: 817, - }, - Value: "__LINE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 821, - EndPos: 835, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 35, - EndLine: 35, - StartPos: 821, - EndPos: 834, - }, - Value: "__NAMESPACE__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 838, - EndPos: 849, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 36, - EndLine: 36, - StartPos: 838, - EndPos: 848, - }, - Value: "__METHOD__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 852, - EndPos: 862, - }, - Expr: &scalar.MagicConstant{ - Position: &position.Position{ - StartLine: 37, - EndLine: 37, - StartPos: 852, - EndPos: 861, - }, - Value: "__TRAIT__", - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 866, - EndPos: 878, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 866, - EndPos: 877, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 867, - EndPos: 872, - }, - Value: "test ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 872, - EndPos: 876, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 39, - EndLine: 39, - StartPos: 872, - EndPos: 876, - }, - Value: "var", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 881, - EndPos: 896, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 881, - EndPos: 895, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 882, - EndPos: 887, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 887, - EndPos: 894, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 887, - EndPos: 891, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 887, - EndPos: 891, - }, - Value: "var", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 40, - EndLine: 40, - StartPos: 892, - EndPos: 893, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 899, - EndPos: 915, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 899, - EndPos: 914, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 900, - EndPos: 905, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 905, - EndPos: 913, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 905, - EndPos: 909, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 905, - EndPos: 909, - }, - Value: "var", - }, - }, - Dim: &expr.UnaryMinus{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 910, - EndPos: 912, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 41, - EndLine: 41, - StartPos: 910, - EndPos: 912, - }, - Value: "1", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 918, - EndPos: 972, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 918, - EndPos: 971, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 919, - EndPos: 924, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 924, - EndPos: 970, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 924, - EndPos: 928, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 924, - EndPos: 928, - }, - Value: "var", - }, - }, - Dim: &scalar.String{ - Position: &position.Position{ - StartLine: 42, - EndLine: 42, - StartPos: 929, - EndPos: 969, - }, - Value: "1234567890123456789012345678901234567890", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 975, - EndPos: 1030, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 975, - EndPos: 1029, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 976, - EndPos: 981, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 981, - EndPos: 1028, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 981, - EndPos: 985, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 981, - EndPos: 985, - }, - Value: "var", - }, - }, - Dim: &scalar.String{ - Position: &position.Position{ - StartLine: 43, - EndLine: 43, - StartPos: 986, - EndPos: 1027, - }, - Value: "-1234567890123456789012345678901234567890", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1033, - EndPos: 1050, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1033, - EndPos: 1049, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1034, - EndPos: 1039, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1039, - EndPos: 1048, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1039, - EndPos: 1043, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1039, - EndPos: 1043, - }, - Value: "var", - }, - }, - Dim: &scalar.String{ - Position: &position.Position{ - StartLine: 44, - EndLine: 44, - StartPos: 1044, - EndPos: 1047, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1053, - EndPos: 1071, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1053, - EndPos: 1070, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1054, - EndPos: 1059, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1059, - EndPos: 1069, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1059, - EndPos: 1063, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1059, - EndPos: 1063, - }, - Value: "var", - }, - }, - Dim: &expr.Variable{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1064, - EndPos: 1068, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 45, - EndLine: 45, - StartPos: 1064, - EndPos: 1068, - }, - Value: "bar", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1074, - EndPos: 1086, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1074, - EndPos: 1085, - }, - Parts: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1075, - EndPos: 1079, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1075, - EndPos: 1079, - }, - Value: "foo", - }, - }, - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1079, - EndPos: 1080, - }, - Value: " ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1080, - EndPos: 1084, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 46, - EndLine: 46, - StartPos: 1080, - EndPos: 1084, - }, - Value: "bar", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1089, - EndPos: 1108, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1089, - EndPos: 1107, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1090, - EndPos: 1095, - }, - Value: "test ", - }, - &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1095, - EndPos: 1104, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1095, - EndPos: 1099, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1095, - EndPos: 1099, - }, - Value: "foo", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1101, - EndPos: 1104, - }, - Value: "bar", - }, - }, - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 47, - EndLine: 47, - StartPos: 1104, - EndPos: 1106, - }, - Value: "()", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 48, - EndLine: 48, - StartPos: 1111, - EndPos: 1125, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 48, - EndLine: 48, - StartPos: 1111, - EndPos: 1124, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 48, - EndLine: 48, - StartPos: 1112, - EndPos: 1117, - }, - Value: "test ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 48, - EndLine: 48, - StartPos: 1117, - EndPos: 1123, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 48, - EndLine: 48, - StartPos: 1119, - EndPos: 1122, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1128, - EndPos: 1145, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1128, - EndPos: 1144, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1129, - EndPos: 1134, - }, - Value: "test ", - }, - &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1134, - EndPos: 1143, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1136, - EndPos: 1139, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1136, - EndPos: 1139, - }, - Value: "foo", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 49, - EndLine: 49, - StartPos: 1140, - EndPos: 1141, - }, - Value: "0", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1148, - EndPos: 1163, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1148, - EndPos: 1162, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1149, - EndPos: 1154, - }, - Value: "test ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1154, - EndPos: 1161, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1156, - EndPos: 1160, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 50, - EndLine: 50, - StartPos: 1156, - EndPos: 1160, - }, - Value: "foo", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1166, - EndPos: 1187, - }, - Expr: &scalar.Encapsed{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1166, - EndPos: 1186, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1167, - EndPos: 1172, - }, - Value: "test ", - }, - &expr.MethodCall{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1173, - EndPos: 1184, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1173, - EndPos: 1177, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1173, - EndPos: 1177, - }, - Value: "foo", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1179, - EndPos: 1182, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 51, - EndLine: 51, - StartPos: 1182, - EndPos: 1184, - }, - }, - }, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 53, - EndLine: 54, - StartPos: 1191, - EndPos: 1209, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 53, - EndLine: 53, - StartPos: 1195, - EndPos: 1197, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 53, - EndLine: 53, - StartPos: 1195, - EndPos: 1197, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 55, - EndLine: 57, - StartPos: 1212, - EndPos: 1245, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1216, - EndPos: 1218, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 55, - EndLine: 55, - StartPos: 1216, - EndPos: 1218, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 56, - EndLine: -1, - StartPos: 1224, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1232, - EndPos: 1234, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 56, - EndLine: 56, - StartPos: 1232, - EndPos: 1234, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 58, - EndLine: 60, - StartPos: 1248, - EndPos: 1274, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1252, - EndPos: 1254, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 58, - EndLine: 58, - StartPos: 1252, - EndPos: 1254, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.AltElse{ - Position: &position.Position{ - StartLine: 59, - EndLine: -1, - StartPos: 1260, - EndPos: -1, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.AltIf{ - Position: &position.Position{ - StartLine: 61, - EndLine: 65, - StartPos: 1277, - EndPos: 1333, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1281, - EndPos: 1283, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 61, - EndLine: 61, - StartPos: 1281, - EndPos: 1283, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 62, - EndLine: -1, - StartPos: 1289, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1297, - EndPos: 1299, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 62, - EndLine: 62, - StartPos: 1297, - EndPos: 1299, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltElseIf{ - Position: &position.Position{ - StartLine: 63, - EndLine: -1, - StartPos: 1304, - EndPos: -1, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1312, - EndPos: 1314, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 63, - EndLine: 63, - StartPos: 1312, - EndPos: 1314, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.AltElse{ - Position: &position.Position{ - StartLine: 64, - EndLine: -1, - StartPos: 1319, - EndPos: -1, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1337, - EndPos: 1357, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1344, - EndPos: 1345, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1347, - EndPos: 1357, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 67, - EndLine: 67, - StartPos: 1349, - EndPos: 1355, - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1360, - EndPos: 1382, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1367, - EndPos: 1368, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1370, - EndPos: 1382, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1372, - EndPos: 1380, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 68, - EndLine: 68, - StartPos: 1378, - EndPos: 1379, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.AltWhile{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1385, - EndPos: 1416, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1392, - EndPos: 1393, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1397, - EndPos: 1406, - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1397, - EndPos: 1406, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 69, - EndLine: 69, - StartPos: 1403, - EndPos: 1404, - }, - Value: "3", - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1419, - EndPos: 1462, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1425, - EndPos: 1428, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassConstList{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1430, - EndPos: 1460, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1430, - EndPos: 1436, - }, - Value: "public", - }, - }, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1443, - EndPos: 1450, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1443, - EndPos: 1446, - }, - Value: "FOO", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1449, - EndPos: 1450, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1452, - EndPos: 1459, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1452, - EndPos: 1455, - }, - Value: "BAR", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 70, - EndLine: 70, - StartPos: 1458, - EndPos: 1459, - }, - Value: "2", - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1465, - EndPos: 1501, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1471, - EndPos: 1474, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassConstList{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1476, - EndPos: 1499, - }, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1482, - EndPos: 1489, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1482, - EndPos: 1485, - }, - Value: "FOO", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1488, - EndPos: 1489, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1491, - EndPos: 1498, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1491, - EndPos: 1494, - }, - Value: "BAR", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 71, - EndLine: 71, - StartPos: 1497, - EndPos: 1498, - }, - Value: "2", - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1504, - EndPos: 1534, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1510, - EndPos: 1513, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1515, - EndPos: 1532, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1524, - EndPos: 1527, - }, - Value: "bar", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 72, - EndLine: 72, - StartPos: 1530, - EndPos: 1532, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1537, - EndPos: 1582, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1543, - EndPos: 1546, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1548, - EndPos: 1580, - }, - ReturnsRef: true, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1572, - EndPos: 1575, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1548, - EndPos: 1554, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1555, - EndPos: 1561, - }, - Value: "static", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 73, - EndLine: 73, - StartPos: 1578, - EndPos: 1580, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1585, - EndPos: 1636, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1591, - EndPos: 1594, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1596, - EndPos: 1634, - }, - ReturnsRef: true, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1620, - EndPos: 1623, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1596, - EndPos: 1602, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1603, - EndPos: 1609, - }, - Value: "static", - }, - }, - ReturnType: &name.Name{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1627, - EndPos: 1631, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1627, - EndPos: 1631, - }, - Value: "void", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 74, - EndLine: 74, - StartPos: 1632, - EndPos: 1634, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1639, - EndPos: 1660, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1654, - EndPos: 1657, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 75, - EndLine: 75, - StartPos: 1639, - EndPos: 1647, - }, - Value: "abstract", - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1663, - EndPos: 1694, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1675, - EndPos: 1678, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1663, - EndPos: 1668, - }, - Value: "final", - }, - }, - Extends: &stmt.ClassExtends{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1679, - EndPos: 1690, - }, - ClassName: &name.Name{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1687, - EndPos: 1690, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 76, - EndLine: 76, - StartPos: 1687, - EndPos: 1690, - }, - Value: "bar", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1697, - EndPos: 1731, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1709, - EndPos: 1712, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1697, - EndPos: 1702, - }, - Value: "final", - }, - }, - Implements: &stmt.ClassImplements{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1713, - EndPos: 1727, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1724, - EndPos: 1727, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 77, - EndLine: 77, - StartPos: 1724, - EndPos: 1727, - }, - Value: "bar", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1734, - EndPos: 1773, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1746, - EndPos: 1749, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1734, - EndPos: 1739, - }, - Value: "final", - }, - }, - Implements: &stmt.ClassImplements{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1750, - EndPos: 1769, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1761, - EndPos: 1764, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1761, - EndPos: 1764, - }, - Value: "bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1766, - EndPos: 1769, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 78, - EndLine: 78, - StartPos: 1766, - EndPos: 1769, - }, - Value: "baz", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1776, - EndPos: 1824, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1776, - EndPos: 1823, - }, - Class: &stmt.Class{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1780, - EndPos: 1823, - }, - PhpDocComment: "", - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1785, - EndPos: 1787, - }, - }, - Extends: &stmt.ClassExtends{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1788, - EndPos: 1799, - }, - ClassName: &name.Name{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1796, - EndPos: 1799, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1796, - EndPos: 1799, - }, - Value: "foo", - }, - }, - }, - }, - Implements: &stmt.ClassImplements{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1800, - EndPos: 1819, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1811, - EndPos: 1814, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1811, - EndPos: 1814, - }, - Value: "bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1816, - EndPos: 1819, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 79, - EndLine: 79, - StartPos: 1816, - EndPos: 1819, - }, - Value: "baz", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.ConstList{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1828, - EndPos: 1851, - }, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1834, - EndPos: 1841, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1834, - EndPos: 1837, - }, - Value: "FOO", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1840, - EndPos: 1841, - }, - Value: "1", - }, - }, - &stmt.Constant{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1843, - EndPos: 1850, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1843, - EndPos: 1846, - }, - Value: "BAR", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 81, - EndLine: 81, - StartPos: 1849, - EndPos: 1850, - }, - Value: "2", - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1854, - EndPos: 1877, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1861, - EndPos: 1862, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1864, - EndPos: 1877, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 82, - EndLine: 82, - StartPos: 1866, - EndPos: 1875, - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1880, - EndPos: 1905, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1887, - EndPos: 1888, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1890, - EndPos: 1905, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1892, - EndPos: 1903, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 83, - EndLine: 83, - StartPos: 1901, - EndPos: 1902, - }, - Value: "2", - }, - }, - }, - }, - }, - &stmt.While{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1908, - EndPos: 1934, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1915, - EndPos: 1916, - }, - Value: "1", - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1918, - EndPos: 1934, - }, - Stmts: []node.Node{ - &stmt.Continue{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1920, - EndPos: 1932, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 84, - EndLine: 84, - StartPos: 1929, - EndPos: 1930, - }, - Value: "3", - }, - }, - }, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 1937, - EndPos: 1954, - }, - Alt: false, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 1945, - EndPos: 1952, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 1945, - EndPos: 1950, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 1951, - EndPos: 1952, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.Nop{ - Position: &position.Position{ - StartLine: 85, - EndLine: 85, - StartPos: 1953, - EndPos: 1954, - }, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 1957, - EndPos: 1976, - }, - Alt: false, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 1965, - EndPos: 1972, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 1965, - EndPos: 1970, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 1971, - EndPos: 1972, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 86, - EndLine: 86, - StartPos: 1974, - EndPos: 1976, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Declare{ - Position: &position.Position{ - StartLine: 87, - EndLine: 87, - StartPos: 1979, - EndPos: 2008, - }, - Alt: true, - Consts: []node.Node{ - &stmt.Constant{ - Position: &position.Position{ - StartLine: 87, - EndLine: 87, - StartPos: 1987, - EndPos: 1994, - }, - PhpDocComment: "", - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 87, - EndLine: 87, - StartPos: 1987, - EndPos: 1992, - }, - Value: "ticks", - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 87, - EndLine: 87, - StartPos: 1993, - EndPos: 1994, - }, - Value: "1", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Do{ - Position: &position.Position{ - StartLine: 88, - EndLine: 88, - StartPos: 2011, - EndPos: 2026, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 88, - EndLine: 88, - StartPos: 2014, - EndPos: 2016, - }, - Stmts: []node.Node{}, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 88, - EndLine: 88, - StartPos: 2023, - EndPos: 2024, - }, - Value: "1", - }, - }, - &stmt.Echo{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2029, - EndPos: 2040, - }, - Exprs: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2034, - EndPos: 2036, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2034, - EndPos: 2036, - }, - Value: "a", - }, - }, - &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 89, - EndLine: 89, - StartPos: 2038, - EndPos: 2039, - }, - Value: "1", - }, - }, - }, - &stmt.Echo{ - Position: &position.Position{ - StartLine: 90, - EndLine: 90, - StartPos: 2043, - EndPos: 2052, - }, - Exprs: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 90, - EndLine: 90, - StartPos: 2048, - EndPos: 2050, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 90, - EndLine: 90, - StartPos: 2048, - EndPos: 2050, - }, - Value: "a", - }, - }, - }, - }, - &stmt.For{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2055, - EndPos: 2090, - }, - Init: []node.Node{ - &assign.Assign{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2059, - EndPos: 2065, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2059, - EndPos: 2061, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2059, - EndPos: 2061, - }, - Value: "i", - }, - }, - Expression: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2064, - EndPos: 2065, - }, - Value: "0", - }, - }, - }, - Cond: []node.Node{ - &binary.Smaller{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2067, - EndPos: 2074, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2067, - EndPos: 2069, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2067, - EndPos: 2069, - }, - Value: "i", - }, - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2072, - EndPos: 2074, - }, - Value: "10", - }, - }, - }, - Loop: []node.Node{ - &expr.PostInc{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2076, - EndPos: 2080, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2076, - EndPos: 2078, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2076, - EndPos: 2078, - }, - Value: "i", - }, - }, - }, - &expr.PostInc{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2082, - EndPos: 2086, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2082, - EndPos: 2084, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2082, - EndPos: 2084, - }, - Value: "i", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 91, - EndLine: 91, - StartPos: 2088, - EndPos: 2090, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltFor{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2093, - EndPos: 2129, - }, - Cond: []node.Node{ - &binary.Smaller{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2099, - EndPos: 2106, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2099, - EndPos: 2101, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2099, - EndPos: 2101, - }, - Value: "i", - }, - }, - Right: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2104, - EndPos: 2106, - }, - Value: "10", - }, - }, - }, - Loop: []node.Node{ - &expr.PostInc{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2108, - EndPos: 2112, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2108, - EndPos: 2110, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2108, - EndPos: 2110, - }, - Value: "i", - }, - }, - }, - &expr.PostInc{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2114, - EndPos: 2118, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2114, - EndPos: 2116, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 92, - EndLine: 92, - StartPos: 2114, - EndPos: 2116, - }, - Value: "i", - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2132, - EndPos: 2153, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2141, - EndPos: 2143, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2141, - EndPos: 2143, - }, - Value: "a", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2147, - EndPos: 2149, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2147, - EndPos: 2149, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 93, - EndLine: 93, - StartPos: 2151, - EndPos: 2153, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.AltForeach{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2156, - EndPos: 2188, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2165, - EndPos: 2167, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2165, - EndPos: 2167, - }, - Value: "a", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2171, - EndPos: 2173, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 94, - EndLine: 94, - StartPos: 2171, - EndPos: 2173, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: -1, - EndLine: -1, - StartPos: -1, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2191, - EndPos: 2218, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2200, - EndPos: 2202, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2200, - EndPos: 2202, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2206, - EndPos: 2208, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2206, - EndPos: 2208, - }, - Value: "k", - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2212, - EndPos: 2214, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2212, - EndPos: 2214, - }, - Value: "v", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 95, - EndLine: 95, - StartPos: 2216, - EndPos: 2218, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2221, - EndPos: 2249, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2230, - EndPos: 2232, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2230, - EndPos: 2232, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2236, - EndPos: 2238, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2236, - EndPos: 2238, - }, - Value: "k", - }, - }, - Variable: &expr.Reference{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2242, - EndPos: 2245, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2243, - EndPos: 2245, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2243, - EndPos: 2245, - }, - Value: "v", - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 96, - EndLine: 96, - StartPos: 2247, - EndPos: 2249, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2252, - EndPos: 2285, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2261, - EndPos: 2263, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2261, - EndPos: 2263, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2267, - EndPos: 2269, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2267, - EndPos: 2269, - }, - Value: "k", - }, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2273, - EndPos: 2281, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2278, - EndPos: 2280, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2278, - EndPos: 2280, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2278, - EndPos: 2280, - }, - Value: "v", - }, - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 97, - EndLine: 97, - StartPos: 2283, - EndPos: 2285, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Foreach{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2288, - EndPos: 2317, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2297, - EndPos: 2299, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2297, - EndPos: 2299, - }, - Value: "a", - }, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2303, - EndPos: 2305, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2303, - EndPos: 2305, - }, - Value: "k", - }, - }, - Variable: &expr.ShortList{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2309, - EndPos: 2313, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2310, - EndPos: 2312, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2310, - EndPos: 2312, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2310, - EndPos: 2312, - }, - Value: "v", - }, - }, - }, - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 98, - EndLine: 98, - StartPos: 2315, - EndPos: 2317, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 99, - EndLine: 99, - StartPos: 2320, - EndPos: 2337, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 99, - EndLine: 99, - StartPos: 2329, - EndPos: 2332, - }, - Value: "foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2340, - EndPos: 2364, - }, - PhpDocComment: "", - ReturnsRef: false, - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2349, - EndPos: 2352, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.Return{ - Position: &position.Position{ - StartLine: 100, - EndLine: 100, - StartPos: 2356, - EndPos: 2363, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2367, - EndPos: 2394, - }, - ReturnsRef: true, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2377, - EndPos: 2380, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.Return{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2384, - EndPos: 2393, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 101, - EndLine: 101, - StartPos: 2391, - EndPos: 2392, - }, - Value: "1", - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2397, - EndPos: 2421, - }, - ReturnsRef: true, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2407, - EndPos: 2410, - }, - Value: "foo", - }, - ReturnType: &name.Name{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2414, - EndPos: 2418, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 102, - EndLine: 102, - StartPos: 2414, - EndPos: 2418, - }, - Value: "void", - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Global{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2424, - EndPos: 2438, - }, - Vars: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2431, - EndPos: 2433, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2431, - EndPos: 2433, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2435, - EndPos: 2437, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 103, - EndLine: 103, - StartPos: 2435, - EndPos: 2437, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Label{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2441, - EndPos: 2443, - }, - LabelName: &node.Identifier{ - Position: &position.Position{ - StartLine: 104, - EndLine: 104, - StartPos: 2441, - EndPos: 2442, - }, - Value: "a", - }, - }, - &stmt.Goto{ - Position: &position.Position{ - StartLine: 105, - EndLine: 105, - StartPos: 2447, - EndPos: 2454, - }, - Label: &node.Identifier{ - Position: &position.Position{ - StartLine: 105, - EndLine: 105, - StartPos: 2452, - EndPos: 2453, - }, - Value: "a", - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2457, - EndPos: 2467, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2461, - EndPos: 2463, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2461, - EndPos: 2463, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 106, - EndLine: 106, - StartPos: 2465, - EndPos: 2467, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2470, - EndPos: 2495, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2474, - EndPos: 2476, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2474, - EndPos: 2476, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2478, - EndPos: 2480, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2481, - EndPos: 2495, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2489, - EndPos: 2491, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2489, - EndPos: 2491, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 107, - EndLine: 107, - StartPos: 2493, - EndPos: 2495, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2498, - EndPos: 2516, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2502, - EndPos: 2504, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2502, - EndPos: 2504, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2506, - EndPos: 2508, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2509, - EndPos: 2516, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 108, - EndLine: 108, - StartPos: 2514, - EndPos: 2516, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2519, - EndPos: 2567, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2523, - EndPos: 2525, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2523, - EndPos: 2525, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2527, - EndPos: 2529, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2530, - EndPos: 2544, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2538, - EndPos: 2540, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2538, - EndPos: 2540, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2542, - EndPos: 2544, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2545, - EndPos: 2559, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2553, - EndPos: 2555, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2553, - EndPos: 2555, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2557, - EndPos: 2559, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2560, - EndPos: 2567, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 109, - EndLine: 109, - StartPos: 2565, - EndPos: 2567, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.If{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2570, - EndPos: 2619, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2574, - EndPos: 2576, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2574, - EndPos: 2576, - }, - Value: "a", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2578, - EndPos: 2580, - }, - Stmts: []node.Node{}, - }, - ElseIf: []node.Node{ - &stmt.ElseIf{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2581, - EndPos: 2595, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2589, - EndPos: 2591, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2589, - EndPos: 2591, - }, - Value: "b", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2593, - EndPos: 2595, - }, - Stmts: []node.Node{}, - }, - }, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2596, - EndPos: 2619, - }, - Stmt: &stmt.If{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2601, - EndPos: 2619, - }, - Cond: &expr.Variable{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2605, - EndPos: 2607, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2605, - EndPos: 2607, - }, - Value: "c", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2609, - EndPos: 2611, - }, - Stmts: []node.Node{}, - }, - Else: &stmt.Else{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2612, - EndPos: 2619, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 110, - EndLine: 110, - StartPos: 2617, - EndPos: 2619, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - }, - &stmt.Nop{ - Position: &position.Position{ - StartLine: 111, - EndLine: 111, - StartPos: 2622, - EndPos: 2624, - }, - }, - &stmt.InlineHtml{ - Position: &position.Position{ - StartLine: 111, - EndLine: 111, - StartPos: 2624, - EndPos: 2637, - }, - Value: "
", - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2642, - EndPos: 2658, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 112, - EndLine: 112, - StartPos: 2652, - EndPos: 2655, - }, - Value: "Foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2661, - EndPos: 2689, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2671, - EndPos: 2674, - }, - Value: "Foo", - }, - Extends: &stmt.InterfaceExtends{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2675, - EndPos: 2686, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2683, - EndPos: 2686, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 113, - EndLine: 113, - StartPos: 2683, - EndPos: 2686, - }, - Value: "Bar", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2692, - EndPos: 2725, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2702, - EndPos: 2705, - }, - Value: "Foo", - }, - Extends: &stmt.InterfaceExtends{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2706, - EndPos: 2722, - }, - InterfaceNames: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2714, - EndPos: 2717, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2714, - EndPos: 2717, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2719, - EndPos: 2722, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 114, - EndLine: 114, - StartPos: 2719, - EndPos: 2722, - }, - Value: "Baz", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2728, - EndPos: 2742, - }, - NamespaceName: &name.Name{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2738, - EndPos: 2741, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 115, - EndLine: 115, - StartPos: 2738, - EndPos: 2741, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2745, - EndPos: 2761, - }, - NamespaceName: &name.Name{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2755, - EndPos: 2758, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 116, - EndLine: 116, - StartPos: 2755, - EndPos: 2758, - }, - Value: "Foo", - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Namespace{ - Position: &position.Position{ - StartLine: 117, - EndLine: 117, - StartPos: 2764, - EndPos: 2776, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2779, - EndPos: 2798, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2785, - EndPos: 2788, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.PropertyList{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2790, - EndPos: 2797, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2790, - EndPos: 2793, - }, - Value: "var", - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2794, - EndPos: 2796, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2794, - EndPos: 2796, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 118, - EndLine: 118, - StartPos: 2794, - EndPos: 2796, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2801, - EndPos: 2838, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2807, - EndPos: 2810, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.PropertyList{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2812, - EndPos: 2837, - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2812, - EndPos: 2818, - }, - Value: "public", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2819, - EndPos: 2825, - }, - Value: "static", - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2826, - EndPos: 2828, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2826, - EndPos: 2828, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2826, - EndPos: 2828, - }, - Value: "a", - }, - }, - }, - &stmt.Property{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2830, - EndPos: 2836, - }, - PhpDocComment: "", - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2830, - EndPos: 2832, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2830, - EndPos: 2832, - }, - Value: "b", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 119, - EndLine: 119, - StartPos: 2835, - EndPos: 2836, - }, - Value: "1", - }, - }, - }, - }, - }, - }, - &stmt.Static{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2841, - EndPos: 2859, - }, - Vars: []node.Node{ - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2848, - EndPos: 2850, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2848, - EndPos: 2850, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2848, - EndPos: 2850, - }, - Value: "a", - }, - }, - }, - &stmt.StaticVar{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2852, - EndPos: 2858, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2852, - EndPos: 2854, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2852, - EndPos: 2854, - }, - Value: "b", - }, - }, - Expr: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 120, - EndLine: 120, - StartPos: 2857, - EndPos: 2858, - }, - Value: "1", - }, - }, - }, - }, - &stmt.AltSwitch{ - Position: &position.Position{ - StartLine: 122, - EndLine: 126, - StartPos: 2863, - EndPos: 2922, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 122, - EndLine: 122, - StartPos: 2871, - EndPos: 2872, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 123, - EndLine: -1, - StartPos: 2879, - EndPos: -1, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 123, - EndLine: -1, - StartPos: 2879, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 123, - EndLine: 123, - StartPos: 2884, - EndPos: 2885, - }, - Value: "1", - }, - Stmts: []node.Node{}, - }, - &stmt.Default{ - Position: &position.Position{ - StartLine: 124, - EndLine: -1, - StartPos: 2890, - EndPos: -1, - }, - Stmts: []node.Node{}, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 125, - EndLine: -1, - StartPos: 2902, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 125, - EndLine: 125, - StartPos: 2907, - EndPos: 2908, - }, - Value: "2", - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.AltSwitch{ - Position: &position.Position{ - StartLine: 128, - EndLine: 131, - StartPos: 2926, - EndPos: 2974, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 128, - EndLine: 128, - StartPos: 2934, - EndPos: 2935, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 129, - EndLine: -1, - StartPos: 2943, - EndPos: -1, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 129, - EndLine: -1, - StartPos: 2943, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 129, - EndLine: 129, - StartPos: 2948, - EndPos: 2949, - }, - Value: "1", - }, - Stmts: []node.Node{}, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 130, - EndLine: -1, - StartPos: 2954, - EndPos: -1, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 130, - EndLine: 130, - StartPos: 2959, - EndPos: 2960, - }, - Value: "2", - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Switch{ - Position: &position.Position{ - StartLine: 133, - EndLine: 136, - StartPos: 2980, - EndPos: 3032, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 133, - EndLine: 133, - StartPos: 2988, - EndPos: 2989, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 133, - EndLine: 136, - StartPos: 2991, - EndPos: 3032, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 134, - EndLine: 134, - StartPos: 2996, - EndPos: 3010, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 134, - EndLine: 134, - StartPos: 3001, - EndPos: 3002, - }, - Value: "1", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 134, - EndLine: 134, - StartPos: 3004, - EndPos: 3010, - }, - }, - }, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 3014, - EndPos: 3028, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 3019, - EndPos: 3020, - }, - Value: "2", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 135, - EndLine: 135, - StartPos: 3022, - EndPos: 3028, - }, - }, - }, - }, - }, - }, - }, - &stmt.Switch{ - Position: &position.Position{ - StartLine: 138, - EndLine: 141, - StartPos: 3038, - EndPos: 3091, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 138, - EndLine: 138, - StartPos: 3046, - EndPos: 3047, - }, - Value: "1", - }, - CaseList: &stmt.CaseList{ - Position: &position.Position{ - StartLine: 138, - EndLine: 141, - StartPos: 3049, - EndPos: 3091, - }, - Cases: []node.Node{ - &stmt.Case{ - Position: &position.Position{ - StartLine: 139, - EndLine: 139, - StartPos: 3055, - EndPos: 3069, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 139, - EndLine: 139, - StartPos: 3060, - EndPos: 3061, - }, - Value: "1", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 139, - EndLine: 139, - StartPos: 3063, - EndPos: 3069, - }, - }, - }, - }, - &stmt.Case{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3073, - EndPos: 3087, - }, - Cond: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3078, - EndPos: 3079, - }, - Value: "2", - }, - Stmts: []node.Node{ - &stmt.Break{ - Position: &position.Position{ - StartLine: 140, - EndLine: 140, - StartPos: 3081, - EndPos: 3087, - }, - }, - }, - }, - }, - }, - }, - &stmt.Throw{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3095, - EndPos: 3104, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3101, - EndPos: 3103, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 143, - EndLine: 143, - StartPos: 3101, - EndPos: 3103, - }, - Value: "e", - }, - }, - }, - &stmt.Trait{ - Position: &position.Position{ - StartLine: 145, - EndLine: 145, - StartPos: 3108, - EndPos: 3120, - }, - PhpDocComment: "", - TraitName: &node.Identifier{ - Position: &position.Position{ - StartLine: 145, - EndLine: 145, - StartPos: 3114, - EndPos: 3117, - }, - Value: "Foo", - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3123, - EndPos: 3145, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3129, - EndPos: 3132, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3135, - EndPos: 3143, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3139, - EndPos: 3142, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3139, - EndPos: 3142, - }, - Value: "Bar", - }, - }, - }, - }, - TraitAdaptationList: &stmt.Nop{ - Position: &position.Position{ - StartLine: 146, - EndLine: 146, - StartPos: 3142, - EndPos: 3143, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3148, - EndPos: 3177, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3154, - EndPos: 3157, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3160, - EndPos: 3175, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3164, - EndPos: 3167, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3164, - EndPos: 3167, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3169, - EndPos: 3172, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3169, - EndPos: 3172, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 147, - EndLine: 147, - StartPos: 3173, - EndPos: 3175, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3180, - EndPos: 3226, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3186, - EndPos: 3189, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3192, - EndPos: 3224, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3196, - EndPos: 3199, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3196, - EndPos: 3199, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3201, - EndPos: 3204, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3201, - EndPos: 3204, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3205, - EndPos: 3224, - }, - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3207, - EndPos: 3221, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3207, - EndPos: 3210, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3207, - EndPos: 3210, - }, - Value: "one", - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 148, - EndLine: 148, - StartPos: 3214, - EndPos: 3221, - }, - Value: "include", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3229, - EndPos: 3274, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3235, - EndPos: 3238, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3241, - EndPos: 3272, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3245, - EndPos: 3248, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3245, - EndPos: 3248, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3250, - EndPos: 3253, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3250, - EndPos: 3253, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3254, - EndPos: 3272, - }, - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3256, - EndPos: 3269, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3256, - EndPos: 3259, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3256, - EndPos: 3259, - }, - Value: "one", - }, - }, - Modifier: &node.Identifier{ - Position: &position.Position{ - StartLine: 149, - EndLine: 149, - StartPos: 3263, - EndPos: 3269, - }, - Value: "public", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3277, - EndPos: 3326, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3283, - EndPos: 3286, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3289, - EndPos: 3324, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3293, - EndPos: 3296, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3293, - EndPos: 3296, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3298, - EndPos: 3301, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3298, - EndPos: 3301, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3302, - EndPos: 3324, - }, - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3304, - EndPos: 3321, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3304, - EndPos: 3307, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3304, - EndPos: 3307, - }, - Value: "one", - }, - }, - Modifier: &node.Identifier{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3311, - EndPos: 3317, - }, - Value: "public", - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 150, - EndLine: 150, - StartPos: 3318, - EndPos: 3321, - }, - Value: "two", - }, - }, - }, - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3329, - EndPos: 3406, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3335, - EndPos: 3338, - }, - Value: "Foo", - }, - Stmts: []node.Node{ - &stmt.TraitUse{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3341, - EndPos: 3404, - }, - Traits: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3345, - EndPos: 3348, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3345, - EndPos: 3348, - }, - Value: "Bar", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3350, - EndPos: 3353, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3350, - EndPos: 3353, - }, - Value: "Baz", - }, - }, - }, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3354, - EndPos: 3404, - }, - Adaptations: []node.Node{ - &stmt.TraitUsePrecedence{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3356, - EndPos: 3384, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3356, - EndPos: 3364, - }, - Trait: &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3356, - EndPos: 3359, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3356, - EndPos: 3359, - }, - Value: "Bar", - }, - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3361, - EndPos: 3364, - }, - Value: "one", - }, - }, - Insteadof: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3375, - EndPos: 3378, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3375, - EndPos: 3378, - }, - Value: "Baz", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3380, - EndPos: 3384, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3380, - EndPos: 3384, - }, - Value: "Quux", - }, - }, - }, - }, - }, - &stmt.TraitUseAlias{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3386, - EndPos: 3401, - }, - Ref: &stmt.TraitMethodRef{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3386, - EndPos: 3394, - }, - Trait: &name.Name{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3386, - EndPos: 3389, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3386, - EndPos: 3389, - }, - Value: "Baz", - }, - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3391, - EndPos: 3394, - }, - Value: "one", - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 151, - EndLine: 151, - StartPos: 3398, - EndPos: 3401, - }, - Value: "two", - }, - }, - }, - }, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 153, - EndLine: -1, - StartPos: 3410, - EndPos: -1, - }, - Stmts: []node.Node{}, - Catches: []node.Node{}, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3419, - EndPos: 3449, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3426, - EndPos: 3449, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3433, - EndPos: 3442, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3433, - EndPos: 3442, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3443, - EndPos: 3445, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 154, - EndLine: 154, - StartPos: 3443, - EndPos: 3445, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3452, - EndPos: 3499, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3459, - EndPos: 3499, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3466, - EndPos: 3475, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3466, - EndPos: 3475, - }, - Value: "Exception", - }, - }, - }, - &name.Name{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3476, - EndPos: 3492, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3476, - EndPos: 3492, - }, - Value: "RuntimeException", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3493, - EndPos: 3495, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 155, - EndLine: 155, - StartPos: 3493, - EndPos: 3495, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3502, - EndPos: 3563, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3509, - EndPos: 3532, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3516, - EndPos: 3525, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3516, - EndPos: 3525, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3526, - EndPos: 3528, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3526, - EndPos: 3528, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Catch{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3533, - EndPos: 3563, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3540, - EndPos: 3556, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3540, - EndPos: 3556, - }, - Value: "RuntimeException", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3557, - EndPos: 3559, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 156, - EndLine: 156, - StartPos: 3557, - EndPos: 3559, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Try{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3566, - EndPos: 3607, - }, - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3573, - EndPos: 3596, - }, - Types: []node.Node{ - &name.Name{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3580, - EndPos: 3589, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3580, - EndPos: 3589, - }, - Value: "Exception", - }, - }, - }, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3590, - EndPos: 3592, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3590, - EndPos: 3592, - }, - Value: "e", - }, - }, - Stmts: []node.Node{}, - }, - }, - Finally: &stmt.Finally{ - Position: &position.Position{ - StartLine: 157, - EndLine: 157, - StartPos: 3597, - EndPos: 3607, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Unset{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3611, - EndPos: 3626, - }, - Vars: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3617, - EndPos: 3619, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3617, - EndPos: 3619, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3621, - EndPos: 3623, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 159, - EndLine: 159, - StartPos: 3621, - EndPos: 3623, - }, - Value: "b", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3630, - EndPos: 3638, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3634, - EndPos: 3637, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3634, - EndPos: 3637, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 161, - EndLine: 161, - StartPos: 3634, - EndPos: 3637, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3641, - EndPos: 3650, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3646, - EndPos: 3649, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3646, - EndPos: 3649, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 162, - EndLine: 162, - StartPos: 3646, - EndPos: 3649, - }, - Value: "Foo", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 163, - EndLine: 163, - StartPos: 3653, - EndPos: 3669, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 163, - EndLine: 163, - StartPos: 3658, - EndPos: 3668, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 163, - EndLine: 163, - StartPos: 3658, - EndPos: 3661, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 163, - EndLine: 163, - StartPos: 3658, - EndPos: 3661, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 163, - EndLine: 163, - StartPos: 3665, - EndPos: 3668, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3672, - EndPos: 3685, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3676, - EndPos: 3679, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3676, - EndPos: 3679, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3676, - EndPos: 3679, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3681, - EndPos: 3684, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3681, - EndPos: 3684, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 164, - EndLine: 164, - StartPos: 3681, - EndPos: 3684, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3688, - EndPos: 3708, - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3692, - EndPos: 3695, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3692, - EndPos: 3695, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3692, - EndPos: 3695, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3697, - EndPos: 3707, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3697, - EndPos: 3700, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3697, - EndPos: 3700, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 165, - EndLine: 165, - StartPos: 3704, - EndPos: 3707, - }, - Value: "Baz", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3711, - EndPos: 3734, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3715, - EndPos: 3723, - }, - Value: "function", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3724, - EndPos: 3727, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3724, - EndPos: 3727, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3724, - EndPos: 3727, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3730, - EndPos: 3733, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3730, - EndPos: 3733, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 166, - EndLine: 166, - StartPos: 3730, - EndPos: 3733, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3737, - EndPos: 3774, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3741, - EndPos: 3749, - }, - Value: "function", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3750, - EndPos: 3760, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3750, - EndPos: 3753, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3750, - EndPos: 3753, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3757, - EndPos: 3760, - }, - Value: "foo", - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3763, - EndPos: 3773, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3763, - EndPos: 3766, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3763, - EndPos: 3766, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 167, - EndLine: 167, - StartPos: 3770, - EndPos: 3773, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3777, - EndPos: 3797, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3781, - EndPos: 3786, - }, - Value: "const", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3787, - EndPos: 3790, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3787, - EndPos: 3790, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3787, - EndPos: 3790, - }, - Value: "Foo", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3793, - EndPos: 3796, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3793, - EndPos: 3796, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 168, - EndLine: 168, - StartPos: 3793, - EndPos: 3796, - }, - Value: "Bar", - }, - }, - }, - }, - }, - }, - &stmt.UseList{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3800, - EndPos: 3834, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3804, - EndPos: 3809, - }, - Value: "const", - }, - Uses: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3810, - EndPos: 3820, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3810, - EndPos: 3813, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3810, - EndPos: 3813, - }, - Value: "Foo", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3817, - EndPos: 3820, - }, - Value: "foo", - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3823, - EndPos: 3833, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3823, - EndPos: 3826, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3823, - EndPos: 3826, - }, - Value: "Bar", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 169, - EndLine: 169, - StartPos: 3830, - EndPos: 3833, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.GroupUse{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3838, - EndPos: 3858, - }, - Prefix: &name.Name{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3843, - EndPos: 3846, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3843, - EndPos: 3846, - }, - Value: "Foo", - }, - }, - }, - UseList: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3848, - EndPos: 3851, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3848, - EndPos: 3851, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3848, - EndPos: 3851, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3853, - EndPos: 3856, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3853, - EndPos: 3856, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 171, - EndLine: 171, - StartPos: 3853, - EndPos: 3856, - }, - Value: "Baz", - }, - }, - }, - }, - }, - }, - &stmt.GroupUse{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3861, - EndPos: 3888, - }, - Prefix: &name.Name{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3865, - EndPos: 3868, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3865, - EndPos: 3868, - }, - Value: "Foo", - }, - }, - }, - UseList: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3870, - EndPos: 3873, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3870, - EndPos: 3873, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3870, - EndPos: 3873, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3875, - EndPos: 3886, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3875, - EndPos: 3878, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3875, - EndPos: 3878, - }, - Value: "Baz", - }, - }, - }, - Alias: &node.Identifier{ - Position: &position.Position{ - StartLine: 172, - EndLine: 172, - StartPos: 3882, - EndPos: 3886, - }, - Value: "quux", - }, - }, - }, - }, - &stmt.GroupUse{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3891, - EndPos: 3919, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3895, - EndPos: 3903, - }, - Value: "function", - }, - Prefix: &name.Name{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3904, - EndPos: 3907, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3904, - EndPos: 3907, - }, - Value: "Foo", - }, - }, - }, - UseList: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3909, - EndPos: 3912, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3909, - EndPos: 3912, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3909, - EndPos: 3912, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3914, - EndPos: 3917, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3914, - EndPos: 3917, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 173, - EndLine: 173, - StartPos: 3914, - EndPos: 3917, - }, - Value: "Baz", - }, - }, - }, - }, - }, - }, - &stmt.GroupUse{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3922, - EndPos: 3948, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3926, - EndPos: 3931, - }, - Value: "const", - }, - Prefix: &name.Name{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3933, - EndPos: 3936, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3933, - EndPos: 3936, - }, - Value: "Foo", - }, - }, - }, - UseList: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3938, - EndPos: 3941, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3938, - EndPos: 3941, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3938, - EndPos: 3941, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3943, - EndPos: 3946, - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3943, - EndPos: 3946, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 174, - EndLine: 174, - StartPos: 3943, - EndPos: 3946, - }, - Value: "Baz", - }, - }, - }, - }, - }, - }, - &stmt.GroupUse{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3951, - EndPos: 3985, - }, - Prefix: &name.Name{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3955, - EndPos: 3958, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3955, - EndPos: 3958, - }, - Value: "Foo", - }, - }, - }, - UseList: []node.Node{ - &stmt.Use{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3966, - EndPos: 3969, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3960, - EndPos: 3965, - }, - Value: "const", - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3966, - EndPos: 3969, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3966, - EndPos: 3969, - }, - Value: "Bar", - }, - }, - }, - }, - &stmt.Use{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3980, - EndPos: 3983, - }, - UseType: &node.Identifier{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3971, - EndPos: 3979, - }, - Value: "function", - }, - Use: &name.Name{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3980, - EndPos: 3983, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 175, - EndLine: 175, - StartPos: 3980, - EndPos: 3983, - }, - Value: "Baz", - }, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3989, - EndPos: 3995, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3989, - EndPos: 3994, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3989, - EndPos: 3991, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3989, - EndPos: 3991, - }, - Value: "a", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 177, - EndLine: 177, - StartPos: 3992, - EndPos: 3993, - }, - Value: "1", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3998, - EndPos: 4007, - }, - Expr: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3998, - EndPos: 4006, - }, - Variable: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3998, - EndPos: 4003, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3998, - EndPos: 4000, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 3998, - EndPos: 4000, - }, - Value: "a", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 4001, - EndPos: 4002, - }, - Value: "1", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 178, - EndLine: 178, - StartPos: 4004, - EndPos: 4005, - }, - Value: "2", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 4010, - EndPos: 4018, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 179, - EndLine: 179, - StartPos: 4010, - EndPos: 4017, - }, - Items: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 4021, - EndPos: 4030, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 4021, - EndPos: 4029, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 4027, - EndPos: 4028, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 180, - EndLine: 180, - StartPos: 4027, - EndPos: 4028, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4033, - EndPos: 4051, - }, - Expr: &expr.Array{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4033, - EndPos: 4050, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4039, - EndPos: 4043, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4039, - EndPos: 4040, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4042, - EndPos: 4043, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4045, - EndPos: 4048, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4045, - EndPos: 4048, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4046, - EndPos: 4048, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 181, - EndLine: 181, - StartPos: 4046, - EndPos: 4048, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4054, - EndPos: 4058, - }, - Expr: &expr.BitwiseNot{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4054, - EndPos: 4057, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4055, - EndPos: 4057, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 182, - EndLine: 182, - StartPos: 4055, - EndPos: 4057, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4061, - EndPos: 4065, - }, - Expr: &expr.BooleanNot{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4061, - EndPos: 4064, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4062, - EndPos: 4064, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 183, - EndLine: 183, - StartPos: 4062, - EndPos: 4064, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4069, - EndPos: 4078, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4069, - EndPos: 4077, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4069, - EndPos: 4072, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4069, - EndPos: 4072, - }, - Value: "Foo", - }, - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 185, - EndLine: 185, - StartPos: 4074, - EndPos: 4077, - }, - Value: "Bar", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4081, - EndPos: 4091, - }, - Expr: &expr.ClassConstFetch{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4081, - EndPos: 4090, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4081, - EndPos: 4085, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4081, - EndPos: 4085, - }, - Value: "foo", - }, - }, - ConstantName: &node.Identifier{ - Position: &position.Position{ - StartLine: 186, - EndLine: 186, - StartPos: 4087, - EndPos: 4090, - }, - Value: "Bar", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4094, - EndPos: 4104, - }, - Expr: &expr.Clone{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4094, - EndPos: 4102, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4100, - EndPos: 4102, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 187, - EndLine: 187, - StartPos: 4100, - EndPos: 4102, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4107, - EndPos: 4116, - }, - Expr: &expr.Clone{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4107, - EndPos: 4115, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4113, - EndPos: 4115, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 188, - EndLine: 188, - StartPos: 4113, - EndPos: 4115, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 189, - EndLine: 189, - StartPos: 4119, - EndPos: 4132, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 189, - EndLine: 189, - StartPos: 4119, - EndPos: 4131, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4135, - EndPos: 4169, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4135, - EndPos: 4168, - }, - Static: false, - PhpDocComment: "", - ReturnsRef: false, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4144, - EndPos: 4146, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4144, - EndPos: 4146, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4144, - EndPos: 4146, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4148, - EndPos: 4150, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4148, - EndPos: 4150, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4148, - EndPos: 4150, - }, - Value: "b", - }, - }, - }, - }, - ClosureUse: &expr.ClosureUse{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4152, - EndPos: 4165, - }, - Uses: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4157, - EndPos: 4159, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4157, - EndPos: 4159, - }, - Value: "c", - }, - }, - &expr.Reference{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4161, - EndPos: 4164, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4162, - EndPos: 4164, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 190, - EndLine: 190, - StartPos: 4162, - EndPos: 4164, - }, - Value: "d", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4172, - EndPos: 4192, - }, - Expr: &expr.Closure{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4172, - EndPos: 4191, - }, - ReturnsRef: false, - Static: false, - PhpDocComment: "", - ReturnType: &name.Name{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4184, - EndPos: 4188, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 191, - EndLine: 191, - StartPos: 4184, - EndPos: 4188, - }, - Value: "void", - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4195, - EndPos: 4199, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4195, - EndPos: 4198, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4195, - EndPos: 4198, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 192, - EndLine: 192, - StartPos: 4195, - EndPos: 4198, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4202, - EndPos: 4216, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4202, - EndPos: 4215, - }, - Constant: &name.Relative{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4202, - EndPos: 4215, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 193, - EndLine: 193, - StartPos: 4212, - EndPos: 4215, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4219, - EndPos: 4224, - }, - Expr: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4219, - EndPos: 4223, - }, - Constant: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4219, - EndPos: 4223, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 194, - EndLine: 194, - StartPos: 4220, - EndPos: 4223, - }, - Value: "foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4228, - EndPos: 4238, - }, - Expr: &expr.Empty{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4228, - EndPos: 4237, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4234, - EndPos: 4236, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 196, - EndLine: 196, - StartPos: 4234, - EndPos: 4236, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 197, - EndLine: 197, - StartPos: 4241, - EndPos: 4245, - }, - Expr: &expr.ErrorSuppress{ - Position: &position.Position{ - StartLine: 197, - EndLine: 197, - StartPos: 4241, - EndPos: 4244, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 197, - EndLine: 197, - StartPos: 4242, - EndPos: 4244, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 197, - EndLine: 197, - StartPos: 4242, - EndPos: 4244, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4248, - EndPos: 4257, - }, - Expr: &expr.Eval{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4248, - EndPos: 4256, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4253, - EndPos: 4255, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 198, - EndLine: 198, - StartPos: 4253, - EndPos: 4255, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4260, - EndPos: 4265, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 199, - EndLine: 199, - StartPos: 4260, - EndPos: 4264, - }, - Die: false, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4268, - EndPos: 4277, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4268, - EndPos: 4276, - }, - Die: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4273, - EndPos: 4275, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 200, - EndLine: 200, - StartPos: 4273, - EndPos: 4275, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4280, - EndPos: 4284, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 201, - EndLine: 201, - StartPos: 4280, - EndPos: 4283, - }, - Die: true, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 202, - EndLine: 202, - StartPos: 4287, - EndPos: 4295, - }, - Expr: &expr.Exit{ - Position: &position.Position{ - StartLine: 202, - EndLine: 202, - StartPos: 4287, - EndPos: 4294, - }, - Die: true, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 202, - EndLine: 202, - StartPos: 4291, - EndPos: 4293, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 202, - EndLine: 202, - StartPos: 4291, - EndPos: 4293, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4298, - EndPos: 4304, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4298, - EndPos: 4303, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4298, - EndPos: 4301, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4298, - EndPos: 4301, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 203, - EndLine: 203, - StartPos: 4301, - EndPos: 4303, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4307, - EndPos: 4323, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4307, - EndPos: 4322, - }, - Function: &name.Relative{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4307, - EndPos: 4320, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4317, - EndPos: 4320, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 204, - EndLine: 204, - StartPos: 4320, - EndPos: 4322, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4326, - EndPos: 4333, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4326, - EndPos: 4332, - }, - Function: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4326, - EndPos: 4330, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4327, - EndPos: 4330, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 205, - EndLine: 205, - StartPos: 4330, - EndPos: 4332, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4336, - EndPos: 4343, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4336, - EndPos: 4342, - }, - Function: &expr.Variable{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4336, - EndPos: 4340, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4336, - EndPos: 4340, - }, - Value: "foo", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 206, - EndLine: 206, - StartPos: 4340, - EndPos: 4342, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4347, - EndPos: 4352, - }, - Expr: &expr.PostDec{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4347, - EndPos: 4351, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4347, - EndPos: 4349, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 208, - EndLine: 208, - StartPos: 4347, - EndPos: 4349, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4355, - EndPos: 4360, - }, - Expr: &expr.PostInc{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4355, - EndPos: 4359, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4355, - EndPos: 4357, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 209, - EndLine: 209, - StartPos: 4355, - EndPos: 4357, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4363, - EndPos: 4368, - }, - Expr: &expr.PreDec{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4363, - EndPos: 4367, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4365, - EndPos: 4367, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 210, - EndLine: 210, - StartPos: 4365, - EndPos: 4367, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 211, - EndLine: 211, - StartPos: 4371, - EndPos: 4376, - }, - Expr: &expr.PreInc{ - Position: &position.Position{ - StartLine: 211, - EndLine: 211, - StartPos: 4371, - EndPos: 4375, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 211, - EndLine: 211, - StartPos: 4373, - EndPos: 4375, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 211, - EndLine: 211, - StartPos: 4373, - EndPos: 4375, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4380, - EndPos: 4391, - }, - Expr: &expr.Include{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4380, - EndPos: 4390, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4388, - EndPos: 4390, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 213, - EndLine: 213, - StartPos: 4388, - EndPos: 4390, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4394, - EndPos: 4410, - }, - Expr: &expr.IncludeOnce{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4394, - EndPos: 4409, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4407, - EndPos: 4409, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 214, - EndLine: 214, - StartPos: 4407, - EndPos: 4409, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4413, - EndPos: 4424, - }, - Expr: &expr.Require{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4413, - EndPos: 4423, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4421, - EndPos: 4423, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 215, - EndLine: 215, - StartPos: 4421, - EndPos: 4423, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4427, - EndPos: 4443, - }, - Expr: &expr.RequireOnce{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4427, - EndPos: 4442, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4440, - EndPos: 4442, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 216, - EndLine: 216, - StartPos: 4440, - EndPos: 4442, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4447, - EndPos: 4465, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4447, - EndPos: 4464, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4447, - EndPos: 4449, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4447, - EndPos: 4449, - }, - Value: "a", - }, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4461, - EndPos: 4464, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 218, - EndLine: 218, - StartPos: 4461, - EndPos: 4464, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4468, - EndPos: 4496, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4468, - EndPos: 4495, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4468, - EndPos: 4470, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4468, - EndPos: 4470, - }, - Value: "a", - }, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4482, - EndPos: 4495, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 219, - EndLine: 219, - StartPos: 4492, - EndPos: 4495, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4499, - EndPos: 4518, - }, - Expr: &expr.InstanceOf{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4499, - EndPos: 4517, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4499, - EndPos: 4501, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4499, - EndPos: 4501, - }, - Value: "a", - }, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4513, - EndPos: 4517, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 220, - EndLine: 220, - StartPos: 4514, - EndPos: 4517, - }, - Value: "Foo", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4522, - EndPos: 4536, - }, - Expr: &expr.Isset{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4522, - EndPos: 4535, - }, - Variables: []node.Node{ - &expr.Variable{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4528, - EndPos: 4530, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4528, - EndPos: 4530, - }, - Value: "a", - }, - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4532, - EndPos: 4534, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 222, - EndLine: 222, - StartPos: 4532, - EndPos: 4534, - }, - Value: "b", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4539, - EndPos: 4553, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4539, - EndPos: 4552, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4539, - EndPos: 4547, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4544, - EndPos: 4546, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4544, - EndPos: 4546, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4544, - EndPos: 4546, - }, - Value: "a", - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4550, - EndPos: 4552, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 223, - EndLine: 223, - StartPos: 4550, - EndPos: 4552, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4556, - EndPos: 4572, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4556, - EndPos: 4571, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4556, - EndPos: 4566, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4561, - EndPos: 4565, - }, - Val: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4561, - EndPos: 4565, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4561, - EndPos: 4563, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4561, - EndPos: 4563, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4569, - EndPos: 4571, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 224, - EndLine: 224, - StartPos: 4569, - EndPos: 4571, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4575, - EndPos: 4595, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4575, - EndPos: 4594, - }, - Variable: &expr.List{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4575, - EndPos: 4589, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4580, - EndPos: 4588, - }, - Val: &expr.List{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4580, - EndPos: 4588, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4585, - EndPos: 4587, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4585, - EndPos: 4587, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4585, - EndPos: 4587, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4592, - EndPos: 4594, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 225, - EndLine: 225, - StartPos: 4592, - EndPos: 4594, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4599, - EndPos: 4609, - }, - Expr: &expr.MethodCall{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4599, - EndPos: 4608, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4599, - EndPos: 4601, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4599, - EndPos: 4601, - }, - Value: "a", - }, - }, - Method: &node.Identifier{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4603, - EndPos: 4606, - }, - Value: "foo", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 227, - EndLine: 227, - StartPos: 4606, - EndPos: 4608, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4612, - EndPos: 4622, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4612, - EndPos: 4621, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4616, - EndPos: 4619, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4616, - EndPos: 4619, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 228, - EndLine: 228, - StartPos: 4619, - EndPos: 4621, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4625, - EndPos: 4645, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4625, - EndPos: 4644, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4629, - EndPos: 4642, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4639, - EndPos: 4642, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 229, - EndLine: 229, - StartPos: 4642, - EndPos: 4644, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4648, - EndPos: 4659, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4648, - EndPos: 4658, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4652, - EndPos: 4656, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4653, - EndPos: 4656, - }, - Value: "Foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 230, - EndLine: 230, - StartPos: 4656, - EndPos: 4658, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4662, - EndPos: 4687, - }, - Expr: &expr.New{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4662, - EndPos: 4686, - }, - Class: &stmt.Class{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4666, - EndPos: 4686, - }, - PhpDocComment: "", - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4672, - EndPos: 4683, - }, - Arguments: []node.Node{ - &node.Argument{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4673, - EndPos: 4675, - }, - IsReference: false, - Variadic: false, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4673, - EndPos: 4675, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4673, - EndPos: 4675, - }, - Value: "a", - }, - }, - }, - &node.Argument{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4677, - EndPos: 4682, - }, - IsReference: false, - Variadic: true, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4680, - EndPos: 4682, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 231, - EndLine: 231, - StartPos: 4680, - EndPos: 4682, - }, - Value: "b", - }, - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4690, - EndPos: 4700, - }, - Expr: &expr.Print{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4690, - EndPos: 4698, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4696, - EndPos: 4698, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 232, - EndLine: 232, - StartPos: 4696, - EndPos: 4698, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4703, - EndPos: 4711, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4703, - EndPos: 4710, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4703, - EndPos: 4705, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4703, - EndPos: 4705, - }, - Value: "a", - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 233, - EndLine: 233, - StartPos: 4707, - EndPos: 4710, - }, - Value: "foo", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 234, - EndLine: 234, - StartPos: 4714, - EndPos: 4723, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 234, - EndLine: 234, - StartPos: 4714, - EndPos: 4722, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 234, - EndLine: 234, - StartPos: 4715, - EndPos: 4719, - }, - Value: "cmd ", - }, - &expr.Variable{ - Position: &position.Position{ - StartLine: 234, - EndLine: 234, - StartPos: 4719, - EndPos: 4721, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 234, - EndLine: 234, - StartPos: 4719, - EndPos: 4721, - }, - Value: "a", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4726, - EndPos: 4732, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4726, - EndPos: 4731, - }, - Parts: []node.Node{ - &scalar.EncapsedStringPart{ - Position: &position.Position{ - StartLine: 235, - EndLine: 235, - StartPos: 4727, - EndPos: 4730, - }, - Value: "cmd", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4735, - EndPos: 4738, - }, - Expr: &expr.ShellExec{ - Position: &position.Position{ - StartLine: 236, - EndLine: 236, - StartPos: 4735, - EndPos: 4737, - }, - Parts: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4741, - EndPos: 4744, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 237, - EndLine: 237, - StartPos: 4741, - EndPos: 4743, - }, - Items: []node.Node{}, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4747, - EndPos: 4751, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4747, - EndPos: 4750, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4748, - EndPos: 4749, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 238, - EndLine: 238, - StartPos: 4748, - EndPos: 4749, - }, - Value: "1", - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4754, - EndPos: 4767, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4754, - EndPos: 4766, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4755, - EndPos: 4759, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4755, - EndPos: 4756, - }, - Value: "1", - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4758, - EndPos: 4759, - }, - Value: "1", - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4761, - EndPos: 4764, - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4761, - EndPos: 4764, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4762, - EndPos: 4764, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 239, - EndLine: 239, - StartPos: 4762, - EndPos: 4764, - }, - Value: "b", - }, - }, - }, - }, - &expr.ArrayItem{}, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4771, - EndPos: 4781, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4771, - EndPos: 4780, - }, - Variable: &expr.ShortList{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4771, - EndPos: 4775, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4772, - EndPos: 4774, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4772, - EndPos: 4774, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4772, - EndPos: 4774, - }, - Value: "a", - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4778, - EndPos: 4780, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 241, - EndLine: 241, - StartPos: 4778, - EndPos: 4780, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4784, - EndPos: 4796, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4784, - EndPos: 4795, - }, - Variable: &expr.ShortList{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4784, - EndPos: 4790, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4785, - EndPos: 4789, - }, - Val: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4785, - EndPos: 4789, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4785, - EndPos: 4787, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4785, - EndPos: 4787, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4793, - EndPos: 4795, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 242, - EndLine: 242, - StartPos: 4793, - EndPos: 4795, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4799, - EndPos: 4815, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4799, - EndPos: 4814, - }, - Variable: &expr.ShortList{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4799, - EndPos: 4809, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4800, - EndPos: 4808, - }, - Val: &expr.List{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4800, - EndPos: 4808, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4805, - EndPos: 4807, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4805, - EndPos: 4807, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4805, - EndPos: 4807, - }, - Value: "a", - }, - }, - }, - }, - }, - }, - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4812, - EndPos: 4814, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 243, - EndLine: 243, - StartPos: 4812, - EndPos: 4814, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4818, - EndPos: 4829, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4818, - EndPos: 4828, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4818, - EndPos: 4821, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4818, - EndPos: 4821, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4823, - EndPos: 4826, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 244, - EndLine: 244, - StartPos: 4826, - EndPos: 4828, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4832, - EndPos: 4853, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4832, - EndPos: 4852, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4832, - EndPos: 4845, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4842, - EndPos: 4845, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4847, - EndPos: 4850, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 245, - EndLine: 245, - StartPos: 4850, - EndPos: 4852, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4856, - EndPos: 4868, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4856, - EndPos: 4867, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4856, - EndPos: 4860, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4857, - EndPos: 4860, - }, - Value: "Foo", - }, - }, - }, - Call: &node.Identifier{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4862, - EndPos: 4865, - }, - Value: "bar", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 246, - EndLine: 246, - StartPos: 4865, - EndPos: 4867, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4871, - EndPos: 4881, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4871, - EndPos: 4880, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4871, - EndPos: 4874, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4871, - EndPos: 4874, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4876, - EndPos: 4880, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 247, - EndLine: 247, - StartPos: 4876, - EndPos: 4880, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4884, - EndPos: 4895, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4884, - EndPos: 4894, - }, - Class: &expr.Variable{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4884, - EndPos: 4888, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4884, - EndPos: 4888, - }, - Value: "foo", - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4890, - EndPos: 4894, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 248, - EndLine: 248, - StartPos: 4890, - EndPos: 4894, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4898, - EndPos: 4918, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4898, - EndPos: 4917, - }, - Class: &name.Relative{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4898, - EndPos: 4911, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4908, - EndPos: 4911, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4913, - EndPos: 4917, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 249, - EndLine: 249, - StartPos: 4913, - EndPos: 4917, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4921, - EndPos: 4932, - }, - Expr: &expr.StaticPropertyFetch{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4921, - EndPos: 4931, - }, - Class: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4921, - EndPos: 4925, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4922, - EndPos: 4925, - }, - Value: "Foo", - }, - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4927, - EndPos: 4931, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 250, - EndLine: 250, - StartPos: 4927, - EndPos: 4931, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4935, - EndPos: 4948, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4935, - EndPos: 4947, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4935, - EndPos: 4937, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4935, - EndPos: 4937, - }, - Value: "a", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4940, - EndPos: 4942, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4940, - EndPos: 4942, - }, - Value: "b", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4945, - EndPos: 4947, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 251, - EndLine: 251, - StartPos: 4945, - EndPos: 4947, - }, - Value: "c", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4951, - EndPos: 4961, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4951, - EndPos: 4960, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4951, - EndPos: 4953, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4951, - EndPos: 4953, - }, - Value: "a", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4958, - EndPos: 4960, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 252, - EndLine: 252, - StartPos: 4958, - EndPos: 4960, - }, - Value: "c", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4964, - EndPos: 4987, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4964, - EndPos: 4986, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4964, - EndPos: 4966, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4964, - EndPos: 4966, - }, - Value: "a", - }, - }, - IfTrue: &expr.Ternary{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4969, - EndPos: 4981, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4969, - EndPos: 4971, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4969, - EndPos: 4971, - }, - Value: "b", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4974, - EndPos: 4976, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4974, - EndPos: 4976, - }, - Value: "c", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4979, - EndPos: 4981, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4979, - EndPos: 4981, - }, - Value: "d", - }, - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4984, - EndPos: 4986, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 253, - EndLine: 253, - StartPos: 4984, - EndPos: 4986, - }, - Value: "e", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4990, - EndPos: 5013, - }, - Expr: &expr.Ternary{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4990, - EndPos: 5012, - }, - Condition: &expr.Ternary{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4990, - EndPos: 5002, - }, - Condition: &expr.Variable{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4990, - EndPos: 4992, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4990, - EndPos: 4992, - }, - Value: "a", - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4995, - EndPos: 4997, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 4995, - EndPos: 4997, - }, - Value: "b", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5000, - EndPos: 5002, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5000, - EndPos: 5002, - }, - Value: "c", - }, - }, - }, - IfTrue: &expr.Variable{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5005, - EndPos: 5007, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5005, - EndPos: 5007, - }, - Value: "d", - }, - }, - IfFalse: &expr.Variable{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5010, - EndPos: 5012, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 254, - EndLine: 254, - StartPos: 5010, - EndPos: 5012, - }, - Value: "e", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 5016, - EndPos: 5020, - }, - Expr: &expr.UnaryMinus{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 5016, - EndPos: 5019, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 5017, - EndPos: 5019, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 255, - EndLine: 255, - StartPos: 5017, - EndPos: 5019, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 256, - EndLine: 256, - StartPos: 5023, - EndPos: 5027, - }, - Expr: &expr.UnaryPlus{ - Position: &position.Position{ - StartLine: 256, - EndLine: 256, - StartPos: 5023, - EndPos: 5026, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 256, - EndLine: 256, - StartPos: 5024, - EndPos: 5026, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 256, - EndLine: 256, - StartPos: 5024, - EndPos: 5026, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5030, - EndPos: 5034, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5030, - EndPos: 5033, - }, - VarName: &expr.Variable{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5031, - EndPos: 5033, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 257, - EndLine: 257, - StartPos: 5031, - EndPos: 5033, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5037, - EndPos: 5043, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 258, - EndLine: 258, - StartPos: 5037, - EndPos: 5042, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5046, - EndPos: 5055, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5046, - EndPos: 5054, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5052, - EndPos: 5054, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 259, - EndLine: 259, - StartPos: 5052, - EndPos: 5054, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5058, - EndPos: 5073, - }, - Expr: &expr.Yield{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5058, - EndPos: 5072, - }, - Key: &expr.Variable{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5064, - EndPos: 5066, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5064, - EndPos: 5066, - }, - Value: "a", - }, - }, - Value: &expr.Variable{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5070, - EndPos: 5072, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 260, - EndLine: 260, - StartPos: 5070, - EndPos: 5072, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5076, - EndPos: 5090, - }, - Expr: &expr.YieldFrom{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5076, - EndPos: 5089, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5087, - EndPos: 5089, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 261, - EndLine: 261, - StartPos: 5087, - EndPos: 5089, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5096, - EndPos: 5106, - }, - Expr: &cast.Array{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5096, - EndPos: 5105, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5103, - EndPos: 5105, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 263, - EndLine: 263, - StartPos: 5103, - EndPos: 5105, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5109, - EndPos: 5121, - }, - Expr: &cast.Bool{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5109, - EndPos: 5120, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5118, - EndPos: 5120, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 264, - EndLine: 264, - StartPos: 5118, - EndPos: 5120, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5124, - EndPos: 5133, - }, - Expr: &cast.Bool{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5124, - EndPos: 5132, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5130, - EndPos: 5132, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 265, - EndLine: 265, - StartPos: 5130, - EndPos: 5132, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5136, - EndPos: 5147, - }, - Expr: &cast.Double{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5136, - EndPos: 5146, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5144, - EndPos: 5146, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 266, - EndLine: 266, - StartPos: 5144, - EndPos: 5146, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 267, - EndLine: 267, - StartPos: 5150, - EndPos: 5160, - }, - Expr: &cast.Double{ - Position: &position.Position{ - StartLine: 267, - EndLine: 267, - StartPos: 5150, - EndPos: 5159, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 267, - EndLine: 267, - StartPos: 5157, - EndPos: 5159, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 267, - EndLine: 267, - StartPos: 5157, - EndPos: 5159, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5163, - EndPos: 5175, - }, - Expr: &cast.Int{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5163, - EndPos: 5174, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5172, - EndPos: 5174, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 268, - EndLine: 268, - StartPos: 5172, - EndPos: 5174, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5178, - EndPos: 5186, - }, - Expr: &cast.Int{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5178, - EndPos: 5185, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5183, - EndPos: 5185, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 269, - EndLine: 269, - StartPos: 5183, - EndPos: 5185, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5189, - EndPos: 5200, - }, - Expr: &cast.Object{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5189, - EndPos: 5199, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5197, - EndPos: 5199, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 270, - EndLine: 270, - StartPos: 5197, - EndPos: 5199, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5203, - EndPos: 5214, - }, - Expr: &cast.String{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5203, - EndPos: 5213, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5211, - EndPos: 5213, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 271, - EndLine: 271, - StartPos: 5211, - EndPos: 5213, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5217, - EndPos: 5227, - }, - Expr: &cast.Unset{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5217, - EndPos: 5226, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5224, - EndPos: 5226, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 272, - EndLine: 272, - StartPos: 5224, - EndPos: 5226, - }, - Value: "a", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5231, - EndPos: 5239, - }, - Expr: &binary.BitwiseAnd{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5231, - EndPos: 5238, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5231, - EndPos: 5233, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5231, - EndPos: 5233, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5236, - EndPos: 5238, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 274, - EndLine: 274, - StartPos: 5236, - EndPos: 5238, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5242, - EndPos: 5250, - }, - Expr: &binary.BitwiseOr{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5242, - EndPos: 5249, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5242, - EndPos: 5244, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5242, - EndPos: 5244, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5247, - EndPos: 5249, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 275, - EndLine: 275, - StartPos: 5247, - EndPos: 5249, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5253, - EndPos: 5261, - }, - Expr: &binary.BitwiseXor{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5253, - EndPos: 5260, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5253, - EndPos: 5255, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5253, - EndPos: 5255, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5258, - EndPos: 5260, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 276, - EndLine: 276, - StartPos: 5258, - EndPos: 5260, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5264, - EndPos: 5273, - }, - Expr: &binary.BooleanAnd{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5264, - EndPos: 5272, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5264, - EndPos: 5266, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5264, - EndPos: 5266, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5270, - EndPos: 5272, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 277, - EndLine: 277, - StartPos: 5270, - EndPos: 5272, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5276, - EndPos: 5285, - }, - Expr: &binary.BooleanOr{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5276, - EndPos: 5284, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5276, - EndPos: 5278, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5276, - EndPos: 5278, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5282, - EndPos: 5284, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 278, - EndLine: 278, - StartPos: 5282, - EndPos: 5284, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5288, - EndPos: 5297, - }, - Expr: &binary.Coalesce{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5288, - EndPos: 5296, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5288, - EndPos: 5290, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5288, - EndPos: 5290, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5294, - EndPos: 5296, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 279, - EndLine: 279, - StartPos: 5294, - EndPos: 5296, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5300, - EndPos: 5308, - }, - Expr: &binary.Concat{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5300, - EndPos: 5307, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5300, - EndPos: 5302, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5300, - EndPos: 5302, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5305, - EndPos: 5307, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 280, - EndLine: 280, - StartPos: 5305, - EndPos: 5307, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5311, - EndPos: 5319, - }, - Expr: &binary.Div{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5311, - EndPos: 5318, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5311, - EndPos: 5313, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5311, - EndPos: 5313, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5316, - EndPos: 5318, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 281, - EndLine: 281, - StartPos: 5316, - EndPos: 5318, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5322, - EndPos: 5331, - }, - Expr: &binary.Equal{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5322, - EndPos: 5330, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5322, - EndPos: 5324, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5322, - EndPos: 5324, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5328, - EndPos: 5330, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 282, - EndLine: 282, - StartPos: 5328, - EndPos: 5330, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5334, - EndPos: 5343, - }, - Expr: &binary.GreaterOrEqual{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5334, - EndPos: 5342, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5334, - EndPos: 5336, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5334, - EndPos: 5336, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5340, - EndPos: 5342, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 283, - EndLine: 283, - StartPos: 5340, - EndPos: 5342, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5346, - EndPos: 5354, - }, - Expr: &binary.Greater{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5346, - EndPos: 5353, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5346, - EndPos: 5348, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5346, - EndPos: 5348, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5351, - EndPos: 5353, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 284, - EndLine: 284, - StartPos: 5351, - EndPos: 5353, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5357, - EndPos: 5367, - }, - Expr: &binary.Identical{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5357, - EndPos: 5366, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5357, - EndPos: 5359, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5357, - EndPos: 5359, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5364, - EndPos: 5366, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 285, - EndLine: 285, - StartPos: 5364, - EndPos: 5366, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5370, - EndPos: 5380, - }, - Expr: &binary.LogicalAnd{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5370, - EndPos: 5379, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5370, - EndPos: 5372, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5370, - EndPos: 5372, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5377, - EndPos: 5379, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 286, - EndLine: 286, - StartPos: 5377, - EndPos: 5379, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5383, - EndPos: 5392, - }, - Expr: &binary.LogicalOr{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5383, - EndPos: 5391, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5383, - EndPos: 5385, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5383, - EndPos: 5385, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5389, - EndPos: 5391, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 287, - EndLine: 287, - StartPos: 5389, - EndPos: 5391, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5395, - EndPos: 5405, - }, - Expr: &binary.LogicalXor{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5395, - EndPos: 5404, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5395, - EndPos: 5397, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5395, - EndPos: 5397, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5402, - EndPos: 5404, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 288, - EndLine: 288, - StartPos: 5402, - EndPos: 5404, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5408, - EndPos: 5416, - }, - Expr: &binary.Minus{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5408, - EndPos: 5415, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5408, - EndPos: 5410, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5408, - EndPos: 5410, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5413, - EndPos: 5415, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 289, - EndLine: 289, - StartPos: 5413, - EndPos: 5415, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5419, - EndPos: 5427, - }, - Expr: &binary.Mod{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5419, - EndPos: 5426, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5419, - EndPos: 5421, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5419, - EndPos: 5421, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5424, - EndPos: 5426, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 290, - EndLine: 290, - StartPos: 5424, - EndPos: 5426, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5430, - EndPos: 5438, - }, - Expr: &binary.Mul{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5430, - EndPos: 5437, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5430, - EndPos: 5432, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5430, - EndPos: 5432, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5435, - EndPos: 5437, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 291, - EndLine: 291, - StartPos: 5435, - EndPos: 5437, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5441, - EndPos: 5450, - }, - Expr: &binary.NotEqual{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5441, - EndPos: 5449, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5441, - EndPos: 5443, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5441, - EndPos: 5443, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5447, - EndPos: 5449, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 292, - EndLine: 292, - StartPos: 5447, - EndPos: 5449, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5453, - EndPos: 5463, - }, - Expr: &binary.NotIdentical{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5453, - EndPos: 5462, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5453, - EndPos: 5455, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5453, - EndPos: 5455, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5460, - EndPos: 5462, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 293, - EndLine: 293, - StartPos: 5460, - EndPos: 5462, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5466, - EndPos: 5474, - }, - Expr: &binary.Plus{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5466, - EndPos: 5473, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5466, - EndPos: 5468, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5466, - EndPos: 5468, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5471, - EndPos: 5473, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 294, - EndLine: 294, - StartPos: 5471, - EndPos: 5473, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5477, - EndPos: 5486, - }, - Expr: &binary.Pow{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5477, - EndPos: 5485, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5477, - EndPos: 5479, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5477, - EndPos: 5479, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5483, - EndPos: 5485, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 295, - EndLine: 295, - StartPos: 5483, - EndPos: 5485, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5489, - EndPos: 5498, - }, - Expr: &binary.ShiftLeft{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5489, - EndPos: 5497, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5489, - EndPos: 5491, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5489, - EndPos: 5491, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5495, - EndPos: 5497, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 296, - EndLine: 296, - StartPos: 5495, - EndPos: 5497, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5501, - EndPos: 5510, - }, - Expr: &binary.ShiftRight{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5501, - EndPos: 5509, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5501, - EndPos: 5503, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5501, - EndPos: 5503, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5507, - EndPos: 5509, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 297, - EndLine: 297, - StartPos: 5507, - EndPos: 5509, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5513, - EndPos: 5522, - }, - Expr: &binary.SmallerOrEqual{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5513, - EndPos: 5521, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5513, - EndPos: 5515, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5513, - EndPos: 5515, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5519, - EndPos: 5521, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 298, - EndLine: 298, - StartPos: 5519, - EndPos: 5521, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5525, - EndPos: 5533, - }, - Expr: &binary.Smaller{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5525, - EndPos: 5532, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5525, - EndPos: 5527, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5525, - EndPos: 5527, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5530, - EndPos: 5532, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 299, - EndLine: 299, - StartPos: 5530, - EndPos: 5532, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5536, - EndPos: 5546, - }, - Expr: &binary.Spaceship{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5536, - EndPos: 5545, - }, - Left: &expr.Variable{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5536, - EndPos: 5538, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5536, - EndPos: 5538, - }, - Value: "a", - }, - }, - Right: &expr.Variable{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5543, - EndPos: 5545, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 300, - EndLine: 300, - StartPos: 5543, - EndPos: 5545, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5550, - EndPos: 5559, - }, - Expr: &assign.Reference{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5550, - EndPos: 5558, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5550, - EndPos: 5552, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5550, - EndPos: 5552, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5556, - EndPos: 5558, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 302, - EndLine: 302, - StartPos: 5556, - EndPos: 5558, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5562, - EndPos: 5570, - }, - Expr: &assign.Assign{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5562, - EndPos: 5569, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5562, - EndPos: 5564, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5562, - EndPos: 5564, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5567, - EndPos: 5569, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 303, - EndLine: 303, - StartPos: 5567, - EndPos: 5569, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5573, - EndPos: 5582, - }, - Expr: &assign.BitwiseAnd{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5573, - EndPos: 5581, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5573, - EndPos: 5575, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5573, - EndPos: 5575, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5579, - EndPos: 5581, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 304, - EndLine: 304, - StartPos: 5579, - EndPos: 5581, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5585, - EndPos: 5594, - }, - Expr: &assign.BitwiseOr{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5585, - EndPos: 5593, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5585, - EndPos: 5587, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5585, - EndPos: 5587, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5591, - EndPos: 5593, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 305, - EndLine: 305, - StartPos: 5591, - EndPos: 5593, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5597, - EndPos: 5606, - }, - Expr: &assign.BitwiseXor{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5597, - EndPos: 5605, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5597, - EndPos: 5599, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5597, - EndPos: 5599, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5603, - EndPos: 5605, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 306, - EndLine: 306, - StartPos: 5603, - EndPos: 5605, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5609, - EndPos: 5618, - }, - Expr: &assign.Concat{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5609, - EndPos: 5617, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5609, - EndPos: 5611, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5609, - EndPos: 5611, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5615, - EndPos: 5617, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 307, - EndLine: 307, - StartPos: 5615, - EndPos: 5617, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5621, - EndPos: 5630, - }, - Expr: &assign.Div{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5621, - EndPos: 5629, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5621, - EndPos: 5623, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5621, - EndPos: 5623, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5627, - EndPos: 5629, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 308, - EndLine: 308, - StartPos: 5627, - EndPos: 5629, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5633, - EndPos: 5642, - }, - Expr: &assign.Minus{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5633, - EndPos: 5641, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5633, - EndPos: 5635, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5633, - EndPos: 5635, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5641, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 309, - EndLine: 309, - StartPos: 5639, - EndPos: 5641, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5645, - EndPos: 5654, - }, - Expr: &assign.Mod{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5645, - EndPos: 5653, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5645, - EndPos: 5647, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5645, - EndPos: 5647, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5651, - EndPos: 5653, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 310, - EndLine: 310, - StartPos: 5651, - EndPos: 5653, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5657, - EndPos: 5666, - }, - Expr: &assign.Mul{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5657, - EndPos: 5665, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5657, - EndPos: 5659, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5657, - EndPos: 5659, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5663, - EndPos: 5665, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 311, - EndLine: 311, - StartPos: 5663, - EndPos: 5665, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5669, - EndPos: 5678, - }, - Expr: &assign.Plus{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5669, - EndPos: 5677, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5669, - EndPos: 5671, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5669, - EndPos: 5671, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5675, - EndPos: 5677, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 312, - EndLine: 312, - StartPos: 5675, - EndPos: 5677, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5681, - EndPos: 5691, - }, - Expr: &assign.Pow{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5681, - EndPos: 5690, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5681, - EndPos: 5683, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5681, - EndPos: 5683, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5688, - EndPos: 5690, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 313, - EndLine: 313, - StartPos: 5688, - EndPos: 5690, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5694, - EndPos: 5704, - }, - Expr: &assign.ShiftLeft{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5694, - EndPos: 5703, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5694, - EndPos: 5696, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5694, - EndPos: 5696, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5701, - EndPos: 5703, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 314, - EndLine: 314, - StartPos: 5701, - EndPos: 5703, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5707, - EndPos: 5717, - }, - Expr: &assign.ShiftRight{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5707, - EndPos: 5716, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5707, - EndPos: 5709, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5707, - EndPos: 5709, - }, - Value: "a", - }, - }, - Expression: &expr.Variable{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5714, - EndPos: 5716, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 315, - EndLine: 315, - StartPos: 5714, - EndPos: 5716, - }, - Value: "b", - }, - }, - }, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5721, - EndPos: 5760, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5727, - EndPos: 5730, - }, - Value: "foo", - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5732, - EndPos: 5758, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5748, - EndPos: 5753, - }, - Value: "class", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5732, - EndPos: 5738, - }, - Value: "public", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 317, - EndLine: 317, - StartPos: 5756, - EndPos: 5758, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5763, - EndPos: 5774, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5763, - EndPos: 5773, - }, - Function: &name.FullyQualified{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5763, - EndPos: 5771, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5764, - EndPos: 5767, - }, - Value: "foo", - }, - &name.NamePart{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5768, - EndPos: 5771, - }, - Value: "bar", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 318, - EndLine: 318, - StartPos: 5771, - EndPos: 5773, - }, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 320, - EndLine: 326, - StartPos: 5778, - EndPos: 5905, - }, - PhpDocComment: "", - ReturnsRef: false, - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5787, - EndPos: 5790, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5791, - EndPos: 5794, - }, - ByRef: true, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5792, - EndPos: 5794, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5792, - EndPos: 5794, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5796, - EndPos: 5801, - }, - ByRef: false, - Variadic: true, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5799, - EndPos: 5801, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 320, - EndLine: 320, - StartPos: 5799, - EndPos: 5801, - }, - Value: "b", - }, - }, - }, - }, - Stmts: []node.Node{ - &stmt.Function{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5830, - EndPos: 5847, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 322, - EndLine: 322, - StartPos: 5839, - EndPos: 5842, - }, - Value: "bar", - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5851, - EndPos: 5863, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 323, - EndLine: 323, - StartPos: 5857, - EndPos: 5860, - }, - Value: "Baz", - }, - Stmts: []node.Node{}, - }, - &stmt.Trait{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5867, - EndPos: 5879, - }, - PhpDocComment: "", - TraitName: &node.Identifier{ - Position: &position.Position{ - StartLine: 324, - EndLine: 324, - StartPos: 5873, - EndPos: 5877, - }, - Value: "Quux", - }, - Stmts: []node.Node{}, - }, - &stmt.Interface{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5883, - EndPos: 5901, - }, - PhpDocComment: "", - InterfaceName: &node.Identifier{ - Position: &position.Position{ - StartLine: 325, - EndLine: 325, - StartPos: 5893, - EndPos: 5898, - }, - Value: "Quuux", - }, - Stmts: []node.Node{}, - }, - }, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5911, - EndPos: 5954, - }, - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5920, - EndPos: 5923, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5924, - EndPos: 5931, - }, - ByRef: true, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5925, - EndPos: 5927, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5925, - EndPos: 5927, - }, - Value: "a", - }, - }, - DefaultValue: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5930, - EndPos: 5931, - }, - Value: "1", - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5933, - EndPos: 5942, - }, - ByRef: false, - Variadic: true, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5936, - EndPos: 5938, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5936, - EndPos: 5938, - }, - Value: "b", - }, - }, - DefaultValue: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5941, - EndPos: 5942, - }, - Value: "1", - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5944, - EndPos: 5950, - }, - ByRef: false, - Variadic: false, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5944, - EndPos: 5946, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5944, - EndPos: 5946, - }, - Value: "c", - }, - }, - DefaultValue: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 328, - EndLine: 328, - StartPos: 5949, - EndPos: 5950, - }, - Value: "1", - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Function{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5957, - EndPos: 5995, - }, - PhpDocComment: "", - ReturnsRef: false, - FunctionName: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5966, - EndPos: 5969, - }, - Value: "foo", - }, - Params: []node.Node{ - &node.Parameter{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5970, - EndPos: 5978, - }, - ByRef: false, - Variadic: false, - VariableType: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5970, - EndPos: 5975, - }, - Value: "array", - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5976, - EndPos: 5978, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5976, - EndPos: 5978, - }, - Value: "a", - }, - }, - }, - &node.Parameter{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5980, - EndPos: 5991, - }, - Variadic: false, - ByRef: false, - VariableType: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5980, - EndPos: 5988, - }, - Value: "callable", - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5989, - EndPos: 5991, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 329, - EndLine: 329, - StartPos: 5989, - EndPos: 5991, - }, - Value: "b", - }, - }, - }, - }, - Stmts: []node.Node{}, - }, - &stmt.Class{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5998, - EndPos: 6100, - }, - PhpDocComment: "", - ClassName: &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6019, - EndPos: 6022, - }, - Value: "foo", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 5998, - EndPos: 6006, - }, - Value: "abstract", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6007, - EndPos: 6012, - }, - Value: "final", - }, - }, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6025, - EndPos: 6066, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6060, - EndPos: 6063, - }, - Value: "bar", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6025, - EndPos: 6033, - }, - Value: "abstract", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6034, - EndPos: 6043, - }, - Value: "protected", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6044, - EndPos: 6050, - }, - Value: "static", - }, - }, - Stmt: &stmt.Nop{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6065, - EndPos: 6066, - }, - }, - }, - &stmt.ClassMethod{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6067, - EndPos: 6098, - }, - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6090, - EndPos: 6093, - }, - Value: "baz", - }, - Modifiers: []node.Node{ - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6067, - EndPos: 6072, - }, - Value: "final", - }, - &node.Identifier{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6073, - EndPos: 6080, - }, - Value: "private", - }, - }, - Stmt: &stmt.StmtList{ - Position: &position.Position{ - StartLine: 330, - EndLine: 330, - StartPos: 6096, - EndPos: 6098, - }, - Stmts: []node.Node{}, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6105, - EndPos: 6119, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6105, - EndPos: 6118, - }, - Variable: &expr.New{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6105, - EndPos: 6112, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6109, - EndPos: 6112, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6109, - EndPos: 6112, - }, - Value: "Foo", - }, - }, - }, - }, - Property: &node.Identifier{ - Position: &position.Position{ - StartLine: 332, - EndLine: 332, - StartPos: 6115, - EndPos: 6118, - }, - Value: "bar", - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6123, - EndPos: 6134, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6123, - EndPos: 6133, - }, - Function: &expr.New{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6123, - EndPos: 6130, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6127, - EndPos: 6130, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6127, - EndPos: 6130, - }, - Value: "Foo", - }, - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 333, - EndLine: 333, - StartPos: 6131, - EndPos: 6133, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6137, - EndPos: 6149, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6137, - EndPos: 6148, - }, - Function: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6137, - EndPos: 6146, - }, - Variable: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6137, - EndPos: 6143, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6138, - EndPos: 6142, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6138, - EndPos: 6142, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6138, - EndPos: 6142, - }, - Value: "foo", - }, - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6144, - EndPos: 6145, - }, - Value: "0", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 334, - EndLine: 334, - StartPos: 6146, - EndPos: 6148, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6161, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6160, - }, - Function: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6158, - }, - Variable: &expr.ConstFetch{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6155, - }, - Constant: &name.Name{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6155, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6152, - EndPos: 6155, - }, - Value: "foo", - }, - }, - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6156, - EndPos: 6157, - }, - Value: "1", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 335, - EndLine: 335, - StartPos: 6158, - EndPos: 6160, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6164, - EndPos: 6172, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6164, - EndPos: 6171, - }, - Function: &scalar.String{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6164, - EndPos: 6169, - }, - Value: "\"foo\"", - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 336, - EndLine: 336, - StartPos: 6169, - EndPos: 6171, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6175, - EndPos: 6187, - }, - Expr: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6175, - EndPos: 6186, - }, - Function: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6175, - EndPos: 6184, - }, - Variable: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6175, - EndPos: 6178, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6176, - EndPos: 6177, - }, - Val: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6176, - EndPos: 6177, - }, - Value: "1", - }, - }, - }, - }, - Dim: &expr.Variable{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6179, - EndPos: 6183, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6179, - EndPos: 6183, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 337, - EndLine: 337, - StartPos: 6184, - EndPos: 6186, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6190, - EndPos: 6199, - }, - Expr: &expr.Variable{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6190, - EndPos: 6198, - }, - VarName: &expr.FunctionCall{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6192, - EndPos: 6197, - }, - Function: &name.Name{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6192, - EndPos: 6195, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6192, - EndPos: 6195, - }, - Value: "foo", - }, - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 338, - EndLine: 338, - StartPos: 6195, - EndPos: 6197, - }, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6203, - EndPos: 6215, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6203, - EndPos: 6214, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6203, - EndPos: 6206, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6203, - EndPos: 6206, - }, - Value: "Foo", - }, - }, - }, - Call: &expr.Variable{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6208, - EndPos: 6212, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6208, - EndPos: 6212, - }, - Value: "bar", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 340, - EndLine: 340, - StartPos: 6212, - EndPos: 6214, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6218, - EndPos: 6235, - }, - Expr: &expr.StaticCall{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6218, - EndPos: 6234, - }, - Class: &name.Name{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6218, - EndPos: 6221, - }, - Parts: []node.Node{ - &name.NamePart{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6218, - EndPos: 6221, - }, - Value: "Foo", - }, - }, - }, - Call: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6224, - EndPos: 6231, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6224, - EndPos: 6228, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6224, - EndPos: 6228, - }, - Value: "bar", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6229, - EndPos: 6230, - }, - Value: "0", - }, - }, - ArgumentList: &node.ArgumentList{ - Position: &position.Position{ - StartLine: 341, - EndLine: 341, - StartPos: 6232, - EndPos: 6234, - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6241, - EndPos: 6252, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6241, - EndPos: 6251, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6241, - EndPos: 6245, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6241, - EndPos: 6245, - }, - Value: "foo", - }, - }, - Property: &expr.Variable{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6247, - EndPos: 6251, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 343, - EndLine: 343, - StartPos: 6247, - EndPos: 6251, - }, - Value: "bar", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6255, - EndPos: 6271, - }, - Expr: &expr.PropertyFetch{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6255, - EndPos: 6269, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6255, - EndPos: 6259, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6255, - EndPos: 6259, - }, - Value: "foo", - }, - }, - Property: &expr.ArrayDimFetch{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6262, - EndPos: 6269, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6262, - EndPos: 6266, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6262, - EndPos: 6266, - }, - Value: "bar", - }, - }, - Dim: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 344, - EndLine: 344, - StartPos: 6267, - EndPos: 6268, - }, - Value: "0", - }, - }, - }, - }, - &stmt.Expression{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6275, - EndPos: 6297, - }, - Expr: &expr.ShortArray{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6275, - EndPos: 6296, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6276, - EndPos: 6282, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6276, - EndPos: 6277, - }, - Value: "1", - }, - Val: &expr.Reference{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6279, - EndPos: 6282, - }, - Variable: &expr.Variable{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6280, - EndPos: 6282, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6280, - EndPos: 6282, - }, - Value: "a", - }, - }, - }, - }, - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6284, - EndPos: 6295, - }, - Key: &scalar.Lnumber{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6284, - EndPos: 6285, - }, - Value: "2", - }, - Val: &expr.List{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6287, - EndPos: 6295, - }, - Items: []node.Node{ - &expr.ArrayItem{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6292, - EndPos: 6294, - }, - Val: &expr.Variable{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6292, - EndPos: 6294, - }, - VarName: &node.Identifier{ - Position: &position.Position{ - StartLine: 346, - EndLine: 346, - StartPos: 6292, - EndPos: 6294, - }, - Value: "b", - }, - }, - }, - }, - }, - }, - }, - }, - }, - &stmt.HaltCompiler{ - Position: &position.Position{ - StartLine: 348, - EndLine: 348, - StartPos: 6301, - EndPos: 6319, - }, - }, - }, - } - - php7parser := php7.NewParser([]byte(src), "7.4") - php7parser.Parse() - actual := php7parser.GetRootNode() - assert.DeepEqual(t, expected, actual) -} - -func TestPhp5Strings(t *testing.T) { - src := `= TokenID(len(_TokenID_index)-1) { - return "TokenID(" + strconv.FormatInt(int64(i+57346), 10) + ")" + if i < 0 || i >= ID(len(_ID_index)-1) { + return "ID(" + strconv.FormatInt(int64(i+57346), 10) + ")" } - return _TokenID_name[_TokenID_index[i]:_TokenID_index[i+1]] + return _ID_name[_ID_index[i]:_ID_index[i+1]] } diff --git a/pkg/version/version.go b/pkg/version/version.go new file mode 100644 index 0000000..632baeb --- /dev/null +++ b/pkg/version/version.go @@ -0,0 +1,102 @@ +package version + +import ( + "errors" + "strconv" + "strings" +) + +type Version struct { + Major, Minor uint64 +} + +var ( + // ErrInvalidSemVer is returned if a version can not be parsed + ErrInvalidSemVer = errors.New("invalid semantic version") + + // ErrUnsupportedVer is returned if a version out of supported range + ErrUnsupportedVer = errors.New("the version is out of supported range") + + php5RangeStart = &Version{Major: 5} + php5RangeEnd = &Version{Major: 5, Minor: 6} + + php7RangeStart = &Version{Major: 7} + php7RangeEnd = &Version{Major: 7, Minor: 4} +) + +func New(v string) (*Version, error) { + // Split the parts into [0]Major, [1]Minor + parts := strings.SplitN(v, ".", 2) + if len(parts) != 2 { + return nil, ErrInvalidSemVer + } + + var ver = new(Version) + var err error + + ver.Major, err = strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return nil, err + } + + ver.Minor, err = strconv.ParseUint(parts[1], 10, 64) + if err != nil { + return nil, err + } + + return ver, nil +} + +func (v *Version) Validate() error { + if !v.InRange(php5RangeStart, php5RangeEnd) && !v.InRange(php7RangeStart, php7RangeEnd) { + return ErrUnsupportedVer + } + + return nil +} + +// Less tests if one version is less than another one +func (v *Version) Less(o *Version) bool { + return v.Compare(o) < 0 +} + +// LessOrEqual tests if one version is less than another one or equal +func (v *Version) LessOrEqual(o *Version) bool { + return v.Compare(o) <= 0 +} + +// Greater tests if one version is greater than another one +func (v *Version) Greater(o *Version) bool { + return v.Compare(o) > 0 +} + +// GreaterOrEqual tests if one version is greater than another one or equal +func (v *Version) GreaterOrEqual(o *Version) bool { + return v.Compare(o) >= 0 +} + +// GreaterOrEqual tests if one version is greater than another one or equal +func (v *Version) InRange(s, e *Version) bool { + return v.Compare(s) >= 0 && v.Compare(e) <= 0 +} + +// Compare compares this version to another one. It returns -1, 0, or 1 if +// the version smaller, equal, or larger than the other version. +func (v *Version) Compare(o *Version) int { + if d := compareSegment(v.Major, o.Major); d != 0 { + return d + } + + return compareSegment(v.Minor, o.Minor) +} + +func compareSegment(v, o uint64) int { + if v < o { + return -1 + } + if v > o { + return 1 + } + + return 0 +} diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go new file mode 100644 index 0000000..a2bde8b --- /dev/null +++ b/pkg/version/version_test.go @@ -0,0 +1,48 @@ +package version_test + +import ( + "gotest.tools/assert" + "testing" + + "github.com/z7zmey/php-parser/pkg/version" +) + +func Test(t *testing.T) { + ver, err := version.New("7.4") + assert.NilError(t, err) + + assert.Equal(t, *ver, version.Version{ + Major: 7, + Minor: 4, + }) +} + +func TestLeadingZero(t *testing.T) { + ver, err := version.New("07.04") + assert.NilError(t, err) + + assert.Equal(t, *ver, version.Version{ + Major: 7, + Minor: 4, + }) +} + +func TestInRange(t *testing.T) { + s, err := version.New("7.0") + assert.NilError(t, err) + + e, err := version.New("7.4") + assert.NilError(t, err) + + ver, err := version.New("7.0") + assert.NilError(t, err) + assert.Assert(t, ver.InRange(s, e)) + + ver, err = version.New("7.2") + assert.NilError(t, err) + assert.Assert(t, ver.InRange(s, e)) + + ver, err = version.New("7.4") + assert.NilError(t, err) + assert.Assert(t, ver.InRange(s, e)) +} diff --git a/pkg/visitor/dumper/dumper.go b/pkg/visitor/dumper/dumper.go new file mode 100644 index 0000000..e38ebeb --- /dev/null +++ b/pkg/visitor/dumper/dumper.go @@ -0,0 +1,2345 @@ +package dumper + +import ( + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "io" + "strconv" + "strings" + + "github.com/z7zmey/php-parser/pkg/ast" +) + +type Dumper struct { + writer io.Writer + indent int + withTokens bool + withPositions bool +} + +func NewDumper(writer io.Writer) *Dumper { + return &Dumper{writer: writer} +} + +func (v *Dumper) WithTokens() *Dumper { + v.withTokens = true + return v +} + +func (v *Dumper) WithPositions() *Dumper { + v.withPositions = true + return v +} + +func (v *Dumper) Dump(n ast.Vertex) { + n.Accept(v) +} + +func (v *Dumper) print(indent int, str string) { + _, err := io.WriteString(v.writer, strings.Repeat("\t", indent)) + if err != nil { + panic(err) + } + + _, err = io.WriteString(v.writer, str) + if err != nil { + panic(err) + } +} + +func (v *Dumper) dumpVertex(key string, node ast.Vertex) { + if node == nil { + return + } + + v.print(v.indent, key+": ") + node.Accept(v) +} + +func (v *Dumper) dumpVertexList(key string, list []ast.Vertex) { + if list == nil { + return + } + + if len(list) == 0 { + v.print(v.indent, key+": []ast.Vertex{},\n") + return + } + + v.print(v.indent, key+": []ast.Vertex{\n") + v.indent++ + + for _, nn := range list { + v.print(v.indent, "") + nn.Accept(v) + } + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) dumpToken(key string, tok *token.Token) { + if !v.withTokens { + return + } + + if tok == nil { + return + } + + if key == "" { + v.print(v.indent, "{\n") + } else { + v.print(v.indent, key+": &token.Token{\n") + } + + v.indent++ + + if tok.ID > 0 { + v.print(v.indent, "ID: token."+tok.ID.String()+",\n") + } + if tok.Value != nil { + v.print(v.indent, "Val: []byte("+strconv.Quote(string(tok.Value))+"),\n") + } + v.dumpPosition(tok.Position) + v.dumpTokenList("FreeFloating", tok.FreeFloating) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) dumpTokenList(key string, list []*token.Token) { + if !v.withTokens { + return + } + + if list == nil { + return + } + + if len(list) == 0 { + v.print(v.indent, key+": []*token.Token{},\n") + return + } + + v.print(v.indent, key+": []*token.Token{\n") + v.indent++ + + for _, tok := range list { + v.dumpToken("", tok) + } + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) dumpPosition(pos *position.Position) { + if !v.withPositions { + return + } + + if pos == nil { + return + } + + v.print(v.indent, "Position: &position.Position{\n") + v.indent++ + + v.print(v.indent, "StartLine: "+strconv.Itoa(pos.StartLine)+",\n") + v.print(v.indent, "EndLine: "+strconv.Itoa(pos.EndLine)+",\n") + v.print(v.indent, "StartPos: "+strconv.Itoa(pos.StartPos)+",\n") + v.print(v.indent, "EndPos: "+strconv.Itoa(pos.EndPos)+",\n") + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) dumpValue(key string, val []byte) { + if val == nil { + return + } + + v.print(v.indent, key+": []byte("+strconv.Quote(string(val))+"),\n") + +} + +func (v *Dumper) Root(n *ast.Root) { + v.print(0, "&ast.Root{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("EndTkn", n.EndTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) Nullable(n *ast.Nullable) { + v.print(0, "&ast.Nullable{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("QuestionTkn", n.QuestionTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) Parameter(n *ast.Parameter) { + v.print(0, "&ast.Parameter{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Type", n.Type) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpToken("VariadicTkn", n.VariadicTkn) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("DefaultValue", n.DefaultValue) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) Identifier(n *ast.Identifier) { + v.print(0, "&ast.Identifier{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IdentifierTkn", n.IdentifierTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) Argument(n *ast.Argument) { + v.print(0, "&ast.Argument{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpToken("VariadicTkn", n.VariadicTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtBreak(n *ast.StmtBreak) { + v.print(0, "&ast.StmtBreak{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("BreakTkn", n.BreakTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtCase(n *ast.StmtCase) { + v.print(0, "&ast.StmtCase{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CaseTkn", n.CaseTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CaseSeparatorTkn", n.CaseSeparatorTkn) + v.dumpVertexList("Stmts", n.Stmts) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtCatch(n *ast.StmtCatch) { + v.print(0, "&ast.StmtCatch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CatchTkn", n.CatchTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Types", n.Types) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpVertex("Var", n.Var) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtClass(n *ast.StmtClass) { + v.print(0, "&ast.StmtClass{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Modifiers", n.Modifiers) + v.dumpToken("ClassTkn", n.ClassTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Args", n.Args) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ExtendsTkn", n.ExtendsTkn) + v.dumpVertex("Extends", n.Extends) + v.dumpToken("ImplementsTkn", n.ImplementsTkn) + v.dumpVertexList("Implements", n.Implements) + v.dumpTokenList("ImplementsSeparatorTkns", n.ImplementsSeparatorTkns) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtClassConstList(n *ast.StmtClassConstList) { + v.print(0, "&ast.StmtClassConstList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Modifiers", n.Modifiers) + v.dumpToken("ConstTkn", n.ConstTkn) + v.dumpVertexList("Consts", n.Consts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtClassMethod(n *ast.StmtClassMethod) { + v.print(0, "&ast.StmtClassMethod{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Modifiers", n.Modifiers) + v.dumpToken("FunctionTkn", n.FunctionTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Params", n.Params) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("ReturnType", n.ReturnType) + v.dumpVertex("Stmt", n.Stmt) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtConstList(n *ast.StmtConstList) { + v.print(0, "&ast.StmtConstList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ConstTkn", n.ConstTkn) + v.dumpVertexList("Consts", n.Consts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtConstant(n *ast.StmtConstant) { + v.print(0, "&ast.StmtConstant{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Name", n.Name) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtContinue(n *ast.StmtContinue) { + v.print(0, "&ast.StmtContinue{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ContinueTkn", n.ContinueTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtDeclare(n *ast.StmtDeclare) { + v.print(0, "&ast.StmtDeclare{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DeclareTkn", n.DeclareTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Consts", n.Consts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpToken("EndDeclareTkn", n.EndDeclareTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtDefault(n *ast.StmtDefault) { + v.print(0, "&ast.StmtDefault{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DefaultTkn", n.DefaultTkn) + v.dumpToken("CaseSeparatorTkn", n.CaseSeparatorTkn) + v.dumpVertexList("Stmts", n.Stmts) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtDo(n *ast.StmtDo) { + v.print(0, "&ast.StmtDo{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DoTkn", n.DoTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpToken("WhileTkn", n.WhileTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") + +} + +func (v *Dumper) StmtEcho(n *ast.StmtEcho) { + v.print(0, "&ast.StmtEcho{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("EchoTkn", n.EchoTkn) + v.dumpVertexList("Exprs", n.Exprs) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtElse(n *ast.StmtElse) { + v.print(0, "&ast.StmtElse{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ElseTkn", n.ElseTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtElseIf(n *ast.StmtElseIf) { + v.print(0, "&ast.StmtElseIf{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ElseIfTkn", n.ElseIfTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtExpression(n *ast.StmtExpression) { + v.print(0, "&ast.StmtExpression{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtFinally(n *ast.StmtFinally) { + v.print(0, "&ast.StmtFinally{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("FinallyTkn", n.FinallyTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtFor(n *ast.StmtFor) { + v.print(0, "&ast.StmtFor{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ForTkn", n.ForTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Init", n.Init) + v.dumpTokenList("InitSeparatorTkns", n.InitSeparatorTkns) + v.dumpToken("InitSemiColonTkn", n.InitSemiColonTkn) + v.dumpVertexList("Cond", n.Cond) + v.dumpTokenList("CondSeparatorTkns", n.CondSeparatorTkns) + v.dumpToken("CondSemiColonTkn", n.CondSemiColonTkn) + v.dumpVertexList("Loop", n.Loop) + v.dumpTokenList("LoopSeparatorTkns", n.LoopSeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpToken("EndForTkn", n.EndForTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtForeach(n *ast.StmtForeach) { + v.print(0, "&ast.StmtForeach{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ForeachTkn", n.ForeachTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("AsTkn", n.AsTkn) + v.dumpVertex("Key", n.Key) + v.dumpToken("DoubleArrowTkn", n.DoubleArrowTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Var", n.Var) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpToken("EndForeachTkn", n.EndForeachTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtFunction(n *ast.StmtFunction) { + v.print(0, "&ast.StmtFunction{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("FunctionTkn", n.FunctionTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Params", n.Params) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("ReturnType", n.ReturnType) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtGlobal(n *ast.StmtGlobal) { + v.print(0, "&ast.StmtGlobal{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("GlobalTkn", n.GlobalTkn) + v.dumpVertexList("Vars", n.Vars) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtGoto(n *ast.StmtGoto) { + v.print(0, "&ast.StmtGoto{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("GotoTkn", n.GotoTkn) + v.dumpVertex("Label", n.Label) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtHaltCompiler(n *ast.StmtHaltCompiler) { + v.print(0, "&ast.StmtHaltCompiler{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("HaltCompilerTkn", n.HaltCompilerTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtIf(n *ast.StmtIf) { + v.print(0, "&ast.StmtIf{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IfTkn", n.IfTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpVertexList("ElseIf", n.ElseIf) + v.dumpVertex("Else", n.Else) + v.dumpToken("EndIfTkn", n.EndIfTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtInlineHtml(n *ast.StmtInlineHtml) { + v.print(0, "&ast.StmtInlineHtml{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("InlineHtmlTkn", n.InlineHtmlTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtInterface(n *ast.StmtInterface) { + v.print(0, "&ast.StmtInterface{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("InterfaceTkn", n.InterfaceTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("ExtendsTkn", n.ExtendsTkn) + v.dumpVertexList("Extends", n.Extends) + v.dumpTokenList("ExtendsSeparatorTkns", n.ExtendsSeparatorTkns) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtLabel(n *ast.StmtLabel) { + v.print(0, "&ast.StmtLabel{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Name", n.Name) + v.dumpToken("ColonTkn", n.ColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtNamespace(n *ast.StmtNamespace) { + v.print(0, "&ast.StmtNamespace{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NsTkn", n.NsTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtNop(n *ast.StmtNop) { + v.print(0, "&ast.StmtNop{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtProperty(n *ast.StmtProperty) { + v.print(0, "&ast.StmtProperty{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtPropertyList(n *ast.StmtPropertyList) { + v.print(0, "&ast.StmtPropertyList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Modifiers", n.Modifiers) + v.dumpVertex("Type", n.Type) + v.dumpVertexList("Props", n.Props) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtReturn(n *ast.StmtReturn) { + v.print(0, "&ast.StmtReturn{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ReturnTkn", n.ReturnTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtStatic(n *ast.StmtStatic) { + v.print(0, "&ast.StmtStatic{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("StaticTkn", n.StaticTkn) + v.dumpVertexList("Vars", n.Vars) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtStaticVar(n *ast.StmtStaticVar) { + v.print(0, "&ast.StmtStaticVar{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtStmtList(n *ast.StmtStmtList) { + v.print(0, "&ast.StmtStmtList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtSwitch(n *ast.StmtSwitch) { + v.print(0, "&ast.StmtSwitch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("SwitchTkn", n.SwitchTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpToken("CaseSeparatorTkn", n.CaseSeparatorTkn) + v.dumpVertexList("Cases", n.Cases) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("EndSwitchTkn", n.EndSwitchTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtThrow(n *ast.StmtThrow) { + v.print(0, "&ast.StmtThrow{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ThrowTkn", n.ThrowTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtTrait(n *ast.StmtTrait) { + v.print(0, "&ast.StmtTrait{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("TraitTkn", n.TraitTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtTraitUse(n *ast.StmtTraitUse) { + v.print(0, "&ast.StmtTraitUse{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("UseTkn", n.UseTkn) + v.dumpVertexList("Traits", n.Traits) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Adaptations", n.Adaptations) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) { + v.print(0, "&ast.StmtTraitUseAlias{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Trait", n.Trait) + v.dumpToken("DoubleColonTkn", n.DoubleColonTkn) + v.dumpVertex("Method", n.Method) + v.dumpToken("AsTkn", n.AsTkn) + v.dumpVertex("Modifier", n.Modifier) + v.dumpVertex("Alias", n.Alias) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) { + v.print(0, "&ast.StmtTraitUsePrecedence{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Trait", n.Trait) + v.dumpToken("DoubleColonTkn", n.DoubleColonTkn) + v.dumpVertex("Method", n.Method) + v.dumpToken("InsteadofTkn", n.InsteadofTkn) + v.dumpVertexList("Insteadof", n.Insteadof) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtTry(n *ast.StmtTry) { + v.print(0, "&ast.StmtTry{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("TryTkn", n.TryTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpVertexList("Catches", n.Catches) + v.dumpVertex("Finally", n.Finally) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtUnset(n *ast.StmtUnset) { + v.print(0, "&ast.StmtUnset{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("UnsetTkn", n.UnsetTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Vars", n.Vars) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtUse(n *ast.StmtUseList) { + v.print(0, "&ast.StmtUseList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("UseTkn", n.UseTkn) + v.dumpVertex("Type", n.Type) + v.dumpVertexList("Uses", n.Uses) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtGroupUse(n *ast.StmtGroupUseList) { + v.print(0, "&ast.StmtGroupUseList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("UseTkn", n.UseTkn) + v.dumpVertex("Type", n.Type) + v.dumpToken("LeadingNsSeparatorTkn", n.LeadingNsSeparatorTkn) + v.dumpVertex("Prefix", n.Prefix) + v.dumpToken("NsSeparatorTkn", n.NsSeparatorTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Uses", n.Uses) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtUseDeclaration(n *ast.StmtUse) { + v.print(0, "&ast.StmtUse{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Type", n.Type) + v.dumpToken("NsSeparatorTkn", n.NsSeparatorTkn) + v.dumpVertex("Uses", n.Use) + v.dumpToken("AsTkn", n.AsTkn) + v.dumpVertex("Alias", n.Alias) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) StmtWhile(n *ast.StmtWhile) { + v.print(0, "&ast.StmtWhile{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("WhileTkn", n.WhileTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("Stmt", n.Stmt) + v.dumpToken("EndWhileTkn", n.EndWhileTkn) + v.dumpToken("SemiColonTkn", n.SemiColonTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprArray(n *ast.ExprArray) { + v.print(0, "&ast.ExprArray{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ArrayTkn", n.ArrayTkn) + v.dumpToken("OpenBracketTkn", n.OpenBracketTkn) + v.dumpVertexList("Items", n.Items) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseBracketTkn", n.CloseBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprArrayDimFetch(n *ast.ExprArrayDimFetch) { + v.print(0, "&ast.ExprArrayDimFetch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("OpenBracketTkn", n.OpenBracketTkn) + v.dumpVertex("Dim", n.Dim) + v.dumpToken("CloseBracketTkn", n.CloseBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprArrayItem(n *ast.ExprArrayItem) { + v.print(0, "&ast.ExprArrayItem{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("EllipsisTkn", n.EllipsisTkn) + v.dumpVertex("Key", n.Key) + v.dumpToken("DoubleArrowTkn", n.DoubleArrowTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Val", n.Val) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprArrowFunction(n *ast.ExprArrowFunction) { + v.print(0, "&ast.ExprArrowFunction{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("StaticTkn", n.StaticTkn) + v.dumpToken("FnTkn", n.FnTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Params", n.Params) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("ReturnType", n.ReturnType) + v.dumpToken("DoubleArrowTkn", n.DoubleArrowTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBitwiseNot(n *ast.ExprBitwiseNot) { + v.print(0, "&ast.ExprBitwiseNot{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("TildaTkn", n.TildaTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBooleanNot(n *ast.ExprBooleanNot) { + v.print(0, "&ast.ExprBooleanNot{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ExclamationTkn", n.ExclamationTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBrackets(n *ast.ExprBrackets) { + v.print(0, "&ast.ExprBrackets{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprClassConstFetch(n *ast.ExprClassConstFetch) { + v.print(0, "&ast.ExprClassConstFetch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Class", n.Class) + v.dumpToken("DoubleColonTkn", n.DoubleColonTkn) + v.dumpVertex("Const", n.Const) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprClone(n *ast.ExprClone) { + v.print(0, "&ast.ExprClone{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CloneTkn", n.CloneTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprClosure(n *ast.ExprClosure) { + v.print(0, "&ast.ExprClosure{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("StaticTkn", n.StaticTkn) + v.dumpToken("FunctionTkn", n.FunctionTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Params", n.Params) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + v.dumpToken("UseTkn", n.UseTkn) + v.dumpToken("UseOpenParenthesisTkn", n.UseOpenParenthesisTkn) + v.dumpVertexList("Uses", n.Uses) + v.dumpTokenList("UseSeparatorTkns", n.UseSeparatorTkns) + v.dumpToken("UseCloseParenthesisTkn", n.UseCloseParenthesisTkn) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("ReturnType", n.ReturnType) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertexList("Stmts", n.Stmts) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprClosureUse(n *ast.ExprClosureUse) { + v.print(0, "&ast.ExprClosureUse{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Var", n.Var) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprConstFetch(n *ast.ExprConstFetch) { + v.print(0, "&ast.ExprConstFetch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Const", n.Const) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprEmpty(n *ast.ExprEmpty) { + v.print(0, "&ast.ExprEmpty{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("EmptyTkn", n.EmptyTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprErrorSuppress(n *ast.ExprErrorSuppress) { + v.print(0, "&ast.ExprErrorSuppress{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("AtTkn", n.AtTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprEval(n *ast.ExprEval) { + v.print(0, "&ast.ExprEval{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("EvalTkn", n.EvalTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprExit(n *ast.ExprExit) { + v.print(0, "&ast.ExprExit{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ExitTkn", n.ExitTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprFunctionCall(n *ast.ExprFunctionCall) { + v.print(0, "&ast.ExprFunctionCall{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Function", n.Function) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Args", n.Args) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprInclude(n *ast.ExprInclude) { + v.print(0, "&ast.ExprInclude{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IncludeOnceTkn", n.IncludeTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprIncludeOnce(n *ast.ExprIncludeOnce) { + v.print(0, "&ast.ExprIncludeOnce{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IncludeOnceTkn", n.IncludeOnceTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprInstanceOf(n *ast.ExprInstanceOf) { + v.print(0, "&ast.ExprInstanceOf{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Expr", n.Expr) + v.dumpToken("InstanceOfTkn", n.InstanceOfTkn) + v.dumpVertex("Class", n.Class) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprIsset(n *ast.ExprIsset) { + v.print(0, "&ast.ExprIsset{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IssetTkn", n.IssetTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Vars", n.Vars) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprList(n *ast.ExprList) { + v.print(0, "&ast.ExprList{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("ListTkn", n.ListTkn) + v.dumpToken("OpenBracketTkn", n.OpenBracketTkn) + v.dumpVertexList("Items", n.Items) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseBracketTkn", n.CloseBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprMethodCall(n *ast.ExprMethodCall) { + v.print(0, "&ast.ExprMethodCall{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("ObjectOperatorTkn", n.ObjectOperatorTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertex("Method", n.Method) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Args", n.Args) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprNew(n *ast.ExprNew) { + v.print(0, "&ast.ExprNew{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NewTkn", n.NewTkn) + v.dumpVertex("Class", n.Class) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Args", n.Args) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPostDec(n *ast.ExprPostDec) { + v.print(0, "&ast.ExprPostDec{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("DecTkn", n.DecTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPostInc(n *ast.ExprPostInc) { + v.print(0, "&ast.ExprPostInc{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("IncTkn", n.IncTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPreDec(n *ast.ExprPreDec) { + v.print(0, "&ast.ExprPreDec{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DecTkn", n.DecTkn) + v.dumpVertex("Var", n.Var) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPreInc(n *ast.ExprPreInc) { + v.print(0, "&ast.ExprPreInc{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("IncTkn", n.IncTkn) + v.dumpVertex("Var", n.Var) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPrint(n *ast.ExprPrint) { + v.print(0, "&ast.ExprPrint{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("PrintTkn", n.PrintTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprPropertyFetch(n *ast.ExprPropertyFetch) { + v.print(0, "&ast.ExprPropertyFetch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("ObjectOperatorTkn", n.ObjectOperatorTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertex("Prop", n.Prop) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprRequire(n *ast.ExprRequire) { + v.print(0, "&ast.ExprRequire{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("RequireTkn", n.RequireTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprRequireOnce(n *ast.ExprRequireOnce) { + v.print(0, "&ast.ExprRequireOnce{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("RequireOnceTkn", n.RequireOnceTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprShellExec(n *ast.ExprShellExec) { + v.print(0, "&ast.ExprShellExec{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenBacktickTkn", n.OpenBacktickTkn) + v.dumpVertexList("Parts", n.Parts) + v.dumpToken("CloseBacktickTkn", n.CloseBacktickTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprStaticCall(n *ast.ExprStaticCall) { + v.print(0, "&ast.ExprStaticCall{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Class", n.Class) + v.dumpToken("DoubleColonTkn", n.DoubleColonTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertex("Call", n.Call) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) + v.dumpVertexList("Args", n.Args) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprStaticPropertyFetch(n *ast.ExprStaticPropertyFetch) { + v.print(0, "&ast.ExprStaticPropertyFetch{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Class", n.Class) + v.dumpToken("DoubleColonTkn", n.DoubleColonTkn) + v.dumpVertex("Prop", n.Prop) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprTernary(n *ast.ExprTernary) { + v.print(0, "&ast.ExprTernary{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Cond", n.Cond) + v.dumpToken("QuestionTkn", n.QuestionTkn) + v.dumpVertex("IfTrue", n.IfTrue) + v.dumpToken("ColonTkn", n.ColonTkn) + v.dumpVertex("IfFalse", n.IfFalse) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprUnaryMinus(n *ast.ExprUnaryMinus) { + v.print(0, "&ast.ExprUnaryMinus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("MinusTkn", n.MinusTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprUnaryPlus(n *ast.ExprUnaryPlus) { + v.print(0, "&ast.ExprUnaryPlus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("PlusTkn", n.PlusTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprVariable(n *ast.ExprVariable) { + v.print(0, "&ast.ExprVariable{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DollarTkn", n.DollarTkn) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprYield(n *ast.ExprYield) { + v.print(0, "&ast.ExprYield{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("YieldTkn", n.YieldTkn) + v.dumpVertex("Key", n.Key) + v.dumpToken("DoubleArrowTkn", n.DoubleArrowTkn) + v.dumpVertex("Val", n.Val) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprYieldFrom(n *ast.ExprYieldFrom) { + v.print(0, "&ast.ExprYieldFrom{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("YieldFromTkn", n.YieldFromTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssign(n *ast.ExprAssign) { + v.print(0, "&ast.ExprAssign{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignReference(n *ast.ExprAssignReference) { + v.print(0, "&ast.ExprAssignReference{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpToken("AmpersandTkn", n.AmpersandTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignBitwiseAnd(n *ast.ExprAssignBitwiseAnd) { + v.print(0, "&ast.ExprAssignBitwiseAnd{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignBitwiseOr(n *ast.ExprAssignBitwiseOr) { + v.print(0, "&ast.ExprAssignBitwiseOr{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignBitwiseXor(n *ast.ExprAssignBitwiseXor) { + v.print(0, "&ast.ExprAssignBitwiseXor{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignCoalesce(n *ast.ExprAssignCoalesce) { + v.print(0, "&ast.ExprAssignCoalesce{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignConcat(n *ast.ExprAssignConcat) { + v.print(0, "&ast.ExprAssignConcat{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignDiv(n *ast.ExprAssignDiv) { + v.print(0, "&ast.ExprAssignDiv{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignMinus(n *ast.ExprAssignMinus) { + v.print(0, "&ast.ExprAssignMinus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignMod(n *ast.ExprAssignMod) { + v.print(0, "&ast.ExprAssignMod{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignMul(n *ast.ExprAssignMul) { + v.print(0, "&ast.ExprAssignMul{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignPlus(n *ast.ExprAssignPlus) { + v.print(0, "&ast.ExprAssignPlus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignPow(n *ast.ExprAssignPow) { + v.print(0, "&ast.ExprAssignPow{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignShiftLeft(n *ast.ExprAssignShiftLeft) { + v.print(0, "&ast.ExprAssignShiftLeft{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprAssignShiftRight(n *ast.ExprAssignShiftRight) { + v.print(0, "&ast.ExprAssignShiftRight{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Var", n.Var) + v.dumpToken("EqualTkn", n.EqualTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryBitwiseAnd(n *ast.ExprBinaryBitwiseAnd) { + v.print(0, "&ast.ExprBinaryBitwiseAnd{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryBitwiseOr(n *ast.ExprBinaryBitwiseOr) { + v.print(0, "&ast.ExprBinaryBitwiseOr{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryBitwiseXor(n *ast.ExprBinaryBitwiseXor) { + v.print(0, "&ast.ExprBinaryBitwiseXor{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryBooleanAnd(n *ast.ExprBinaryBooleanAnd) { + v.print(0, "&ast.ExprBinaryBooleanAnd{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryBooleanOr(n *ast.ExprBinaryBooleanOr) { + v.print(0, "&ast.ExprBinaryBooleanOr{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryCoalesce(n *ast.ExprBinaryCoalesce) { + v.print(0, "&ast.ExprBinaryCoalesce{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryConcat(n *ast.ExprBinaryConcat) { + v.print(0, "&ast.ExprBinaryConcat{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryDiv(n *ast.ExprBinaryDiv) { + v.print(0, "&ast.ExprBinaryDiv{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryEqual(n *ast.ExprBinaryEqual) { + v.print(0, "&ast.ExprBinaryEqual{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryGreater(n *ast.ExprBinaryGreater) { + v.print(0, "&ast.ExprBinaryGreater{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryGreaterOrEqual(n *ast.ExprBinaryGreaterOrEqual) { + v.print(0, "&ast.ExprBinaryGreaterOrEqual{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryIdentical(n *ast.ExprBinaryIdentical) { + v.print(0, "&ast.ExprBinaryIdentical{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryLogicalAnd(n *ast.ExprBinaryLogicalAnd) { + v.print(0, "&ast.ExprBinaryLogicalAnd{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryLogicalOr(n *ast.ExprBinaryLogicalOr) { + v.print(0, "&ast.ExprBinaryLogicalOr{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryLogicalXor(n *ast.ExprBinaryLogicalXor) { + v.print(0, "&ast.ExprBinaryLogicalXor{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryMinus(n *ast.ExprBinaryMinus) { + v.print(0, "&ast.ExprBinaryMinus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryMod(n *ast.ExprBinaryMod) { + v.print(0, "&ast.ExprBinaryMod{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryMul(n *ast.ExprBinaryMul) { + v.print(0, "&ast.ExprBinaryMul{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryNotEqual(n *ast.ExprBinaryNotEqual) { + v.print(0, "&ast.ExprBinaryNotEqual{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryNotIdentical(n *ast.ExprBinaryNotIdentical) { + v.print(0, "&ast.ExprBinaryNotIdentical{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryPlus(n *ast.ExprBinaryPlus) { + v.print(0, "&ast.ExprBinaryPlus{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryPow(n *ast.ExprBinaryPow) { + v.print(0, "&ast.ExprBinaryPow{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryShiftLeft(n *ast.ExprBinaryShiftLeft) { + v.print(0, "&ast.ExprBinaryShiftLeft{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinaryShiftRight(n *ast.ExprBinaryShiftRight) { + v.print(0, "&ast.ExprBinaryShiftRight{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinarySmaller(n *ast.ExprBinarySmaller) { + v.print(0, "&ast.ExprBinarySmaller{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinarySmallerOrEqual(n *ast.ExprBinarySmallerOrEqual) { + v.print(0, "&ast.ExprBinarySmallerOrEqual{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprBinarySpaceship(n *ast.ExprBinarySpaceship) { + v.print(0, "&ast.ExprBinarySpaceship{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertex("Left", n.Left) + v.dumpToken("OpTkn", n.OpTkn) + v.dumpVertex("Right", n.Right) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastArray(n *ast.ExprCastArray) { + v.print(0, "&ast.ExprCastArray{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastBool(n *ast.ExprCastBool) { + v.print(0, "&ast.ExprCastBool{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastDouble(n *ast.ExprCastDouble) { + v.print(0, "&ast.ExprCastDouble{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastInt(n *ast.ExprCastInt) { + v.print(0, "&ast.ExprCastInt{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastObject(n *ast.ExprCastObject) { + v.print(0, "&ast.ExprCastObject{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastString(n *ast.ExprCastString) { + v.print(0, "&ast.ExprCastString{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ExprCastUnset(n *ast.ExprCastUnset) { + v.print(0, "&ast.ExprCastUnset{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("CastTkn", n.CastTkn) + v.dumpVertex("Expr", n.Expr) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarDnumber(n *ast.ScalarDnumber) { + v.print(0, "&ast.ScalarDnumber{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NumberTkn", n.NumberTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarEncapsed(n *ast.ScalarEncapsed) { + v.print(0, "&ast.ScalarEncapsed{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenQuoteTkn", n.OpenQuoteTkn) + v.dumpVertexList("Parts", n.Parts) + v.dumpToken("CloseQuoteTkn", n.CloseQuoteTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarEncapsedStringPart(n *ast.ScalarEncapsedStringPart) { + v.print(0, "&ast.ScalarEncapsedStringPart{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("EncapsedStrTkn", n.EncapsedStrTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarEncapsedStringVar(n *ast.ScalarEncapsedStringVar) { + v.print(0, "&ast.ScalarEncapsedStringVar{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("DollarOpenCurlyBracketTkn", n.DollarOpenCurlyBracketTkn) + v.dumpVertex("Name", n.Name) + v.dumpToken("OpenSquareBracketTkn", n.OpenSquareBracketTkn) + v.dumpVertex("Dim", n.Dim) + v.dumpToken("CloseSquareBracketTkn", n.CloseSquareBracketTkn) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarEncapsedStringBrackets(n *ast.ScalarEncapsedStringBrackets) { + v.print(0, "&ast.ScalarEncapsedStringBrackets{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn) + v.dumpVertex("Var", n.Var) + v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarHeredoc(n *ast.ScalarHeredoc) { + v.print(0, "&ast.ScalarHeredoc{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("OpenHeredocTkn", n.OpenHeredocTkn) + v.dumpVertexList("Parts", n.Parts) + v.dumpToken("CloseHeredocTkn", n.CloseHeredocTkn) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarLnumber(n *ast.ScalarLnumber) { + v.print(0, "&ast.ScalarLnumber{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NumberTkn", n.NumberTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarMagicConstant(n *ast.ScalarMagicConstant) { + v.print(0, "&ast.ScalarMagicConstant{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("MagicConstTkn", n.MagicConstTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) ScalarString(n *ast.ScalarString) { + v.print(0, "&ast.ScalarString{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("MinusTkn", n.MinusTkn) + v.dumpToken("StringTkn", n.StringTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) NameName(n *ast.Name) { + v.print(0, "&ast.Name{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpVertexList("Parts", n.Parts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) NameFullyQualified(n *ast.NameFullyQualified) { + v.print(0, "&ast.NameFullyQualified{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NsSeparatorTkn", n.NsSeparatorTkn) + v.dumpVertexList("Parts", n.Parts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) NameRelative(n *ast.NameRelative) { + v.print(0, "&ast.NameRelative{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("NsTkn", n.NsTkn) + v.dumpToken("NsSeparatorTkn", n.NsSeparatorTkn) + v.dumpVertexList("Parts", n.Parts) + v.dumpTokenList("SeparatorTkns", n.SeparatorTkns) + + v.indent-- + v.print(v.indent, "},\n") +} + +func (v *Dumper) NameNamePart(n *ast.NamePart) { + v.print(0, "&ast.NamePart{\n") + v.indent++ + + v.dumpPosition(n.Position) + v.dumpToken("StringTkn", n.StringTkn) + v.dumpValue("Val", n.Value) + + v.indent-- + v.print(v.indent, "},\n") +} diff --git a/pkg/visitor/dumper/dumper_test.go b/pkg/visitor/dumper/dumper_test.go new file mode 100644 index 0000000..2a9ec04 --- /dev/null +++ b/pkg/visitor/dumper/dumper_test.go @@ -0,0 +1,76 @@ +package dumper_test + +import ( + "bytes" + "github.com/z7zmey/php-parser/pkg/position" + "github.com/z7zmey/php-parser/pkg/token" + "github.com/z7zmey/php-parser/pkg/visitor/dumper" + "testing" + + "github.com/z7zmey/php-parser/pkg/ast" +) + +func TestDumper_root(t *testing.T) { + o := bytes.NewBufferString("") + + p := dumper.NewDumper(o).WithTokens().WithPositions() + n := &ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 3, + EndPos: 4, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + EndTkn: &token.Token{ + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Value: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 3, + EndPos: 4, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `&ast.Root{ + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 3, + EndPos: 4, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{ + }, + }, + EndTkn: &token.Token{ + FreeFloating: []*token.Token{ + { + ID: token.T_WHITESPACE, + Val: []byte(" "), + Position: &position.Position{ + StartLine: 1, + EndLine: 2, + StartPos: 3, + EndPos: 4, + }, + }, + }, + }, +}, +` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} diff --git a/pkg/visitor/formatter/formatter.go b/pkg/visitor/formatter/formatter.go new file mode 100644 index 0000000..4f9ce9c --- /dev/null +++ b/pkg/visitor/formatter/formatter.go @@ -0,0 +1,2040 @@ +package formatter + +import ( + "bytes" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/token" +) + +type formatterState int + +const ( + FormatterStateHTML formatterState = iota + FormatterStatePHP +) + +type formatter struct { + state formatterState + indent int + freeFloating []*token.Token + + lastSemiColon *token.Token +} + +func NewFormatter() *formatter { + return &formatter{} +} + +func (f *formatter) WithState(state formatterState) *formatter { + f.state = state + return f +} + +func (f *formatter) WithIndent(indent int) *formatter { + f.indent = indent + return f +} + +func (f *formatter) addFreeFloating(id token.ID, val []byte) { + f.freeFloating = append(f.freeFloating, &token.Token{ + ID: id, + Value: val, + }) +} + +func (f *formatter) addIndent() { + if f.indent < 1 { + return + } + + f.freeFloating = append(f.freeFloating, &token.Token{ + ID: token.T_WHITESPACE, + Value: bytes.Repeat([]byte(" "), f.indent), + }) +} + +func (f *formatter) resetFreeFloating() { + f.freeFloating = nil +} + +func (f *formatter) getFreeFloating() []*token.Token { + defer f.resetFreeFloating() + + if f.state == FormatterStateHTML { + t := &token.Token{ + ID: token.T_OPEN_TAG, + Value: []byte("') + } else { + *list = insert(*list, i+insertCounter, &ast.StmtNop{ + SemiColonTkn: &token.Token{ + Value: []byte("?>"), + }, + }) + insertCounter++ + } + } else { + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + stmt.Accept(f) + } +} + +func (f *formatter) newSemicolonTkn() *token.Token { + f.lastSemiColon = f.newToken(';', []byte(";")) + return f.lastSemiColon +} + +func insert(s []ast.Vertex, k int, vs ...ast.Vertex) []ast.Vertex { + if n := len(s) + len(vs); n <= cap(s) { + s2 := s[:n] + copy(s2[k+len(vs):], s[k:]) + copy(s2[k:], vs) + return s2 + } + s2 := make([]ast.Vertex, len(s)+len(vs)) + copy(s2, s[:k]) + copy(s2[k:], vs) + copy(s2[k+len(vs):], s[k:]) + return s2 +} + +func (f *formatter) Root(n *ast.Root) { + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + + f.formatStmts(&n.Stmts) +} + +func (f *formatter) Nullable(n *ast.Nullable) { + n.QuestionTkn = f.newToken('?', []byte("?")) + n.Expr.Accept(f) +} + +func (f *formatter) Parameter(n *ast.Parameter) { + if n.Type != nil { + n.Type.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + if n.VariadicTkn != nil { + n.VariadicTkn = f.newToken(token.T_ELLIPSIS, []byte("...")) + } + + n.Var.Accept(f) + + if n.DefaultValue != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.DefaultValue.Accept(f) + } +} + +func (f *formatter) Identifier(n *ast.Identifier) { + if n.IdentifierTkn == nil { + n.IdentifierTkn = f.newToken(token.T_STRING, n.Value) + } else { + n.IdentifierTkn.FreeFloating = f.getFreeFloating() + } +} + +func (f *formatter) Argument(n *ast.Argument) { + if n.VariadicTkn != nil { + n.VariadicTkn = f.newToken(token.T_ELLIPSIS, []byte("...")) + } + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.Expr.Accept(f) +} + +func (f *formatter) StmtBreak(n *ast.StmtBreak) { + n.BreakTkn = f.newToken(token.T_BREAK, []byte("break")) + + if n.Expr != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtCase(n *ast.StmtCase) { + n.CaseTkn = f.newToken(token.T_CASE, []byte("case")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Cond.Accept(f) + + n.CaseSeparatorTkn = f.newToken(':', []byte(":")) + + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- +} + +func (f *formatter) StmtCatch(n *ast.StmtCatch) { + n.CatchTkn = f.newToken(token.T_CATCH, []byte("catch")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.SeparatorTkns = make([]*token.Token, len(n.Types)-1) + for i, t := range n.Types { + t.Accept(f) + + if i != len(n.Types)-1 { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.SeparatorTkns[i] = f.newToken('|', []byte("|")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Var.Accept(f) + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtClass(n *ast.StmtClass) { + for _, m := range n.Modifiers { + m.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.ClassTkn = f.newToken(token.T_CLASS, []byte("class")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Name.Accept(f) + + n.OpenParenthesisTkn = nil + n.CloseParenthesisTkn = nil + if len(n.Args) > 0 { + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.SeparatorTkns = f.formatList(n.Args, ',') + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + if n.Extends != nil { + n.ExtendsTkn = f.newToken(token.T_EXTENDS, []byte("extends")) + n.Extends.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + if n.Implements != nil { + n.ImplementsTkn = f.newToken(token.T_IMPLEMENTS, []byte("implements")) + n.ImplementsSeparatorTkns = f.formatList(n.Implements, ',') + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtClassConstList(n *ast.StmtClassConstList) { + for _, m := range n.Modifiers { + m.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.ConstTkn = f.newToken(token.T_CONST, []byte("const")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = f.formatList(n.Consts, ',') + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtClassMethod(n *ast.StmtClassMethod) { + for _, m := range n.Modifiers { + m.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.FunctionTkn = f.newToken(token.T_FUNCTION, []byte("function")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.Name.Accept(f) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.SeparatorTkns = nil + if len(n.Params) > 0 { + n.SeparatorTkns = f.formatList(n.Params, ',') + } + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + if n.ReturnType != nil { + n.ColonTkn = f.newToken(':', []byte(":")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.ReturnType.Accept(f) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtConstList(n *ast.StmtConstList) { + n.ConstTkn = f.newToken(token.T_CONST, []byte("const")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = f.formatList(n.Consts, ',') + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtConstant(n *ast.StmtConstant) { + n.Name.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) StmtContinue(n *ast.StmtContinue) { + n.ContinueTkn = f.newToken(token.T_CONTINUE, []byte("continue")) + + if n.Expr != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtDeclare(n *ast.StmtDeclare) { + n.ColonTkn = nil + n.EndDeclareTkn = nil + n.SemiColonTkn = nil + + n.DeclareTkn = f.newToken(token.T_DECLARE, []byte("declare")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.SeparatorTkns = nil + if len(n.Consts) > 0 { + n.SeparatorTkns = f.formatList(n.Consts, ',') + } + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtDefault(n *ast.StmtDefault) { + n.DefaultTkn = f.newToken(token.T_DEFAULT, []byte("default")) + + n.CaseSeparatorTkn = f.newToken(':', []byte(":")) + + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- +} + +func (f *formatter) StmtDo(n *ast.StmtDo) { + n.DoTkn = f.newToken(token.T_DO, []byte("do")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.WhileTkn = f.newToken(token.T_WHILE, []byte("while")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Cond.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtEcho(n *ast.StmtEcho) { + n.EchoTkn = f.newToken(token.T_ECHO, []byte("echo")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = nil + if len(n.Exprs) > 0 { + n.SeparatorTkns = f.formatList(n.Exprs, ',') + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtElse(n *ast.StmtElse) { + n.ColonTkn = nil + + n.ElseTkn = f.newToken(token.T_ELSE, []byte("else")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtElseIf(n *ast.StmtElseIf) { + n.ColonTkn = nil + + n.ElseIfTkn = f.newToken(token.T_ELSEIF, []byte("elseif")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Cond.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtExpression(n *ast.StmtExpression) { + n.Expr.Accept(f) + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtFinally(n *ast.StmtFinally) { + n.FinallyTkn = f.newToken(token.T_FINALLY, []byte("finally")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtFor(n *ast.StmtFor) { + n.ColonTkn = nil + n.EndForTkn = nil + n.SemiColonTkn = nil + + n.ForTkn = f.newToken(token.T_FOR, []byte("for")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.InitSeparatorTkns = nil + if len(n.Init) > 0 { + n.InitSeparatorTkns = f.formatList(n.Init, ',') + } + + n.InitSemiColonTkn = f.newSemicolonTkn() + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.CondSeparatorTkns = nil + if len(n.Cond) > 0 { + n.CondSeparatorTkns = f.formatList(n.Cond, ',') + } + + n.CondSemiColonTkn = f.newSemicolonTkn() + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.LoopSeparatorTkns = nil + if len(n.Loop) > 0 { + n.LoopSeparatorTkns = f.formatList(n.Loop, ',') + } + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtForeach(n *ast.StmtForeach) { + n.ColonTkn = nil + n.EndForeachTkn = nil + n.SemiColonTkn = nil + + n.ForeachTkn = f.newToken(token.T_FOREACH, []byte("foreach")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.Expr.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.AsTkn = f.newToken(token.T_AS, []byte("as")) + + if n.Key != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Key.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.DoubleArrowTkn = f.newToken(token.T_DOUBLE_ARROW, []byte("=>")) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + n.Var.Accept(f) + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) StmtFunction(n *ast.StmtFunction) { + n.FunctionTkn = f.newToken(token.T_FUNCTION, []byte("function")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.Name.Accept(f) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + + n.SeparatorTkns = nil + if len(n.Params) > 0 { + n.SeparatorTkns = f.formatList(n.Params, ',') + } + + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + if n.ReturnType != nil { + n.ColonTkn = f.newToken(':', []byte(":")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.ReturnType.Accept(f) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtGlobal(n *ast.StmtGlobal) { + n.GlobalTkn = f.newToken(token.T_GLOBAL, []byte("global")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = nil + if len(n.Vars) > 0 { + n.SeparatorTkns = f.formatList(n.Vars, ',') + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtGoto(n *ast.StmtGoto) { + n.GotoTkn = f.newToken(token.T_GOTO, []byte("goto")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Label.Accept(f) + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtHaltCompiler(n *ast.StmtHaltCompiler) { + n.HaltCompilerTkn = f.newToken(token.T_HALT_COMPILER, []byte("__halt_compiler")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtIf(n *ast.StmtIf) { + n.ColonTkn = nil + n.EndIfTkn = nil + n.SemiColonTkn = nil + + n.IfTkn = f.newToken(token.T_IF, []byte("if")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Cond.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) + + if len(n.ElseIf) > 0 { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + f.formatList(n.ElseIf, ' ') + } + + if n.Else != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Else.Accept(f) + } +} + +func (f *formatter) StmtInlineHtml(n *ast.StmtInlineHtml) { + n.InlineHtmlTkn = f.newToken(token.T_STRING, n.Value) + f.state = FormatterStateHTML +} + +func (f *formatter) StmtInterface(n *ast.StmtInterface) { + n.InterfaceTkn = f.newToken(token.T_INTERFACE, []byte("interface")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Name.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.Extends != nil { + n.ExtendsTkn = f.newToken(token.T_EXTENDS, []byte("extends")) + n.ExtendsSeparatorTkns = f.formatList(n.Extends, ',') + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtLabel(n *ast.StmtLabel) { + n.Name.Accept(f) + n.ColonTkn = f.newToken(':', []byte(":")) +} + +func (f *formatter) StmtNamespace(n *ast.StmtNamespace) { + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + n.SemiColonTkn = nil + + n.NsTkn = f.newToken(token.T_NAMESPACE, []byte("namespace")) + + if n.Name != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Name.Accept(f) + } + + if len(n.Stmts) > 0 { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } else { + n.SemiColonTkn = f.newSemicolonTkn() + } + +} + +func (f *formatter) StmtNop(n *ast.StmtNop) { + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtProperty(n *ast.StmtProperty) { + n.Var.Accept(f) + + if n.Expr != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) + } +} + +func (f *formatter) StmtPropertyList(n *ast.StmtPropertyList) { + for _, m := range n.Modifiers { + m.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + if n.Type != nil { + n.Type.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.SeparatorTkns = f.formatList(n.Props, ',') + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtReturn(n *ast.StmtReturn) { + n.ReturnTkn = f.newToken(token.T_RETURN, []byte("return")) + + if n.Expr != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtStatic(n *ast.StmtStatic) { + n.StaticTkn = f.newToken(token.T_STATIC, []byte("static")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = nil + if len(n.Vars) > 0 { + n.SeparatorTkns = f.formatList(n.Vars, ',') + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtStaticVar(n *ast.StmtStaticVar) { + n.Var.Accept(f) + + if n.Expr != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) + } +} + +func (f *formatter) StmtStmtList(n *ast.StmtStmtList) { + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtSwitch(n *ast.StmtSwitch) { + n.CaseSeparatorTkn = nil + n.ColonTkn = nil + n.EndSwitchTkn = nil + n.SemiColonTkn = nil + + n.SwitchTkn = f.newToken(token.T_SWITCH, []byte("switch")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Cond.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Cases) > 0 { + f.indent++ + f.formatStmts(&n.Cases) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtThrow(n *ast.StmtThrow) { + n.ThrowTkn = f.newToken(token.T_THROW, []byte("throw")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtTrait(n *ast.StmtTrait) { + n.TraitTkn = f.newToken(token.T_TRAIT, []byte("trait")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Name.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) StmtTraitUse(n *ast.StmtTraitUse) { + n.UseTkn = f.newToken(token.T_USE, []byte("use")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = f.formatList(n.Traits, ',') + + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + n.SemiColonTkn = nil + + if len(n.Adaptations) > 0 { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Adaptations) > 0 { + f.indent++ + f.formatStmts(&n.Adaptations) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } else { + n.SemiColonTkn = f.newToken(';', []byte(";")) + } +} + +func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) { + if n.Trait != nil { + n.Trait.Accept(f) + n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::")) + } + + n.Method.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.AsTkn = f.newToken(token.T_AS, []byte("as")) + + if n.Modifier != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Modifier.Accept(f) + } + + if n.Alias != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Alias.Accept(f) + } + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) { + if n.Trait != nil { + n.Trait.Accept(f) + n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::")) + } + + n.Method.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.InsteadofTkn = f.newToken(token.T_INSTEADOF, []byte("insteadof")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.SeparatorTkns = f.formatList(n.Insteadof, ',') + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtTry(n *ast.StmtTry) { + n.TryTkn = f.newToken(token.T_TRY, []byte("try")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + + for _, catch := range n.Catches { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + catch.Accept(f) + } + + if n.Finally != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Finally.Accept(f) + } +} + +func (f *formatter) StmtUnset(n *ast.StmtUnset) { + n.UnsetTkn = f.newToken(token.T_UNSET, []byte("unset")) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Vars, ',') + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtUse(n *ast.StmtUseList) { + n.UseTkn = f.newToken(token.T_USE, []byte("use")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.Type != nil { + n.Type.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.SeparatorTkns = f.formatList(n.Uses, ',') + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtGroupUse(n *ast.StmtGroupUseList) { + n.UseTkn = f.newToken(token.T_USE, []byte("use")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.Type != nil { + n.Type.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.LeadingNsSeparatorTkn = nil + + n.Prefix.Accept(f) + n.NsSeparatorTkn = f.newToken(token.T_NS_SEPARATOR, []byte("\\")) + + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.SeparatorTkns = f.formatList(n.Uses, ',') + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + + n.SemiColonTkn = f.newSemicolonTkn() +} + +func (f *formatter) StmtUseDeclaration(n *ast.StmtUse) { + if n.Type != nil { + n.Type.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.NsSeparatorTkn = nil + + n.Use.Accept(f) + + if n.Alias != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.AsTkn = f.newToken(token.T_AS, []byte("as")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Alias.Accept(f) + } +} + +func (f *formatter) StmtWhile(n *ast.StmtWhile) { + n.ColonTkn = nil + n.EndWhileTkn = nil + n.SemiColonTkn = nil + + n.WhileTkn = f.newToken(token.T_WHILE, []byte("while")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Cond.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Stmt.Accept(f) +} + +func (f *formatter) ExprArray(n *ast.ExprArray) { + n.ArrayTkn = f.newToken(token.T_ARRAY, []byte("array")) + n.OpenBracketTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Items, ',') + n.CloseBracketTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprArrayDimFetch(n *ast.ExprArrayDimFetch) { + n.Var.Accept(f) + n.OpenBracketTkn = f.newToken('[', []byte("[")) + n.Dim.Accept(f) + n.CloseBracketTkn = f.newToken(']', []byte("]")) +} + +func (f *formatter) ExprArrayItem(n *ast.ExprArrayItem) { + if n.EllipsisTkn != nil { + n.EllipsisTkn = f.newToken(token.T_ELLIPSIS, []byte("...")) + } + + if n.Key != nil { + n.Key.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.DoubleArrowTkn = f.newToken(token.T_DOUBLE_ARROW, []byte("=>")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.Val.Accept(f) +} + +func (f *formatter) ExprArrowFunction(n *ast.ExprArrowFunction) { + if n.StaticTkn != nil { + n.StaticTkn = f.newToken(token.T_STATIC, []byte("static")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.FnTkn = f.newToken(token.T_FN, []byte("fn")) + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = nil + if len(n.Params) > 0 { + n.SeparatorTkns = f.formatList(n.Params, ',') + } + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + n.ColonTkn = nil + if n.ReturnType != nil { + n.ColonTkn = f.newToken(':', []byte(":")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.ReturnType.Accept(f) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.DoubleArrowTkn = f.newToken(token.T_DOUBLE_ARROW, []byte("=>")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprBitwiseNot(n *ast.ExprBitwiseNot) { + n.TildaTkn = f.newToken('~', []byte("~")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprBooleanNot(n *ast.ExprBooleanNot) { + n.ExclamationTkn = f.newToken('!', []byte("!")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprBrackets(n *ast.ExprBrackets) { + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Expr.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprClassConstFetch(n *ast.ExprClassConstFetch) { + n.Class.Accept(f) + n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::")) + n.Const.Accept(f) +} + +func (f *formatter) ExprClone(n *ast.ExprClone) { + n.CloneTkn = f.newToken(token.T_CLONE, []byte("clone")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprClosure(n *ast.ExprClosure) { + if n.StaticTkn != nil { + n.StaticTkn = f.newToken(token.T_STATIC, []byte("static")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.FunctionTkn = f.newToken(token.T_FN, []byte("function")) + + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = nil + if len(n.Params) > 0 { + n.SeparatorTkns = f.formatList(n.Params, ',') + } + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + + n.UseTkn = nil + n.UseOpenParenthesisTkn = nil + n.UseCloseParenthesisTkn = nil + n.UseSeparatorTkns = nil + if len(n.Uses) > 0 { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.UseTkn = f.newToken(token.T_USE, []byte("use")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Uses, ',') + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + } + + n.ColonTkn = nil + if n.ReturnType != nil { + n.ColonTkn = f.newToken(':', []byte(":")) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.ReturnType.Accept(f) + } + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + if len(n.Stmts) > 0 { + f.indent++ + f.formatStmts(&n.Stmts) + f.indent-- + + f.addFreeFloating(token.T_WHITESPACE, []byte("\n")) + f.addIndent() + } + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) ExprClosureUse(n *ast.ExprClosureUse) { + if n.AmpersandTkn != nil { + n.AmpersandTkn = f.newToken('&', []byte("&")) + } + + n.Var.Accept(f) +} + +func (f *formatter) ExprConstFetch(n *ast.ExprConstFetch) { + n.Const.Accept(f) +} + +func (f *formatter) ExprEmpty(n *ast.ExprEmpty) { + n.EmptyTkn = f.newToken(token.T_EMPTY, []byte("empty")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Expr.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprErrorSuppress(n *ast.ExprErrorSuppress) { + n.AtTkn = f.newToken('@', []byte("@")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprEval(n *ast.ExprEval) { + n.EvalTkn = f.newToken(token.T_EVAL, []byte("eval")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Expr.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprExit(n *ast.ExprExit) { + n.ExitTkn = f.newToken(token.T_EVAL, []byte("exit")) + + n.OpenParenthesisTkn = nil + n.CloseParenthesisTkn = nil + if n.Expr != nil { + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.Expr.Accept(f) + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + } +} + +func (f *formatter) ExprFunctionCall(n *ast.ExprFunctionCall) { + n.Function.Accept(f) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = nil + if len(n.Args) > 0 { + n.SeparatorTkns = f.formatList(n.Args, ',') + } + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprInclude(n *ast.ExprInclude) { + n.IncludeTkn = f.newToken(token.T_INCLUDE, []byte("include")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprIncludeOnce(n *ast.ExprIncludeOnce) { + n.IncludeOnceTkn = f.newToken(token.T_INCLUDE_ONCE, []byte("include_once")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprInstanceOf(n *ast.ExprInstanceOf) { + n.Expr.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.InstanceOfTkn = f.newToken(token.T_INSTANCEOF, []byte("instanceof")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Class.Accept(f) +} + +func (f *formatter) ExprIsset(n *ast.ExprIsset) { + n.IssetTkn = f.newToken(token.T_ISSET, []byte("isset")) + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Vars, ',') + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprList(n *ast.ExprList) { + n.ListTkn = f.newToken(token.T_LIST, []byte("list")) + n.OpenBracketTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Items, ',') + n.CloseBracketTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprMethodCall(n *ast.ExprMethodCall) { + n.Var.Accept(f) + n.ObjectOperatorTkn = f.newToken(token.T_OBJECT_OPERATOR, []byte("->")) + + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + switch n.Method.(type) { + case *ast.Identifier: + case *ast.ExprVariable: + default: + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } + + n.Method.Accept(f) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = nil + if len(n.Args) > 0 { + n.SeparatorTkns = f.formatList(n.Args, ',') + } + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprNew(n *ast.ExprNew) { + n.NewTkn = f.newToken(token.T_NEW, []byte("new")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Class.Accept(f) + + n.SeparatorTkns = nil + n.OpenParenthesisTkn = nil + n.CloseParenthesisTkn = nil + if len(n.Args) > 0 { + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = f.formatList(n.Args, ',') + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) + } +} + +func (f *formatter) ExprPostDec(n *ast.ExprPostDec) { + n.Var.Accept(f) + n.DecTkn = f.newToken(token.T_DEC, []byte("--")) +} + +func (f *formatter) ExprPostInc(n *ast.ExprPostInc) { + n.Var.Accept(f) + n.IncTkn = f.newToken(token.T_INC, []byte("++")) +} + +func (f *formatter) ExprPreDec(n *ast.ExprPreDec) { + n.DecTkn = f.newToken(token.T_DEC, []byte("--")) + n.Var.Accept(f) +} + +func (f *formatter) ExprPreInc(n *ast.ExprPreInc) { + n.IncTkn = f.newToken(token.T_INC, []byte("++")) + n.Var.Accept(f) +} + +func (f *formatter) ExprPrint(n *ast.ExprPrint) { + n.PrintTkn = f.newToken(token.T_PRINT, []byte("print")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprPropertyFetch(n *ast.ExprPropertyFetch) { + n.Var.Accept(f) + n.ObjectOperatorTkn = f.newToken(token.T_OBJECT_OPERATOR, []byte("->")) + + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + switch n.Prop.(type) { + case *ast.Identifier: + case *ast.ExprVariable: + default: + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } + + n.Prop.Accept(f) +} + +func (f *formatter) ExprRequire(n *ast.ExprRequire) { + n.RequireTkn = f.newToken(token.T_REQUIRE, []byte("require")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprRequireOnce(n *ast.ExprRequireOnce) { + n.RequireOnceTkn = f.newToken(token.T_REQUIRE_ONCE, []byte("require_once")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprShellExec(n *ast.ExprShellExec) { + n.OpenBacktickTkn = f.newToken('`', []byte("`")) + for _, p := range n.Parts { + p.Accept(f) + } + n.CloseBacktickTkn = f.newToken('`', []byte("`")) +} + +func (f *formatter) ExprStaticCall(n *ast.ExprStaticCall) { + n.Class.Accept(f) + n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::")) + + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + switch n.Call.(type) { + case *ast.Identifier: + case *ast.ExprVariable: + default: + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } + + n.Call.Accept(f) + + n.OpenParenthesisTkn = f.newToken('(', []byte("(")) + n.SeparatorTkns = nil + if len(n.Args) > 0 { + n.SeparatorTkns = f.formatList(n.Args, ',') + } + n.CloseParenthesisTkn = f.newToken(')', []byte(")")) +} + +func (f *formatter) ExprStaticPropertyFetch(n *ast.ExprStaticPropertyFetch) { + n.Class.Accept(f) + n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::")) + n.Prop.Accept(f) +} + +func (f *formatter) ExprTernary(n *ast.ExprTernary) { + n.Cond.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.QuestionTkn = f.newToken('?', []byte("?")) + if n.IfTrue != nil { + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.IfTrue.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + n.ColonTkn = f.newToken(':', []byte(":")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.IfFalse.Accept(f) +} + +func (f *formatter) ExprUnaryMinus(n *ast.ExprUnaryMinus) { + n.MinusTkn = f.newToken('-', []byte("-")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprUnaryPlus(n *ast.ExprUnaryPlus) { + n.PlusTkn = f.newToken('+', []byte("+")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprVariable(n *ast.ExprVariable) { + if _, ok := n.Name.(*ast.Identifier); !ok { + n.DollarTkn = f.newToken('$', []byte("$")) + } + + n.OpenCurlyBracketTkn = nil + n.CloseCurlyBracketTkn = nil + switch n.Name.(type) { + case *ast.Identifier: + case *ast.ExprVariable: + default: + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) + } + + n.Name.Accept(f) +} + +func (f *formatter) ExprYield(n *ast.ExprYield) { + n.YieldTkn = f.newToken(token.T_YIELD, []byte("yield")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + if n.Key != nil { + n.Key.Accept(f) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.DoubleArrowTkn = f.newToken(token.T_DOUBLE_ARROW, []byte("=>")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + } + + n.Val.Accept(f) +} + +func (f *formatter) ExprYieldFrom(n *ast.ExprYieldFrom) { + n.YieldFromTkn = f.newToken(token.T_YIELD_FROM, []byte("yield from")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssign(n *ast.ExprAssign) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignReference(n *ast.ExprAssignReference) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken('=', []byte("=")) + n.AmpersandTkn = f.newToken('&', []byte("&")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignBitwiseAnd(n *ast.ExprAssignBitwiseAnd) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_AND_EQUAL, []byte("&=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignBitwiseOr(n *ast.ExprAssignBitwiseOr) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_OR_EQUAL, []byte("|=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignBitwiseXor(n *ast.ExprAssignBitwiseXor) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_XOR_EQUAL, []byte("^=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignCoalesce(n *ast.ExprAssignCoalesce) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_COALESCE_EQUAL, []byte("??=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignConcat(n *ast.ExprAssignConcat) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_CONCAT_EQUAL, []byte(".=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignDiv(n *ast.ExprAssignDiv) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_DIV_EQUAL, []byte("/=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignMinus(n *ast.ExprAssignMinus) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_MINUS_EQUAL, []byte("-=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignMod(n *ast.ExprAssignMod) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_MOD_EQUAL, []byte("%=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignMul(n *ast.ExprAssignMul) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_MUL_EQUAL, []byte("*=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignPlus(n *ast.ExprAssignPlus) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_PLUS_EQUAL, []byte("+=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignPow(n *ast.ExprAssignPow) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_POW_EQUAL, []byte("**=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignShiftLeft(n *ast.ExprAssignShiftLeft) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_SL_EQUAL, []byte("<<=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprAssignShiftRight(n *ast.ExprAssignShiftRight) { + n.Var.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.EqualTkn = f.newToken(token.T_SR_EQUAL, []byte(">>=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Expr.Accept(f) +} + +func (f *formatter) ExprBinaryBitwiseAnd(n *ast.ExprBinaryBitwiseAnd) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('&', []byte("&")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryBitwiseOr(n *ast.ExprBinaryBitwiseOr) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('|', []byte("|")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryBitwiseXor(n *ast.ExprBinaryBitwiseXor) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('^', []byte("^")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryBooleanAnd(n *ast.ExprBinaryBooleanAnd) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_BOOLEAN_AND, []byte("&&")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryBooleanOr(n *ast.ExprBinaryBooleanOr) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_BOOLEAN_OR, []byte("||")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryCoalesce(n *ast.ExprBinaryCoalesce) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_COALESCE, []byte("??")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryConcat(n *ast.ExprBinaryConcat) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('.', []byte(".")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryDiv(n *ast.ExprBinaryDiv) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('/', []byte("/")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryEqual(n *ast.ExprBinaryEqual) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_EQUAL, []byte("==")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryGreater(n *ast.ExprBinaryGreater) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('>', []byte(">")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryGreaterOrEqual(n *ast.ExprBinaryGreaterOrEqual) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_GREATER_OR_EQUAL, []byte(">=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryIdentical(n *ast.ExprBinaryIdentical) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_IDENTICAL, []byte("===")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryLogicalAnd(n *ast.ExprBinaryLogicalAnd) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_LOGICAL_AND, []byte("and")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryLogicalOr(n *ast.ExprBinaryLogicalOr) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_LOGICAL_OR, []byte("or")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryLogicalXor(n *ast.ExprBinaryLogicalXor) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_LOGICAL_XOR, []byte("xor")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryMinus(n *ast.ExprBinaryMinus) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('-', []byte("-")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryMod(n *ast.ExprBinaryMod) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('%', []byte("%")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryMul(n *ast.ExprBinaryMul) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('*', []byte("*")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryNotEqual(n *ast.ExprBinaryNotEqual) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_NOT_EQUAL, []byte("!=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryNotIdentical(n *ast.ExprBinaryNotIdentical) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_NOT_IDENTICAL, []byte("!==")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryPlus(n *ast.ExprBinaryPlus) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('+', []byte("+")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryPow(n *ast.ExprBinaryPow) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_POW, []byte("**")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryShiftLeft(n *ast.ExprBinaryShiftLeft) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_SL, []byte("<<")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinaryShiftRight(n *ast.ExprBinaryShiftRight) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_SR, []byte(">>")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinarySmaller(n *ast.ExprBinarySmaller) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken('<', []byte("<")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinarySmallerOrEqual(n *ast.ExprBinarySmallerOrEqual) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_IS_SMALLER_OR_EQUAL, []byte("<=")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprBinarySpaceship(n *ast.ExprBinarySpaceship) { + n.Left.Accept(f) + + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + n.OpTkn = f.newToken(token.T_SPACESHIP, []byte("<=>")) + f.addFreeFloating(token.T_WHITESPACE, []byte(" ")) + + n.Right.Accept(f) +} + +func (f *formatter) ExprCastArray(n *ast.ExprCastArray) { + n.CastTkn = f.newToken(token.T_ARRAY_CAST, []byte("(array)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastBool(n *ast.ExprCastBool) { + n.CastTkn = f.newToken(token.T_BOOL_CAST, []byte("(bool)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastDouble(n *ast.ExprCastDouble) { + n.CastTkn = f.newToken(token.T_DOUBLE_CAST, []byte("(float)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastInt(n *ast.ExprCastInt) { + n.CastTkn = f.newToken(token.T_INT_CAST, []byte("(int)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastObject(n *ast.ExprCastObject) { + n.CastTkn = f.newToken(token.T_OBJECT_CAST, []byte("(object)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastString(n *ast.ExprCastString) { + n.CastTkn = f.newToken(token.T_STRING_CAST, []byte("(string)")) + n.Expr.Accept(f) +} + +func (f *formatter) ExprCastUnset(n *ast.ExprCastUnset) { + n.CastTkn = f.newToken(token.T_UNSET_CAST, []byte("(unset)")) + n.Expr.Accept(f) +} + +func (f *formatter) ScalarDnumber(n *ast.ScalarDnumber) { + if n.NumberTkn == nil { + n.NumberTkn = f.newToken(token.T_STRING, n.Value) + } else { + n.NumberTkn.FreeFloating = f.getFreeFloating() + } +} + +func (f *formatter) ScalarEncapsed(n *ast.ScalarEncapsed) { + n.OpenQuoteTkn = f.newToken('"', []byte("\"")) + for _, p := range n.Parts { + p.Accept(f) + } + n.CloseQuoteTkn = f.newToken('"', []byte("\"")) +} + +func (f *formatter) ScalarEncapsedStringPart(n *ast.ScalarEncapsedStringPart) { + if n.EncapsedStrTkn == nil { + n.EncapsedStrTkn = f.newToken(token.T_STRING, n.Value) + } else { + n.EncapsedStrTkn.FreeFloating = f.getFreeFloating() + } +} + +func (f *formatter) ScalarEncapsedStringVar(n *ast.ScalarEncapsedStringVar) { + n.DollarOpenCurlyBracketTkn = f.newToken(token.T_DOLLAR_OPEN_CURLY_BRACES, []byte("${")) + n.Name.Accept(f) + + n.OpenSquareBracketTkn = nil + n.CloseSquareBracketTkn = nil + if n.Dim != nil { + n.OpenSquareBracketTkn = f.newToken('[', []byte("[")) + n.Dim.Accept(f) + n.CloseSquareBracketTkn = f.newToken(']', []byte("]")) + } + + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) ScalarEncapsedStringBrackets(n *ast.ScalarEncapsedStringBrackets) { + n.OpenCurlyBracketTkn = f.newToken('{', []byte("{")) + n.Var.Accept(f) + n.CloseCurlyBracketTkn = f.newToken('}', []byte("}")) +} + +func (f *formatter) ScalarHeredoc(n *ast.ScalarHeredoc) { + n.OpenHeredocTkn = f.newToken(token.T_START_HEREDOC, []byte("<< $val) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtFunction(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtFunction{ + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function foo() { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtFunction_Ref(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtFunction{ + AmpersandTkn: &token.Token{}, + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function &foo() { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtFunction_Params(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtFunction{ + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + Params: []ast.Vertex{ + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function foo($a, $b) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtFunction_ReturnType(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtFunction{ + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + ReturnType: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("bar"), + }, + }, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function foo(): bar { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtGlobal(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtGlobal{ + Vars: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `global $a, $b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtGoto(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtGoto{ + Label: &ast.Identifier{ + Value: []byte("FOO"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `goto FOO;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtHaltCompiler(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtHaltCompiler{} + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `__halt_compiler();` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtIf(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `if ($foo) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtIf_ElseIf(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + ElseIf: []ast.Vertex{ + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + }, + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$baz"), + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `if ($foo) { + ; + } elseif($bar) { + ; + } elseif($baz) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtIf_Else(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + Else: &ast.StmtElse{ + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `if ($foo) { + ; + } else { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_StmtInlineHtml(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.Root{ + Stmts: []ast.Vertex{ + &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + &ast.StmtInlineHtml{ + Value: []byte("
"), + }, + &ast.StmtEcho{ + Exprs: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + }, + }, + &ast.StmtInlineHtml{ + Value: []byte("
"), + }, + &ast.StmtNop{}, + }, + }, + }, + } + + f := formatter.NewFormatter() + n.Accept(f) + + p := printer.NewPrinter(o) + n.Accept(p) + + expected := `
$bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprArrayItem_Variadic(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprArrayItem{ + EllipsisTkn: &token.Token{}, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `...$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprArrowFunction(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprArrowFunction{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `fn() => $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprArrowFunction_Ref(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprArrowFunction{ + AmpersandTkn: &token.Token{}, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `fn&() => $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprArrowFunction_Params(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprArrowFunction{ + Params: []ast.Vertex{ + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `fn($a, $b) => $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprArrowFunction_ReturnType(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprArrowFunction{ + ReturnType: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `fn(): foo => $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBitwiseNot(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBitwiseNot{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `~$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBooleanNot(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBooleanNot{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `!$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBrackets(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBrackets{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `($foo)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClassConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClassConstFetch{ + Class: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Const: &ast.Identifier{ + Value: []byte("bar"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo::bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClone(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClone{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `clone $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosure(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosure{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function() { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosure_Ref(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosure{ + AmpersandTkn: &token.Token{}, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function&() { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosure_Params(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosure{ + Params: []ast.Vertex{ + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function($a, $b) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosure_ReturnType(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosure{ + ReturnType: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function(): foo { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosure_Use(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosure{ + Uses: []ast.Vertex{ + &ast.ExprClosureUse{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + }, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `function() use($foo) { + ; + }` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosureUse(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosureUse{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$a` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprClosureUse_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprClosureUse{ + AmpersandTkn: &token.Token{}, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `&$a` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprConstFetch{ + Const: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("FOO"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `FOO` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprEmpty{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `empty($foo)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprErrorSuppress(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprErrorSuppress{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `@$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprEval(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprEval{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `eval($foo)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprExit(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprExit{} + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `exit` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprExit_Expr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprExit{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `exit($foo)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprFunctionCall(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprFunctionCall{ + Function: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo()` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprFunctionCall_Arguments(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprFunctionCall{ + Function: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo($bar)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprInclude(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprInclude{ + Expr: &ast.ScalarString{ + Value: []byte("'foo.php'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `include 'foo.php'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprIncludeOnce(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprIncludeOnce{ + Expr: &ast.ScalarString{ + Value: []byte("'foo.php'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `include_once 'foo.php'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprInstanceOf(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprInstanceOf{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("bar"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo instanceof bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprIsset(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprIsset{ + Vars: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `isset($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprList(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `list($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprMethodCall(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprMethodCall{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Method: &ast.Identifier{ + Value: []byte("bar"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo->bar()` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprMethodCall_Expr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprMethodCall{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Method: &ast.ScalarString{ + Value: []byte("'bar'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo->{'bar'}()` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprMethodCall_Arguments(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprMethodCall{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Method: &ast.Identifier{ + Value: []byte("bar"), + }, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo->bar($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprNew(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprNew{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `new foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprNew_Arguments(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprNew{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `new foo($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPreDec(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPreDec{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `--$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPreInc(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPreInc{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `++$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPostDec(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPostDec{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo--` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPostInc(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPostInc{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo++` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPrint(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPrint{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `print $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPropertyFetch{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Prop: &ast.Identifier{ + Value: []byte("bar"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo->bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprPropertyFetch_Expr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprPropertyFetch{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Prop: &ast.ScalarString{ + Value: []byte("'bar'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo->{'bar'}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprRequire(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprRequire{ + Expr: &ast.ScalarString{ + Value: []byte("'foo.php'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `require 'foo.php'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprRequireOnce(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprRequireOnce{ + Expr: &ast.ScalarString{ + Value: []byte("'foo.php'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `require_once 'foo.php'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprShellExec(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprShellExec{} + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := "``" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprShellExec_Part(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprShellExec{ + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Value: []byte("foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := "`foo`" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprShellExec_Parts(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprShellExec{ + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Value: []byte("foo "), + }, + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + &ast.ScalarEncapsedStringPart{ + Value: []byte(" baz"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := "`foo $bar baz`" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprStaticCall(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprStaticCall{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Call: &ast.Identifier{ + Value: []byte("bar"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo::bar()` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprStaticCall_Expr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprStaticCall{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Call: &ast.ScalarString{ + Value: []byte("'bar'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo::{'bar'}()` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprStaticCall_Arguments(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprStaticCall{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Call: &ast.Identifier{ + Value: []byte("bar"), + }, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$a"), + }, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$b"), + }, + }, + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo::bar($a, $b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprStaticPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprStaticPropertyFetch{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("foo"), + }, + }, + }, + Prop: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo::$bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprTernary(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprTernary{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + IfTrue: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + IfFalse: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$baz"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ? $bar : $baz` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprTernary_short(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprTernary{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + IfFalse: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ?: $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprUnaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprUnaryMinus{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `-$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprUnaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprUnaryPlus{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `+$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprVariable(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprVariable_Variable(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprVariable{ + Name: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprVariable_Expression(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprVariable{ + Name: &ast.ScalarString{ + Value: []byte("'foo'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `${'foo'}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprYield(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprYield{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `yield $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprYield_Key(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprYield{ + Key: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `yield $foo => $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprYieldFrom(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprYieldFrom{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `yield from $foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssign(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssign{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo = $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignReference(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignReference{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo =& $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignBitwiseAnd(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignBitwiseAnd{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo &= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignBitwiseOr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignBitwiseOr{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo |= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignBitwiseXor(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignBitwiseXor{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ^= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignCoalesce(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignCoalesce{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ??= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignConcat(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignConcat{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo .= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignDiv(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignDiv{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo /= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignMinus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignMinus{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo -= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignMod(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignMod{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo %= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignMul(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignMul{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo *= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignPlus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignPlus{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo += $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignPow(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignPow{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo **= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignShiftLeft(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignShiftLeft{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo <<= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprAssignShiftRight(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprAssignShiftRight{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo >>= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryBitwiseAnd(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryBitwiseAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo & $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryBitwiseOr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryBitwiseOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo | $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryBitwiseXor(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryBitwiseXor{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ^ $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryBooleanAnd(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryBooleanAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo && $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryBooleanOr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryBooleanOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo || $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryCoalesce(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryCoalesce{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ?? $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryConcat(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryConcat{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo . $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryDiv(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryDiv{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo / $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryEqual(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo == $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryGreater(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryGreater{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo > $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryGreaterOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryGreaterOrEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo >= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryIdentical{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo === $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryLogicalAnd(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryLogicalAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo and $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryLogicalOr(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryLogicalOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo or $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryLogicalXor(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryLogicalXor{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo xor $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryMinus{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo - $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryMod(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryMod{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo % $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryMul(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryMul{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo * $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryNotEqual(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryNotEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo != $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryNotIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryNotIdentical{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo !== $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryPlus{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo + $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryPow(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryPow{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo ** $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryShiftLeft(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryShiftLeft{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo << $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinaryShiftRight(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinaryShiftRight{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo >> $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinarySmaller(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinarySmaller{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo < $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinarySmallerOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinarySmallerOrEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo <= $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprBinarySpaceship(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprBinarySpaceship{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `$foo <=> $bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastArray(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastArray{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(array)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastBool(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastBool{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(bool)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastDouble(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastDouble{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(float)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastInt(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastInt{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(int)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastObject(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastObject{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(object)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastString(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastString{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(string)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ExprCastUnset(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ExprCastUnset{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `(unset)$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarDnumber(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarDnumber{ + Value: []byte("1234"), + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `1234` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsed(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsed{} + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `""` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsed_Part(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsed{ + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Value: []byte("foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `"foo"` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsed_Parts(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsed{ + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{ + Value: []byte("foo "), + }, + &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$bar"), + }, + }, + &ast.ScalarEncapsedStringPart{ + Value: []byte(" baz"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `"foo $bar baz"` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsedStringPart(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsedStringPart{ + Value: []byte("foo"), + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsedStringVar(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsedStringVar{ + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `${foo}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsedStringVar_Dim(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsedStringVar{ + Name: &ast.Identifier{ + Value: []byte("foo"), + }, + Dim: &ast.ScalarString{ + Value: []byte("'bar'"), + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `${foo['bar']}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarEncapsedStringBrackets(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarEncapsedStringBrackets{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{ + Value: []byte("$foo"), + }, + }, + } + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `{$foo}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestFormatter_ScalarHeredoc(t *testing.T) { + o := bytes.NewBufferString("") + + n := &ast.ScalarHeredoc{} + + f := formatter.NewFormatter().WithState(formatter.FormatterStatePHP).WithIndent(1) + n.Accept(f) + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n.Accept(p) + + expected := `<< 1 { + // if name qualified, replace first part by alias + return aliasName + "\\" + concatNameParts(n.Parts[1:]), nil + } + + return aliasName, nil + } + + return "", errors.New("must be instance of name.Names") +} + +// ResolveAlias returns alias or error if not found +func (ns *Namespace) ResolveAlias(nameNode ast.Vertex, aliasType string) (string, error) { + aliasType = strings.ToLower(aliasType) + nameParts := nameNode.(*ast.Name).Parts + + firstPartStr := string(nameParts[0].(*ast.NamePart).Value) + + if len(nameParts) > 1 { // resolve aliases for qualified names, always against class alias type + firstPartStr = strings.ToLower(firstPartStr) + aliasType = "" + } else { + if aliasType != "const" { // constants are case-sensitive + firstPartStr = strings.ToLower(firstPartStr) + } + } + + aliasName, ok := ns.Aliases[aliasType][firstPartStr] + if !ok { + return "", errors.New("Not found") + } + + return aliasName, nil +} + +func concatNameParts(parts ...[]ast.Vertex) string { + str := "" + + for _, p := range parts { + for _, n := range p { + if str == "" { + str = string(n.(*ast.NamePart).Value) + } else { + str = str + "\\" + string(n.(*ast.NamePart).Value) + } + } + } + + return str +} diff --git a/pkg/visitor/nsresolver/namespace_resolver_test.go b/pkg/visitor/nsresolver/namespace_resolver_test.go new file mode 100644 index 0000000..324ba0d --- /dev/null +++ b/pkg/visitor/nsresolver/namespace_resolver_test.go @@ -0,0 +1,980 @@ +package nsresolver_test + +import ( + "github.com/z7zmey/php-parser/pkg/visitor/nsresolver" + "github.com/z7zmey/php-parser/pkg/visitor/traverser" + "testing" + + "gotest.tools/assert" + + "github.com/z7zmey/php-parser/pkg/ast" +) + +func TestResolveStaticCall(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprStaticCall{ + Class: nameBC, + Call: &ast.Identifier{Value: []byte("foo")}, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveStaticPropertyFetch(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprStaticPropertyFetch{ + Class: nameBC, + Prop: &ast.Identifier{Value: []byte("foo")}, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveClassConstFetch(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprClassConstFetch{ + Class: nameBC, + Const: &ast.Identifier{Value: []byte("FOO")}, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveNew(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprNew{ + Class: nameBC, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveInstanceOf(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprInstanceOf{ + Expr: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + Class: nameBC, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveInstanceCatch(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + nameDE := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("D")}, &ast.NamePart{Value: []byte("E")}}} + nameF := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + &ast.StmtUse{ + Use: nameDE, + Alias: &ast.Identifier{Value: []byte("F")}, + }, + }, + }, + &ast.StmtTry{ + Stmts: []ast.Vertex{}, + Catches: []ast.Vertex{ + &ast.StmtCatch{ + Types: []ast.Vertex{ + nameBC, + nameF, + }, + Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + Stmts: []ast.Vertex{}, + }, + }, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameBC: "A\\B\\C", + nameF: "D\\E", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveFunctionCall(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Type: &ast.Identifier{Value: []byte("function")}, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprFunctionCall{ + Function: nameB, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameB: "A\\B", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveConstFetch(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Type: &ast.Identifier{Value: []byte("const")}, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.ExprConstFetch{ + Const: nameB, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameB: "A\\B", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveGroupUse(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("D")}}} + nameE := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("E")}}} + nameC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}}} + nameF := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtGroupUseList{ + Prefix: nameAB, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Type: &ast.Identifier{Value: []byte("Function")}, + Use: nameF, + }, + &ast.StmtUse{ + Type: &ast.Identifier{Value: []byte("const")}, + Use: nameC, + }, + }, + }, + &ast.StmtGroupUseList{ + Prefix: nameBD, + Type: &ast.Identifier{Value: []byte("Function")}, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameE, + }, + }, + }, + &ast.ExprConstFetch{ + Const: nameC, + }, + &ast.ExprFunctionCall{ + Function: nameF, + }, + &ast.ExprFunctionCall{ + Function: nameE, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameC: "A\\B\\C", + nameF: "A\\B\\F", + nameE: "B\\D\\E", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveTraitUse(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}}} + nameD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("D")}}} + + fullyQualifiedNameB := &ast.NameFullyQualified{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}}} + fullyQualifiedNameBC := &ast.NameFullyQualified{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + relativeNameB := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}}} + relativeNameBC := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAB, + }, + }, + }, + &ast.StmtTraitUse{ + Traits: []ast.Vertex{ + nameB, + relativeNameB, + }, + Adaptations: []ast.Vertex{ + &ast.StmtTraitUsePrecedence{ + Trait: fullyQualifiedNameB, + Method: &ast.Identifier{Value: []byte("foo")}, + Insteadof: []ast.Vertex{fullyQualifiedNameBC}, + }, + &ast.StmtTraitUseAlias{ + Trait: relativeNameBC, + Method: &ast.Identifier{Value: []byte("foo")}, + Alias: &ast.Identifier{Value: []byte("bar")}, + }, + }, + }, + &ast.StmtTraitUse{ + Traits: []ast.Vertex{ + nameD, + }, + }, + }, + } + + expected := map[ast.Vertex]string{ + nameB: "A\\B", + nameD: "D", + relativeNameB: "B", + fullyQualifiedNameB: "B", + fullyQualifiedNameBC: "B\\C", + relativeNameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveClassName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + class := &ast.StmtClass{ + Name: &ast.Identifier{Value: []byte("A")}, + Extends: nameAB, + Implements: []ast.Vertex{ + nameBC, + }, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + class, + }, + } + + expected := map[ast.Vertex]string{ + class: "A", + nameAB: "A\\B", + nameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveInterfaceName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + interfaceNode := &ast.StmtInterface{ + Name: &ast.Identifier{Value: []byte("A")}, + Extends: []ast.Vertex{ + nameAB, + nameBC, + }, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + interfaceNode, + }, + } + + expected := map[ast.Vertex]string{ + interfaceNode: "A", + nameAB: "A\\B", + nameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveTraitName(t *testing.T) { + traitNode := &ast.StmtTrait{ + Name: &ast.Identifier{Value: []byte("A")}, + Stmts: []ast.Vertex{}, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + traitNode, + }, + } + + expected := map[ast.Vertex]string{ + traitNode: "A", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveFunctionName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + functionNode := &ast.StmtFunction{ + Name: &ast.Identifier{Value: []byte("A")}, + Params: []ast.Vertex{ + &ast.Parameter{ + Type: nameAB, + Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + }, + }, + ReturnType: &ast.Nullable{Expr: nameBC}, + Stmts: []ast.Vertex{}, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + functionNode, + }, + } + + expected := map[ast.Vertex]string{ + functionNode: "A", + nameAB: "A\\B", + nameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveMethodName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + methodNode := &ast.StmtClassMethod{ + Name: &ast.Identifier{Value: []byte("A")}, + Params: []ast.Vertex{ + &ast.Parameter{ + Type: nameAB, + Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + }, + }, + ReturnType: &ast.Nullable{Expr: nameBC}, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{}, + }, + } + + expected := map[ast.Vertex]string{ + nameAB: "A\\B", + nameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(methodNode) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveClosureName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}} + + closureNode := &ast.ExprClosure{ + Params: []ast.Vertex{ + &ast.Parameter{ + Type: nameAB, + Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + }, + }, + ReturnType: &ast.Nullable{Expr: nameBC}, + Stmts: []ast.Vertex{}, + } + + expected := map[ast.Vertex]string{ + nameAB: "A\\B", + nameBC: "B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(closureNode) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveConstantsName(t *testing.T) { + nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + + constantB := &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("B")}, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + constantC := &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("C")}, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: nameAB, + }, + &ast.StmtConstList{ + Consts: []ast.Vertex{ + constantB, + constantC, + }, + }, + }, + } + + expected := map[ast.Vertex]string{ + constantB: "A\\B\\B", + constantC: "A\\B\\C", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveNamespaces(t *testing.T) { + namespaceAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + namespaceCD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("D")}}} + + nameAC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("C")}}} + nameCF := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("F")}}} + nameFG := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}, &ast.NamePart{Value: []byte("G")}}} + relativeNameCE := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("E")}}} + + constantB := &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("B")}, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + constantC := &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("C")}, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: namespaceAB, + }, + &ast.StmtConstList{ + Consts: []ast.Vertex{ + constantB, + constantC, + }, + }, + &ast.ExprStaticCall{ + Class: nameFG, + Call: &ast.Identifier{Value: []byte("foo")}, + }, + &ast.StmtNamespace{ + Stmts: []ast.Vertex{}, + }, + &ast.StmtNamespace{ + Name: namespaceCD, + Stmts: []ast.Vertex{ + &ast.StmtUseList{ + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: nameAC, + }, + }, + }, + &ast.ExprStaticCall{ + Class: relativeNameCE, + Call: &ast.Identifier{Value: []byte("foo")}, + }, + &ast.ExprStaticCall{ + Class: nameCF, + Call: &ast.Identifier{Value: []byte("foo")}, + }, + }, + }, + }, + } + + expected := map[ast.Vertex]string{ + constantB: "A\\B\\B", + constantC: "A\\B\\C", + nameFG: "A\\B\\F\\G", + relativeNameCE: "C\\D\\C\\E", + nameCF: "A\\C\\F", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestResolveStaticCallDinamicClassName(t *testing.T) { + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.ExprStaticCall{ + Class: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}}, + Call: &ast.Identifier{Value: []byte("foo")}, + }, + }, + } + + expected := map[ast.Vertex]string{} + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestDoNotResolveReservedConstants(t *testing.T) { + namespaceName := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}} + + constantTrue := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("True")}, + }, + } + + constantFalse := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("False")}, + }, + } + + constantNull := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("NULL")}, + }, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: namespaceName, + }, + &ast.StmtExpression{ + Expr: &ast.ExprConstFetch{ + Const: constantTrue, + }, + }, + &ast.StmtExpression{ + Expr: &ast.ExprConstFetch{ + Const: constantFalse, + }, + }, + &ast.StmtExpression{ + Expr: &ast.ExprConstFetch{ + Const: constantNull, + }, + }, + }, + } + + expected := map[ast.Vertex]string{ + constantTrue: "true", + constantFalse: "false", + constantNull: "null", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestDoNotResolveReservedNames(t *testing.T) { + + nameInt := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("int")}, + }, + } + + nameFloat := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("float")}, + }, + } + + nameBool := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("bool")}, + }, + } + + nameString := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("string")}, + }, + } + + nameVoid := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("void")}, + }, + } + + nameIterable := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("iterable")}, + }, + } + + nameObject := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("object")}, + }, + } + + function := &ast.StmtFunction{ + Name: &ast.Identifier{Value: []byte("bar")}, + Params: []ast.Vertex{ + &ast.Parameter{ + Type: nameInt, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Int")}, + }, + }, + &ast.Parameter{ + Type: nameFloat, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Float")}, + }, + }, + &ast.Parameter{ + Type: nameBool, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Bool")}, + }, + }, + &ast.Parameter{ + Type: nameString, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("String")}, + }, + }, + &ast.Parameter{ + Type: nameVoid, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Void")}, + }, + }, + &ast.Parameter{ + Type: nameIterable, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Iterable")}, + }, + }, + &ast.Parameter{ + Type: nameObject, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("Object")}, + }, + }, + }, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Foo")}, + }, + }, + }, + function, + }, + } + + expected := map[ast.Vertex]string{ + function: "Foo\\bar", + nameInt: "int", + nameFloat: "float", + nameBool: "bool", + nameString: "string", + nameVoid: "void", + nameIterable: "iterable", + nameObject: "object", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} + +func TestDoNotResolveReservedSpecialNames(t *testing.T) { + + nameSelf := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Self")}, + }, + } + + nameStatic := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Static")}, + }, + } + + nameParent := &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Parent")}, + }, + } + + cls := &ast.StmtClass{ + Name: &ast.Identifier{Value: []byte("Bar")}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Expr: &ast.ExprStaticCall{ + Class: nameSelf, + Call: &ast.Identifier{Value: []byte("func")}, + }, + }, + &ast.StmtExpression{ + Expr: &ast.ExprStaticCall{ + Class: nameStatic, + Call: &ast.Identifier{Value: []byte("func")}, + }, + }, + &ast.StmtExpression{ + Expr: &ast.ExprStaticCall{ + Class: nameParent, + Call: &ast.Identifier{Value: []byte("func")}, + }, + }, + }, + } + + stxTree := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Foo")}, + }, + }, + }, + cls, + }, + } + + expected := map[ast.Vertex]string{ + cls: "Foo\\Bar", + nameSelf: "self", + nameStatic: "static", + nameParent: "parent", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stxTree) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} +func TestResolvePropertyTypeName(t *testing.T) { + nameSimple := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameRelative := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + nameFullyQualified := &ast.NameFullyQualified{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}} + + propertyNodeSimple := &ast.StmtPropertyList{ + Type: nameSimple, + } + + propertyNodeRelative := &ast.StmtPropertyList{ + Type: nameRelative, + } + + propertyNodeFullyQualified := &ast.StmtPropertyList{ + Type: nameFullyQualified, + } + + classNode := &ast.StmtClass{ + Name: &ast.Identifier{Value: []byte("Bar")}, + Stmts: []ast.Vertex{ + propertyNodeSimple, + propertyNodeRelative, + propertyNodeFullyQualified, + }, + } + + stmts := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNamespace{ + Name: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{Value: []byte("Foo")}, + }, + }, + }, + classNode, + }, + } + + expected := map[ast.Vertex]string{ + nameSimple: "Foo\\A\\B", + nameRelative: "Foo\\A\\B", + nameFullyQualified: "A\\B", + classNode: "Foo\\Bar", + } + + nsResolver := nsresolver.NewNamespaceResolver() + traverser.NewTraverser(nsResolver).Traverse(stmts) + + assert.DeepEqual(t, expected, nsResolver.ResolvedNames) +} diff --git a/pkg/visitor/null.go b/pkg/visitor/null.go new file mode 100644 index 0000000..e5edcc0 --- /dev/null +++ b/pkg/visitor/null.go @@ -0,0 +1,643 @@ +package visitor + +import ( + "github.com/z7zmey/php-parser/pkg/ast" +) + +type Null struct { +} + +func (v *Null) Enter(_ string, _ bool) { + // do nothing +} +func (v *Null) Leave(_ string, _ bool) { + // do nothing +} + +func (v *Null) EnterNode(_ ast.Vertex) bool { + return true +} + +func (v *Null) LeaveNode(_ ast.Vertex) { + // do nothing +} + +func (v *Null) Root(_ *ast.Root) { + // do nothing +} + +func (v *Null) Nullable(_ *ast.Nullable) { + // do nothing +} + +func (v *Null) Parameter(_ *ast.Parameter) { + // do nothing +} + +func (v *Null) Identifier(_ *ast.Identifier) { + // do nothing +} + +func (v *Null) Argument(_ *ast.Argument) { + // do nothing +} + +func (v *Null) StmtBreak(_ *ast.StmtBreak) { + // do nothing +} + +func (v *Null) StmtCase(_ *ast.StmtCase) { + // do nothing +} + +func (v *Null) StmtCatch(_ *ast.StmtCatch) { + // do nothing +} + +func (v *Null) StmtClass(_ *ast.StmtClass) { + // do nothing +} + +func (v *Null) StmtClassConstList(_ *ast.StmtClassConstList) { + // do nothing +} + +func (v *Null) StmtClassMethod(_ *ast.StmtClassMethod) { + // do nothing +} + +func (v *Null) StmtConstList(_ *ast.StmtConstList) { + // do nothing +} + +func (v *Null) StmtConstant(_ *ast.StmtConstant) { + // do nothing +} + +func (v *Null) StmtContinue(_ *ast.StmtContinue) { + // do nothing +} + +func (v *Null) StmtDeclare(_ *ast.StmtDeclare) { + // do nothing +} + +func (v *Null) StmtDefault(_ *ast.StmtDefault) { + // do nothing +} + +func (v *Null) StmtDo(_ *ast.StmtDo) { + // do nothing +} + +func (v *Null) StmtEcho(_ *ast.StmtEcho) { + // do nothing +} + +func (v *Null) StmtElse(_ *ast.StmtElse) { + // do nothing +} + +func (v *Null) StmtElseIf(_ *ast.StmtElseIf) { + // do nothing +} + +func (v *Null) StmtExpression(_ *ast.StmtExpression) { + // do nothing +} + +func (v *Null) StmtFinally(_ *ast.StmtFinally) { + // do nothing +} + +func (v *Null) StmtFor(_ *ast.StmtFor) { + // do nothing +} + +func (v *Null) StmtForeach(_ *ast.StmtForeach) { + // do nothing +} + +func (v *Null) StmtFunction(_ *ast.StmtFunction) { + // do nothing +} + +func (v *Null) StmtGlobal(_ *ast.StmtGlobal) { + // do nothing +} + +func (v *Null) StmtGoto(_ *ast.StmtGoto) { + // do nothing +} + +func (v *Null) StmtHaltCompiler(_ *ast.StmtHaltCompiler) { + // do nothing +} + +func (v *Null) StmtIf(_ *ast.StmtIf) { + // do nothing +} + +func (v *Null) StmtInlineHtml(_ *ast.StmtInlineHtml) { + // do nothing +} + +func (v *Null) StmtInterface(_ *ast.StmtInterface) { + // do nothing +} + +func (v *Null) StmtLabel(_ *ast.StmtLabel) { + // do nothing +} + +func (v *Null) StmtNamespace(_ *ast.StmtNamespace) { + // do nothing +} + +func (v *Null) StmtNop(_ *ast.StmtNop) { + // do nothing +} + +func (v *Null) StmtProperty(_ *ast.StmtProperty) { + // do nothing +} + +func (v *Null) StmtPropertyList(_ *ast.StmtPropertyList) { + // do nothing +} + +func (v *Null) StmtReturn(_ *ast.StmtReturn) { + // do nothing +} + +func (v *Null) StmtStatic(_ *ast.StmtStatic) { + // do nothing +} + +func (v *Null) StmtStaticVar(_ *ast.StmtStaticVar) { + // do nothing +} + +func (v *Null) StmtStmtList(_ *ast.StmtStmtList) { + // do nothing +} + +func (v *Null) StmtSwitch(_ *ast.StmtSwitch) { + // do nothing +} + +func (v *Null) StmtThrow(_ *ast.StmtThrow) { + // do nothing +} + +func (v *Null) StmtTrait(_ *ast.StmtTrait) { + // do nothing +} + +func (v *Null) StmtTraitUse(_ *ast.StmtTraitUse) { + // do nothing +} + +func (v *Null) StmtTraitUseAlias(_ *ast.StmtTraitUseAlias) { + // do nothing +} + +func (v *Null) StmtTraitUsePrecedence(_ *ast.StmtTraitUsePrecedence) { + // do nothing +} + +func (v *Null) StmtTry(_ *ast.StmtTry) { + // do nothing +} + +func (v *Null) StmtUnset(_ *ast.StmtUnset) { + // do nothing +} + +func (v *Null) StmtUse(_ *ast.StmtUseList) { + // do nothing +} + +func (v *Null) StmtGroupUse(_ *ast.StmtGroupUseList) { + // do nothing +} + +func (v *Null) StmtUseDeclaration(_ *ast.StmtUse) { + // do nothing +} + +func (v *Null) StmtWhile(_ *ast.StmtWhile) { + // do nothing +} + +func (v *Null) ExprArray(_ *ast.ExprArray) { + // do nothing +} + +func (v *Null) ExprArrayDimFetch(_ *ast.ExprArrayDimFetch) { + // do nothing +} + +func (v *Null) ExprArrayItem(_ *ast.ExprArrayItem) { + // do nothing +} + +func (v *Null) ExprArrowFunction(_ *ast.ExprArrowFunction) { + // do nothing +} + +func (v *Null) ExprBitwiseNot(_ *ast.ExprBitwiseNot) { + // do nothing +} + +func (v *Null) ExprBooleanNot(_ *ast.ExprBooleanNot) { + // do nothing +} + +func (v *Null) ExprBrackets(_ *ast.ExprBrackets) { + // do nothing +} + +func (v *Null) ExprClassConstFetch(_ *ast.ExprClassConstFetch) { + // do nothing +} + +func (v *Null) ExprClone(_ *ast.ExprClone) { + // do nothing +} + +func (v *Null) ExprClosure(_ *ast.ExprClosure) { + // do nothing +} + +func (v *Null) ExprClosureUse(_ *ast.ExprClosureUse) { + // do nothing +} + +func (v *Null) ExprConstFetch(_ *ast.ExprConstFetch) { + // do nothing +} + +func (v *Null) ExprEmpty(_ *ast.ExprEmpty) { + // do nothing +} + +func (v *Null) ExprErrorSuppress(_ *ast.ExprErrorSuppress) { + // do nothing +} + +func (v *Null) ExprEval(_ *ast.ExprEval) { + // do nothing +} + +func (v *Null) ExprExit(_ *ast.ExprExit) { + // do nothing +} + +func (v *Null) ExprFunctionCall(_ *ast.ExprFunctionCall) { + // do nothing +} + +func (v *Null) ExprInclude(_ *ast.ExprInclude) { + // do nothing +} + +func (v *Null) ExprIncludeOnce(_ *ast.ExprIncludeOnce) { + // do nothing +} + +func (v *Null) ExprInstanceOf(_ *ast.ExprInstanceOf) { + // do nothing +} + +func (v *Null) ExprIsset(_ *ast.ExprIsset) { + // do nothing +} + +func (v *Null) ExprList(_ *ast.ExprList) { + // do nothing +} + +func (v *Null) ExprMethodCall(_ *ast.ExprMethodCall) { + // do nothing +} + +func (v *Null) ExprNew(_ *ast.ExprNew) { + // do nothing +} + +func (v *Null) ExprPostDec(_ *ast.ExprPostDec) { + // do nothing +} + +func (v *Null) ExprPostInc(_ *ast.ExprPostInc) { + // do nothing +} + +func (v *Null) ExprPreDec(_ *ast.ExprPreDec) { + // do nothing +} + +func (v *Null) ExprPreInc(_ *ast.ExprPreInc) { + // do nothing +} + +func (v *Null) ExprPrint(_ *ast.ExprPrint) { + // do nothing +} + +func (v *Null) ExprPropertyFetch(_ *ast.ExprPropertyFetch) { + // do nothing +} + +func (v *Null) ExprRequire(_ *ast.ExprRequire) { + // do nothing +} + +func (v *Null) ExprRequireOnce(_ *ast.ExprRequireOnce) { + // do nothing +} + +func (v *Null) ExprShellExec(_ *ast.ExprShellExec) { + // do nothing +} + +func (v *Null) ExprStaticCall(_ *ast.ExprStaticCall) { + // do nothing +} + +func (v *Null) ExprStaticPropertyFetch(_ *ast.ExprStaticPropertyFetch) { + // do nothing +} + +func (v *Null) ExprTernary(_ *ast.ExprTernary) { + // do nothing +} + +func (v *Null) ExprUnaryMinus(_ *ast.ExprUnaryMinus) { + // do nothing +} + +func (v *Null) ExprUnaryPlus(_ *ast.ExprUnaryPlus) { + // do nothing +} + +func (v *Null) ExprVariable(_ *ast.ExprVariable) { + // do nothing +} + +func (v *Null) ExprYield(_ *ast.ExprYield) { + // do nothing +} + +func (v *Null) ExprYieldFrom(_ *ast.ExprYieldFrom) { + // do nothing +} + +func (v *Null) ExprAssign(_ *ast.ExprAssign) { + // do nothing +} + +func (v *Null) ExprAssignReference(_ *ast.ExprAssignReference) { + // do nothing +} + +func (v *Null) ExprAssignBitwiseAnd(_ *ast.ExprAssignBitwiseAnd) { + // do nothing +} + +func (v *Null) ExprAssignBitwiseOr(_ *ast.ExprAssignBitwiseOr) { + // do nothing +} + +func (v *Null) ExprAssignBitwiseXor(_ *ast.ExprAssignBitwiseXor) { + // do nothing +} + +func (v *Null) ExprAssignCoalesce(_ *ast.ExprAssignCoalesce) { + // do nothing +} + +func (v *Null) ExprAssignConcat(_ *ast.ExprAssignConcat) { + // do nothing +} + +func (v *Null) ExprAssignDiv(_ *ast.ExprAssignDiv) { + // do nothing +} + +func (v *Null) ExprAssignMinus(_ *ast.ExprAssignMinus) { + // do nothing +} + +func (v *Null) ExprAssignMod(_ *ast.ExprAssignMod) { + // do nothing +} + +func (v *Null) ExprAssignMul(_ *ast.ExprAssignMul) { + // do nothing +} + +func (v *Null) ExprAssignPlus(_ *ast.ExprAssignPlus) { + // do nothing +} + +func (v *Null) ExprAssignPow(_ *ast.ExprAssignPow) { + // do nothing +} + +func (v *Null) ExprAssignShiftLeft(_ *ast.ExprAssignShiftLeft) { + // do nothing +} + +func (v *Null) ExprAssignShiftRight(_ *ast.ExprAssignShiftRight) { + // do nothing +} + +func (v *Null) ExprBinaryBitwiseAnd(_ *ast.ExprBinaryBitwiseAnd) { + // do nothing +} + +func (v *Null) ExprBinaryBitwiseOr(_ *ast.ExprBinaryBitwiseOr) { + // do nothing +} + +func (v *Null) ExprBinaryBitwiseXor(_ *ast.ExprBinaryBitwiseXor) { + // do nothing +} + +func (v *Null) ExprBinaryBooleanAnd(_ *ast.ExprBinaryBooleanAnd) { + // do nothing +} + +func (v *Null) ExprBinaryBooleanOr(_ *ast.ExprBinaryBooleanOr) { + // do nothing +} + +func (v *Null) ExprBinaryCoalesce(_ *ast.ExprBinaryCoalesce) { + // do nothing +} + +func (v *Null) ExprBinaryConcat(_ *ast.ExprBinaryConcat) { + // do nothing +} + +func (v *Null) ExprBinaryDiv(_ *ast.ExprBinaryDiv) { + // do nothing +} + +func (v *Null) ExprBinaryEqual(_ *ast.ExprBinaryEqual) { + // do nothing +} + +func (v *Null) ExprBinaryGreater(_ *ast.ExprBinaryGreater) { + // do nothing +} + +func (v *Null) ExprBinaryGreaterOrEqual(_ *ast.ExprBinaryGreaterOrEqual) { + // do nothing +} + +func (v *Null) ExprBinaryIdentical(_ *ast.ExprBinaryIdentical) { + // do nothing +} + +func (v *Null) ExprBinaryLogicalAnd(_ *ast.ExprBinaryLogicalAnd) { + // do nothing +} + +func (v *Null) ExprBinaryLogicalOr(_ *ast.ExprBinaryLogicalOr) { + // do nothing +} + +func (v *Null) ExprBinaryLogicalXor(_ *ast.ExprBinaryLogicalXor) { + // do nothing +} + +func (v *Null) ExprBinaryMinus(_ *ast.ExprBinaryMinus) { + // do nothing +} + +func (v *Null) ExprBinaryMod(_ *ast.ExprBinaryMod) { + // do nothing +} + +func (v *Null) ExprBinaryMul(_ *ast.ExprBinaryMul) { + // do nothing +} + +func (v *Null) ExprBinaryNotEqual(_ *ast.ExprBinaryNotEqual) { + // do nothing +} + +func (v *Null) ExprBinaryNotIdentical(_ *ast.ExprBinaryNotIdentical) { + // do nothing +} + +func (v *Null) ExprBinaryPlus(_ *ast.ExprBinaryPlus) { + // do nothing +} + +func (v *Null) ExprBinaryPow(_ *ast.ExprBinaryPow) { + // do nothing +} + +func (v *Null) ExprBinaryShiftLeft(_ *ast.ExprBinaryShiftLeft) { + // do nothing +} + +func (v *Null) ExprBinaryShiftRight(_ *ast.ExprBinaryShiftRight) { + // do nothing +} + +func (v *Null) ExprBinarySmaller(_ *ast.ExprBinarySmaller) { + // do nothing +} + +func (v *Null) ExprBinarySmallerOrEqual(_ *ast.ExprBinarySmallerOrEqual) { + // do nothing +} + +func (v *Null) ExprBinarySpaceship(_ *ast.ExprBinarySpaceship) { + // do nothing +} + +func (v *Null) ExprCastArray(_ *ast.ExprCastArray) { + // do nothing +} + +func (v *Null) ExprCastBool(_ *ast.ExprCastBool) { + // do nothing +} + +func (v *Null) ExprCastDouble(_ *ast.ExprCastDouble) { + // do nothing +} + +func (v *Null) ExprCastInt(_ *ast.ExprCastInt) { + // do nothing +} + +func (v *Null) ExprCastObject(_ *ast.ExprCastObject) { + // do nothing +} + +func (v *Null) ExprCastString(_ *ast.ExprCastString) { + // do nothing +} + +func (v *Null) ExprCastUnset(_ *ast.ExprCastUnset) { + // do nothing +} + +func (v *Null) ScalarDnumber(_ *ast.ScalarDnumber) { + // do nothing +} + +func (v *Null) ScalarEncapsed(_ *ast.ScalarEncapsed) { + // do nothing +} + +func (v *Null) ScalarEncapsedStringPart(_ *ast.ScalarEncapsedStringPart) { + // do nothing +} + +func (v *Null) ScalarEncapsedStringBrackets(_ *ast.ScalarEncapsedStringBrackets) { + // do nothing +} + +func (v *Null) ScalarEncapsedStringVar(_ *ast.ScalarEncapsedStringVar) { + // do nothing +} + +func (v *Null) ScalarHeredoc(_ *ast.ScalarHeredoc) { + // do nothing +} + +func (v *Null) ScalarLnumber(_ *ast.ScalarLnumber) { + // do nothing +} + +func (v *Null) ScalarMagicConstant(_ *ast.ScalarMagicConstant) { + // do nothing +} + +func (v *Null) ScalarString(_ *ast.ScalarString) { + // do nothing +} + +func (v *Null) NameName(_ *ast.Name) { + // do nothing +} + +func (v *Null) NameFullyQualified(_ *ast.NameFullyQualified) { + // do nothing +} + +func (v *Null) NameRelative(_ *ast.NameRelative) { + // do nothing +} + +func (v *Null) NameNamePart(_ *ast.NamePart) { + // do nothing +} diff --git a/pkg/visitor/printer/printer.go b/pkg/visitor/printer/printer.go new file mode 100644 index 0000000..76e230e --- /dev/null +++ b/pkg/visitor/printer/printer.go @@ -0,0 +1,1237 @@ +package printer + +import ( + "bytes" + "github.com/z7zmey/php-parser/pkg/ast" + "github.com/z7zmey/php-parser/pkg/token" + "io" +) + +type printerState int + +const ( + PrinterStateHTML printerState = iota + PrinterStatePHP +) + +type printer struct { + output io.Writer + state printerState + last []byte +} + +func NewPrinter(output io.Writer) *printer { + return &printer{ + output: output, + } +} + +func (p *printer) WithState(state printerState) *printer { + p.state = state + return p +} + +func isValidVarName(r byte) bool { + return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' || r >= 0x80 +} + +func (p *printer) write(b []byte) { + if len(b) == 0 { + return + } + + if p.state == PrinterStateHTML { + if !bytes.HasPrefix(b, []byte(""))) + p.printToken(n.AmpersandTkn, nil) + p.printNode(n.Var) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, nil) + if stmt, ok := n.Stmt.(*ast.StmtStmtList); ok && n.ColonTkn != nil { + p.printToken(stmt.OpenCurlyBracketTkn, nil) + p.printList(stmt.Stmts) + p.printToken(stmt.CloseCurlyBracketTkn, nil) + } else { + p.printNode(n.Stmt) + } + p.printToken(n.EndForeachTkn, p.ifToken(n.ColonTkn, []byte("endforeach"), nil)) + p.printToken(n.SemiColonTkn, p.ifToken(n.ColonTkn, []byte(";"), nil)) +} + +func (p *printer) StmtFunction(n *ast.StmtFunction) { + p.printToken(n.FunctionTkn, []byte("function")) + p.printToken(n.AmpersandTkn, nil) + p.printNode(n.Name) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Params, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, p.ifNode(n.ReturnType, []byte(":"))) + p.printNode(n.ReturnType) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) StmtGlobal(n *ast.StmtGlobal) { + p.printToken(n.GlobalTkn, []byte("global")) + p.printSeparatedList(n.Vars, n.SeparatorTkns, []byte(",")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtGoto(n *ast.StmtGoto) { + p.printToken(n.GotoTkn, []byte("goto")) + p.printNode(n.Label) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtHaltCompiler(n *ast.StmtHaltCompiler) { + p.printToken(n.HaltCompilerTkn, []byte("__halt_compiler")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtIf(n *ast.StmtIf) { + p.printToken(n.IfTkn, []byte("if")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printNode(n.Cond) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, nil) + if stmt, ok := n.Stmt.(*ast.StmtStmtList); ok && n.ColonTkn != nil { + p.printToken(stmt.OpenCurlyBracketTkn, nil) + p.printList(stmt.Stmts) + p.printToken(stmt.CloseCurlyBracketTkn, nil) + } else { + p.printNode(n.Stmt) + } + p.printList(n.ElseIf) + p.printNode(n.Else) + p.printToken(n.EndIfTkn, p.ifToken(n.ColonTkn, []byte("endif"), nil)) + p.printToken(n.SemiColonTkn, p.ifToken(n.ColonTkn, []byte(";"), nil)) +} + +func (p *printer) StmtInlineHtml(n *ast.StmtInlineHtml) { + p.state = PrinterStatePHP + if p.last != nil && !bytes.HasSuffix(p.last, []byte("?>")) && !bytes.HasSuffix(p.last, []byte("?>\n")) { + p.write([]byte("?>")) + } + + p.printToken(n.InlineHtmlTkn, n.Value) + p.state = PrinterStateHTML +} + +func (p *printer) StmtInterface(n *ast.StmtInterface) { + p.printToken(n.InterfaceTkn, []byte("interface")) + p.printNode(n.Name) + p.printToken(n.ExtendsTkn, p.ifNodeList(n.Extends, []byte("extends"))) + p.printSeparatedList(n.Extends, n.ExtendsSeparatorTkns, []byte(",")) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) StmtLabel(n *ast.StmtLabel) { + p.printNode(n.Name) + p.printToken(n.ColonTkn, []byte(":")) +} + +func (p *printer) StmtNamespace(n *ast.StmtNamespace) { + p.printToken(n.NsTkn, []byte("namespace")) + p.printNode(n.Name) + p.printToken(n.OpenCurlyBracketTkn, p.ifNodeList(n.Stmts, []byte("{"))) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, p.ifNodeList(n.Stmts, []byte("}"))) + p.printToken(n.SemiColonTkn, p.ifNotNodeList(n.Stmts, []byte(";"))) +} + +func (p *printer) StmtNop(n *ast.StmtNop) { + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtProperty(n *ast.StmtProperty) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, p.ifNode(n.Expr, []byte("="))) + p.printNode(n.Expr) +} + +func (p *printer) StmtPropertyList(n *ast.StmtPropertyList) { + p.printList(n.Modifiers) + p.printNode(n.Type) + p.printSeparatedList(n.Props, n.SeparatorTkns, []byte(",")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtReturn(n *ast.StmtReturn) { + p.printToken(n.ReturnTkn, []byte("return")) + p.printNode(n.Expr) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtStatic(n *ast.StmtStatic) { + p.printToken(n.StaticTkn, []byte("static")) + p.printSeparatedList(n.Vars, n.SeparatorTkns, []byte(",")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtStaticVar(n *ast.StmtStaticVar) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, p.ifNode(n.Expr, []byte("="))) + p.printNode(n.Expr) +} + +func (p *printer) StmtStmtList(n *ast.StmtStmtList) { + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) StmtSwitch(n *ast.StmtSwitch) { + p.printToken(n.SwitchTkn, []byte("switch")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printNode(n.Cond) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, nil) + p.printToken(n.OpenCurlyBracketTkn, p.ifNotToken(n.ColonTkn, []byte("{"))) + p.printToken(n.CaseSeparatorTkn, nil) + p.printList(n.Cases) + p.printToken(n.CloseCurlyBracketTkn, p.ifNotToken(n.ColonTkn, []byte("}"))) + p.printToken(n.EndSwitchTkn, p.ifToken(n.ColonTkn, []byte("endswitch"), nil)) + p.printToken(n.SemiColonTkn, p.ifToken(n.ColonTkn, []byte(";"), nil)) +} + +func (p *printer) StmtThrow(n *ast.StmtThrow) { + p.printToken(n.ThrowTkn, []byte("throw")) + p.printNode(n.Expr) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtTrait(n *ast.StmtTrait) { + p.printToken(n.TraitTkn, []byte("trait")) + p.printNode(n.Name) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) { + p.printToken(n.UseTkn, []byte("use")) + p.printSeparatedList(n.Traits, n.SeparatorTkns, []byte(",")) + p.printToken(n.OpenCurlyBracketTkn, p.ifNodeList(n.Adaptations, []byte("{"))) + p.printList(n.Adaptations) + p.printToken(n.CloseCurlyBracketTkn, p.ifNodeList(n.Adaptations, []byte("}"))) + p.printToken(n.SemiColonTkn, p.ifNotToken(n.OpenCurlyBracketTkn, p.ifNotNodeList(n.Adaptations, []byte(";")))) +} + +func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) { + p.printNode(n.Trait) + p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::"))) + p.printNode(n.Method) + p.printToken(n.AsTkn, []byte("as")) + p.printNode(n.Modifier) + p.printNode(n.Alias) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) { + p.printNode(n.Trait) + p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::"))) + p.printNode(n.Method) + p.printToken(n.InsteadofTkn, []byte("insteadof")) + p.printSeparatedList(n.Insteadof, n.SeparatorTkns, []byte(",")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtTry(n *ast.StmtTry) { + p.printToken(n.TryTkn, []byte("try")) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) + p.printList(n.Catches) + p.printNode(n.Finally) +} + +func (p *printer) StmtUnset(n *ast.StmtUnset) { + p.printToken(n.UnsetTkn, []byte("unset")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Vars, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtUse(n *ast.StmtUseList) { + p.printToken(n.UseTkn, []byte("use")) + p.printNode(n.Type) + p.printSeparatedList(n.Uses, n.SeparatorTkns, []byte(",")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtGroupUse(n *ast.StmtGroupUseList) { + p.printToken(n.UseTkn, []byte("use")) + p.printNode(n.Type) + p.printToken(n.LeadingNsSeparatorTkn, nil) + p.printNode(n.Prefix) + p.printToken(n.NsSeparatorTkn, []byte("\\")) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printSeparatedList(n.Uses, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) + p.printToken(n.SemiColonTkn, []byte(";")) +} + +func (p *printer) StmtUseDeclaration(n *ast.StmtUse) { + p.printNode(n.Type) + p.printToken(n.NsSeparatorTkn, nil) + p.printNode(n.Use) + p.printToken(n.AsTkn, p.ifNode(n.Alias, []byte("as"))) + p.printNode(n.Alias) +} + +func (p *printer) StmtWhile(n *ast.StmtWhile) { + p.printToken(n.WhileTkn, []byte("while")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printNode(n.Cond) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, nil) + if stmt, ok := n.Stmt.(*ast.StmtStmtList); ok && n.ColonTkn != nil { + p.printToken(stmt.OpenCurlyBracketTkn, nil) + p.printList(stmt.Stmts) + p.printToken(stmt.CloseCurlyBracketTkn, nil) + } else { + p.printNode(n.Stmt) + } + p.printToken(n.EndWhileTkn, p.ifToken(n.ColonTkn, []byte("endwhile"), nil)) + p.printToken(n.SemiColonTkn, p.ifToken(n.ColonTkn, []byte(";"), nil)) +} + +func (p *printer) ExprArray(n *ast.ExprArray) { + p.printToken(n.ArrayTkn, nil) + p.printToken(n.OpenBracketTkn, p.ifToken(n.ArrayTkn, []byte("("), []byte("["))) + p.printSeparatedList(n.Items, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseBracketTkn, p.ifToken(n.ArrayTkn, []byte(")"), []byte("]"))) +} + +func (p *printer) ExprArrayDimFetch(n *ast.ExprArrayDimFetch) { + p.printNode(n.Var) + p.printToken(n.OpenBracketTkn, []byte("[")) + p.printNode(n.Dim) + p.printToken(n.CloseBracketTkn, []byte("]")) +} + +func (p *printer) ExprArrayItem(n *ast.ExprArrayItem) { + p.printToken(n.EllipsisTkn, nil) + p.printNode(n.Key) + p.printToken(n.DoubleArrowTkn, p.ifNode(n.Key, []byte("=>"))) + p.printToken(n.AmpersandTkn, nil) + p.printNode(n.Val) +} + +func (p *printer) ExprArrowFunction(n *ast.ExprArrowFunction) { + p.printToken(n.StaticTkn, nil) + p.printToken(n.FnTkn, []byte("fn")) + p.printToken(n.AmpersandTkn, nil) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Params, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.ColonTkn, p.ifNode(n.ReturnType, []byte(":"))) + p.printNode(n.ReturnType) + p.printToken(n.DoubleArrowTkn, []byte("=>")) + p.printNode(n.Expr) +} + +func (p *printer) ExprBitwiseNot(n *ast.ExprBitwiseNot) { + p.printToken(n.TildaTkn, []byte("~")) + p.printNode(n.Expr) +} + +func (p *printer) ExprBooleanNot(n *ast.ExprBooleanNot) { + p.printToken(n.ExclamationTkn, []byte("!")) + p.printNode(n.Expr) +} + +func (p *printer) ExprBrackets(n *ast.ExprBrackets) { + p.printToken(n.OpenParenthesisTkn, nil) + p.printNode(n.Expr) + p.printToken(n.CloseParenthesisTkn, nil) +} + +func (p *printer) ExprClassConstFetch(n *ast.ExprClassConstFetch) { + p.printNode(n.Class) + p.printToken(n.DoubleColonTkn, []byte("::")) + p.printNode(n.Const) +} + +func (p *printer) ExprClone(n *ast.ExprClone) { + p.printToken(n.CloneTkn, []byte("clone")) + p.printNode(n.Expr) +} + +func (p *printer) ExprClosure(n *ast.ExprClosure) { + p.printToken(n.StaticTkn, nil) + p.printToken(n.FunctionTkn, []byte("function")) + p.printToken(n.AmpersandTkn, nil) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Params, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) + p.printToken(n.UseTkn, p.ifNodeList(n.Uses, []byte("use"))) + p.printToken(n.UseOpenParenthesisTkn, p.ifNodeList(n.Uses, []byte("("))) + p.printSeparatedList(n.Uses, n.UseSeparatorTkns, []byte(",")) + p.printToken(n.UseCloseParenthesisTkn, p.ifNodeList(n.Uses, []byte(")"))) + p.printToken(n.ColonTkn, p.ifNode(n.ReturnType, []byte(":"))) + p.printNode(n.ReturnType) + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printList(n.Stmts) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) ExprClosureUse(n *ast.ExprClosureUse) { + p.printToken(n.AmpersandTkn, nil) + p.printNode(n.Var) +} + +func (p *printer) ExprConstFetch(n *ast.ExprConstFetch) { + p.printNode(n.Const) +} + +func (p *printer) ExprEmpty(n *ast.ExprEmpty) { + p.printToken(n.EmptyTkn, []byte("empty")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printNode(n.Expr) + p.printToken(n.CloseParenthesisTkn, []byte(")")) +} + +func (p *printer) ExprErrorSuppress(n *ast.ExprErrorSuppress) { + p.printToken(n.AtTkn, []byte("@")) + p.printNode(n.Expr) +} + +func (p *printer) ExprEval(n *ast.ExprEval) { + p.printToken(n.EvalTkn, []byte("eval")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printNode(n.Expr) + p.printToken(n.CloseParenthesisTkn, []byte(")")) +} + +func (p *printer) ExprExit(n *ast.ExprExit) { + p.printToken(n.ExitTkn, []byte("exit")) + p.printToken(n.OpenParenthesisTkn, nil) + p.printNode(n.Expr) + p.printToken(n.CloseParenthesisTkn, p.ifToken(n.OpenParenthesisTkn, []byte(")"), nil)) +} + +func (p *printer) ExprFunctionCall(n *ast.ExprFunctionCall) { + p.printNode(n.Function) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Args, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) +} + +func (p *printer) ExprInclude(n *ast.ExprInclude) { + p.printToken(n.IncludeTkn, []byte("include")) + p.printNode(n.Expr) +} + +func (p *printer) ExprIncludeOnce(n *ast.ExprIncludeOnce) { + p.printToken(n.IncludeOnceTkn, []byte("include_once")) + p.printNode(n.Expr) +} + +func (p *printer) ExprInstanceOf(n *ast.ExprInstanceOf) { + p.printNode(n.Expr) + p.printToken(n.InstanceOfTkn, []byte("instanceof")) + p.printNode(n.Class) +} + +func (p *printer) ExprIsset(n *ast.ExprIsset) { + p.printToken(n.IssetTkn, []byte("isset")) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Vars, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) +} + +func (p *printer) ExprList(n *ast.ExprList) { + p.printToken(n.ListTkn, p.ifToken(n.OpenBracketTkn, nil, []byte("list"))) + p.printToken(n.OpenBracketTkn, []byte("(")) + p.printSeparatedList(n.Items, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseBracketTkn, []byte(")")) +} + +func (p *printer) ExprMethodCall(n *ast.ExprMethodCall) { + p.printNode(n.Var) + p.printToken(n.ObjectOperatorTkn, []byte("->")) + p.printToken(n.OpenCurlyBracketTkn, nil) + p.printNode(n.Method) + p.printToken(n.CloseCurlyBracketTkn, nil) + p.printToken(n.OpenParenthesisTkn, []byte("(")) + p.printSeparatedList(n.Args, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, []byte(")")) +} + +func (p *printer) ExprNew(n *ast.ExprNew) { + p.printToken(n.NewTkn, []byte("new")) + p.printNode(n.Class) + p.printToken(n.OpenParenthesisTkn, p.ifNodeList(n.Args, []byte("("))) + p.printSeparatedList(n.Args, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, p.ifNodeList(n.Args, []byte(")"))) +} + +func (p *printer) ExprPostDec(n *ast.ExprPostDec) { + p.printNode(n.Var) + p.printToken(n.DecTkn, []byte("--")) +} + +func (p *printer) ExprPostInc(n *ast.ExprPostInc) { + p.printNode(n.Var) + p.printToken(n.IncTkn, []byte("++")) +} + +func (p *printer) ExprPreDec(n *ast.ExprPreDec) { + p.printToken(n.DecTkn, []byte("--")) + p.printNode(n.Var) +} + +func (p *printer) ExprPreInc(n *ast.ExprPreInc) { + p.printToken(n.IncTkn, []byte("++")) + p.printNode(n.Var) +} + +func (p *printer) ExprPrint(n *ast.ExprPrint) { + p.printToken(n.PrintTkn, []byte("print")) + p.printNode(n.Expr) +} + +func (p *printer) ExprPropertyFetch(n *ast.ExprPropertyFetch) { + p.printNode(n.Var) + p.printToken(n.ObjectOperatorTkn, []byte("->")) + p.printToken(n.OpenCurlyBracketTkn, nil) + p.printNode(n.Prop) + p.printToken(n.CloseCurlyBracketTkn, nil) +} + +func (p *printer) ExprRequire(n *ast.ExprRequire) { + p.printToken(n.RequireTkn, []byte("require")) + p.printNode(n.Expr) +} + +func (p *printer) ExprRequireOnce(n *ast.ExprRequireOnce) { + p.printToken(n.RequireOnceTkn, []byte("require_once")) + p.printNode(n.Expr) +} + +func (p *printer) ExprShellExec(n *ast.ExprShellExec) { + p.printToken(n.OpenBacktickTkn, []byte("`")) + p.printList(n.Parts) + p.printToken(n.CloseBacktickTkn, []byte("`")) +} + +func (p *printer) ExprStaticCall(n *ast.ExprStaticCall) { + p.printNode(n.Class) + p.printToken(n.DoubleColonTkn, []byte("::")) + p.printToken(n.OpenCurlyBracketTkn, nil) + p.printNode(n.Call) + p.printToken(n.CloseCurlyBracketTkn, nil) + p.printToken(n.OpenParenthesisTkn, p.ifNodeList(n.Args, []byte("("))) + p.printSeparatedList(n.Args, n.SeparatorTkns, []byte(",")) + p.printToken(n.CloseParenthesisTkn, p.ifNodeList(n.Args, []byte(")"))) +} + +func (p *printer) ExprStaticPropertyFetch(n *ast.ExprStaticPropertyFetch) { + p.printNode(n.Class) + p.printToken(n.DoubleColonTkn, []byte("::")) + p.printNode(n.Prop) +} + +func (p *printer) ExprTernary(n *ast.ExprTernary) { + p.printNode(n.Cond) + p.printToken(n.QuestionTkn, []byte("?")) + p.printNode(n.IfTrue) + p.printToken(n.ColonTkn, []byte(":")) + p.printNode(n.IfFalse) +} + +func (p *printer) ExprUnaryMinus(n *ast.ExprUnaryMinus) { + p.printToken(n.MinusTkn, []byte("-")) + p.printNode(n.Expr) +} + +func (p *printer) ExprUnaryPlus(n *ast.ExprUnaryPlus) { + p.printToken(n.PlusTkn, []byte("+")) + p.printNode(n.Expr) +} + +func (p *printer) ExprVariable(n *ast.ExprVariable) { + p.printToken(n.DollarTkn, nil) + p.printToken(n.OpenCurlyBracketTkn, nil) + p.printNode(n.Name) + p.printToken(n.CloseCurlyBracketTkn, nil) +} + +func (p *printer) ExprYield(n *ast.ExprYield) { + p.printToken(n.YieldTkn, []byte("yield")) + p.printNode(n.Key) + p.printToken(n.DoubleArrowTkn, p.ifNode(n.Key, []byte("=>"))) + p.printNode(n.Val) +} + +func (p *printer) ExprYieldFrom(n *ast.ExprYieldFrom) { + p.printToken(n.YieldFromTkn, []byte("yield from")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssign(n *ast.ExprAssign) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignReference(n *ast.ExprAssignReference) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("=")) + p.printToken(n.AmpersandTkn, []byte("&")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignBitwiseAnd(n *ast.ExprAssignBitwiseAnd) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("&=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignBitwiseOr(n *ast.ExprAssignBitwiseOr) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("|=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignBitwiseXor(n *ast.ExprAssignBitwiseXor) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("^=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignCoalesce(n *ast.ExprAssignCoalesce) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("??=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignConcat(n *ast.ExprAssignConcat) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte(".=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignDiv(n *ast.ExprAssignDiv) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("/=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignMinus(n *ast.ExprAssignMinus) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("-=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignMod(n *ast.ExprAssignMod) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("%=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignMul(n *ast.ExprAssignMul) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("*=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignPlus(n *ast.ExprAssignPlus) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("+=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignPow(n *ast.ExprAssignPow) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("**=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignShiftLeft(n *ast.ExprAssignShiftLeft) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte("<<=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprAssignShiftRight(n *ast.ExprAssignShiftRight) { + p.printNode(n.Var) + p.printToken(n.EqualTkn, []byte(">>=")) + p.printNode(n.Expr) +} + +func (p *printer) ExprBinaryBitwiseAnd(n *ast.ExprBinaryBitwiseAnd) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("&")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryBitwiseOr(n *ast.ExprBinaryBitwiseOr) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("|")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryBitwiseXor(n *ast.ExprBinaryBitwiseXor) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("^")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryBooleanAnd(n *ast.ExprBinaryBooleanAnd) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("&&")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryBooleanOr(n *ast.ExprBinaryBooleanOr) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("||")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryCoalesce(n *ast.ExprBinaryCoalesce) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("??")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryConcat(n *ast.ExprBinaryConcat) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte(".")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryDiv(n *ast.ExprBinaryDiv) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("/")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryEqual(n *ast.ExprBinaryEqual) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("==")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryGreater(n *ast.ExprBinaryGreater) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte(">")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryGreaterOrEqual(n *ast.ExprBinaryGreaterOrEqual) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte(">=")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryIdentical(n *ast.ExprBinaryIdentical) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("===")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryLogicalAnd(n *ast.ExprBinaryLogicalAnd) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("and")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryLogicalOr(n *ast.ExprBinaryLogicalOr) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("or")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryLogicalXor(n *ast.ExprBinaryLogicalXor) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("xor")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryMinus(n *ast.ExprBinaryMinus) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("-")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryMod(n *ast.ExprBinaryMod) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("%")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryMul(n *ast.ExprBinaryMul) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("*")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryNotEqual(n *ast.ExprBinaryNotEqual) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("!=")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryNotIdentical(n *ast.ExprBinaryNotIdentical) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("!==")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryPlus(n *ast.ExprBinaryPlus) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("+")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryPow(n *ast.ExprBinaryPow) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("**")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryShiftLeft(n *ast.ExprBinaryShiftLeft) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("<<")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinaryShiftRight(n *ast.ExprBinaryShiftRight) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte(">>")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinarySmaller(n *ast.ExprBinarySmaller) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("<")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinarySmallerOrEqual(n *ast.ExprBinarySmallerOrEqual) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("<=")) + p.printNode(n.Right) +} + +func (p *printer) ExprBinarySpaceship(n *ast.ExprBinarySpaceship) { + p.printNode(n.Left) + p.printToken(n.OpTkn, []byte("<=>")) + p.printNode(n.Right) +} + +func (p *printer) ExprCastArray(n *ast.ExprCastArray) { + p.printToken(n.CastTkn, []byte("(array)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastBool(n *ast.ExprCastBool) { + p.printToken(n.CastTkn, []byte("(bool)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastDouble(n *ast.ExprCastDouble) { + p.printToken(n.CastTkn, []byte("(float)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastInt(n *ast.ExprCastInt) { + p.printToken(n.CastTkn, []byte("(int)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastObject(n *ast.ExprCastObject) { + p.printToken(n.CastTkn, []byte("(object)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastString(n *ast.ExprCastString) { + p.printToken(n.CastTkn, []byte("(string)")) + p.printNode(n.Expr) +} + +func (p *printer) ExprCastUnset(n *ast.ExprCastUnset) { + p.printToken(n.CastTkn, []byte("(unset)")) + p.printNode(n.Expr) +} + +func (p *printer) ScalarDnumber(n *ast.ScalarDnumber) { + p.printToken(n.NumberTkn, n.Value) +} + +func (p *printer) ScalarEncapsed(n *ast.ScalarEncapsed) { + p.printToken(n.OpenQuoteTkn, []byte("\"")) + p.printList(n.Parts) + p.printToken(n.CloseQuoteTkn, []byte("\"")) +} + +func (p *printer) ScalarEncapsedStringPart(n *ast.ScalarEncapsedStringPart) { + p.printToken(n.EncapsedStrTkn, n.Value) +} + +func (p *printer) ScalarEncapsedStringVar(n *ast.ScalarEncapsedStringVar) { + p.printToken(n.DollarOpenCurlyBracketTkn, []byte("${")) + p.printNode(n.Name) + p.printToken(n.OpenSquareBracketTkn, p.ifNode(n.Dim, []byte("["))) + p.printNode(n.Dim) + p.printToken(n.CloseSquareBracketTkn, p.ifNode(n.Dim, []byte("]"))) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) ScalarEncapsedStringBrackets(n *ast.ScalarEncapsedStringBrackets) { + p.printToken(n.OpenCurlyBracketTkn, []byte("{")) + p.printNode(n.Var) + p.printToken(n.CloseCurlyBracketTkn, []byte("}")) +} + +func (p *printer) ScalarHeredoc(n *ast.ScalarHeredoc) { + p.printToken(n.OpenHeredocTkn, []byte("<<testHTML")}, + &ast.StmtEcho{ + Exprs: []ast.Vertex{ + &ast.ScalarString{ + Value: []byte(`"a"`), + }, + }, + }, + &ast.StmtInlineHtml{Value: []byte("
HTML
")}, + &ast.StmtEcho{ + Exprs: []ast.Vertex{ + &ast.ScalarString{ + Value: []byte(`"b"`), + }, + }, + }, + }, + } + n.Accept(p) + + expected := `
HTML
HTML
>=$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// binary + +func TestPrinterPrintBinaryBitwiseAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryBitwiseAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a&$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryBitwiseOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryBitwiseOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a|$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryBitwiseXor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryBitwiseXor{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a^$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryBooleanAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryBooleanAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a&&$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryBooleanOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryBooleanOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a||$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryCoalesce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryCoalesce{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a??$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryConcat(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryConcat{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a.$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryDiv(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryDiv{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a/$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a==$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryGreaterOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryGreaterOrEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a>=$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryGreater(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryGreater{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a>$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryIdentical{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a===$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryLogicalAnd(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryLogicalAnd{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a and$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryLogicalOr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryLogicalOr{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a or$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryLogicalXor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryLogicalXor{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a xor$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryMinus{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a-$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryMod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryMod{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a%$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryMul(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryMul{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a*$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryNotEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryNotEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a!=$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryNotIdentical(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryNotIdentical{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a!==$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryPlus{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a+$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryPow(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryPow{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a**$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryShiftLeft(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryShiftLeft{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a<<$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinaryShiftRight(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinaryShiftRight{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a>>$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinarySmallerOrEqual(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinarySmallerOrEqual{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a<=$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinarySmaller(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinarySmaller{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a<$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBinarySpaceship(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBinarySpaceship{ + Left: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Right: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a<=>$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// cast + +func TestPrinterPrintArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastArray{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(array)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintBool(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastBool{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(bool)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintDouble(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastDouble{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(float)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintInt(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastInt{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(int)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintObject(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastObject{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(object)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintString(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastString{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(string)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintUnset(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprCastUnset{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `(unset)$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// expr + +func TestPrinterPrintExprArrayDimFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArrayDimFetch{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Dim: &ast.ScalarLnumber{Value: []byte("1")}, + } + n.Accept(p) + + expected := `$var[1]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprArrayItemWithKey(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArrayItem{ + Key: &ast.ScalarString{Value: []byte("'Hello'")}, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + } + n.Accept(p) + + expected := `'Hello'=>$world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprArrayItem(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + } + n.Accept(p) + + expected := `$world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprArrayItem_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArrayItem{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + } + n.Accept(p) + + expected := `&$world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprArrayItemUnpack(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArrayItem{ + EllipsisTkn: &token.Token{ + Value: []byte("..."), + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + } + n.Accept(p) + + expected := `...$world` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArray{ + ArrayTkn: &token.Token{ + Value: []byte("array"), + }, + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Key: &ast.ScalarString{Value: []byte("'Hello'")}, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + }, + &ast.ExprArrayItem{ + Key: &ast.ScalarLnumber{Value: []byte("2")}, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + }, + } + n.Accept(p) + + expected := `array('Hello'=>$world,2=>&$var,$var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprBitwiseNot(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBitwiseNot{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `~$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprBooleanNot(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBooleanNot{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `!$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprBracket(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprBooleanNot{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `!$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprClassConstFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprClassConstFetch{ + Class: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Const: &ast.Identifier{ + Value: []byte("CONST"), + }, + } + n.Accept(p) + + expected := `$var::CONST` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprClone(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprClone{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `clone$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprClosureUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprClosureUse{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$foo")}, + }, + } + n.Accept(p) + + expected := `$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprClosureUse_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprClosureUse{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$foo")}, + }, + } + n.Accept(p) + + expected := `&$foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprClosure(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprClosure{ + StaticTkn: &token.Token{ + Value: []byte("static"), + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Params: []ast.Vertex{ + &ast.Parameter{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + }, + Uses: []ast.Vertex{ + &ast.ExprClosureUse{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.ExprClosureUse{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + ReturnType: &ast.NameFullyQualified{ + Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + } + n.Accept(p) + + 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 TestPrinterPrintExprArrowFunction(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtExpression{ + Expr: &ast.ExprArrowFunction{ + StaticTkn: &token.Token{ + Value: []byte("static"), + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Params: []ast.Vertex{ + &ast.Parameter{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + }, + ReturnType: &ast.NameFullyQualified{ + Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}, + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + } + n.Accept(p) + + expected := `static fn&(&$var):\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).WithState(printer.PrinterStatePHP) + n := &ast.ExprConstFetch{ + Const: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("null")}}}, + } + n.Accept(p) + + expected := "null" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprEmpty{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `empty($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrettyPrinterrorSuppress(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprErrorSuppress{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `@$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintEval(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprEval{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `eval($var)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExit(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprExit{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `exit$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintDie(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprExit{ + ExitTkn: &token.Token{ + Value: []byte("die"), + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.ExprFunctionCall{ + Function: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Args: []ast.Vertex{ + &ast.Argument{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.Argument{ + VariadicTkn: &token.Token{ + Value: []byte("..."), + }, + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + }, + }, + } + n.Accept(p) + + expected := `$var(&$a,...$b,$c)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintInclude(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprInclude{ + Expr: &ast.ScalarString{Value: []byte("'path'")}, + } + n.Accept(p) + + expected := `include'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintIncludeOnce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprIncludeOnce{ + Expr: &ast.ScalarString{Value: []byte("'path'")}, + } + n.Accept(p) + + expected := `include_once'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintInstanceOf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprInstanceOf{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Class: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + } + n.Accept(p) + + expected := `$var instanceof Foo` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintIsset(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprIsset{ + Vars: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + } + n.Accept(p) + + expected := `isset($a,$b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + }, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `list($a,list($b,$c))` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintMethodCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprMethodCall{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$foo")}, + }, + Method: &ast.Identifier{Value: []byte("bar")}, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + } + n.Accept(p) + + expected := `$foo->bar($a,$b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintNew(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprNew{ + Class: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("Foo"), + }, + }, + }, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + } + n.Accept(p) + + expected := `new Foo($a,$b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPostDec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPostDec{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `$var--` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPostInc(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPostInc{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `$var++` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPreDec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPreDec{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `--$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPreInc(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPreInc{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `++$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPrint(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPrint{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `print$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprPropertyFetch{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$foo")}, + }, + Prop: &ast.Identifier{Value: []byte("bar")}, + } + n.Accept(p) + + expected := `$foo->bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintRequire(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprRequire{ + Expr: &ast.ScalarString{Value: []byte("'path'")}, + } + n.Accept(p) + + expected := `require'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintRequireOnce(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprRequireOnce{ + Expr: &ast.ScalarString{Value: []byte("'path'")}, + } + n.Accept(p) + + expected := `require_once'path'` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintShellExec(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprShellExec{ + Parts: []ast.Vertex{ + &ast.ScalarEncapsedStringPart{Value: []byte("hello ")}, + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + &ast.ScalarEncapsedStringPart{Value: []byte("!")}, + }, + } + n.Accept(p) + + expected := "`hello $world!`" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintExprShortArray(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprArray{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Key: &ast.ScalarString{Value: []byte("'Hello'")}, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$world")}, + }, + }, + &ast.ExprArrayItem{ + Key: &ast.ScalarLnumber{Value: []byte("2")}, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + }, + } + n.Accept(p) + + expected := `['Hello'=>$world,2=>&$var,$var]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintShortList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprList{ + OpenBracketTkn: &token.Token{ + Value: []byte("["), + }, + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprList{ + Items: []ast.Vertex{ + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + &ast.ExprArrayItem{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + }, + }, + }, + }, + }, + CloseBracketTkn: &token.Token{ + Value: []byte("]"), + }, + } + n.Accept(p) + + expected := `[$a,list($b,$c)]` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStaticCall(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprStaticCall{ + Class: &ast.Identifier{Value: []byte("Foo")}, + Call: &ast.Identifier{Value: []byte("bar")}, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + } + n.Accept(p) + + expected := `Foo::bar($a,$b)` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStaticPropertyFetch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprStaticPropertyFetch{ + Class: &ast.Identifier{Value: []byte("Foo")}, + Prop: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$bar")}, + }, + } + n.Accept(p) + + expected := `Foo::$bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintTernary(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprTernary{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + IfFalse: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + } + n.Accept(p) + + expected := `$a?:$b` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintTernaryFull(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprTernary{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + IfTrue: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + IfFalse: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + } + n.Accept(p) + + expected := `$a?$b:$c` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintUnaryMinus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprUnaryMinus{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `-$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintUnaryPlus(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprUnaryPlus{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `+$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintVariable(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprVariable{ + DollarTkn: &token.Token{ + Value: []byte("$"), + }, + OpenCurlyBracketTkn: &token.Token{ + Value: []byte("{"), + }, + Name: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + CloseCurlyBracketTkn: &token.Token{ + Value: []byte("}"), + }, + } + n.Accept(p) + + expected := `${$var}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintYieldFrom(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprYieldFrom{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `yield from$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintYield(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprYield{ + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `yield$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintYieldFull(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.ExprYield{ + Key: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$k")}, + }, + Val: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `yield$k=>$var` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +// stmt + +func TestPrinterPrintAltElseIf(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + } + n.Accept(p) + + expected := `elseif($a):$b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltElseIfEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{}, + } + n.Accept(p) + + expected := `elseif($a):` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltElse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtElse{ + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + } + n.Accept(p) + + expected := `else:$b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltElseEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtElse{ + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{}, + } + n.Accept(p) + + expected := `else:` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltFor(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtFor{ + Init: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + Cond: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + Loop: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$d")}, + }}, + }, + }, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.StmtForeach{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Key: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$key")}, + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$val")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$d")}, + }}, + }, + }, + } + n.Accept(p) + + expected := `foreach($var as$key=>$val):$d;endforeach;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltForeach_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtForeach{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Key: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$key")}, + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$val")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$d")}, + }}, + }, + }, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$d")}, + }}, + }, + }, + ElseIf: []ast.Vertex{ + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + }, + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{}, + }, + }, + Else: &ast.StmtElse{ + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + }, + } + n.Accept(p) + + expected := `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 TestPrinterPrintStmtAltSwitch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtSwitch{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Cases: []ast.Vertex{ + &ast.StmtCase{ + Cond: &ast.ScalarString{Value: []byte("'a'")}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + &ast.StmtCase{ + Cond: &ast.ScalarString{Value: []byte("'b'")}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + }, + } + n.Accept(p) + + expected := `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 TestPrinterPrintAltWhile(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtWhile{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + ColonTkn: &token.Token{ + Value: []byte(":"), + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + } + n.Accept(p) + + expected := `while($a):$b;endwhile;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtBreak(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtBreak{ + Expr: &ast.ScalarLnumber{ + Value: []byte("1"), + }, + } + n.Accept(p) + + expected := "break 1;" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtCase(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtCase{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + } + n.Accept(p) + + expected := `case$a:$a;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtCaseEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtCase{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmts: []ast.Vertex{}, + } + n.Accept(p) + + expected := "case$a:" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtCatch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtCatch{ + Types: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Exception")}}}, + &ast.NameFullyQualified{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("RuntimeException")}}}, + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$e")}, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + } + n.Accept(p) + + expected := `catch(Exception|\RuntimeException$e){$a;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtClassMethod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtClassMethod{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Name: &ast.Identifier{Value: []byte("foo")}, + Params: []ast.Vertex{ + &ast.Parameter{ + Type: &ast.Nullable{Expr: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("int")}}}}, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + DefaultValue: &ast.ExprConstFetch{Const: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("null")}}}}, + }, + &ast.Parameter{ + VariadicTkn: &token.Token{ + Value: []byte("..."), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + ReturnType: &ast.Name{ + Parts: []ast.Vertex{&ast.NamePart{Value: []byte("void")}}, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + } + n.Accept(p) + + 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 TestPrinterPrintStmtAbstractClassMethod(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtClassMethod{ + Modifiers: []ast.Vertex{ + &ast.Identifier{Value: []byte("public")}, + &ast.Identifier{Value: []byte("static")}, + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Name: &ast.Identifier{Value: []byte("foo")}, + Params: []ast.Vertex{ + &ast.Parameter{ + Type: &ast.Nullable{Expr: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("int")}}}}, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + DefaultValue: &ast.ExprConstFetch{Const: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("null")}}}}, + }, + &ast.Parameter{ + VariadicTkn: &token.Token{ + Value: []byte("..."), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + ReturnType: &ast.Name{ + Parts: []ast.Vertex{&ast.NamePart{Value: []byte("void")}}, + }, + Stmt: &ast.StmtNop{}, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.StmtClass{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("abstract")}}, + Name: &ast.Identifier{Value: []byte("Foo")}, + Extends: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + Implements: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Quuz")}}}, + }, + Stmts: []ast.Vertex{ + &ast.StmtClassConstList{ + Modifiers: []ast.Vertex{ + &ast.Identifier{Value: []byte("public")}, + &ast.Identifier{Value: []byte("static")}, + }, + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'bar'")}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `abstract class Foo extends Bar implements Baz,Quuz{public static const FOO='bar';}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtAnonymousClass(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtClass{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("abstract")}}, + Args: []ast.Vertex{ + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.Argument{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + Extends: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + Implements: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Quuz")}}}, + }, + Stmts: []ast.Vertex{ + &ast.StmtClassConstList{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'bar'")}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `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 TestPrinterPrintStmtClassConstList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtClassConstList{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'a'")}, + }, + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("BAR")}, + Expr: &ast.ScalarString{Value: []byte("'b'")}, + }, + }, + } + n.Accept(p) + + expected := `public const FOO='a',BAR='b';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtConstList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtConstList{ + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'a'")}, + }, + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("BAR")}, + Expr: &ast.ScalarString{Value: []byte("'b'")}, + }, + }, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'BAR'")}, + } + n.Accept(p) + + expected := "FOO='BAR'" + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtContinue(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtContinue{ + Expr: &ast.ScalarLnumber{ + Value: []byte("1"), + }, + } + n.Accept(p) + + expected := `continue 1;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDeclareStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDeclare{ + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'bar'")}, + }, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + } + n.Accept(p) + + expected := `declare(FOO='bar'){;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDeclareExpr(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDeclare{ + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'bar'")}, + }, + }, + Stmt: &ast.StmtExpression{Expr: &ast.ScalarString{Value: []byte("'bar'")}}, + } + n.Accept(p) + + expected := `declare(FOO='bar')'bar';` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDeclareNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDeclare{ + Consts: []ast.Vertex{ + &ast.StmtConstant{ + Name: &ast.Identifier{Value: []byte("FOO")}, + Expr: &ast.ScalarString{Value: []byte("'bar'")}, + }, + }, + Stmt: &ast.StmtNop{}, + } + n.Accept(p) + + expected := `declare(FOO='bar');` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDefalut(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDefault{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + } + n.Accept(p) + + expected := `default:$a;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDefalutEmpty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDefault{ + Stmts: []ast.Vertex{}, + } + n.Accept(p) + + expected := `default:` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDo_Expression(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDo{ + Cond: &ast.ScalarLnumber{Value: []byte("1")}, + Stmt: &ast.StmtExpression{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + } + n.Accept(p) + + expected := `do$a;while(1);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtDo_StmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtDo{ + Cond: &ast.ScalarLnumber{Value: []byte("1")}, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + } + n.Accept(p) + + 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) + n := &ast.Root{ + Stmts: []ast.Vertex{ + &ast.StmtEcho{ + Exprs: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `$v){;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtForeach_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtForeach{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Key: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$k")}, + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$v")}, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + } + n.Accept(p) + + expected := `foreach($a as$k=>&$v){;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtFunction(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtFunction{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Name: &ast.Identifier{Value: []byte("foo")}, + Params: []ast.Vertex{ + &ast.Parameter{ + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + }, + }, + ReturnType: &ast.NameFullyQualified{ + Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}, + }, + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + } + n.Accept(p) + + 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).WithState(printer.PrinterStatePHP) + n := &ast.StmtGlobal{ + Vars: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + } + n.Accept(p) + + expected := `global$a,$b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtGoto(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtGoto{ + Label: &ast.Identifier{Value: []byte("FOO")}, + } + n.Accept(p) + + expected := `goto FOO;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintHaltCompiler(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtHaltCompiler{} + n.Accept(p) + + expected := `__halt_compiler();` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintIfExpression(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmt: &ast.StmtExpression{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + ElseIf: []ast.Vertex{ + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$d")}, + }, + }, + }, + }, + }, + &ast.StmtElseIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$e")}, + }, + Stmt: &ast.StmtNop{}, + }, + }, + Else: &ast.StmtElse{ + Stmt: &ast.StmtExpression{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$f")}, + }, + }, + }, + } + n.Accept(p) + + expected := `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 TestPrinterPrintIfStmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `if($a){$b;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintIfNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtIf{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmt: &ast.StmtNop{}, + } + n.Accept(p) + + expected := `if($a);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintInlineHtml(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.Root{ + Stmts: []ast.Vertex{ + &ast.StmtInlineHtml{ + Value: []byte("test"), + }, + }, + } + n.Accept(p) + + expected := `test` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintInterface(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtInterface{ + Name: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Extends: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + }, + Stmts: []ast.Vertex{ + &ast.StmtClassMethod{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, + Name: &ast.Identifier{Value: []byte("foo")}, + Params: []ast.Vertex{}, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `interface Foo extends Bar,Baz{public function foo(){$a;}}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintLabel(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtLabel{ + Name: &ast.Identifier{Value: []byte("FOO")}, + } + n.Accept(p) + + expected := `FOO:` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintNamespace(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtNamespace{ + Name: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + } + n.Accept(p) + + expected := `namespace Foo;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintNamespaceWithStmts(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtNamespace{ + Name: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + } + n.Accept(p) + + expected := `namespace Foo{$a;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintNop(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtNop{} + n.Accept(p) + + expected := `;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintPropertyList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtPropertyList{ + Modifiers: []ast.Vertex{ + &ast.Identifier{Value: []byte("public")}, + &ast.Identifier{Value: []byte("static")}, + }, + Type: &ast.Name{ + Parts: []ast.Vertex{ + &ast.NamePart{ + Value: []byte("Foo"), + }, + }, + }, + Props: []ast.Vertex{ + &ast.StmtProperty{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Expr: &ast.ScalarString{Value: []byte("'a'")}, + }, + &ast.StmtProperty{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + } + n.Accept(p) + + expected := `public static Foo$a='a',$b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintProperty(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtProperty{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + n.Accept(p) + + expected := `$a=1` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintReturn(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtReturn{ + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + n.Accept(p) + + expected := `return 1;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStaticVar(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtStaticVar{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Expr: &ast.ScalarLnumber{Value: []byte("1")}, + } + n.Accept(p) + + expected := `$a=1` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStatic(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtStatic{ + Vars: []ast.Vertex{ + &ast.StmtStaticVar{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + }, + &ast.StmtStaticVar{ + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + }, + } + n.Accept(p) + + expected := `static$a,$b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + } + n.Accept(p) + + expected := `{$a;$b;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtListNested(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$c")}, + }}, + }, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `{$a;{$b;{$c;}}}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtSwitch(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtSwitch{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + Cases: []ast.Vertex{ + &ast.StmtCase{ + Cond: &ast.ScalarString{Value: []byte("'a'")}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + &ast.StmtCase{ + Cond: &ast.ScalarString{Value: []byte("'b'")}, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + }, + } + n.Accept(p) + + expected := `switch($var){case'a':$a;case'b':$b;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtThrow(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtThrow{ + Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$var")}, + }, + } + n.Accept(p) + + expected := `throw$var;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtTraitUseAlias(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTraitUseAlias{ + Trait: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Method: &ast.Identifier{Value: []byte("a")}, + Modifier: &ast.Identifier{Value: []byte("public")}, + Alias: &ast.Identifier{Value: []byte("b")}, + } + n.Accept(p) + + expected := `Foo::a as public b;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtTraitUsePrecedence(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTraitUsePrecedence{ + Trait: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Method: &ast.Identifier{Value: []byte("a")}, + Insteadof: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + }, + } + n.Accept(p) + + expected := `Foo::a insteadof Bar,Baz;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtTraitUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTraitUse{ + Traits: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + }, + } + n.Accept(p) + + expected := `use Foo,Bar;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtTraitAdaptations(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTraitUse{ + Traits: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Bar")}}}, + }, + Adaptations: []ast.Vertex{ + &ast.StmtTraitUseAlias{ + Trait: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Method: &ast.Identifier{Value: []byte("a")}, + Alias: &ast.Identifier{Value: []byte("b")}, + }, + }, + } + n.Accept(p) + + expected := `use Foo,Bar{Foo::a as b;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintTrait(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTrait{ + Name: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Stmts: []ast.Vertex{ + &ast.StmtClassMethod{ + Modifiers: []ast.Vertex{&ast.Identifier{Value: []byte("public")}}, + Name: &ast.Identifier{Value: []byte("foo")}, + Params: []ast.Vertex{}, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + }, + }, + } + n.Accept(p) + + expected := `trait Foo{public function foo(){$a;}}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtTry(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtTry{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + Catches: []ast.Vertex{ + &ast.StmtCatch{ + Types: []ast.Vertex{ + &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Exception")}}}, + &ast.NameFullyQualified{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("RuntimeException")}}}, + }, + Var: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$e")}, + }, + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }}, + }, + }, + }, + Finally: &ast.StmtFinally{ + Stmts: []ast.Vertex{ + &ast.StmtNop{}, + }, + }, + } + n.Accept(p) + + expected := `try{$a;}catch(Exception|\RuntimeException$e){$b;}finally{;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtUnset(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtUnset{ + Vars: []ast.Vertex{ + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$b")}, + }, + }, + } + n.Accept(p) + + expected := `unset($a,$b);` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtUseList{ + Type: &ast.Identifier{Value: []byte("function")}, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Alias: &ast.Identifier{Value: []byte("Bar")}, + }, + &ast.StmtUse{ + Use: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + }, + }, + } + n.Accept(p) + + expected := `use function Foo as Bar,Baz;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintStmtGroupUse(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtGroupUseList{ + Type: &ast.Identifier{Value: []byte("function")}, + Prefix: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Uses: []ast.Vertex{ + &ast.StmtUse{ + Use: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Alias: &ast.Identifier{Value: []byte("Bar")}, + }, + &ast.StmtUse{ + Use: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Baz")}}}, + }, + }, + } + n.Accept(p) + + expected := `use function Foo\{Foo as Bar,Baz};` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintUseDeclaration(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtUse{ + Type: &ast.Identifier{Value: []byte("function")}, + Use: &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("Foo")}}}, + Alias: &ast.Identifier{Value: []byte("Bar")}, + } + n.Accept(p) + + expected := `function Foo as Bar` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintWhileStmtList(t *testing.T) { + o := bytes.NewBufferString("") + + p := printer.NewPrinter(o).WithState(printer.PrinterStatePHP) + n := &ast.StmtWhile{ + Cond: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }, + Stmt: &ast.StmtStmtList{ + Stmts: []ast.Vertex{ + &ast.StmtExpression{Expr: &ast.ExprVariable{ + Name: &ast.Identifier{Value: []byte("$a")}, + }}, + }, + }, + } + n.Accept(p) + + expected := `while($a){$a;}` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} diff --git a/pkg/visitor/traverser/traverser.go b/pkg/visitor/traverser/traverser.go new file mode 100644 index 0000000..8cc0e30 --- /dev/null +++ b/pkg/visitor/traverser/traverser.go @@ -0,0 +1,1164 @@ +package traverser + +import ( + "github.com/z7zmey/php-parser/pkg/ast" +) + +type Traverser struct { + v ast.Visitor +} + +func NewTraverser(v ast.Visitor) *Traverser { + return &Traverser{ + v: v, + } +} + +func (t *Traverser) Traverse(n ast.Vertex) { + if n != nil { + n.Accept(t) + } +} + +func (t *Traverser) Root(n *ast.Root) { + n.Accept(t.v) + + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) Nullable(n *ast.Nullable) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) Parameter(n *ast.Parameter) { + n.Accept(t.v) + + t.Traverse(n.Type) + t.Traverse(n.Var) + t.Traverse(n.DefaultValue) +} + +func (t *Traverser) Identifier(n *ast.Identifier) { + n.Accept(t.v) +} + +func (t *Traverser) Argument(n *ast.Argument) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtBreak(n *ast.StmtBreak) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtCase(n *ast.StmtCase) { + n.Accept(t.v) + + t.Traverse(n.Cond) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtCatch(n *ast.StmtCatch) { + n.Accept(t.v) + + for _, nn := range n.Types { + nn.Accept(t) + } + t.Traverse(n.Var) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtClass(n *ast.StmtClass) { + n.Accept(t.v) + + for _, nn := range n.Modifiers { + nn.Accept(t) + } + t.Traverse(n.Name) + for _, nn := range n.Args { + nn.Accept(t) + } + t.Traverse(n.Extends) + for _, nn := range n.Implements { + nn.Accept(t) + } + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtClassConstList(n *ast.StmtClassConstList) { + n.Accept(t.v) + + for _, nn := range n.Modifiers { + nn.Accept(t) + } + for _, nn := range n.Consts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtClassMethod(n *ast.StmtClassMethod) { + n.Accept(t.v) + + for _, nn := range n.Modifiers { + nn.Accept(t) + } + t.Traverse(n.Name) + for _, nn := range n.Params { + nn.Accept(t) + } + t.Traverse(n.ReturnType) + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtConstList(n *ast.StmtConstList) { + n.Accept(t.v) + + for _, nn := range n.Consts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtConstant(n *ast.StmtConstant) { + n.Accept(t.v) + + t.Traverse(n.Name) + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtContinue(n *ast.StmtContinue) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtDeclare(n *ast.StmtDeclare) { + n.Accept(t.v) + + for _, nn := range n.Consts { + nn.Accept(t) + } + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtDefault(n *ast.StmtDefault) { + n.Accept(t.v) + + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtDo(n *ast.StmtDo) { + n.Accept(t.v) + + t.Traverse(n.Stmt) + t.Traverse(n.Cond) +} + +func (t *Traverser) StmtEcho(n *ast.StmtEcho) { + n.Accept(t.v) + + for _, nn := range n.Exprs { + nn.Accept(t) + } +} + +func (t *Traverser) StmtElse(n *ast.StmtElse) { + n.Accept(t.v) + + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtElseIf(n *ast.StmtElseIf) { + n.Accept(t.v) + + t.Traverse(n.Cond) + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtExpression(n *ast.StmtExpression) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtFinally(n *ast.StmtFinally) { + n.Accept(t.v) + + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtFor(n *ast.StmtFor) { + n.Accept(t.v) + + for _, nn := range n.Init { + nn.Accept(t) + } + for _, nn := range n.Cond { + nn.Accept(t) + } + for _, nn := range n.Loop { + nn.Accept(t) + } + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtForeach(n *ast.StmtForeach) { + n.Accept(t.v) + + t.Traverse(n.Expr) + t.Traverse(n.Key) + t.Traverse(n.Var) + t.Traverse(n.Stmt) +} + +func (t *Traverser) StmtFunction(n *ast.StmtFunction) { + n.Accept(t.v) + + t.Traverse(n.Name) + for _, nn := range n.Params { + nn.Accept(t) + } + t.Traverse(n.ReturnType) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtGlobal(n *ast.StmtGlobal) { + n.Accept(t.v) + + for _, nn := range n.Vars { + nn.Accept(t) + } +} + +func (t *Traverser) StmtGoto(n *ast.StmtGoto) { + n.Accept(t.v) + + t.Traverse(n.Label) +} + +func (t *Traverser) StmtHaltCompiler(n *ast.StmtHaltCompiler) { + n.Accept(t.v) +} + +func (t *Traverser) StmtIf(n *ast.StmtIf) { + n.Accept(t.v) + + t.Traverse(n.Cond) + t.Traverse(n.Stmt) + for _, nn := range n.ElseIf { + nn.Accept(t) + } + t.Traverse(n.Else) +} + +func (t *Traverser) StmtInlineHtml(n *ast.StmtInlineHtml) { + n.Accept(t.v) +} + +func (t *Traverser) StmtInterface(n *ast.StmtInterface) { + n.Accept(t.v) + + t.Traverse(n.Name) + for _, nn := range n.Extends { + nn.Accept(t) + } + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtLabel(n *ast.StmtLabel) { + n.Accept(t.v) + + t.Traverse(n.Name) +} + +func (t *Traverser) StmtNamespace(n *ast.StmtNamespace) { + n.Accept(t.v) + + t.Traverse(n.Name) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtNop(n *ast.StmtNop) { + n.Accept(t.v) +} + +func (t *Traverser) StmtProperty(n *ast.StmtProperty) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtPropertyList(n *ast.StmtPropertyList) { + n.Accept(t.v) + + for _, nn := range n.Modifiers { + nn.Accept(t) + } + t.Traverse(n.Type) + for _, nn := range n.Props { + nn.Accept(t) + } +} + +func (t *Traverser) StmtReturn(n *ast.StmtReturn) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtStatic(n *ast.StmtStatic) { + n.Accept(t.v) + + for _, nn := range n.Vars { + nn.Accept(t) + } +} + +func (t *Traverser) StmtStaticVar(n *ast.StmtStaticVar) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtStmtList(n *ast.StmtStmtList) { + n.Accept(t.v) + + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtSwitch(n *ast.StmtSwitch) { + n.Accept(t.v) + + t.Traverse(n.Cond) + for _, nn := range n.Cases { + nn.Accept(t) + } +} + +func (t *Traverser) StmtThrow(n *ast.StmtThrow) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) StmtTrait(n *ast.StmtTrait) { + n.Accept(t.v) + + t.Traverse(n.Name) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) StmtTraitUse(n *ast.StmtTraitUse) { + n.Accept(t.v) + + for _, nn := range n.Traits { + nn.Accept(t) + } + for _, nn := range n.Adaptations { + nn.Accept(t) + } +} + +func (t *Traverser) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) { + n.Accept(t.v) + + t.Traverse(n.Trait) + t.Traverse(n.Method) + t.Traverse(n.Modifier) + t.Traverse(n.Alias) +} + +func (t *Traverser) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) { + n.Accept(t.v) + + t.Traverse(n.Trait) + t.Traverse(n.Method) + for _, nn := range n.Insteadof { + nn.Accept(t) + } +} + +func (t *Traverser) StmtTry(n *ast.StmtTry) { + n.Accept(t.v) + + for _, nn := range n.Stmts { + nn.Accept(t) + } + for _, nn := range n.Catches { + nn.Accept(t) + } + t.Traverse(n.Finally) +} + +func (t *Traverser) StmtUnset(n *ast.StmtUnset) { + n.Accept(t.v) + + for _, nn := range n.Vars { + nn.Accept(t) + } +} + +func (t *Traverser) StmtUse(n *ast.StmtUseList) { + n.Accept(t.v) + + t.Traverse(n.Type) + for _, nn := range n.Uses { + nn.Accept(t) + } +} + +func (t *Traverser) StmtGroupUse(n *ast.StmtGroupUseList) { + n.Accept(t.v) + + t.Traverse(n.Type) + t.Traverse(n.Prefix) + for _, nn := range n.Uses { + nn.Accept(t) + } +} + +func (t *Traverser) StmtUseDeclaration(n *ast.StmtUse) { + n.Accept(t.v) + + t.Traverse(n.Type) + t.Traverse(n.Use) + t.Traverse(n.Alias) +} + +func (t *Traverser) StmtWhile(n *ast.StmtWhile) { + n.Accept(t.v) + + t.Traverse(n.Cond) + t.Traverse(n.Stmt) +} + +func (t *Traverser) ExprArray(n *ast.ExprArray) { + n.Accept(t.v) + + for _, nn := range n.Items { + nn.Accept(t) + } +} + +func (t *Traverser) ExprArrayDimFetch(n *ast.ExprArrayDimFetch) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Dim) +} + +func (t *Traverser) ExprArrayItem(n *ast.ExprArrayItem) { + n.Accept(t.v) + + t.Traverse(n.Key) + t.Traverse(n.Val) +} + +func (t *Traverser) ExprArrowFunction(n *ast.ExprArrowFunction) { + n.Accept(t.v) + + for _, nn := range n.Params { + nn.Accept(t) + } + t.Traverse(n.ReturnType) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprBitwiseNot(n *ast.ExprBitwiseNot) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprBooleanNot(n *ast.ExprBooleanNot) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprBrackets(n *ast.ExprBrackets) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprClassConstFetch(n *ast.ExprClassConstFetch) { + n.Accept(t.v) + + t.Traverse(n.Class) + t.Traverse(n.Const) +} + +func (t *Traverser) ExprClone(n *ast.ExprClone) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprClosure(n *ast.ExprClosure) { + n.Accept(t.v) + + for _, nn := range n.Params { + nn.Accept(t) + } + for _, nn := range n.Uses { + nn.Accept(t) + } + t.Traverse(n.ReturnType) + for _, nn := range n.Stmts { + nn.Accept(t) + } +} + +func (t *Traverser) ExprClosureUse(n *ast.ExprClosureUse) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ExprConstFetch(n *ast.ExprConstFetch) { + n.Accept(t.v) + + t.Traverse(n.Const) +} + +func (t *Traverser) ExprEmpty(n *ast.ExprEmpty) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprErrorSuppress(n *ast.ExprErrorSuppress) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprEval(n *ast.ExprEval) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprExit(n *ast.ExprExit) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprFunctionCall(n *ast.ExprFunctionCall) { + n.Accept(t.v) + + t.Traverse(n.Function) + for _, nn := range n.Args { + nn.Accept(t) + } +} + +func (t *Traverser) ExprInclude(n *ast.ExprInclude) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprIncludeOnce(n *ast.ExprIncludeOnce) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprInstanceOf(n *ast.ExprInstanceOf) { + n.Accept(t.v) + + t.Traverse(n.Expr) + t.Traverse(n.Class) +} + +func (t *Traverser) ExprIsset(n *ast.ExprIsset) { + n.Accept(t.v) + + for _, nn := range n.Vars { + nn.Accept(t) + } +} + +func (t *Traverser) ExprList(n *ast.ExprList) { + n.Accept(t.v) + + for _, nn := range n.Items { + nn.Accept(t) + } +} + +func (t *Traverser) ExprMethodCall(n *ast.ExprMethodCall) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Method) + for _, nn := range n.Args { + nn.Accept(t) + } +} + +func (t *Traverser) ExprNew(n *ast.ExprNew) { + n.Accept(t.v) + + t.Traverse(n.Class) + for _, nn := range n.Args { + nn.Accept(t) + } +} + +func (t *Traverser) ExprPostDec(n *ast.ExprPostDec) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ExprPostInc(n *ast.ExprPostInc) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ExprPreDec(n *ast.ExprPreDec) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ExprPreInc(n *ast.ExprPreInc) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ExprPrint(n *ast.ExprPrint) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprPropertyFetch(n *ast.ExprPropertyFetch) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Prop) +} + +func (t *Traverser) ExprRequire(n *ast.ExprRequire) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprRequireOnce(n *ast.ExprRequireOnce) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprShellExec(n *ast.ExprShellExec) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) ExprStaticCall(n *ast.ExprStaticCall) { + n.Accept(t.v) + + t.Traverse(n.Class) + t.Traverse(n.Call) + for _, nn := range n.Args { + nn.Accept(t) + } +} + +func (t *Traverser) ExprStaticPropertyFetch(n *ast.ExprStaticPropertyFetch) { + n.Accept(t.v) + + t.Traverse(n.Class) + t.Traverse(n.Prop) +} + +func (t *Traverser) ExprTernary(n *ast.ExprTernary) { + n.Accept(t.v) + + t.Traverse(n.Cond) + t.Traverse(n.IfTrue) + t.Traverse(n.IfFalse) +} + +func (t *Traverser) ExprUnaryMinus(n *ast.ExprUnaryMinus) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprUnaryPlus(n *ast.ExprUnaryPlus) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprVariable(n *ast.ExprVariable) { + n.Accept(t.v) + + t.Traverse(n.Name) +} + +func (t *Traverser) ExprYield(n *ast.ExprYield) { + n.Accept(t.v) + + t.Traverse(n.Key) + t.Traverse(n.Val) +} + +func (t *Traverser) ExprYieldFrom(n *ast.ExprYieldFrom) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssign(n *ast.ExprAssign) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignReference(n *ast.ExprAssignReference) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignBitwiseAnd(n *ast.ExprAssignBitwiseAnd) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignBitwiseOr(n *ast.ExprAssignBitwiseOr) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignBitwiseXor(n *ast.ExprAssignBitwiseXor) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignCoalesce(n *ast.ExprAssignCoalesce) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignConcat(n *ast.ExprAssignConcat) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignDiv(n *ast.ExprAssignDiv) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignMinus(n *ast.ExprAssignMinus) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignMod(n *ast.ExprAssignMod) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignMul(n *ast.ExprAssignMul) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignPlus(n *ast.ExprAssignPlus) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignPow(n *ast.ExprAssignPow) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignShiftLeft(n *ast.ExprAssignShiftLeft) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprAssignShiftRight(n *ast.ExprAssignShiftRight) { + n.Accept(t.v) + + t.Traverse(n.Var) + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprBinaryBitwiseAnd(n *ast.ExprBinaryBitwiseAnd) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryBitwiseOr(n *ast.ExprBinaryBitwiseOr) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryBitwiseXor(n *ast.ExprBinaryBitwiseXor) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryBooleanAnd(n *ast.ExprBinaryBooleanAnd) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryBooleanOr(n *ast.ExprBinaryBooleanOr) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryCoalesce(n *ast.ExprBinaryCoalesce) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryConcat(n *ast.ExprBinaryConcat) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryDiv(n *ast.ExprBinaryDiv) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryEqual(n *ast.ExprBinaryEqual) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryGreater(n *ast.ExprBinaryGreater) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryGreaterOrEqual(n *ast.ExprBinaryGreaterOrEqual) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryIdentical(n *ast.ExprBinaryIdentical) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryLogicalAnd(n *ast.ExprBinaryLogicalAnd) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryLogicalOr(n *ast.ExprBinaryLogicalOr) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryLogicalXor(n *ast.ExprBinaryLogicalXor) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryMinus(n *ast.ExprBinaryMinus) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryMod(n *ast.ExprBinaryMod) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryMul(n *ast.ExprBinaryMul) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryNotEqual(n *ast.ExprBinaryNotEqual) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryNotIdentical(n *ast.ExprBinaryNotIdentical) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryPlus(n *ast.ExprBinaryPlus) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryPow(n *ast.ExprBinaryPow) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryShiftLeft(n *ast.ExprBinaryShiftLeft) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinaryShiftRight(n *ast.ExprBinaryShiftRight) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinarySmaller(n *ast.ExprBinarySmaller) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinarySmallerOrEqual(n *ast.ExprBinarySmallerOrEqual) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprBinarySpaceship(n *ast.ExprBinarySpaceship) { + n.Accept(t.v) + + t.Traverse(n.Left) + t.Traverse(n.Right) +} + +func (t *Traverser) ExprCastArray(n *ast.ExprCastArray) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastBool(n *ast.ExprCastBool) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastDouble(n *ast.ExprCastDouble) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastInt(n *ast.ExprCastInt) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastObject(n *ast.ExprCastObject) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastString(n *ast.ExprCastString) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ExprCastUnset(n *ast.ExprCastUnset) { + n.Accept(t.v) + + t.Traverse(n.Expr) +} + +func (t *Traverser) ScalarDnumber(n *ast.ScalarDnumber) { + n.Accept(t.v) +} + +func (t *Traverser) ScalarEncapsed(n *ast.ScalarEncapsed) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) ScalarEncapsedStringPart(n *ast.ScalarEncapsedStringPart) { + n.Accept(t.v) +} + +func (t *Traverser) ScalarEncapsedStringVar(n *ast.ScalarEncapsedStringVar) { + n.Accept(t.v) + + t.Traverse(n.Name) + t.Traverse(n.Dim) +} + +func (t *Traverser) ScalarEncapsedStringBrackets(n *ast.ScalarEncapsedStringBrackets) { + n.Accept(t.v) + + t.Traverse(n.Var) +} + +func (t *Traverser) ScalarHeredoc(n *ast.ScalarHeredoc) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) ScalarLnumber(n *ast.ScalarLnumber) { + n.Accept(t.v) +} + +func (t *Traverser) ScalarMagicConstant(n *ast.ScalarMagicConstant) { + n.Accept(t.v) +} + +func (t *Traverser) ScalarString(n *ast.ScalarString) { + n.Accept(t.v) +} + +func (t *Traverser) NameName(n *ast.Name) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) NameFullyQualified(n *ast.NameFullyQualified) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) NameRelative(n *ast.NameRelative) { + n.Accept(t.v) + + for _, nn := range n.Parts { + nn.Accept(t) + } +} + +func (t *Traverser) NameNamePart(n *ast.NamePart) { + n.Accept(t.v) +} diff --git a/position/position_test.go b/position/position_test.go deleted file mode 100644 index 0e322b6..0000000 --- a/position/position_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package position_test - -import ( - "testing" - - "github.com/z7zmey/php-parser/position" -) - -func TestPrintPosition(t *testing.T) { - pos := position.NewPosition(1, 1, 2, 5) - - expected := "Pos{Line: 1-1 Pos: 2-5}" - - actual := pos.String() - - if expected != actual { - t.Errorf("expected and actual are not equal\n") - } -} diff --git a/positionbuilder/position_builder.go b/positionbuilder/position_builder.go deleted file mode 100644 index b6b8aa4..0000000 --- a/positionbuilder/position_builder.go +++ /dev/null @@ -1,207 +0,0 @@ -package positionbuilder - -import ( - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/position" - "github.com/z7zmey/php-parser/scanner" -) - -// PositionBuilder provide functions to constuct positions -type PositionBuilder struct{} - -type startPos struct { - startLine int - startPos int -} - -type endPos struct { - endLine int - endPos int -} - -func (b *PositionBuilder) getListStartPos(l []node.Node) startPos { - if l == nil { - return startPos{-1, -1} - } - - if len(l) == 0 { - return startPos{-1, -1} - } - - return b.getNodeStartPos(l[0]) -} - -func (b *PositionBuilder) getNodeStartPos(n node.Node) startPos { - sl := -1 - sp := -1 - - if n == nil { - return startPos{-1, -1} - } - - p := n.GetPosition() - if p != nil { - sl = p.StartLine - sp = p.StartPos - } - - return startPos{sl, sp} -} - -func (b *PositionBuilder) getListEndPos(l []node.Node) endPos { - if l == nil { - return endPos{-1, -1} - } - - if len(l) == 0 { - return endPos{-1, -1} - } - - return b.getNodeEndPos(l[len(l)-1]) -} - -func (b *PositionBuilder) getNodeEndPos(n node.Node) endPos { - el := -1 - ep := -1 - - if n == nil { - return endPos{-1, -1} - } - - p := n.GetPosition() - if p != nil { - el = p.EndLine - ep = p.EndPos - } - - return endPos{el, ep} -} - -// NewNodeListPosition returns new Position -func (b *PositionBuilder) NewNodeListPosition(list []node.Node) *position.Position { - return &position.Position{ - StartLine: b.getListStartPos(list).startLine, - EndLine: b.getListEndPos(list).endLine, - StartPos: b.getListStartPos(list).startPos, - EndPos: b.getListEndPos(list).endPos, - } -} - -// NewNodePosition returns new Position -func (b *PositionBuilder) NewNodePosition(n node.Node) *position.Position { - return &position.Position{ - StartLine: b.getNodeStartPos(n).startLine, - EndLine: b.getNodeEndPos(n).endLine, - StartPos: b.getNodeStartPos(n).startPos, - EndPos: b.getNodeEndPos(n).endPos, - } -} - -// NewTokenPosition returns new Position -func (b *PositionBuilder) NewTokenPosition(t *scanner.Token) *position.Position { - return &position.Position{ - StartLine: t.StartLine, - EndLine: t.EndLine, - StartPos: t.StartPos, - EndPos: t.EndPos, - } -} - -// NewTokensPosition returns new Position -func (b *PositionBuilder) NewTokensPosition(startToken *scanner.Token, endToken *scanner.Token) *position.Position { - return &position.Position{ - StartLine: startToken.StartLine, - EndLine: endToken.EndLine, - StartPos: startToken.StartPos, - EndPos: endToken.EndPos, - } -} - -// NewTokenNodePosition returns new Position -func (b *PositionBuilder) NewTokenNodePosition(t *scanner.Token, n node.Node) *position.Position { - return &position.Position{ - StartLine: t.StartLine, - EndLine: b.getNodeEndPos(n).endLine, - StartPos: t.StartPos, - EndPos: b.getNodeEndPos(n).endPos, - } -} - -// NewNodeTokenPosition returns new Position -func (b *PositionBuilder) NewNodeTokenPosition(n node.Node, t *scanner.Token) *position.Position { - return &position.Position{ - StartLine: b.getNodeStartPos(n).startLine, - EndLine: t.EndLine, - StartPos: b.getNodeStartPos(n).startPos, - EndPos: t.EndPos, - } -} - -// NewNodesPosition returns new Position -func (b *PositionBuilder) NewNodesPosition(startNode node.Node, endNode node.Node) *position.Position { - return &position.Position{ - StartLine: b.getNodeStartPos(startNode).startLine, - EndLine: b.getNodeEndPos(endNode).endLine, - StartPos: b.getNodeStartPos(startNode).startPos, - EndPos: b.getNodeEndPos(endNode).endPos, - } -} - -// NewNodeListTokenPosition returns new Position -func (b *PositionBuilder) NewNodeListTokenPosition(list []node.Node, t *scanner.Token) *position.Position { - return &position.Position{ - StartLine: b.getListStartPos(list).startLine, - EndLine: t.EndLine, - StartPos: b.getListStartPos(list).startPos, - EndPos: t.EndPos, - } -} - -// NewTokenNodeListPosition returns new Position -func (b *PositionBuilder) NewTokenNodeListPosition(t *scanner.Token, list []node.Node) *position.Position { - return &position.Position{ - StartLine: t.StartLine, - EndLine: b.getListEndPos(list).endLine, - StartPos: t.StartPos, - EndPos: b.getListEndPos(list).endPos, - } -} - -// NewNodeNodeListPosition returns new Position -func (b *PositionBuilder) NewNodeNodeListPosition(n node.Node, list []node.Node) *position.Position { - return &position.Position{ - StartLine: b.getNodeStartPos(n).startLine, - EndLine: b.getListEndPos(list).endLine, - StartPos: b.getNodeStartPos(n).startPos, - EndPos: b.getListEndPos(list).endPos, - } -} - -// NewNodeListNodePosition returns new Position -func (b *PositionBuilder) NewNodeListNodePosition(list []node.Node, n node.Node) *position.Position { - return &position.Position{ - StartLine: b.getListStartPos(list).startLine, - EndLine: b.getNodeEndPos(n).endLine, - StartPos: b.getListStartPos(list).startPos, - EndPos: b.getNodeEndPos(n).endPos, - } -} - -// NewOptionalListTokensPosition returns new Position -func (b *PositionBuilder) NewOptionalListTokensPosition(list []node.Node, t *scanner.Token, endToken *scanner.Token) *position.Position { - if list == nil { - return &position.Position{ - StartLine: t.StartLine, - EndLine: endToken.EndLine, - StartPos: t.StartPos, - EndPos: endToken.EndPos, - } - } - - return &position.Position{ - StartLine: b.getListStartPos(list).startLine, - EndLine: endToken.EndLine, - StartPos: b.getListStartPos(list).startPos, - EndPos: endToken.EndPos, - } -} diff --git a/positionbuilder/position_builder_test.go b/positionbuilder/position_builder_test.go deleted file mode 100644 index fd8fa2b..0000000 --- a/positionbuilder/position_builder_test.go +++ /dev/null @@ -1,463 +0,0 @@ -package positionbuilder_test - -import ( - "testing" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/position" - "github.com/z7zmey/php-parser/positionbuilder" - - "github.com/z7zmey/php-parser/scanner" -) - -func TestNewTokenPosition(t *testing.T) { - builder := positionbuilder.PositionBuilder{} - - tkn := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - - pos := builder.NewTokenPosition(tkn) - - if pos.String() != `Pos{Line: 1-1 Pos: 0-3}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewTokensPosition(t *testing.T) { - builder := positionbuilder.PositionBuilder{} - - token1 := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - token2 := &scanner.Token{ - Value: `foo`, - StartLine: 2, - EndLine: 2, - StartPos: 4, - EndPos: 6, - } - - pos := builder.NewTokensPosition(token1, token2) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-6}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodePosition(t *testing.T) { - n := node.NewIdentifier("test node") - n.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodePosition(n) - - if pos.String() != `Pos{Line: 1-1 Pos: 0-3}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewTokenNodePosition(t *testing.T) { - tkn := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - n := node.NewIdentifier("test node") - n.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 4, - EndPos: 12, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewTokenNodePosition(tkn, n) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-12}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodeTokenPosition(t *testing.T) { - n := node.NewIdentifier("test node") - n.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 9, - }) - - tkn := &scanner.Token{ - Value: `foo`, - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 12, - } - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeTokenPosition(n, tkn) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-12}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodeListPosition(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 9, - }) - - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 19, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeListPosition([]node.Node{n1, n2}) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-19}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodesPosition(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 9, - }) - - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 19, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodesPosition(n1, n2) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-19}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodeListTokenPosition(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 9, - }) - - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 10, - EndPos: 19, - }) - - tkn := &scanner.Token{ - Value: `foo`, - StartLine: 3, - EndLine: 3, - StartPos: 20, - EndPos: 22, - } - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeListTokenPosition([]node.Node{n1, n2}, tkn) - - if pos.String() != `Pos{Line: 1-3 Pos: 0-22}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewTokenNodeListPosition(t *testing.T) { - tkn := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 2, - } - - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 3, - EndPos: 10, - }) - - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 11, - EndPos: 20, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewTokenNodeListPosition(tkn, []node.Node{n1, n2}) - - if pos.String() != `Pos{Line: 1-3 Pos: 0-20}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodeNodeListPosition(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 8, - }) - - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 17, - }) - - n3 := node.NewIdentifier("test node") - n3.SetPosition(&position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 18, - EndPos: 26, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeNodeListPosition(n1, []node.Node{n2, n3}) - - if pos.String() != `Pos{Line: 1-3 Pos: 0-26}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewNodeListNodePosition(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 8, - }) - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 17, - }) - n3 := node.NewIdentifier("test node") - n3.SetPosition(&position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 18, - EndPos: 26, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeListNodePosition([]node.Node{n1, n2}, n3) - - if pos.String() != `Pos{Line: 1-3 Pos: 0-26}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewOptionalListTokensPosition(t *testing.T) { - builder := positionbuilder.PositionBuilder{} - - token1 := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - token2 := &scanner.Token{ - Value: `foo`, - StartLine: 2, - EndLine: 2, - StartPos: 4, - EndPos: 6, - } - - pos := builder.NewOptionalListTokensPosition(nil, token1, token2) - - if pos.String() != `Pos{Line: 1-2 Pos: 0-6}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNewOptionalListTokensPosition2(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 8, - }) - n2 := node.NewIdentifier("test node") - n2.SetPosition(&position.Position{ - StartLine: 2, - EndLine: 2, - StartPos: 9, - EndPos: 17, - }) - n3 := node.NewIdentifier("test node") - n3.SetPosition(&position.Position{ - StartLine: 3, - EndLine: 3, - StartPos: 18, - EndPos: 26, - }) - - builder := positionbuilder.PositionBuilder{} - - token1 := &scanner.Token{ - Value: `foo`, - StartLine: 4, - EndLine: 4, - StartPos: 27, - EndPos: 29, - } - token2 := &scanner.Token{ - Value: `foo`, - StartLine: 5, - EndLine: 5, - StartPos: 30, - EndPos: 32, - } - - pos := builder.NewOptionalListTokensPosition([]node.Node{n2, n3}, token1, token2) - - if pos.String() != `Pos{Line: 2-5 Pos: 9-32}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNilNodePos(t *testing.T) { - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodesPosition(nil, nil) - - if pos.String() != `Pos{Line: -1--1 Pos: -1--1}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNilNodeListPos(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 8, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeNodeListPosition(n1, nil) - - if pos.String() != `Pos{Line: 1--1 Pos: 0--1}` { - t.Errorf("token value is not equal\n") - } -} - -func TestNilNodeListTokenPos(t *testing.T) { - token := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeListTokenPosition(nil, token) - - if pos.String() != `Pos{Line: -1-1 Pos: -1-3}` { - t.Errorf("token value is not equal\n") - } -} - -func TestEmptyNodeListPos(t *testing.T) { - n1 := node.NewIdentifier("test node") - n1.SetPosition(&position.Position{ - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 8, - }) - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeNodeListPosition(n1, []node.Node{}) - - if pos.String() != `Pos{Line: 1--1 Pos: 0--1}` { - t.Errorf("token value is not equal\n") - } -} - -func TestEmptyNodeListTokenPos(t *testing.T) { - token := &scanner.Token{ - Value: `foo`, - StartLine: 1, - EndLine: 1, - StartPos: 0, - EndPos: 3, - } - - builder := positionbuilder.PositionBuilder{} - - pos := builder.NewNodeListTokenPosition([]node.Node{}, token) - - if pos.String() != `Pos{Line: -1-1 Pos: -1-3}` { - t.Errorf("token value is not equal\n") - } -} diff --git a/printer/pretty_printer.go b/printer/pretty_printer.go deleted file mode 100644 index 980b597..0000000 --- a/printer/pretty_printer.go +++ /dev/null @@ -1,2201 +0,0 @@ -package printer - -import ( - "io" - "strings" - - "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" -) - -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) { - var stmts []node.Node - v := n.(*node.Root) - - if len(v.Stmts) > 0 { - firstStmt := v.Stmts[0] - 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, nn.Label) - - 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, "<\"'\n")) -} - -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.Unpack { - io.WriteString(p.w, "...") - } - - 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\"\n", - 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 TestPrintExprArrayItemUnpack(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrettyPrinter(o, " ") - p.Print(&expr.ArrayItem{ - Unpack: true, - Val: &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 { - io.WriteString(p.w, glue) - } - - p.Print(n) - } -} - -func (p *Printer) printNodes(nn []node.Node) { - for _, n := range nn { - p.Print(n) - } -} - -func (p *Printer) printFreeFloating(n node.Node, pos freefloating.Position) { - if n == nil { - return - } - - for _, m := range (*n.GetFreeFloating())[pos] { - io.WriteString(p.w, m.Value) - } -} - -func (p *Printer) 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.printAssignReference(n) - case *assign.BitwiseAnd: - p.printAssignBitwiseAnd(n) - case *assign.BitwiseOr: - p.printAssignBitwiseOr(n) - case *assign.BitwiseXor: - p.printAssignBitwiseXor(n) - case *assign.Coalesce: - p.printAssignCoalesce(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.ArrowFunction: - p.printExprArrowFunction(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.ConstList: - p.printStmtConstList(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.TraitAdaptationList: - p.printStmtTraitAdaptationList(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 *Printer) printNodeRoot(n node.Node) { - nn := n.(*node.Root) - p.SetState(HtmlState) - p.printFreeFloating(nn, freefloating.Start) - p.printNodes(nn.Stmts) - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNodeIdentifier(n node.Node) { - nn := n.(*node.Identifier) - p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, nn.Value) - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNodeParameter(n node.Node) { - nn := n.(*node.Parameter) - p.printFreeFloating(nn, freefloating.Start) - - if nn.VariableType != nil { - p.Print(nn.VariableType) - } - p.printFreeFloating(nn, freefloating.OptionalType) - - if nn.ByRef { - io.WriteString(p.w, "&") - } - p.printFreeFloating(nn, freefloating.Ampersand) - - if nn.Variadic { - io.WriteString(p.w, "...") - } - p.printFreeFloating(nn, freefloating.Variadic) - - p.Print(nn.Variable) - - if nn.DefaultValue != nil { - p.printFreeFloating(nn, freefloating.Var) - io.WriteString(p.w, "=") - p.Print(nn.DefaultValue) - } - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNodeNullable(n node.Node) { - nn := n.(*node.Nullable) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "?") - p.Print(nn.Expr) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNodeArgument(n node.Node) { - nn := n.(*node.Argument) - p.printFreeFloating(nn, freefloating.Start) - - if nn.IsReference { - io.WriteString(p.w, "&") - } - p.printFreeFloating(nn, freefloating.Ampersand) - - if nn.Variadic { - io.WriteString(p.w, "...") - } - p.printFreeFloating(nn, freefloating.Variadic) - - p.Print(nn.Expr) - - p.printFreeFloating(nn, freefloating.End) -} - -// name - -func (p *Printer) printNameNamePart(n node.Node) { - nn := n.(*name.NamePart) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, nn.Value) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNameName(n node.Node) { - nn := n.(*name.Name) - p.printFreeFloating(nn, freefloating.Start) - - p.joinPrint("\\", nn.Parts) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printNameFullyQualified(n node.Node) { - nn := n.(*name.FullyQualified) - p.printFreeFloating(nn, freefloating.Start) - - 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) { - 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) { - 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) { - 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) { - 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) { - nn := n.(*scalar.Encapsed) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "\"") - for _, part := range nn.Parts { - switch part.(type) { - 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: - p.Print(part) - } - } - 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, nn.Label) - - for _, part := range nn.Parts { - switch part.(type) { - 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: - p.Print(part) - } - } - - io.WriteString(p.w, strings.Trim(nn.Label, "<\"'\n")) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printScalarMagicConstant(n node.Node) { - 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) - p.printFreeFloating(nn, freefloating.Var) - io.WriteString(p.w, "=") - p.Print(nn.Expression) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printAssignReference(n node.Node) { - nn := n.(*assign.Reference) - p.printFreeFloating(nn, freefloating.Start) - p.Print(nn.Variable) - 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) - 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) - 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) - p.printFreeFloating(nn, freefloating.Var) - io.WriteString(p.w, "^=") - p.Print(nn.Expression) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printAssignCoalesce(n node.Node) { - nn := n.(*assign.Coalesce) - p.printFreeFloating(nn, freefloating.Start) - p.Print(nn.Variable) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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)") - } - - 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)") - } - - 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)") - } - - 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)") - } - - 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)") - } - - 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)") - } - - 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)") - } - - 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) - 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) 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.Unpack { - io.WriteString(p.w, "...") - } - - if nn.Key != nil { - p.Print(nn.Key) - 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) - 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) printExprArrowFunction(n node.Node) { - nn := n.(*expr.ArrowFunction) - p.printFreeFloating(nn, freefloating.Start) - - if nn.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, "fn") - 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.printFreeFloating(nn, freefloating.ParameterList) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Params) - - if nn.ReturnType != nil { - io.WriteString(p.w, ":") - p.Print(nn.ReturnType) - } - p.printFreeFloating(nn, freefloating.ReturnType) - - io.WriteString(p.w, "=>") - - p.printNode(nn.Expr) - - 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, "::") - p.Print(nn.ConstantName) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printExprClone(n node.Node) { - nn := n.(*expr.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) - 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") - } - p.printFreeFloating(nn, freefloating.Static) - if nn.Static && n.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - - 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.printFreeFloating(nn, freefloating.ParameterList) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Params) - - if nn.ClosureUse != nil { - p.Print(nn.ClosureUse) - } - p.printFreeFloating(nn, freefloating.LexicalVars) - - if nn.ReturnType != nil { - io.WriteString(p.w, ":") - p.Print(nn.ReturnType) - } - p.printFreeFloating(nn, freefloating.ReturnType) - - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - 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) - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printExprEmpty(n node.Node) { - nn := n.(*expr.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) - 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) - - 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) - 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.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) - 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) - 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) - 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.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.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.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") - 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.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") - if nn.Expr.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Expr) - - 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") - 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") - 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, "`") - 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.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.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.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) - p.printFreeFloating(nn, freefloating.Cond) - io.WriteString(p.w, "?") - - if nn.IfTrue != nil { - p.Print(nn.IfTrue) - } - p.printFreeFloating(nn, freefloating.True) - - 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) { - 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") - 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") - - if nn.Key != nil { - if nn.Key.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Key) - 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") - p.printFreeFloating(nn, freefloating.ElseIf) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - 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 { - 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") - p.printFreeFloating(nn, freefloating.Else) - io.WriteString(p.w, ":") - - if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 { - 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.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) - p.printFreeFloating(nn, freefloating.Stmts) - - 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") - p.printFreeFloating(nn, freefloating.Foreach) - io.WriteString(p.w, "(") - p.Print(nn.Expr) - 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) - 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, ")") - 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, "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") - p.printFreeFloating(nn, freefloating.If) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - 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 { - p.Print(elseif) - } - - if nn.Else != nil { - p.Print(nn.Else) - } - - 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") - p.printFreeFloating(nn, freefloating.Switch) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Cond) - io.WriteString(p.w, ":") - - 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, "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") - p.printFreeFloating(nn, freefloating.While) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - 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, "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 { - if nn.Expr.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Expr) - } - p.printFreeFloating(nn, freefloating.Expr) - - 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") - if nn.Cond.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Cond) - p.printFreeFloating(nn, freefloating.Expr) - p.printFreeFloating(nn, freefloating.CaseSeparator) - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, ":") - } - - if len(nn.Stmts) > 0 { - 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.printFreeFloating(nn, freefloating.Catch) - io.WriteString(p.w, "(") - p.joinPrint("|", nn.Types) - p.Print(nn.Variable) - p.printFreeFloating(nn, freefloating.Var) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Cond) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - 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 { - 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, "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.printFreeFloating(nn, freefloating.ParameterList) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Params) - - if nn.ReturnType != nil { - io.WriteString(p.w, ":") - p.Print(nn.ReturnType) - } - - 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 { - 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 { - 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.printFreeFloating(nn.ArgumentList, freefloating.ArgumentList) - io.WriteString(p.w, ")") - p.printFreeFloating(nn.ArgumentList, freefloating.End) - } - - if nn.Extends != nil { - 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 { - 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) - } - - p.printFreeFloating(nn, freefloating.Name) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - 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 { - 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, " ") - } - p.joinPrint(",", nn.Consts) - p.printFreeFloating(nn, freefloating.ConstList) - - p.printFreeFloating(nn, freefloating.SemiColon) - if nn.GetFreeFloating().IsEmpty() { - 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) - 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 { - if nn.Expr.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Expr) - } - p.printFreeFloating(nn, freefloating.Expr) - - 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.printFreeFloating(nn, freefloating.Declare) - io.WriteString(p.w, "(") - p.joinPrint(",", nn.Consts) - p.printFreeFloating(nn, freefloating.ConstList) - io.WriteString(p.w, ")") - - 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) - 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 { - 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") - - if _, ok := nn.Stmt.(*stmt.StmtList); !ok { - if nn.Stmt.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - } - - 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) - 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) - - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, "echo") - } - if nn.Exprs[0].GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - - p.printFreeFloating(nn, freefloating.Start) - p.printFreeFloating(nn, freefloating.Echo) - - p.joinPrint(",", nn.Exprs) - p.printFreeFloating(nn, freefloating.Expr) - - p.printFreeFloating(nn, freefloating.SemiColon) - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, ";") - } - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtElseif(n node.Node) { - nn := n.(*stmt.ElseIf) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "elseif") - p.printFreeFloating(nn, freefloating.ElseIf) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ")") - - p.Print(nn.Stmt) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtElse(n node.Node) { - nn := n.(*stmt.Else) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "else") - - if _, ok := nn.Stmt.(*stmt.StmtList); !ok { - if nn.Stmt.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - } - - p.Print(nn.Stmt) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtExpression(n node.Node) { - nn := n.(*stmt.Expression) - p.printFreeFloating(nn, freefloating.Start) - - p.Print(nn.Expr) - p.printFreeFloating(nn, freefloating.Expr) - - p.printFreeFloating(nn, freefloating.SemiColon) - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, ";") - } - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtFinally(n node.Node) { - nn := n.(*stmt.Finally) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "finally") - p.printFreeFloating(nn, freefloating.Finally) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "}") - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtFor(n node.Node) { - nn := n.(*stmt.For) - p.printFreeFloating(nn, freefloating.Start) - - 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.Print(nn.Stmt) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtForeach(n node.Node) { - nn := n.(*stmt.Foreach) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "foreach") - p.printFreeFloating(nn, freefloating.Foreach) - io.WriteString(p.w, "(") - - p.Print(nn.Expr) - 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) - 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, ")") - - 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") - 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.printFreeFloating(nn, freefloating.ParamList) - io.WriteString(p.w, ")") - p.printFreeFloating(nn, freefloating.Params) - - if nn.ReturnType != nil { - io.WriteString(p.w, ":") - p.Print(nn.ReturnType) - } - p.printFreeFloating(nn, freefloating.ReturnType) - - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - 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) - 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") - if nn.Label.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Label) - 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") - p.printFreeFloating(nn, freefloating.Use) - - if nn.UseType != nil { - if nn.UseType.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.UseType) - } - - if nn.Prefix.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Prefix) - 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) { - 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") - p.printFreeFloating(n, freefloating.If) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - p.printFreeFloating(n, freefloating.Expr) - io.WriteString(p.w, ")") - - p.Print(nn.Stmt) - - if nn.ElseIf != nil { - p.printNodes(nn.ElseIf) - } - - if nn.Else != nil { - 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, nn.Value) - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtInterface(n node.Node) { - nn := n.(*stmt.Interface) - p.printFreeFloating(nn, freefloating.Start) - - io.WriteString(p.w, "interface") - - if nn.InterfaceName.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - - p.Print(nn.InterfaceName) - - if nn.Extends != nil { - p.printFreeFloating(nn.Extends, freefloating.Start) - if nn.Extends.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - io.WriteString(p.w, "extends") - if nn.Extends.InterfaceNames[0].GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.joinPrint(",", nn.Extends.InterfaceNames) - } - - p.printFreeFloating(nn, freefloating.Name) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "}") - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtLabel(n node.Node) { - nn := n.(*stmt.Label) - p.printFreeFloating(nn, freefloating.Start) - - p.Print(nn.LabelName) - p.printFreeFloating(nn, freefloating.Label) - - io.WriteString(p.w, ":") - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtNamespace(n node.Node) { - nn := n.(*stmt.Namespace) - p.printFreeFloating(nn, freefloating.Start) - io.WriteString(p.w, "namespace") - - if nn.NamespaceName != nil { - if nn.NamespaceName.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.NamespaceName) - } - - if nn.Stmts != nil { - p.printFreeFloating(nn, freefloating.Namespace) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "}") - } else { - p.printFreeFloating(nn, freefloating.SemiColon) - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, ";") - } - } - - p.printFreeFloating(nn, freefloating.End) -} - -func (p *Printer) printStmtNop(n node.Node) { - p.printFreeFloating(n, freefloating.Start) - p.printFreeFloating(n, freefloating.SemiColon) - if n.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, ";") - } - p.printFreeFloating(n, freefloating.End) -} - -func (p *Printer) printStmtPropertyList(n node.Node) { - nn := n.(*stmt.PropertyList) - p.printFreeFloating(nn, freefloating.Start) - - for k, m := range nn.Modifiers { - if k > 0 && m.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(m) - } - - if nn.Type != nil && nn.Type.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - - p.Print(nn.Type) - - 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 { - 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") - if nn.Expr != nil && nn.Expr.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Expr) - 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 { - 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") - - 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, "{") - p.printNodes(nn.Stmts) - 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") - p.printFreeFloating(nn, freefloating.Switch) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ")") - - p.printFreeFloating(nn.CaseList, freefloating.Start) - io.WriteString(p.w, "{") - p.printFreeFloating(nn.CaseList, freefloating.CaseListStart) - p.printNodes(nn.CaseList.Cases) - 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") - if nn.Expr.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Expr) - 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.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) - p.printFreeFloating(nn, freefloating.Ref) - - if nn.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - io.WriteString(p.w, "as") - - if nn.Modifier != nil { - if nn.Modifier.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Modifier) - } - - if nn.Alias != nil { - if nn.Alias.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.Alias) - } - p.printFreeFloating(nn, freefloating.Alias) - - 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) - p.printFreeFloating(nn, freefloating.Ref) - if nn.GetFreeFloating().IsEmpty() { - 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") - 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") - if nn.TraitName.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.TraitName) - - p.printFreeFloating(nn, freefloating.Name) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - 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") - p.printFreeFloating(nn, freefloating.Try) - io.WriteString(p.w, "{") - p.printNodes(nn.Stmts) - p.printFreeFloating(nn, freefloating.Stmts) - io.WriteString(p.w, "}") - - if nn.Catches != nil { - p.printNodes(nn.Catches) - } - - if nn.Finally != nil { - 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.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") - - if nn.UseType != nil { - if nn.UseType.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - p.Print(nn.UseType) - } - - 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) - if nn.UseType.GetFreeFloating().IsEmpty() { - io.WriteString(p.w, " ") - } - } - - p.printFreeFloating(nn, freefloating.Slash) - - p.Print(nn.Use) - - if nn.Alias != nil { - 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") - p.printFreeFloating(nn, freefloating.While) - io.WriteString(p.w, "(") - p.Print(nn.Cond) - p.printFreeFloating(nn, freefloating.Expr) - io.WriteString(p.w, ")") - - p.Print(nn.Stmt) - - p.printFreeFloating(nn, freefloating.End) -} diff --git a/printer/printer_test.go b/printer/printer_test.go deleted file mode 100644 index 331de66..0000000 --- a/printer/printer_test.go +++ /dev/null @@ -1,4493 +0,0 @@ -package printer_test - -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" - "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/printer" -) - -func TestPrinterPrintFile(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&node.Root{ - 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'"}, - }, - }, - }, - }, - }, - }, - }, - }, - }) - - expected := `HTML"}, - &stmt.Expression{ - 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
>=$b` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -// binary - -func TestPrinterPrintBinaryBitwiseAnd(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryBitwiseOr(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryBitwiseXor(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryBooleanAnd(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryBooleanOr(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryCoalesce(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryConcat(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryDiv(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryEqual(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryGreaterOrEqual(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryGreater(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryIdentical(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryLogicalAnd(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryLogicalOr(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryLogicalXor(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryMinus(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryMod(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryMul(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryNotEqual(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryNotIdentical(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryPlus(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryPow(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryShiftLeft(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinaryShiftRight(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinarySmallerOrEqual(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinarySmaller(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBinarySpaceship(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintArray(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintBool(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&cast.Bool{ - Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "var"}, - }, - }) - - expected := `(boolean)$var` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintDouble(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintInt(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&cast.Int{ - Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "var"}, - }, - }) - - expected := `(integer)$var` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintObject(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintString(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintUnset(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprArrayDimFetch(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprArrayItemWithKey(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprArrayItem(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprArrayItemUnpack(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&expr.ArrayItem{ - Unpack: true, - Val: &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 TestPrinterPrintExprArray(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - &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 TestPrinterPrintExprBitwiseNot(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprBooleanNot(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprClassConstFetch(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprClone(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprClosureUse(t *testing.T) { - o := bytes.NewBufferString("") - - 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 TestPrinterPrintExprClosure(t *testing.T) { - o := bytes.NewBufferString("") - - 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 TestPrinterPrintExprArrowFunction(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Expression{ - Expr: &expr.ArrowFunction{ - Static: true, - ReturnsRef: true, - 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"}}, - }, - Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - }, - }) - - expected := `static fn&(&$var):\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"}}}, - }) - - expected := "null" - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrettyPrinterrorSuppress(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintEval(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExit(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintDie(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - 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 TestPrinterPrintInclude(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintIncludeOnce(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintInstanceOf(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintIsset(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - }) - - expected := `isset($a,$b)` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintMethodCall(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintNew(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPostDec(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPostInc(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPreDec(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPreInc(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPrint(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintPropertyFetch(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprReference(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintRequire(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintRequireOnce(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintShellExec(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintExprShortArray(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - &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 TestPrinterPrintShortList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStaticCall(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - &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 TestPrinterPrintStaticPropertyFetch(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintTernary(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintTernaryFull(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }) - - expected := `$a?$b:$c` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintUnaryMinus(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintUnaryPlus(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintVariable(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintYieldFrom(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintYield(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintYieldFull(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintAltElseIf(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintAltElseIfEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintAltElse(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintAltElseEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintAltFor(t *testing.T) { - o := bytes.NewBufferString("") - - 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: "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 := `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 TestPrinterPrintStmtAltSwitch(t *testing.T) { - o := bytes.NewBufferString("") - - 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: "a"}, - }}, - }, - }, - &stmt.Case{ - Cond: &scalar.String{Value: "'b'"}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }}, - }, - }, - }, - }, - }) - - expected := `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 TestPrinterPrintAltWhile(t *testing.T) { - o := bytes.NewBufferString("") - - 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 := `while($a):$b;endwhile;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtBreak(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtCase(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtCaseEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtCatch(t *testing.T) { - o := bytes.NewBufferString("") - - 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.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - }) - - expected := `catch(Exception|\RuntimeException$e){$a;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtClassMethod(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtAbstractClassMethod(t *testing.T) { - o := bytes.NewBufferString("") - - 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.ClassConstList{ - Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - &node.Identifier{Value: "static"}, - }, - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, - }, - }, - }) - - expected := `abstract class Foo extends Bar implements Baz,Quuz{public static const FOO='bar';}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtAnonymousClass(t *testing.T) { - o := bytes.NewBufferString("") - - 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.ClassConstList{ - Modifiers: []node.Node{&node.Identifier{Value: "public"}}, - Consts: []node.Node{ - &stmt.Constant{ - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.String{Value: "'bar'"}, - }, - }, - }, - }, - }) - - expected := `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 TestPrinterPrintStmtClassConstList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtConstList(t *testing.T) { - o := bytes.NewBufferString("") - - 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'" - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtContinue(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtDeclareStmts(t *testing.T) { - o := bytes.NewBufferString("") - - 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'){;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtDeclareExpr(t *testing.T) { - o := bytes.NewBufferString("") - - 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';` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtDeclareNop(t *testing.T) { - o := bytes.NewBufferString("") - - 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.Nop{}, - }) - - expected := `declare(FOO='bar');` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtDefalut(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtDefalutEmpty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtDo_Expression(t *testing.T) { - o := bytes.NewBufferString("") - - 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 := `do $a;while(1);` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtDo_StmtList(t *testing.T) { - o := bytes.NewBufferString("") - - 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.Echo{ - Exprs: []node.Node{ - &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }, - }, - }, - }, - }) - - expected := `$v){;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtFunction(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - }) - - expected := `global$a,$b;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtGoto(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintStmtGroupUse(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(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 TestPrinterPrintHaltCompiler(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.HaltCompiler{}) - - expected := `__halt_compiler();` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintIfExpression(t *testing.T) { - o := bytes.NewBufferString("") - - 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"}, - }, - }, - 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 := `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 TestPrinterPrintIfStmtList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&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 := `if($a){$b;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintIfNop(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 TestPrinterPrintInlineHtml(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&node.Root{ - Stmts: []node.Node{ - &stmt.InlineHtml{ - Value: "test", - }, - }, - }) - - expected := `test` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintInterface(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Interface{ - InterfaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Extends: &stmt.InterfaceExtends{ - InterfaceNames: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, - &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: "foo"}, - Params: []node.Node{}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - }, - }, - }, - }) - - expected := `interface Foo extends Bar,Baz{public function foo(){$a;}}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintLabel(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Label{ - LabelName: &node.Identifier{Value: "FOO"}, - }) - - expected := `FOO:` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintNamespace(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Namespace{ - NamespaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - }) - - expected := `namespace Foo;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintNamespaceWithStmts(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Namespace{ - NamespaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - }) - - expected := `namespace Foo{$a;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintNop(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Nop{}) - - expected := `;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintPropertyList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.PropertyList{ - Modifiers: []node.Node{ - &node.Identifier{Value: "public"}, - &node.Identifier{Value: "static"}, - }, - Type: &name.Name{ - Parts: []node.Node{ - &name.NamePart{ - Value: "Foo", - }, - }, - }, - Properties: []node.Node{ - &stmt.Property{ - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - Expr: &scalar.String{Value: "'a'"}, - }, - &stmt.Property{ - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }, - }, - }, - }) - - expected := `public static Foo $a='a',$b;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintProperty(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Property{ - Variable: &expr.Variable{ - FreeFloating: freefloating.Collection{ - freefloating.Start: []freefloating.String{ - { - StringType: freefloating.TokenType, - Value: "$", - }, - }, - }, - VarName: &node.Identifier{Value: "a"}, - }, - Expr: &scalar.Lnumber{Value: "1"}, - }) - - expected := `$a=1` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintReturn(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Return{ - Expr: &scalar.Lnumber{Value: "1"}, - }) - - expected := `return 1;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStaticVar(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.StaticVar{ - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - Expr: &scalar.Lnumber{Value: "1"}, - }) - - expected := `$a=1` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStatic(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Static{ - Vars: []node.Node{ - &stmt.StaticVar{ - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - }, - &stmt.StaticVar{ - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }, - }, - }, - }) - - expected := `static$a,$b;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - &stmt.Expression{Expr: &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 TestPrinterPrintStmtListNested(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }}, - &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &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 TestPrinterPrintStmtSwitch(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Switch{ - 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 := `switch($var){case 'a':$a;case 'b':$b;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtThrow(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Throw{ - Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "var"}, - }, - }) - - expected := `throw $var;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitAdaptationList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitAdaptationList{ - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Trait: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Method: &node.Identifier{Value: "a"}, - }, - Alias: &node.Identifier{Value: "b"}, - }, - }, - }) - - expected := `{Foo::a as b;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitMethodRef(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitMethodRef{ - Method: &node.Identifier{Value: "a"}, - }) - - expected := `a` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitMethodRefFull(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitMethodRef{ - Trait: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Method: &node.Identifier{Value: "a"}, - }) - - expected := `Foo::a` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitUseAlias(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Trait: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Method: &node.Identifier{Value: "a"}, - }, - Modifier: &node.Identifier{Value: "public"}, - Alias: &node.Identifier{Value: "b"}, - }) - - expected := `Foo::a as public b;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitUsePrecedence(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitUsePrecedence{ - Ref: &stmt.TraitMethodRef{ - Trait: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Method: &node.Identifier{Value: "a"}, - }, - Insteadof: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, - }, - }) - - expected := `Foo::a insteadof Bar,Baz;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitUse(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitUse{ - Traits: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, - }, - TraitAdaptationList: &stmt.Nop{}, - }) - - expected := `use Foo,Bar;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTraitAdaptations(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.TraitUse{ - Traits: []node.Node{ - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Adaptations: []node.Node{ - &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Trait: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Method: &node.Identifier{Value: "a"}, - }, - Alias: &node.Identifier{Value: "b"}, - }, - }, - }, - }) - - expected := `use Foo,Bar{Foo::a as b;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintTrait(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Trait{ - TraitName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Stmts: []node.Node{ - &stmt.ClassMethod{ - Modifiers: []node.Node{&node.Identifier{Value: "public"}}, - MethodName: &node.Identifier{Value: "foo"}, - Params: []node.Node{}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - }, - }, - }, - }) - - expected := `trait Foo{public function foo(){$a;}}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtTry(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Try{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - Catches: []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: "b"}, - }}, - }, - }, - }, - Finally: &stmt.Finally{ - Stmts: []node.Node{ - &stmt.Nop{}, - }, - }, - }) - - expected := `try{$a;}catch(Exception|\RuntimeException$e){$b;}finally{;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtUnset(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Unset{ - Vars: []node.Node{ - &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - &expr.Variable{ - VarName: &node.Identifier{Value: "b"}, - }, - }, - }) - - expected := `unset($a,$b);` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintStmtUseList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, - Uses: []node.Node{ - &stmt.Use{ - Use: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Alias: &node.Identifier{Value: "Bar"}, - }, - &stmt.Use{ - Use: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, - }, - }, - }) - - expected := `use function Foo as Bar,Baz;` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintUse(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.Use{ - UseType: &node.Identifier{Value: "function"}, - Use: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, - Alias: &node.Identifier{Value: "Bar"}, - }) - - expected := `function Foo as Bar` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} - -func TestPrinterPrintWhileStmtList(t *testing.T) { - o := bytes.NewBufferString("") - - p := printer.NewPrinter(o) - p.Print(&stmt.While{ - Cond: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Expression{Expr: &expr.Variable{ - VarName: &node.Identifier{Value: "a"}, - }}, - }, - }, - }) - - expected := `while($a){$a;}` - actual := o.String() - - if expected != actual { - t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) - } -} diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go deleted file mode 100644 index 63a01af..0000000 --- a/scanner/scanner_test.go +++ /dev/null @@ -1,1659 +0,0 @@ -package scanner - -import ( - "testing" - - "github.com/z7zmey/php-parser/freefloating" - "github.com/z7zmey/php-parser/position" - "gotest.tools/assert" -) - -type lval struct { - Tkn *Token -} - -func (lv *lval) Token(t *Token) { - lv.Tkn = t -} - -func TestTokens(t *testing.T) { - src := `inline html - - - - - <=> - != - <> - !== - == - === - <<= - >>= - >= - <= - ** - << - >> - ?? - - # inline comment - // inline comment - - /* - multiline comment - */ - - /** - * PHP Doc comment - */ - - ; - : - , - . - [ - ] - ( - ) - | - / - ^ - & - + - - - * - = - % - ! - ~ - $ - < - > - ? - @ - { - } - - $var - str - - -> ` + "\t\r\n" + ` ->prop - - ( array ) - ( bool ) - ( boolean ) - ( real ) - ( double ) - ( float ) - ( int ) - ( integer ) - ( object ) - ( string ) - ( binary ) - ( unset ) - - ` - - expected := []string{ - T_INLINE_HTML.String(), - TokenID(int(';')).String(), - T_INLINE_HTML.String(), - T_ECHO.String(), - TokenID(int(';')).String(), - T_INLINE_HTML.String(), - - T_ABSTRACT.String(), - T_ARRAY.String(), - T_AS.String(), - T_BREAK.String(), - T_CALLABLE.String(), - T_CASE.String(), - T_CATCH.String(), - T_CLASS.String(), - T_CLONE.String(), - T_CONST.String(), - T_CONTINUE.String(), - T_DECLARE.String(), - T_DEFAULT.String(), - T_DO.String(), - T_ECHO.String(), - T_ELSE.String(), - T_ELSEIF.String(), - T_EMPTY.String(), - T_ENDDECLARE.String(), - T_ENDFOR.String(), - T_ENDFOREACH.String(), - T_ENDIF.String(), - T_ENDSWITCH.String(), - T_ENDWHILE.String(), - T_EVAL.String(), - T_EXIT.String(), - T_EXTENDS.String(), - T_FINAL.String(), - T_FINALLY.String(), - T_FOR.String(), - T_FOREACH.String(), - T_FUNCTION.String(), - T_FUNCTION.String(), - T_GLOBAL.String(), - T_GOTO.String(), - T_IF.String(), - T_ISSET.String(), - T_IMPLEMENTS.String(), - T_INSTANCEOF.String(), - T_INSTEADOF.String(), - T_INTERFACE.String(), - T_LIST.String(), - T_NAMESPACE.String(), - T_PRIVATE.String(), - T_PUBLIC.String(), - T_PRINT.String(), - T_PROTECTED.String(), - T_RETURN.String(), - T_STATIC.String(), - T_SWITCH.String(), - T_THROW.String(), - T_TRAIT.String(), - T_TRY.String(), - T_UNSET.String(), - T_USE.String(), - T_VAR.String(), - T_WHILE.String(), - T_YIELD_FROM.String(), - T_YIELD.String(), - T_INCLUDE.String(), - T_INCLUDE_ONCE.String(), - T_REQUIRE.String(), - T_REQUIRE_ONCE.String(), - - T_CLASS_C.String(), - T_DIR.String(), - T_FILE.String(), - T_FUNC_C.String(), - T_LINE.String(), - T_NS_C.String(), - T_METHOD_C.String(), - T_TRAIT_C.String(), - T_HALT_COMPILER.String(), - - T_NEW.String(), - T_LOGICAL_AND.String(), - T_LOGICAL_OR.String(), - T_LOGICAL_XOR.String(), - - T_NS_SEPARATOR.String(), - T_ELLIPSIS.String(), - T_PAAMAYIM_NEKUDOTAYIM.String(), - T_BOOLEAN_AND.String(), - T_BOOLEAN_OR.String(), - T_AND_EQUAL.String(), - T_OR_EQUAL.String(), - T_CONCAT_EQUAL.String(), - T_MUL_EQUAL.String(), - T_POW_EQUAL.String(), - T_DIV_EQUAL.String(), - T_PLUS_EQUAL.String(), - T_MINUS_EQUAL.String(), - T_XOR_EQUAL.String(), - T_MOD_EQUAL.String(), - T_DEC.String(), - T_INC.String(), - T_DOUBLE_ARROW.String(), - T_SPACESHIP.String(), - T_IS_NOT_EQUAL.String(), - T_IS_NOT_EQUAL.String(), - T_IS_NOT_IDENTICAL.String(), - T_IS_EQUAL.String(), - T_IS_IDENTICAL.String(), - T_SL_EQUAL.String(), - T_SR_EQUAL.String(), - T_IS_GREATER_OR_EQUAL.String(), - T_IS_SMALLER_OR_EQUAL.String(), - T_POW.String(), - T_SL.String(), - T_SR.String(), - T_COALESCE.String(), - - TokenID(int(';')).String(), - TokenID(int(':')).String(), - TokenID(int(',')).String(), - TokenID(int('.')).String(), - TokenID(int('[')).String(), - TokenID(int(']')).String(), - TokenID(int('(')).String(), - TokenID(int(')')).String(), - TokenID(int('|')).String(), - TokenID(int('/')).String(), - TokenID(int('^')).String(), - TokenID(int('&')).String(), - TokenID(int('+')).String(), - TokenID(int('-')).String(), - TokenID(int('*')).String(), - TokenID(int('=')).String(), - TokenID(int('%')).String(), - TokenID(int('!')).String(), - TokenID(int('~')).String(), - TokenID(int('$')).String(), - TokenID(int('<')).String(), - TokenID(int('>')).String(), - TokenID(int('?')).String(), - TokenID(int('@')).String(), - TokenID(int('{')).String(), - TokenID(int('}')).String(), - - T_VARIABLE.String(), - T_STRING.String(), - - T_OBJECT_OPERATOR.String(), - T_OBJECT_OPERATOR.String(), - T_STRING.String(), - - T_ARRAY_CAST.String(), - T_BOOL_CAST.String(), - T_BOOL_CAST.String(), - T_DOUBLE_CAST.String(), - T_DOUBLE_CAST.String(), - T_DOUBLE_CAST.String(), - T_INT_CAST.String(), - T_INT_CAST.String(), - T_OBJECT_CAST.String(), - T_STRING_CAST.String(), - T_STRING_CAST.String(), - T_UNSET_CAST.String(), - } - - lexer := NewLexer([]byte(src)) - lexer.WithFreeFloating = true - lv := &lval{} - actual := []string{} - - for { - token := lexer.Lex(lv) - if token == 0 { - break - } - - actual = append(actual, TokenID(token).String()) - } - - assert.DeepEqual(t, expected, actual) -} - -func TestShebang(t *testing.T) { - src := `#!/usr/bin/env php -prop - $var[1] - $var[0x1] - $var[0b1] - $var[var_name] - $var[$var] - - {$var} - ${var_name} - {s $ \$a -CAT; - ` - - expected := []string{ - T_START_HEREDOC.String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_END_HEREDOC.String(), - TokenID(int(';')).String(), - - T_START_HEREDOC.String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_END_HEREDOC.String(), - TokenID(int(';')).String(), - - T_START_HEREDOC.String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - T_OBJECT_OPERATOR.String(), - T_STRING.String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - TokenID(int('[')).String(), - T_NUM_STRING.String(), - TokenID(int(']')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - TokenID(int('[')).String(), - T_NUM_STRING.String(), - TokenID(int(']')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - TokenID(int('[')).String(), - T_NUM_STRING.String(), - TokenID(int(']')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - TokenID(int('[')).String(), - T_STRING.String(), - TokenID(int(']')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_VARIABLE.String(), - TokenID(int('[')).String(), - T_VARIABLE.String(), - TokenID(int(']')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_CURLY_OPEN.String(), - T_VARIABLE.String(), - TokenID(int('}')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_DOLLAR_OPEN_CURLY_BRACES.String(), - T_STRING_VARNAME.String(), - TokenID(int('}')).String(), - T_ENCAPSED_AND_WHITESPACE.String(), - T_END_HEREDOC.String(), - TokenID(int(';')).String(), - } - - lexer := NewLexer([]byte(src)) - lexer.WithFreeFloating = true - lv := &lval{} - actual := []string{} - - for { - token := lexer.Lex(lv) - if token == 0 { - break - } - - actual = append(actual, TokenID(token).String()) - } - - assert.DeepEqual(t, expected, actual) -} - -func TestHereDocTokens2(t *testing.T) { - src := ` test test - ` - - expected := []string{ - T_VARIABLE.String(), - TokenID(int(';')).String(), - T_INLINE_HTML.String(), - - T_VARIABLE.String(), - TokenID(int(';')).String(), - T_INLINE_HTML.String(), - } - - lexer := NewLexer([]byte(src)) - lexer.WithFreeFloating = true - lv := &lval{} - actual := []string{} - - for { - token := lexer.Lex(lv) - if token == 0 { - break - } - - actual = append(actual, TokenID(token).String()) - } - - assert.DeepEqual(t, expected, actual) -} - -func TestStringTokensAfterVariable(t *testing.T) { - src := ` test` - - expected := []freefloating.String{ - { - Value: " bar ( '' ) ;` - - lexer := NewLexer([]byte(src)) - lexer.WithFreeFloating = true - lv := &lval{} - - expected := []freefloating.String{ - { - Value: " second.major { - return 1, nil - } - - if first.minor < second.minor { - return -1, nil - } - - if first.minor > second.minor { - return 1, nil - } - - return 0, nil -} - -func parse(v string) (version, error) { - parts := strings.Split(v, ".") - if len(parts) != 2 { - return version{}, errors.New("version must contain major and minor parts") - } - - major, err := strconv.Atoi(parts[0]) - if err != nil { - return version{}, err - } - - minor, err := strconv.Atoi(parts[1]) - if err != nil { - return version{}, err - } - - return version{major, minor}, nil -} diff --git a/visitor/dumper.go b/visitor/dumper.go deleted file mode 100644 index 785679a..0000000 --- a/visitor/dumper.go +++ /dev/null @@ -1,83 +0,0 @@ -// Package visitor contains walker.visitor implementations -package visitor - -import ( - "fmt" - "io" - "reflect" - "strings" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/walker" -) - -// Dumper writes ast hierarchy to an io.Writer -// Also prints comments and positions attached to nodes -type Dumper struct { - Writer io.Writer - Indent string - NsResolver *NamespaceResolver -} - -// EnterNode is invoked at every node in hierarchy -func (d *Dumper) EnterNode(w walker.Walkable) bool { - n := w.(node.Node) - - fmt.Fprintf(d.Writer, "%v[%v]\n", d.Indent, reflect.TypeOf(n)) - - if n.GetPosition() != nil { - fmt.Fprintf(d.Writer, "%v\"Position\": %s\n", d.Indent+" ", n.GetPosition()) - } - - if d.NsResolver != nil { - if namespacedName, ok := d.NsResolver.ResolvedNames[n]; ok { - fmt.Fprintf(d.Writer, "%v\"NamespacedName\": %q\n", d.Indent+" ", namespacedName) - } - } - - 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 { - 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 -} - -// LeaveNode is invoked after node process -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 deleted file mode 100644 index cdfc78d..0000000 --- a/visitor/dumper_test.go +++ /dev/null @@ -1,151 +0,0 @@ -package visitor_test - -import ( - "os" - - "github.com/z7zmey/php-parser/php7" - "github.com/z7zmey/php-parser/visitor" -) - -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 deleted file mode 100644 index 2970615..0000000 --- a/visitor/go_dumper_test.go +++ /dev/null @@ -1,528 +0,0 @@ -package visitor_test - -import ( - "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, "}") - - d.isNotFirstNode = true - d.isChildNode = false -} - -func (d *JsonDumper) EnterChildNode(key string, w walker.Walkable) { - fmt.Fprintf(d.Writer, ",%q:", key) - d.isChildNode = true -} - -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) - d.isNotFirstNode = false - -} - -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 deleted file mode 100644 index b803fc3..0000000 --- a/visitor/json_dumper_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package visitor_test - -import ( - "os" - - "github.com/z7zmey/php-parser/php7" - "github.com/z7zmey/php-parser/visitor" -) - -func ExampleJsonDumper() { - src := ` 1 { - // if name qualified, replace first part by alias - return aliasName + "\\" + concatNameParts(n.Parts[1:]), nil - } - - return aliasName, nil - } - - return "", errors.New("must be instance of name.Names") -} - -// ResolveAlias returns alias or error if not found -func (ns *Namespace) ResolveAlias(nameNode node.Node, aliasType string) (string, error) { - aliasType = strings.ToLower(aliasType) - nameParts := nameNode.(*name.Name).Parts - - firstPartStr := nameParts[0].(*name.NamePart).Value - - if len(nameParts) > 1 { // resolve aliases for qualified names, always against class alias type - firstPartStr = strings.ToLower(firstPartStr) - aliasType = "" - } else { - if aliasType != "const" { // constants are case-sensitive - firstPartStr = strings.ToLower(firstPartStr) - } - } - - aliasName, ok := ns.Aliases[aliasType][firstPartStr] - if !ok { - return "", errors.New("Not found") - } - - return aliasName, nil -} - -func concatNameParts(parts ...[]node.Node) string { - str := "" - - for _, p := range parts { - for _, n := range p { - if str == "" { - str = n.(*name.NamePart).Value - } else { - str = str + "\\" + n.(*name.NamePart).Value - } - } - } - - return str -} diff --git a/visitor/namespace_resolver_test.go b/visitor/namespace_resolver_test.go deleted file mode 100644 index b9137cd..0000000 --- a/visitor/namespace_resolver_test.go +++ /dev/null @@ -1,1028 +0,0 @@ -package visitor_test - -import ( - "testing" - - "gotest.tools/assert" - - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/node/expr" - "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/visitor" -) - -func TestResolveStaticCall(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.StaticCall{ - Class: nameBC, - Call: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveStaticPropertyFetch(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.StaticPropertyFetch{ - Class: nameBC, - Property: &node.Identifier{Value: "foo"}, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveClassConstFetch(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.ClassConstFetch{ - Class: nameBC, - ConstantName: &node.Identifier{Value: "FOO"}, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveNew(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.New{ - Class: nameBC, - ArgumentList: &node.ArgumentList{}, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveInstanceOf(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.InstanceOf{ - Expr: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Class: nameBC, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveInstanceCatch(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - nameDE := &name.Name{Parts: []node.Node{&name.NamePart{Value: "D"}, &name.NamePart{Value: "E"}}} - nameF := &name.Name{Parts: []node.Node{&name.NamePart{Value: "F"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - &stmt.Use{ - Use: nameDE, - Alias: &node.Identifier{Value: "F"}, - }, - }, - }, - &stmt.Try{ - Stmts: []node.Node{}, - Catches: []node.Node{ - &stmt.Catch{ - Types: []node.Node{ - nameBC, - nameF, - }, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Stmts: []node.Node{}, - }, - }, - }, - }, - } - - expected := map[node.Node]string{ - nameBC: "A\\B\\C", - nameF: "D\\E", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveFunctionCall(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - UseType: &node.Identifier{Value: "function"}, - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.FunctionCall{ - Function: nameB, - ArgumentList: &node.ArgumentList{}, - }, - }, - } - - expected := map[node.Node]string{ - nameB: "A\\B", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveConstFetch(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - UseType: &node.Identifier{Value: "const"}, - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &expr.ConstFetch{ - Constant: nameB, - }, - }, - } - - expected := map[node.Node]string{ - nameB: "A\\B", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveGroupUse(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBD := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "D"}}} - nameE := &name.Name{Parts: []node.Node{&name.NamePart{Value: "E"}}} - nameC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "C"}}} - nameF := &name.Name{Parts: []node.Node{&name.NamePart{Value: "F"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.GroupUse{ - Prefix: nameAB, - UseList: []node.Node{ - &stmt.Use{ - UseType: &node.Identifier{Value: "Function"}, - Use: nameF, - }, - &stmt.Use{ - UseType: &node.Identifier{Value: "const"}, - Use: nameC, - }, - }, - }, - &stmt.GroupUse{ - Prefix: nameBD, - UseType: &node.Identifier{Value: "Function"}, - UseList: []node.Node{ - &stmt.Use{ - Use: nameE, - }, - }, - }, - &expr.ConstFetch{ - Constant: nameC, - }, - &expr.FunctionCall{ - Function: nameF, - ArgumentList: &node.ArgumentList{}, - }, - &expr.FunctionCall{ - Function: nameE, - ArgumentList: &node.ArgumentList{}, - }, - }, - } - - expected := map[node.Node]string{ - nameC: "A\\B\\C", - nameF: "A\\B\\F", - nameE: "B\\D\\E", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveTraitUse(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}}} - nameD := &name.Name{Parts: []node.Node{&name.NamePart{Value: "D"}}} - - fullyQualifiedNameB := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}}} - fullyQualifiedNameBC := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - relativeNameB := &name.Relative{Parts: []node.Node{&name.NamePart{Value: "B"}}} - relativeNameBC := &name.Relative{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAB, - }, - }, - }, - &stmt.TraitUse{ - Traits: []node.Node{ - nameB, - relativeNameB, - }, - TraitAdaptationList: &stmt.TraitAdaptationList{ - Adaptations: []node.Node{ - &stmt.TraitUsePrecedence{ - Ref: &stmt.TraitMethodRef{ - Trait: fullyQualifiedNameB, - Method: &node.Identifier{Value: "foo"}, - }, - Insteadof: []node.Node{fullyQualifiedNameBC}, - }, - &stmt.TraitUseAlias{ - Ref: &stmt.TraitMethodRef{ - Trait: relativeNameBC, - Method: &node.Identifier{Value: "foo"}, - }, - Alias: &node.Identifier{Value: "bar"}, - }, - }, - }, - }, - &stmt.TraitUse{ - Traits: []node.Node{ - nameD, - }, - }, - }, - } - - expected := map[node.Node]string{ - nameB: "A\\B", - nameD: "D", - relativeNameB: "B", - fullyQualifiedNameB: "B", - fullyQualifiedNameBC: "B\\C", - relativeNameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveClassName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - class := &stmt.Class{ - PhpDocComment: "", - ClassName: &node.Identifier{Value: "A"}, - Extends: &stmt.ClassExtends{ - ClassName: nameAB, - }, - Implements: &stmt.ClassImplements{ - InterfaceNames: []node.Node{ - nameBC, - }, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - class, - }, - } - - expected := map[node.Node]string{ - class: "A", - nameAB: "A\\B", - nameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveInterfaceName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - interfaceNode := &stmt.Interface{ - PhpDocComment: "", - InterfaceName: &node.Identifier{Value: "A"}, - Extends: &stmt.InterfaceExtends{ - InterfaceNames: []node.Node{ - nameAB, - nameBC, - }, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - interfaceNode, - }, - } - - expected := map[node.Node]string{ - interfaceNode: "A", - nameAB: "A\\B", - nameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveTraitName(t *testing.T) { - traitNode := &stmt.Trait{ - PhpDocComment: "", - TraitName: &node.Identifier{Value: "A"}, - Stmts: []node.Node{}, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - traitNode, - }, - } - - expected := map[node.Node]string{ - traitNode: "A", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveFunctionName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - functionNode := &stmt.Function{ - ReturnsRef: false, - PhpDocComment: "", - FunctionName: &node.Identifier{Value: "A"}, - Params: []node.Node{ - &node.Parameter{ - ByRef: false, - Variadic: false, - VariableType: nameAB, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - }, - }, - ReturnType: &node.Nullable{Expr: nameBC}, - Stmts: []node.Node{}, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - functionNode, - }, - } - - expected := map[node.Node]string{ - functionNode: "A", - nameAB: "A\\B", - nameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveMethodName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - methodNode := &stmt.ClassMethod{ - ReturnsRef: false, - PhpDocComment: "", - MethodName: &node.Identifier{Value: "A"}, - Params: []node.Node{ - &node.Parameter{ - ByRef: false, - Variadic: false, - VariableType: nameAB, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - }, - }, - ReturnType: &node.Nullable{Expr: nameBC}, - Stmt: &stmt.StmtList{ - Stmts: []node.Node{}, - }, - } - - expected := map[node.Node]string{ - nameAB: "A\\B", - nameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - methodNode.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveClosureName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameBC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}} - - closureNode := &expr.Closure{ - ReturnsRef: false, - Static: false, - PhpDocComment: "", - Params: []node.Node{ - &node.Parameter{ - ByRef: false, - Variadic: false, - VariableType: nameAB, - Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - }, - }, - ReturnType: &node.Nullable{Expr: nameBC}, - Stmts: []node.Node{}, - } - - expected := map[node.Node]string{ - nameAB: "A\\B", - nameBC: "B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - closureNode.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveConstantsName(t *testing.T) { - nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - - constantB := &stmt.Constant{ - PhpDocComment: "", - ConstantName: &node.Identifier{Value: "B"}, - Expr: &scalar.Lnumber{Value: "1"}, - } - constantC := &stmt.Constant{ - PhpDocComment: "", - ConstantName: &node.Identifier{Value: "C"}, - Expr: &scalar.Lnumber{Value: "1"}, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: nameAB, - }, - &stmt.ConstList{ - Consts: []node.Node{ - constantB, - constantC, - }, - }, - }, - } - - expected := map[node.Node]string{ - constantB: "A\\B\\B", - constantC: "A\\B\\C", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveNamespaces(t *testing.T) { - namespaceAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - namespaceCD := &name.Name{Parts: []node.Node{&name.NamePart{Value: "C"}, &name.NamePart{Value: "D"}}} - - nameAC := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "C"}}} - nameCF := &name.Name{Parts: []node.Node{&name.NamePart{Value: "C"}, &name.NamePart{Value: "F"}}} - nameFG := &name.Name{Parts: []node.Node{&name.NamePart{Value: "F"}, &name.NamePart{Value: "G"}}} - relativeNameCE := &name.Relative{Parts: []node.Node{&name.NamePart{Value: "C"}, &name.NamePart{Value: "E"}}} - - constantB := &stmt.Constant{ - PhpDocComment: "", - ConstantName: &node.Identifier{Value: "B"}, - Expr: &scalar.Lnumber{Value: "1"}, - } - constantC := &stmt.Constant{ - PhpDocComment: "", - ConstantName: &node.Identifier{Value: "C"}, - Expr: &scalar.Lnumber{Value: "1"}, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: namespaceAB, - }, - &stmt.ConstList{ - Consts: []node.Node{ - constantB, - constantC, - }, - }, - &expr.StaticCall{ - Class: nameFG, - Call: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - &stmt.Namespace{ - Stmts: []node.Node{}, - }, - &stmt.Namespace{ - NamespaceName: namespaceCD, - Stmts: []node.Node{ - &stmt.UseList{ - Uses: []node.Node{ - &stmt.Use{ - Use: nameAC, - }, - }, - }, - &expr.StaticCall{ - Class: relativeNameCE, - Call: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - &expr.StaticCall{ - Class: nameCF, - Call: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - }, - }, - } - - expected := map[node.Node]string{ - constantB: "A\\B\\B", - constantC: "A\\B\\C", - nameFG: "A\\B\\F\\G", - relativeNameCE: "C\\D\\C\\E", - nameCF: "A\\C\\F", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolveStaticCallDinamicClassName(t *testing.T) { - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &expr.StaticCall{ - Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, - Call: &node.Identifier{Value: "foo"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - } - - expected := map[node.Node]string{} - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestDoNotResolveReservedConstants(t *testing.T) { - namespaceName := &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}} - - constantTrue := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "True"}, - }, - } - - constantFalse := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "False"}, - }, - } - - constantNull := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "NULL"}, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: namespaceName, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: constantTrue, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: constantFalse, - }, - }, - &stmt.Expression{ - Expr: &expr.ConstFetch{ - Constant: constantNull, - }, - }, - }, - } - - expected := map[node.Node]string{ - constantTrue: "true", - constantFalse: "false", - constantNull: "null", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestDoNotResolveReservedNames(t *testing.T) { - - nameInt := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "int"}, - }, - } - - nameFloat := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "float"}, - }, - } - - nameBool := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "bool"}, - }, - } - - nameString := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "string"}, - }, - } - - nameVoid := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "void"}, - }, - } - - nameIterable := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "iterable"}, - }, - } - - nameObject := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "object"}, - }, - } - - function := &stmt.Function{ - FunctionName: &node.Identifier{Value: "bar"}, - Params: []node.Node{ - &node.Parameter{ - VariableType: nameInt, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Int"}, - }, - }, - &node.Parameter{ - VariableType: nameFloat, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Float"}, - }, - }, - &node.Parameter{ - VariableType: nameBool, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Bool"}, - }, - }, - &node.Parameter{ - VariableType: nameString, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "String"}, - }, - }, - &node.Parameter{ - VariableType: nameVoid, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Void"}, - }, - }, - &node.Parameter{ - VariableType: nameIterable, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Iterable"}, - }, - }, - &node.Parameter{ - VariableType: nameObject, - Variable: &expr.Variable{ - VarName: &node.Identifier{Value: "Object"}, - }, - }, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - function, - }, - } - - expected := map[node.Node]string{ - function: "Foo\\bar", - nameInt: "int", - nameFloat: "float", - nameBool: "bool", - nameString: "string", - nameVoid: "void", - nameIterable: "iterable", - nameObject: "object", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestDoNotResolveReservedSpecialNames(t *testing.T) { - - nameSelf := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Self"}, - }, - } - - nameStatic := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Static"}, - }, - } - - nameParent := &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Parent"}, - }, - } - - cls := &stmt.Class{ - ClassName: &node.Identifier{Value: "Bar"}, - Stmts: []node.Node{ - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: nameSelf, - Call: &node.Identifier{Value: "func"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: nameStatic, - Call: &node.Identifier{Value: "func"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - &stmt.Expression{ - Expr: &expr.StaticCall{ - Class: nameParent, - Call: &node.Identifier{Value: "func"}, - ArgumentList: &node.ArgumentList{}, - }, - }, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - cls, - }, - } - - expected := map[node.Node]string{ - cls: "Foo\\Bar", - nameSelf: "self", - nameStatic: "static", - nameParent: "parent", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} - -func TestResolvePropertyTypeName(t *testing.T) { - nameSimple := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameRelative := &name.Relative{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - nameFullyQualified := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}} - - propertyNodeSimple := &stmt.PropertyList{ - Type: nameSimple, - } - - propertyNodeRelative := &stmt.PropertyList{ - Type: nameRelative, - } - - propertyNodeFullyQualified := &stmt.PropertyList{ - Type: nameFullyQualified, - } - - classNode := &stmt.Class{ - ClassName: &node.Identifier{Value: "Bar"}, - Stmts: []node.Node{ - propertyNodeSimple, - propertyNodeRelative, - propertyNodeFullyQualified, - }, - } - - ast := &stmt.StmtList{ - Stmts: []node.Node{ - &stmt.Namespace{ - NamespaceName: &name.Name{ - Parts: []node.Node{ - &name.NamePart{Value: "Foo"}, - }, - }, - }, - classNode, - }, - } - - expected := map[node.Node]string{ - nameSimple: "Foo\\A\\B", - nameRelative: "Foo\\A\\B", - nameFullyQualified: "A\\B", - classNode: "Foo\\Bar", - } - - nsResolver := visitor.NewNamespaceResolver() - ast.Walk(nsResolver) - - assert.DeepEqual(t, expected, nsResolver.ResolvedNames) -} diff --git a/visitor/pretty_json_dumper.go b/visitor/pretty_json_dumper.go deleted file mode 100644 index 9e0e7a9..0000000 --- a/visitor/pretty_json_dumper.go +++ /dev/null @@ -1,190 +0,0 @@ -// Package visitor contains walker.visitor implementations -package visitor - -import ( - "fmt" - "io" - "reflect" - - "github.com/z7zmey/php-parser/freefloating" - "github.com/z7zmey/php-parser/node" - "github.com/z7zmey/php-parser/walker" -) - -type PrettyJsonDumper struct { - Writer io.Writer - NsResolver *NamespaceResolver - depth int - isChildNode bool - isNotFirstNode bool -} - -func NewPrettyJsonDumper(Writer io.Writer, NsResolver *NamespaceResolver) *PrettyJsonDumper { - return &PrettyJsonDumper{ - Writer: Writer, - NsResolver: NsResolver, - depth: 0, - isChildNode: false, - isNotFirstNode: false, - } -} - -func (d *PrettyJsonDumper) printIndent(w io.Writer) { - for i := 0; i < d.depth; i++ { - fmt.Fprint(d.Writer, " ") - } -} - -// EnterNode is invoked at every node in hierarchy -func (d *PrettyJsonDumper) EnterNode(w walker.Walkable) bool { - n := w.(node.Node) - - nodeType := reflect.TypeOf(n).String() - - if d.isChildNode { - d.isChildNode = false - } else if d.isNotFirstNode { - fmt.Fprint(d.Writer, ",\n") - d.printIndent(d.Writer) - } else { - d.printIndent(d.Writer) - d.isNotFirstNode = true - } - - fmt.Fprint(d.Writer, "{\n") - d.depth++ - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %q", "type", nodeType) - - if p := n.GetPosition(); p != nil { - fmt.Fprint(d.Writer, ",\n") - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: {\n", "position") - d.depth++ - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %d,\n", "startPos", p.StartPos) - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %d,\n", "endPos", p.EndPos) - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %d,\n", "startLine", p.StartLine) - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %d\n", "endLine", p.EndLine) - d.depth-- - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "}") - } - - if d.NsResolver != nil { - if namespacedName, ok := d.NsResolver.ResolvedNames[n]; ok { - fmt.Fprint(d.Writer, ",\n") - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "\"namespacedName\": %q", namespacedName) - } - } - - if !n.GetFreeFloating().IsEmpty() { - fmt.Fprint(d.Writer, ",\n") - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "\"freefloating\": {\n") - d.depth++ - i := 0 - for key, freeFloatingStrings := range *n.GetFreeFloating() { - if i != 0 { - fmt.Fprint(d.Writer, ",\n") - } - i++ - - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: [\n", key) - d.depth++ - - j := 0 - for _, freeFloatingString := range freeFloatingStrings { - if j != 0 { - fmt.Fprint(d.Writer, ",\n") - } - j++ - - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "{\n") - d.depth++ - d.printIndent(d.Writer) - switch freeFloatingString.StringType { - case freefloating.CommentType: - fmt.Fprintf(d.Writer, "%q: %q,\n", "type", "freefloating.CommentType") - case freefloating.WhiteSpaceType: - fmt.Fprintf(d.Writer, "%q: %q,\n", "type", "freefloating.WhiteSpaceType") - case freefloating.TokenType: - fmt.Fprintf(d.Writer, "%q: %q,\n", "type", "freefloating.TokenType") - } - d.printIndent(d.Writer) - fmt.Fprintf(d.Writer, "%q: %q\n", "value", freeFloatingString.Value) - d.depth-- - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "}") - } - - d.depth-- - fmt.Fprint(d.Writer, "\n") - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "]") - } - d.depth-- - fmt.Fprint(d.Writer, "\n") - d.printIndent(d.Writer) - fmt.Fprint(d.Writer, "}") - } - - if a := n.Attributes(); len(a) > 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, "}") - - d.isNotFirstNode = true - d.isChildNode = false -} - -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 deleted file mode 100644 index 307581d..0000000 --- a/visitor/pretty_json_dumper_test.go +++ /dev/null @@ -1,509 +0,0 @@ -package visitor_test - -import ( - "os" - - "github.com/z7zmey/php-parser/php7" - "github.com/z7zmey/php-parser/visitor" -) - -func ExamplePrettyJsonDumper() { - src := `