diff --git a/go.mod b/go.mod index bdad5a47c25..bf92ab168e8 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Masterminds/squirrel v1.5.4 github.com/NYTimes/gziphandler v1.1.1 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 - github.com/alicebob/miniredis/v2 v2.30.0 + github.com/alicebob/miniredis/v2 v2.30.1 github.com/armon/go-metrics v0.4.1 github.com/aws/aws-sdk-go v1.44.217 github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b @@ -191,7 +191,7 @@ require ( github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/vimeo/galaxycache v0.0.0-20210323154928-b7e5d71c067a // indirect github.com/weaveworks/promrus v1.2.0 // indirect - github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 // indirect + github.com/yuin/gopher-lua v1.1.0 // indirect go.mongodb.org/mongo-driver v1.11.2 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 // indirect diff --git a/go.sum b/go.sum index 217bb6ae5c2..e06257ce085 100644 --- a/go.sum +++ b/go.sum @@ -505,8 +505,8 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= -github.com/alicebob/miniredis/v2 v2.30.0 h1:uA3uhDbCxfO9+DI/DuGeAMr9qI+noVWwGPNTFuKID5M= -github.com/alicebob/miniredis/v2 v2.30.0/go.mod h1:84TWKZlxYkfgMucPBf5SOQBYJceZeQRFIaQgNMiCX6Q= +github.com/alicebob/miniredis/v2 v2.30.1 h1:HM1rlQjq1bm9yQcsawJqSZBJ9AYgxvjkMsNtddh90+g= +github.com/alicebob/miniredis/v2 v2.30.1/go.mod h1:b25qWj4fCEsBeAAR2mlb0ufImGC6uH3VlUfb/HS5zKg= github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible h1:9gWa46nstkJ9miBReJcN8Gq34cBFbzSpQZVVT9N09TM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20210818145353-234c94e4ce64/go.mod h1:2qMFB56yOP3KzkB3PbYZ4AlUFg3a88F67TIx5lB/WwY= @@ -1920,8 +1920,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 h1:5mLPGnFdSsevFRFc9q3yYbBkB6tsm4aCwwQV/j1JQAQ= -github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= +github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= diff --git a/vendor/github.com/alicebob/miniredis/v2/CHANGELOG.md b/vendor/github.com/alicebob/miniredis/v2/CHANGELOG.md index d9700af64e9..b30a29477dd 100644 --- a/vendor/github.com/alicebob/miniredis/v2/CHANGELOG.md +++ b/vendor/github.com/alicebob/miniredis/v2/CHANGELOG.md @@ -1,6 +1,11 @@ ## Changelog +### v2.30.1 + +- support SET NX GET special case + + ### v2.30.0 - implement redis 7.0.x (from 6.X). Main changes: diff --git a/vendor/github.com/alicebob/miniredis/v2/Makefile b/vendor/github.com/alicebob/miniredis/v2/Makefile index 2aa4cd2c573..125f574cffe 100644 --- a/vendor/github.com/alicebob/miniredis/v2/Makefile +++ b/vendor/github.com/alicebob/miniredis/v2/Makefile @@ -9,4 +9,4 @@ testrace: go test -race ./... int: - ${MAKE} -C integration all + INT=1 go test ./... diff --git a/vendor/github.com/alicebob/miniredis/v2/cmd_string.go b/vendor/github.com/alicebob/miniredis/v2/cmd_string.go index cec9d48343c..b8013f2811c 100644 --- a/vendor/github.com/alicebob/miniredis/v2/cmd_string.go +++ b/vendor/github.com/alicebob/miniredis/v2/cmd_string.go @@ -131,16 +131,27 @@ func (m *Miniredis) cmdSet(c *server.Peer, cmd string, args []string) { withTx(m, c, func(c *server.Peer, ctx *connCtx) { db := m.db(ctx.selectedDB) + readonly := false if opts.nx { if db.exists(opts.key) { - c.WriteNull() - return + if opts.get { + // special case for SET NX GET + readonly = true + } else { + c.WriteNull() + return + } } } if opts.xx { if !db.exists(opts.key) { - c.WriteNull() - return + if opts.get { + // special case for SET XX GET + readonly = true + } else { + c.WriteNull() + return + } } } if opts.keepttl { @@ -154,14 +165,17 @@ func (m *Miniredis) cmdSet(c *server.Peer, cmd string, args []string) { return } } + old, existed := db.stringKeys[opts.key] - db.del(opts.key, true) // be sure to remove existing values of other type keys. - // a vanilla SET clears the expire - if opts.ttl >= 0 { // EXAT/PXAT can expire right away - db.stringSet(opts.key, opts.value) - } - if opts.ttl != 0 { - db.ttl[opts.key] = opts.ttl + if !readonly { + db.del(opts.key, true) // be sure to remove existing values of other type keys. + // a vanilla SET clears the expire + if opts.ttl >= 0 { // EXAT/PXAT can expire right away + db.stringSet(opts.key, opts.value) + } + if opts.ttl != 0 { + db.ttl[opts.key] = opts.ttl + } } if opts.get { if !existed { diff --git a/vendor/github.com/yuin/gopher-lua/.travis.yml b/vendor/github.com/yuin/gopher-lua/.travis.yml deleted file mode 100644 index 68df5e7b1a1..00000000000 --- a/vendor/github.com/yuin/gopher-lua/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go - -go: - - "1.9.x" - - "1.10.x" - - "1.11.x" -env: - global: - GO111MODULE=off - -before_install: - - go get github.com/axw/gocov/gocov - - go get github.com/mattn/goveralls - - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi -install: - - go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep '\.' | grep -v gopher-lua) -script: - - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/yuin/gopher-lua/README.rst b/vendor/github.com/yuin/gopher-lua/README.rst index 2b6de3259ac..cc936311069 100644 --- a/vendor/github.com/yuin/gopher-lua/README.rst +++ b/vendor/github.com/yuin/gopher-lua/README.rst @@ -3,14 +3,14 @@ GopherLua: VM and compiler for Lua in Go. =============================================================================== -.. image:: https://godoc.org/github.com/yuin/gopher-lua?status.svg - :target: http://godoc.org/github.com/yuin/gopher-lua +.. image:: https://pkg.go.dev/badge/github.com/yuin/gopher-lua.svg + :target: https://pkg.go.dev/github.com/yuin/gopher-lua -.. image:: https://travis-ci.org/yuin/gopher-lua.svg - :target: https://travis-ci.org/yuin/gopher-lua +.. image:: https://github.com/yuin/gopher-lua/workflows/test/badge.svg?branch=master&event=push + :target: https://github.com/yuin/gopher-lua/actions?query=workflow:test -.. image:: https://coveralls.io/repos/yuin/gopher-lua/badge.svg - :target: https://coveralls.io/r/yuin/gopher-lua +.. image:: https://coveralls.io/repos/github/yuin/gopher-lua/badge.svg?branch=master + :target: https://coveralls.io/github/yuin/gopher-lua .. image:: https://badges.gitter.im/Join%20Chat.svg :alt: Join the chat at https://gitter.im/yuin/gopher-lua @@ -19,7 +19,7 @@ GopherLua: VM and compiler for Lua in Go. | -GopherLua is a Lua5.1 VM and compiler written in Go. GopherLua has a same goal +GopherLua is a Lua5.1(+ `goto` statement in Lua5.2) VM and compiler written in Go. GopherLua has a same goal with Lua: **Be a scripting language with extensible semantics** . It provides Go APIs that allow you to easily embed a scripting language to your Go host programs. @@ -830,6 +830,8 @@ Miscellaneous notes - ``file:setvbuf`` does not support a line buffering. - Daylight saving time is not supported. - GopherLua has a function to set an environment variable : ``os.setenv(name, value)`` +- GopherLua support ``goto`` and ``::label::`` statement in Lua5.2. + - `goto` is a keyword and not a valid variable name. ---------------------------------------------------------------- Standalone interpreter diff --git a/vendor/github.com/yuin/gopher-lua/_vm.go b/vendor/github.com/yuin/gopher-lua/_vm.go index 049107e1774..687fe797a63 100644 --- a/vendor/github.com/yuin/gopher-lua/_vm.go +++ b/vendor/github.com/yuin/gopher-lua/_vm.go @@ -840,7 +840,7 @@ func luaModulo(lhs, rhs LNumber) LNumber { flhs := float64(lhs) frhs := float64(rhs) v := math.Mod(flhs, frhs) - if flhs < 0 || frhs < 0 && !(flhs < 0 && frhs < 0) { + if frhs > 0 && v < 0 || frhs < 0 && v > 0 { v += frhs } return LNumber(v) diff --git a/vendor/github.com/yuin/gopher-lua/ast/stmt.go b/vendor/github.com/yuin/gopher-lua/ast/stmt.go index 56ea6d1a23a..e24880b6e0c 100644 --- a/vendor/github.com/yuin/gopher-lua/ast/stmt.go +++ b/vendor/github.com/yuin/gopher-lua/ast/stmt.go @@ -93,3 +93,15 @@ type ReturnStmt struct { type BreakStmt struct { StmtBase } + +type LabelStmt struct { + StmtBase + + Name string +} + +type GotoStmt struct { + StmtBase + + Label string +} diff --git a/vendor/github.com/yuin/gopher-lua/compile.go b/vendor/github.com/yuin/gopher-lua/compile.go index 75c75550e42..c3736777a4d 100644 --- a/vendor/github.com/yuin/gopher-lua/compile.go +++ b/vendor/github.com/yuin/gopher-lua/compile.go @@ -2,9 +2,10 @@ package lua import ( "fmt" - "github.com/yuin/gopher-lua/ast" "math" "reflect" + + "github.com/yuin/gopher-lua/ast" ) /* internal constants & structs {{{ */ @@ -94,7 +95,11 @@ func sline(pos ast.PositionHolder) int { } func eline(pos ast.PositionHolder) int { - return pos.LastLine() + line := pos.LastLine() + if line == 0 { + return pos.Line() + } + return line } func savereg(ec *expcontext, reg int) int { @@ -134,6 +139,28 @@ func lnumberValue(expr ast.Expr) (LNumber, bool) { /* utilities }}} */ +type gotoLabelDesc struct { // {{{ + Id int + Name string + Pc int + Line int + NumActiveLocalVars int +} + +func newLabelDesc(id int, name string, pc, line, n int) *gotoLabelDesc { + return &gotoLabelDesc{ + Id: id, + Name: name, + Pc: pc, + Line: line, + NumActiveLocalVars: n, + } +} + +func (l *gotoLabelDesc) SetNumActiveLocalVars(n int) { + l.NumActiveLocalVars = n +} // }}} + type CompileError struct { // {{{ context *funcContext Line int @@ -328,16 +355,18 @@ func (vp *varNamePool) Register(name string) int { /* FuncContext {{{ */ type codeBlock struct { - LocalVars *varNamePool - BreakLabel int - Parent *codeBlock - RefUpvalue bool - LineStart int - LastLine int + LocalVars *varNamePool + BreakLabel int + Parent *codeBlock + RefUpvalue bool + LineStart int + LastLine int + labels map[string]*gotoLabelDesc + firstGotoIndex int } -func newCodeBlock(localvars *varNamePool, blabel int, parent *codeBlock, pos ast.PositionHolder) *codeBlock { - bl := &codeBlock{localvars, blabel, parent, false, 0, 0} +func newCodeBlock(localvars *varNamePool, blabel int, parent *codeBlock, pos ast.PositionHolder, firstGotoIndex int) *codeBlock { + bl := &codeBlock{localvars, blabel, parent, false, 0, 0, map[string]*gotoLabelDesc{}, firstGotoIndex} if pos != nil { bl.LineStart = pos.Line() bl.LastLine = pos.LastLine() @@ -345,33 +374,136 @@ func newCodeBlock(localvars *varNamePool, blabel int, parent *codeBlock, pos ast return bl } +func (b *codeBlock) AddLabel(label *gotoLabelDesc) *gotoLabelDesc { + if old, ok := b.labels[label.Name]; ok { + return old + } + b.labels[label.Name] = label + return nil +} + +func (b *codeBlock) GetLabel(label string) *gotoLabelDesc { + if v, ok := b.labels[label]; ok { + return v + } + return nil +} + +func (b *codeBlock) LocalVarsCount() int { + count := 0 + for block := b; block != nil; block = block.Parent { + count += len(block.LocalVars.Names()) + } + return count +} + type funcContext struct { - Proto *FunctionProto - Code *codeStore - Parent *funcContext - Upvalues *varNamePool - Block *codeBlock - Blocks []*codeBlock - regTop int - labelId int - labelPc map[int]int + Proto *FunctionProto + Code *codeStore + Parent *funcContext + Upvalues *varNamePool + Block *codeBlock + Blocks []*codeBlock + regTop int + labelId int + labelPc map[int]int + gotosCount int + unresolvedGotos map[int]*gotoLabelDesc } func newFuncContext(sourcename string, parent *funcContext) *funcContext { fc := &funcContext{ - Proto: newFunctionProto(sourcename), - Code: &codeStore{make([]uint32, 0, 1024), make([]int, 0, 1024), 0}, - Parent: parent, - Upvalues: newVarNamePool(0), - Block: newCodeBlock(newVarNamePool(0), labelNoJump, nil, nil), - regTop: 0, - labelId: 1, - labelPc: map[int]int{}, + Proto: newFunctionProto(sourcename), + Code: &codeStore{make([]uint32, 0, 1024), make([]int, 0, 1024), 0}, + Parent: parent, + Upvalues: newVarNamePool(0), + Block: newCodeBlock(newVarNamePool(0), labelNoJump, nil, nil, 0), + regTop: 0, + labelId: 1, + labelPc: map[int]int{}, + gotosCount: 0, + unresolvedGotos: map[int]*gotoLabelDesc{}, } fc.Blocks = []*codeBlock{fc.Block} return fc } +func (fc *funcContext) CheckUnresolvedGoto() { + for i := fc.Block.firstGotoIndex; i < fc.gotosCount; i++ { + gotoLabel, ok := fc.unresolvedGotos[i] + if !ok { + continue + } + raiseCompileError(fc, fc.Proto.LastLineDefined, "no visible label '%s' for at line %d", gotoLabel.Name, gotoLabel.Line) + } +} + +func (fc *funcContext) AddUnresolvedGoto(label *gotoLabelDesc) { + fc.unresolvedGotos[fc.gotosCount] = label + fc.gotosCount++ +} + +func (fc *funcContext) AddNamedLabel(label *gotoLabelDesc) { + if old := fc.Block.AddLabel(label); old != nil { + raiseCompileError(fc, label.Line+1, "label '%s' already defined on line %d", label.Name, old.Line) + } + fc.SetLabelPc(label.Id, label.Pc) +} + +func (fc *funcContext) GetNamedLabel(name string) *gotoLabelDesc { + return fc.Block.GetLabel(name) +} + +func (fc *funcContext) ResolveGoto(from, to *gotoLabelDesc, index int) { + if from.NumActiveLocalVars < to.NumActiveLocalVars { + varName := fc.Block.LocalVars.Names()[len(fc.Block.LocalVars.Names())-1] + raiseCompileError(fc, to.Line+1, " at line %d jumps into the scope of local '%s'", to.Name, from.Line, varName) + } + fc.Code.SetSbx(from.Pc, to.Id) + delete(fc.unresolvedGotos, index) +} + +func (fc *funcContext) FindLabel(block *codeBlock, gotoLabel *gotoLabelDesc, i int) bool { + target := block.GetLabel(gotoLabel.Name) + if target != nil { + if gotoLabel.NumActiveLocalVars > target.NumActiveLocalVars && block.RefUpvalue { + fc.Code.SetA(gotoLabel.Pc-1, target.NumActiveLocalVars) + } + fc.ResolveGoto(gotoLabel, target, i) + return true + } + return false +} + +func (fc *funcContext) ResolveCurrentBlockGotosWithParentBlock() { + blockActiveLocalVars := fc.Block.Parent.LocalVarsCount() + for i := fc.Block.firstGotoIndex; i < fc.gotosCount; i++ { + gotoLabel, ok := fc.unresolvedGotos[i] + if !ok { + continue + } + if gotoLabel.NumActiveLocalVars > blockActiveLocalVars { + if fc.Block.RefUpvalue { + fc.Code.SetA(gotoLabel.Pc-1, blockActiveLocalVars) + } + gotoLabel.SetNumActiveLocalVars(blockActiveLocalVars) + } + fc.FindLabel(fc.Block.Parent, gotoLabel, i) + } +} + +func (fc *funcContext) ResolveForwardGoto(target *gotoLabelDesc) { + for i := fc.Block.firstGotoIndex; i <= fc.gotosCount; i++ { + gotoLabel, ok := fc.unresolvedGotos[i] + if !ok { + continue + } + if gotoLabel.Name == target.Name { + fc.ResolveGoto(gotoLabel, target, i) + } + } +} + func (fc *funcContext) NewLabel() int { ret := fc.labelId fc.labelId++ @@ -400,6 +532,13 @@ func (fc *funcContext) ConstIndex(value LValue) int { } return v } +func (fc *funcContext) BlockLocalVarsCount() int { + count := 0 + for block := fc.Block; block != nil; block = block.Parent { + count += len(block.LocalVars.Names()) + } + return count +} func (fc *funcContext) RegisterLocalVar(name string) int { ret := fc.Block.LocalVars.Register(name) @@ -431,7 +570,7 @@ func (fc *funcContext) LocalVars() []varNamePoolValue { } func (fc *funcContext) EnterBlock(blabel int, pos ast.PositionHolder) { - fc.Block = newCodeBlock(newVarNamePool(fc.RegTop()), blabel, fc.Block, pos) + fc.Block = newCodeBlock(newVarNamePool(fc.RegTop()), blabel, fc.Block, pos, fc.gotosCount) fc.Blocks = append(fc.Blocks, fc.Block) } @@ -447,6 +586,10 @@ func (fc *funcContext) CloseUpvalues() int { func (fc *funcContext) LeaveBlock() int { closed := fc.CloseUpvalues() fc.EndScope() + + if fc.Block.Parent != nil { + fc.ResolveCurrentBlockGotosWithParentBlock() + } fc.Block = fc.Block.Parent fc.SetRegTop(fc.Block.LocalVars.LastIndex()) return closed @@ -471,9 +614,17 @@ func (fc *funcContext) RegTop() int { /* FuncContext }}} */ -func compileChunk(context *funcContext, chunk []ast.Stmt) { // {{{ - for _, stmt := range chunk { - compileStmt(context, stmt) +func compileChunk(context *funcContext, chunk []ast.Stmt, untilFollows bool) { // {{{ + for i, stmt := range chunk { + lastStmt := true + for j := i + 1; j < len(chunk); j++ { + _, ok := chunk[j].(*ast.LabelStmt) + if !ok { + lastStmt = false + break + } + } + compileStmt(context, stmt, lastStmt && !untilFollows) } } // }}} @@ -485,13 +636,21 @@ func compileBlock(context *funcContext, chunk []ast.Stmt) { // {{{ ph.SetLine(sline(chunk[0])) ph.SetLastLine(eline(chunk[len(chunk)-1])) context.EnterBlock(labelNoJump, ph) - for _, stmt := range chunk { - compileStmt(context, stmt) + for i, stmt := range chunk { + lastStmt := true + for j := i + 1; j < len(chunk); j++ { + _, ok := chunk[j].(*ast.LabelStmt) + if !ok { + lastStmt = false + break + } + } + compileStmt(context, stmt, lastStmt) } context.LeaveBlock() } // }}} -func compileStmt(context *funcContext, stmt ast.Stmt) { // {{{ +func compileStmt(context *funcContext, stmt ast.Stmt, isLastStmt bool) { // {{{ switch st := stmt.(type) { case *ast.AssignStmt: compileAssignStmt(context, st) @@ -501,7 +660,7 @@ func compileStmt(context *funcContext, stmt ast.Stmt) { // {{{ compileFuncCallExpr(context, context.RegTop(), st.Expr.(*ast.FuncCallExpr), ecnone(-1)) case *ast.DoBlockStmt: context.EnterBlock(labelNoJump, st) - compileChunk(context, st.Stmts) + compileChunk(context, st.Stmts, false) context.LeaveBlock() case *ast.WhileStmt: compileWhileStmt(context, st) @@ -519,14 +678,17 @@ func compileStmt(context *funcContext, stmt ast.Stmt) { // {{{ compileNumberForStmt(context, st) case *ast.GenericForStmt: compileGenericForStmt(context, st) + case *ast.LabelStmt: + compileLabelStmt(context, st, isLastStmt) + case *ast.GotoStmt: + compileGotoStmt(context, st) } } // }}} func compileAssignStmtLeft(context *funcContext, stmt *ast.AssignStmt) (int, []*assigncontext) { // {{{ reg := context.RegTop() acs := make([]*assigncontext, 0, len(stmt.Lhs)) - for i, lhs := range stmt.Lhs { - islast := i == len(stmt.Lhs)-1 + for _, lhs := range stmt.Lhs { switch st := lhs.(type) { case *ast.IdentExpr: identtype := getIdentRefType(context, context, st) @@ -537,9 +699,7 @@ func compileAssignStmtLeft(context *funcContext, stmt *ast.AssignStmt) (int, []* case ecUpvalue: context.Upvalues.RegisterUnique(st.Value) case ecLocal: - if islast { - ec.reg = context.FindLocalVar(st.Value) - } + ec.reg = context.FindLocalVar(st.Value) } acs = append(acs, &assigncontext{ec, 0, 0, false, false}) case *ast.AttrGetExpr: @@ -825,7 +985,7 @@ func compileWhileStmt(context *funcContext, stmt *ast.WhileStmt) { // {{{ compileBranchCondition(context, context.RegTop(), stmt.Condition, thenlabel, elselabel, false) context.SetLabelPc(thenlabel, context.Code.LastPC()) context.EnterBlock(elselabel, stmt) - compileChunk(context, stmt.Stmts) + compileChunk(context, stmt.Stmts, false) context.CloseUpvalues() context.Code.AddASbx(OP_JMP, 0, condlabel, eline(stmt)) context.LeaveBlock() @@ -840,7 +1000,7 @@ func compileRepeatStmt(context *funcContext, stmt *ast.RepeatStmt) { // {{{ context.SetLabelPc(initlabel, context.Code.LastPC()) context.SetLabelPc(elselabel, context.Code.LastPC()) context.EnterBlock(thenlabel, stmt) - compileChunk(context, stmt.Stmts) + compileChunk(context, stmt.Stmts, true) compileBranchCondition(context, context.RegTop(), stmt.Condition, thenlabel, elselabel, false) context.SetLabelPc(thenlabel, context.Code.LastPC()) @@ -916,7 +1076,7 @@ func compileNumberForStmt(context *funcContext, stmt *ast.NumberForStmt) { // {{ context.RegisterLocalVar(stmt.Name) bodypc := code.LastPC() - compileChunk(context, stmt.Stmts) + compileChunk(context, stmt.Stmts, false) context.LeaveBlock() @@ -949,7 +1109,7 @@ func compileGenericForStmt(context *funcContext, stmt *ast.GenericForStmt) { // } context.SetLabelPc(bodylabel, code.LastPC()) - compileChunk(context, stmt.Stmts) + compileChunk(context, stmt.Stmts, false) context.LeaveBlock() @@ -960,6 +1120,24 @@ func compileGenericForStmt(context *funcContext, stmt *ast.GenericForStmt) { // context.SetLabelPc(endlabel, code.LastPC()) } // }}} +func compileLabelStmt(context *funcContext, stmt *ast.LabelStmt, isLastStmt bool) { // {{{ + labelId := context.NewLabel() + label := newLabelDesc(labelId, stmt.Name, context.Code.LastPC(), sline(stmt), context.BlockLocalVarsCount()) + context.AddNamedLabel(label) + if isLastStmt { + label.SetNumActiveLocalVars(context.Block.Parent.LocalVarsCount()) + } + context.ResolveForwardGoto(label) +} // }}} + +func compileGotoStmt(context *funcContext, stmt *ast.GotoStmt) { // {{{ + context.Code.AddABC(OP_CLOSE, 0, 0, 0, sline(stmt)) + context.Code.AddASbx(OP_JMP, 0, labelNoJump, sline(stmt)) + label := newLabelDesc(-1, stmt.Label, context.Code.LastPC(), sline(stmt), context.BlockLocalVarsCount()) + context.AddUnresolvedGoto(label) + context.FindLabel(context.Block, label, context.gotosCount-1) +} // }}} + func compileExpr(context *funcContext, reg int, expr ast.Expr, ec *expcontext) int { // {{{ code := context.Code sreg := savereg(ec, reg) @@ -1149,10 +1327,11 @@ func compileFunctionExpr(context *funcContext, funcexpr *ast.FunctionExpr, ec *e context.Proto.IsVarArg |= VarArgIsVarArg } - compileChunk(context, funcexpr.Stmts) + compileChunk(context, funcexpr.Stmts, false) context.Code.AddABC(OP_RETURN, 0, 1, 0, eline(funcexpr)) context.EndScope() + context.CheckUnresolvedGoto() context.Proto.Code = context.Code.List() context.Proto.DbgSourcePositions = context.Code.PosList() context.Proto.DbgUpvalues = context.Upvalues.Names() @@ -1468,7 +1647,17 @@ func compileLogicalOpExprAux(context *funcContext, reg int, expr ast.Expr, ec *e a := reg sreg := savereg(ec, a) - if !hasnextcond && thenlabel == elselabel { + isLastAnd := elselabel == lb.e && thenlabel != elselabel + isLastOr := thenlabel == lb.e && hasnextcond + + if ident, ok := expr.(*ast.IdentExpr); ok && (isLastAnd || isLastOr) && getIdentRefType(context, context, ident) == ecLocal { + b := context.FindLocalVar(ident.Value) + op := OP_TESTSET + if sreg == b { + op = OP_TEST + } + code.AddABC(op, sreg, b, 0^flip, sline(expr)) + } else if !hasnextcond && thenlabel == elselabel { reg += compileExpr(context, reg, expr, &expcontext{ec.ctype, intMax(a, sreg), ec.varargopt}) last := context.Code.Last() if opGetOpCode(last) == OP_MOVE && opGetArgA(last) == a { @@ -1478,7 +1667,7 @@ func compileLogicalOpExprAux(context *funcContext, reg int, expr ast.Expr, ec *e } } else { reg += compileExpr(context, reg, expr, ecnone(0)) - if sreg == a { + if !hasnextcond { code.AddABC(OP_TEST, a, 0, 0^flip, sline(expr)) } else { code.AddABC(OP_TESTSET, sreg, a, 0^flip, sline(expr)) @@ -1669,6 +1858,10 @@ func Compile(chunk []ast.Stmt, name string) (proto *FunctionProto, err error) { err = nil parlist := &ast.ParList{HasVargs: true, Names: []string{}} funcexpr := &ast.FunctionExpr{ParList: parlist, Stmts: chunk} + if len(chunk) > 0 { + funcexpr.SetLastLine(sline(chunk[0])) + funcexpr.SetLastLine(eline(chunk[len(chunk)-1]) + 1) + } context := newFuncContext(name, nil) compileFunctionExpr(context, funcexpr, ecnone(0)) proto = context.Proto diff --git a/vendor/github.com/yuin/gopher-lua/parse/lexer.go b/vendor/github.com/yuin/gopher-lua/parse/lexer.go index 6ad57ceed7d..c20a0bdd69e 100644 --- a/vendor/github.com/yuin/gopher-lua/parse/lexer.go +++ b/vendor/github.com/yuin/gopher-lua/parse/lexer.go @@ -4,11 +4,12 @@ import ( "bufio" "bytes" "fmt" - "github.com/yuin/gopher-lua/ast" "io" "reflect" "strconv" "strings" + + "github.com/yuin/gopher-lua/ast" ) const EOF = -1 @@ -286,7 +287,7 @@ var reservedWords = map[string]int{ "end": TEnd, "false": TFalse, "for": TFor, "function": TFunction, "if": TIf, "in": TIn, "local": TLocal, "nil": TNil, "not": TNot, "or": TOr, "return": TReturn, "repeat": TRepeat, "then": TThen, "true": TTrue, - "until": TUntil, "while": TWhile} + "until": TUntil, "while": TWhile, "goto": TGoto} func (sc *Scanner) Scan(lexer *Lexer) (ast.Token, error) { redo: @@ -408,7 +409,16 @@ redo: tok.Type = '.' } tok.Str = buf.String() - case '+', '*', '/', '%', '^', '#', '(', ')', '{', '}', ']', ';', ':', ',': + case ':': + if sc.Peek() == ':' { + tok.Type = T2Colon + tok.Str = "::" + sc.Next() + } else { + tok.Type = ch + tok.Str = string(rune(ch)) + } + case '+', '*', '/', '%', '^', '#', '(', ')', '{', '}', ']', ';', ',': tok.Type = ch tok.Str = string(rune(ch)) default: diff --git a/vendor/github.com/yuin/gopher-lua/parse/parser.go b/vendor/github.com/yuin/gopher-lua/parse/parser.go index c7565816490..aee06c8c812 100644 --- a/vendor/github.com/yuin/gopher-lua/parse/parser.go +++ b/vendor/github.com/yuin/gopher-lua/parse/parser.go @@ -54,16 +54,18 @@ const TThen = 57363 const TTrue = 57364 const TUntil = 57365 const TWhile = 57366 -const TEqeq = 57367 -const TNeq = 57368 -const TLte = 57369 -const TGte = 57370 -const T2Comma = 57371 -const T3Comma = 57372 -const TIdent = 57373 -const TNumber = 57374 -const TString = 57375 -const UNARY = 57376 +const TGoto = 57367 +const TEqeq = 57368 +const TNeq = 57369 +const TLte = 57370 +const TGte = 57371 +const T2Comma = 57372 +const T3Comma = 57373 +const T2Colon = 57374 +const TIdent = 57375 +const TNumber = 57376 +const TString = 57377 +const UNARY = 57378 var yyToknames = [...]string{ "$end", @@ -90,12 +92,14 @@ var yyToknames = [...]string{ "TTrue", "TUntil", "TWhile", + "TGoto", "TEqeq", "TNeq", "TLte", "TGte", "T2Comma", "T3Comma", + "T2Colon", "TIdent", "TNumber", "TString", @@ -128,7 +132,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line parser.go.y:517 +//line parser.go.y:525 func TokenName(c int) string { if c >= TAnd && c-TAnd < len(yyToknames) { @@ -144,200 +148,207 @@ var yyExca = [...]int8{ -1, 1, 1, -1, -2, 0, - -1, 17, - 46, 31, - 47, 31, - -2, 68, - -1, 93, - 46, 32, - 47, 32, - -2, 68, + -1, 19, + 48, 33, + 49, 33, + -2, 70, + -1, 97, + 48, 34, + 49, 34, + -2, 70, } const yyPrivate = 57344 -const yyLast = 579 +const yyLast = 616 var yyAct = [...]uint8{ - 24, 88, 50, 23, 45, 84, 56, 65, 137, 153, - 136, 113, 52, 142, 54, 53, 33, 134, 65, 132, - 62, 63, 32, 61, 108, 109, 48, 111, 106, 41, - 42, 105, 49, 155, 166, 81, 82, 83, 138, 104, - 22, 91, 131, 80, 95, 92, 162, 74, 48, 85, - 150, 99, 165, 148, 49, 149, 75, 76, 77, 78, - 79, 67, 80, 107, 106, 148, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 72, 73, 71, 70, 74, 65, 39, 40, - 47, 139, 133, 68, 69, 75, 76, 77, 78, 79, - 60, 80, 141, 144, 143, 146, 145, 31, 67, 147, - 9, 48, 110, 97, 48, 152, 151, 49, 38, 62, - 49, 17, 66, 77, 78, 79, 96, 80, 59, 72, - 73, 71, 70, 74, 154, 102, 91, 156, 55, 157, - 68, 69, 75, 76, 77, 78, 79, 21, 80, 187, - 94, 20, 26, 184, 37, 179, 163, 112, 25, 35, - 178, 93, 170, 172, 27, 171, 164, 173, 19, 159, - 175, 174, 29, 89, 28, 39, 40, 20, 182, 181, - 100, 34, 135, 183, 67, 39, 40, 47, 186, 64, - 51, 1, 90, 87, 36, 130, 86, 30, 66, 18, - 46, 44, 43, 8, 58, 72, 73, 71, 70, 74, - 57, 67, 168, 169, 167, 3, 68, 69, 75, 76, - 77, 78, 79, 160, 80, 66, 4, 2, 0, 0, - 0, 158, 72, 73, 71, 70, 74, 0, 0, 0, - 0, 0, 0, 68, 69, 75, 76, 77, 78, 79, - 26, 80, 37, 0, 0, 0, 25, 35, 140, 0, - 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, - 29, 21, 28, 39, 40, 20, 26, 0, 37, 34, - 0, 0, 25, 35, 0, 0, 0, 0, 27, 0, - 0, 0, 36, 98, 0, 0, 29, 89, 28, 39, - 40, 20, 26, 0, 37, 34, 0, 0, 25, 35, - 0, 0, 0, 0, 27, 67, 90, 176, 36, 0, - 0, 0, 29, 21, 28, 39, 40, 20, 0, 66, - 0, 34, 0, 0, 0, 0, 72, 73, 71, 70, - 74, 0, 67, 0, 36, 0, 0, 68, 69, 75, - 76, 77, 78, 79, 0, 80, 66, 0, 177, 0, - 0, 0, 0, 72, 73, 71, 70, 74, 0, 67, - 0, 185, 0, 0, 68, 69, 75, 76, 77, 78, - 79, 0, 80, 66, 0, 161, 0, 0, 0, 0, - 72, 73, 71, 70, 74, 0, 67, 0, 0, 0, - 0, 68, 69, 75, 76, 77, 78, 79, 0, 80, - 66, 0, 0, 180, 0, 0, 0, 72, 73, 71, - 70, 74, 0, 67, 0, 0, 0, 0, 68, 69, - 75, 76, 77, 78, 79, 0, 80, 66, 0, 0, - 103, 0, 0, 0, 72, 73, 71, 70, 74, 0, - 67, 0, 101, 0, 0, 68, 69, 75, 76, 77, - 78, 79, 0, 80, 66, 0, 0, 0, 0, 0, - 0, 72, 73, 71, 70, 74, 0, 67, 0, 0, - 0, 0, 68, 69, 75, 76, 77, 78, 79, 0, - 80, 66, 0, 0, 0, 0, 0, 0, 72, 73, - 71, 70, 74, 0, 0, 0, 0, 0, 0, 68, - 69, 75, 76, 77, 78, 79, 0, 80, 72, 73, - 71, 70, 74, 0, 0, 0, 0, 0, 0, 68, - 69, 75, 76, 77, 78, 79, 0, 80, 7, 10, - 0, 0, 0, 0, 14, 15, 13, 0, 16, 0, - 0, 0, 6, 12, 0, 0, 0, 11, 0, 0, - 0, 0, 0, 0, 21, 0, 0, 0, 20, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 5, + 26, 92, 52, 25, 47, 88, 158, 58, 142, 118, + 141, 167, 54, 69, 56, 55, 35, 139, 41, 42, + 49, 160, 34, 67, 63, 137, 50, 64, 112, 113, + 69, 109, 51, 48, 46, 45, 147, 85, 86, 87, + 115, 110, 24, 95, 43, 44, 99, 96, 78, 136, + 50, 171, 143, 103, 69, 108, 51, 84, 79, 80, + 81, 82, 83, 89, 84, 111, 110, 41, 42, 49, + 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 81, 82, 83, 170, + 84, 153, 155, 33, 154, 144, 9, 138, 40, 23, + 153, 19, 62, 22, 114, 101, 146, 149, 148, 151, + 150, 71, 100, 152, 66, 50, 65, 61, 50, 157, + 156, 51, 57, 64, 51, 70, 116, 106, 192, 21, + 173, 174, 172, 76, 77, 75, 74, 78, 98, 159, + 189, 95, 161, 97, 162, 72, 73, 79, 80, 81, + 82, 83, 68, 84, 184, 183, 177, 169, 164, 104, + 140, 168, 117, 53, 1, 91, 135, 175, 32, 20, + 176, 8, 178, 60, 59, 180, 179, 3, 165, 28, + 4, 39, 2, 187, 186, 27, 37, 0, 188, 0, + 0, 29, 0, 191, 71, 0, 0, 0, 0, 0, + 31, 0, 93, 30, 41, 42, 22, 0, 70, 0, + 36, 0, 0, 0, 0, 0, 76, 77, 75, 74, + 78, 94, 0, 38, 71, 90, 0, 0, 72, 73, + 79, 80, 81, 82, 83, 0, 84, 0, 70, 0, + 0, 0, 0, 163, 0, 0, 76, 77, 75, 74, + 78, 0, 0, 0, 0, 0, 0, 0, 72, 73, + 79, 80, 81, 82, 83, 28, 84, 39, 0, 0, + 0, 27, 37, 145, 0, 0, 0, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 31, 0, 23, 30, + 41, 42, 22, 28, 0, 39, 36, 0, 0, 27, + 37, 0, 0, 0, 0, 29, 0, 0, 0, 38, + 102, 0, 0, 0, 31, 0, 93, 30, 41, 42, + 22, 28, 0, 39, 36, 0, 0, 27, 37, 0, + 0, 0, 0, 29, 0, 94, 71, 38, 181, 0, + 0, 0, 31, 0, 23, 30, 41, 42, 22, 0, + 70, 0, 36, 0, 0, 0, 0, 0, 76, 77, + 75, 74, 78, 71, 0, 38, 0, 0, 0, 0, + 72, 73, 79, 80, 81, 82, 83, 70, 84, 0, + 0, 182, 0, 0, 0, 76, 77, 75, 74, 78, + 71, 0, 190, 0, 0, 0, 0, 72, 73, 79, + 80, 81, 82, 83, 70, 84, 0, 0, 166, 0, + 0, 0, 76, 77, 75, 74, 78, 71, 0, 0, + 0, 0, 0, 0, 72, 73, 79, 80, 81, 82, + 83, 70, 84, 0, 185, 0, 0, 0, 0, 76, + 77, 75, 74, 78, 71, 0, 0, 0, 0, 0, + 0, 72, 73, 79, 80, 81, 82, 83, 70, 84, + 0, 107, 0, 0, 0, 0, 76, 77, 75, 74, + 78, 71, 0, 105, 0, 0, 0, 0, 72, 73, + 79, 80, 81, 82, 83, 70, 84, 0, 0, 0, + 0, 0, 0, 76, 77, 75, 74, 78, 71, 0, + 0, 0, 0, 0, 0, 72, 73, 79, 80, 81, + 82, 83, 70, 84, 0, 0, 0, 0, 0, 0, + 76, 77, 75, 74, 78, 0, 0, 0, 0, 0, + 0, 0, 72, 73, 79, 80, 81, 82, 83, 0, + 84, 7, 10, 0, 0, 0, 0, 14, 15, 13, + 0, 16, 71, 0, 0, 6, 12, 0, 0, 0, + 11, 18, 0, 0, 0, 0, 0, 0, 17, 23, + 0, 0, 0, 22, 76, 77, 75, 74, 78, 0, + 0, 0, 0, 5, 0, 0, 72, 73, 79, 80, + 81, 82, 83, 0, 84, 76, 77, 75, 74, 78, + 0, 0, 0, 0, 0, 0, 0, 72, 73, 79, + 80, 81, 82, 83, 0, 84, } var yyPact = [...]int16{ - -1000, -1000, 533, -5, -1000, -1000, 292, -1000, -17, 152, - -1000, 292, -1000, 292, 107, 97, 88, -1000, -1000, -1000, - 292, -1000, -1000, -29, 473, -1000, -1000, -1000, -1000, -1000, - -1000, 152, -1000, -1000, 292, 292, 292, 14, -1000, -1000, - 142, 292, 116, 292, 95, -1000, 82, 240, -1000, -1000, - 171, -1000, 446, 112, 419, -7, 17, 14, -24, -1000, - 81, -19, -1000, 104, -42, 292, 292, 292, 292, 292, - 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, - 292, -1, -1, -1, -1000, -11, -1000, -37, -1000, -8, - 292, 473, -29, -1000, 152, 207, -1000, 55, -1000, -40, - -1000, -1000, 292, -1000, 292, 292, 34, -1000, 24, 19, - 14, 292, -1000, -1000, 473, 57, 493, 18, 18, 18, - 18, 18, 18, 18, 83, 83, -1, -1, -1, -1, - -44, -1000, -1000, -14, -1000, 266, -1000, -1000, 292, 180, - -1000, -1000, -1000, 160, 473, -1000, 338, 40, -1000, -1000, - -1000, -1000, -29, -1000, 157, 22, -1000, 473, -12, -1000, - 205, 292, -1000, 154, -1000, -1000, 292, -1000, -1000, 292, - 311, 151, -1000, 473, 146, 392, -1000, 292, -1000, -1000, - -1000, 144, 365, -1000, -1000, -1000, 140, -1000, + -1000, -1000, 536, -5, -1000, -1000, 311, -1000, -4, -17, + -1000, 311, -1000, 311, 89, 84, 90, 83, 81, -1000, + -1000, -1000, 311, -1000, -1000, -36, 494, -1000, -1000, -1000, + -1000, -1000, -1000, -17, -1000, -1000, 311, 311, 311, 26, + -1000, -1000, 169, 311, 66, 311, 79, -1000, 72, 255, + -1000, -1000, 150, -1000, 467, 104, 440, 7, 17, 26, + -22, -1000, 71, -8, -1000, 94, -1000, 107, -46, 311, + 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, + 311, 311, 311, 311, 311, 11, 11, 11, -1000, -6, + -1000, -39, -1000, 4, 311, 494, -36, -1000, -17, 220, + -1000, 32, -1000, -19, -1000, -1000, 311, -1000, 311, 311, + 67, -1000, 61, 59, 26, 311, -1000, -1000, -1000, 494, + 548, 569, 18, 18, 18, 18, 18, 18, 18, 44, + 44, 11, 11, 11, 11, -49, -1000, -1000, -28, -1000, + 283, -1000, -1000, 311, 190, -1000, -1000, -1000, 149, 494, + -1000, 359, 5, -1000, -1000, -1000, -1000, -36, -1000, 148, + 58, -1000, 494, 3, -1000, 123, 311, -1000, 147, -1000, + -1000, 311, -1000, -1000, 311, 332, 146, -1000, 494, 145, + 413, -1000, 311, -1000, -1000, -1000, 131, 386, -1000, -1000, + -1000, 119, -1000, } var yyPgo = [...]uint8{ - 0, 190, 227, 2, 226, 223, 215, 210, 204, 203, - 118, 6, 3, 0, 22, 107, 168, 199, 4, 197, - 5, 195, 16, 193, 1, 182, + 0, 163, 182, 2, 180, 178, 177, 174, 173, 171, + 98, 7, 3, 0, 22, 93, 129, 169, 4, 168, + 5, 166, 16, 165, 1, 160, } var yyR1 = [...]int8{ 0, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, - 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, + 4, 4, 4, 4, 5, 5, 6, 6, 6, 7, + 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, + 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 14, 15, 15, - 15, 15, 17, 16, 16, 18, 18, 18, 18, 19, - 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, - 24, 24, 24, 25, 25, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, + 15, 15, 15, 15, 17, 16, 16, 18, 18, 18, + 18, 19, 20, 20, 21, 21, 21, 22, 22, 23, + 23, 23, 24, 24, 24, 25, 25, } var yyR2 = [...]int8{ 0, 1, 2, 3, 0, 2, 2, 1, 3, 1, 3, 5, 4, 6, 8, 9, 11, 7, 3, 4, - 4, 2, 0, 5, 1, 2, 1, 1, 3, 1, - 3, 1, 3, 1, 4, 3, 1, 3, 1, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, - 1, 3, 3, 2, 4, 2, 3, 1, 1, 2, - 5, 4, 1, 1, 3, 2, 3, 1, 3, 2, - 3, 5, 1, 1, 1, + 4, 2, 3, 2, 0, 5, 1, 2, 1, 1, + 3, 1, 3, 1, 3, 1, 4, 3, 1, 3, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, + 1, 1, 1, 3, 3, 2, 4, 2, 3, 1, + 1, 2, 5, 4, 1, 1, 3, 2, 3, 1, + 3, 2, 3, 5, 1, 1, 1, } var yyChk = [...]int16{ - -1000, -1, -2, -6, -4, 45, 19, 5, -9, -15, - 6, 24, 20, 13, 11, 12, 15, -10, -17, -16, - 35, 31, 45, -12, -13, 16, 10, 22, 32, 30, - -19, -15, -14, -22, 39, 17, 52, 12, -10, 33, - 34, 46, 47, 50, 49, -18, 48, 35, -22, -14, - -3, -1, -13, -3, -13, 31, -11, -7, -8, 31, - 12, -11, 31, -13, -16, 47, 18, 4, 36, 37, - 28, 27, 25, 26, 29, 38, 39, 40, 41, 42, - 44, -13, -13, -13, -20, 35, 54, -23, -24, 31, - 50, -13, -12, -10, -15, -13, 31, 31, 53, -12, - 9, 6, 23, 21, 46, 14, 47, -20, 48, 49, - 31, 46, 53, 53, -13, -13, -13, -13, -13, -13, + -1000, -1, -2, -6, -4, 47, 19, 5, -9, -15, + 6, 24, 20, 13, 11, 12, 15, 32, 25, -10, + -17, -16, 37, 33, 47, -12, -13, 16, 10, 22, + 34, 31, -19, -15, -14, -22, 41, 17, 54, 12, + -10, 35, 36, 48, 49, 52, 51, -18, 50, 37, + -22, -14, -3, -1, -13, -3, -13, 33, -11, -7, + -8, 33, 12, -11, 33, 33, 33, -13, -16, 49, + 18, 4, 38, 39, 29, 28, 26, 27, 30, 40, + 41, 42, 43, 44, 46, -13, -13, -13, -20, 37, + 56, -23, -24, 33, 52, -13, -12, -10, -15, -13, + 33, 33, 55, -12, 9, 6, 23, 21, 48, 14, + 49, -20, 50, 51, 33, 48, 32, 55, 55, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -21, 53, 30, -11, 54, -25, 47, 45, 46, -13, - 51, -18, 53, -3, -13, -3, -13, -12, 31, 31, - 31, -20, -12, 53, -3, 47, -24, -13, 51, 9, - -5, 47, 6, -3, 9, 30, 46, 9, 7, 8, - -13, -3, 9, -13, -3, -13, 6, 47, 9, 9, - 21, -3, -13, -3, 9, 6, -3, 9, + -13, -13, -13, -13, -13, -21, 55, 31, -11, 56, + -25, 49, 47, 48, -13, 53, -18, 55, -3, -13, + -3, -13, -12, 33, 33, 33, -20, -12, 55, -3, + 49, -24, -13, 53, 9, -5, 49, 6, -3, 9, + 31, 48, 9, 7, 8, -13, -3, 9, -13, -3, + -13, 6, 49, 9, 9, 21, -3, -13, -3, 9, + 6, -3, 9, } var yyDef = [...]int8{ - 4, -2, 1, 2, 5, 6, 24, 26, 0, 9, - 4, 0, 4, 0, 0, 0, 0, -2, 69, 70, - 0, 33, 3, 25, 38, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 0, 0, 0, 0, 68, 67, - 0, 0, 0, 0, 0, 73, 0, 0, 77, 78, - 0, 7, 0, 0, 0, 36, 0, 0, 27, 29, - 0, 21, 36, 0, 70, 0, 0, 0, 0, 0, + 4, -2, 1, 2, 5, 6, 26, 28, 0, 9, + 4, 0, 4, 0, 0, 0, 0, 0, 0, -2, + 71, 72, 0, 35, 3, 27, 40, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 0, 0, 0, 0, + 70, 69, 0, 0, 0, 0, 0, 75, 0, 0, + 79, 80, 0, 7, 0, 0, 0, 38, 0, 0, + 29, 31, 0, 21, 38, 0, 23, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 64, 65, 66, 79, 0, 85, 0, 87, 33, - 0, 92, 8, -2, 0, 0, 35, 0, 75, 0, - 10, 4, 0, 4, 0, 0, 0, 18, 0, 0, - 0, 0, 71, 72, 39, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 0, 4, 82, 83, 86, 89, 93, 94, 0, 0, - 34, 74, 76, 0, 12, 22, 0, 0, 37, 28, - 30, 19, 20, 4, 0, 0, 88, 90, 0, 11, - 0, 0, 4, 0, 81, 84, 0, 13, 4, 0, - 0, 0, 80, 91, 0, 0, 4, 0, 17, 14, - 4, 0, 0, 23, 15, 4, 0, 16, + 0, 0, 0, 0, 0, 66, 67, 68, 81, 0, + 87, 0, 89, 35, 0, 94, 8, -2, 0, 0, + 37, 0, 77, 0, 10, 4, 0, 4, 0, 0, + 0, 18, 0, 0, 0, 0, 22, 73, 74, 41, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 0, 4, 84, 85, 88, + 91, 95, 96, 0, 0, 36, 76, 78, 0, 12, + 24, 0, 0, 39, 30, 32, 19, 20, 4, 0, + 0, 90, 92, 0, 11, 0, 0, 4, 0, 83, + 86, 0, 13, 4, 0, 0, 0, 82, 93, 0, + 0, 4, 0, 17, 14, 4, 0, 0, 25, 15, + 4, 0, 16, } var yyTok1 = [...]int8{ 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, 3, 3, 52, 3, 42, 3, 3, - 35, 53, 40, 38, 47, 39, 49, 41, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 48, 45, - 37, 46, 36, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 54, 3, 44, 3, 3, + 37, 55, 42, 40, 49, 41, 51, 43, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 50, 47, + 39, 48, 38, 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, 50, 3, 51, 44, 3, 3, 3, 3, 3, + 3, 52, 3, 53, 46, 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, 34, 3, 54, + 3, 3, 3, 36, 3, 56, } var yyTok2 = [...]int8{ 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, 43, + 32, 33, 34, 35, 45, } var yyTok3 = [...]int8{ @@ -856,61 +867,75 @@ yydefault: yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) } case 22: + yyDollar = yyS[yypt-3 : yypt+1] +//line parser.go.y:191 + { + yyVAL.stmt = &ast.LabelStmt{Name: yyDollar[2].token.Str} + yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) + } + case 23: + yyDollar = yyS[yypt-2 : yypt+1] +//line parser.go.y:195 + { + yyVAL.stmt = &ast.GotoStmt{Label: yyDollar[2].token.Str} + yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) + } + case 24: yyDollar = yyS[yypt-0 : yypt+1] -//line parser.go.y:193 +//line parser.go.y:201 { yyVAL.stmts = []ast.Stmt{} } - case 23: + case 25: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:196 +//line parser.go.y:204 { yyVAL.stmts = append(yyDollar[1].stmts, &ast.IfStmt{Condition: yyDollar[3].expr, Then: yyDollar[5].stmts}) yyVAL.stmts[len(yyVAL.stmts)-1].SetLine(yyDollar[2].token.Pos.Line) } - case 24: + case 26: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:202 +//line parser.go.y:210 { yyVAL.stmt = &ast.ReturnStmt{Exprs: nil} yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) } - case 25: + case 27: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:206 +//line parser.go.y:214 { yyVAL.stmt = &ast.ReturnStmt{Exprs: yyDollar[2].exprlist} yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) } - case 26: + case 28: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:210 +//line parser.go.y:218 { yyVAL.stmt = &ast.BreakStmt{} yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line) } - case 27: + case 29: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:216 +//line parser.go.y:224 { yyVAL.funcname = yyDollar[1].funcname } - case 28: + case 30: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:219 +//line parser.go.y:227 { yyVAL.funcname = &ast.FuncName{Func: nil, Receiver: yyDollar[1].funcname.Func, Method: yyDollar[3].token.Str} } - case 29: + case 31: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:224 +//line parser.go.y:232 { yyVAL.funcname = &ast.FuncName{Func: &ast.IdentExpr{Value: yyDollar[1].token.Str}} yyVAL.funcname.Func.SetLine(yyDollar[1].token.Pos.Line) } - case 30: + case 32: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:228 +//line parser.go.y:236 { key := &ast.StringExpr{Value: yyDollar[3].token.Str} key.SetLine(yyDollar[3].token.Pos.Line) @@ -918,278 +943,278 @@ yydefault: fn.SetLine(yyDollar[3].token.Pos.Line) yyVAL.funcname = &ast.FuncName{Func: fn} } - case 31: + case 33: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:237 +//line parser.go.y:245 { yyVAL.exprlist = []ast.Expr{yyDollar[1].expr} } - case 32: + case 34: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:240 +//line parser.go.y:248 { yyVAL.exprlist = append(yyDollar[1].exprlist, yyDollar[3].expr) } - case 33: + case 35: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:245 +//line parser.go.y:253 { yyVAL.expr = &ast.IdentExpr{Value: yyDollar[1].token.Str} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } - case 34: + case 36: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:249 +//line parser.go.y:257 { yyVAL.expr = &ast.AttrGetExpr{Object: yyDollar[1].expr, Key: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } - case 35: + case 37: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:253 +//line parser.go.y:261 { key := &ast.StringExpr{Value: yyDollar[3].token.Str} key.SetLine(yyDollar[3].token.Pos.Line) yyVAL.expr = &ast.AttrGetExpr{Object: yyDollar[1].expr, Key: key} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } - case 36: - yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:261 - { - yyVAL.namelist = []string{yyDollar[1].token.Str} - } - case 37: - yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:264 - { - yyVAL.namelist = append(yyDollar[1].namelist, yyDollar[3].token.Str) - } case 38: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:269 { - yyVAL.exprlist = []ast.Expr{yyDollar[1].expr} + yyVAL.namelist = []string{yyDollar[1].token.Str} } case 39: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:272 { - yyVAL.exprlist = append(yyDollar[1].exprlist, yyDollar[3].expr) + yyVAL.namelist = append(yyDollar[1].namelist, yyDollar[3].token.Str) } case 40: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:277 { - yyVAL.expr = &ast.NilExpr{} - yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) + yyVAL.exprlist = []ast.Expr{yyDollar[1].expr} } case 41: - yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:281 + yyDollar = yyS[yypt-3 : yypt+1] +//line parser.go.y:280 { - yyVAL.expr = &ast.FalseExpr{} - yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) + yyVAL.exprlist = append(yyDollar[1].exprlist, yyDollar[3].expr) } case 42: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:285 { - yyVAL.expr = &ast.TrueExpr{} + yyVAL.expr = &ast.NilExpr{} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } case 43: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:289 { - yyVAL.expr = &ast.NumberExpr{Value: yyDollar[1].token.Str} + yyVAL.expr = &ast.FalseExpr{} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } case 44: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:293 { - yyVAL.expr = &ast.Comma3Expr{} + yyVAL.expr = &ast.TrueExpr{} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } case 45: yyDollar = yyS[yypt-1 : yypt+1] //line parser.go.y:297 { - yyVAL.expr = yyDollar[1].expr + yyVAL.expr = &ast.NumberExpr{Value: yyDollar[1].token.Str} + yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } case 46: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:300 +//line parser.go.y:301 { - yyVAL.expr = yyDollar[1].expr + yyVAL.expr = &ast.Comma3Expr{} + yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } case 47: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:303 +//line parser.go.y:305 { yyVAL.expr = yyDollar[1].expr } case 48: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:306 +//line parser.go.y:308 { yyVAL.expr = yyDollar[1].expr } case 49: - yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:309 + yyDollar = yyS[yypt-1 : yypt+1] +//line parser.go.y:311 { - yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "or", Rhs: yyDollar[3].expr} - yyVAL.expr.SetLine(yyDollar[1].expr.Line()) + yyVAL.expr = yyDollar[1].expr } case 50: - yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:313 + yyDollar = yyS[yypt-1 : yypt+1] +//line parser.go.y:314 { - yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "and", Rhs: yyDollar[3].expr} - yyVAL.expr.SetLine(yyDollar[1].expr.Line()) + yyVAL.expr = yyDollar[1].expr } case 51: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:317 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "or", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 52: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:321 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "and", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 53: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:325 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">=", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 54: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:329 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<=", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 55: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:333 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "==", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">=", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 56: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:337 { - yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "~=", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<=", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 57: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:341 { - yyVAL.expr = &ast.StringConcatOpExpr{Lhs: yyDollar[1].expr, Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "==", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 58: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:345 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "+", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "~=", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 59: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:349 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "-", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.StringConcatOpExpr{Lhs: yyDollar[1].expr, Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 60: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:353 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "*", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "+", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 61: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:357 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "/", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "-", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 62: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:361 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "%", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "*", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 63: yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:365 { - yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "^", Rhs: yyDollar[3].expr} + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "/", Rhs: yyDollar[3].expr} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } case 64: - yyDollar = yyS[yypt-2 : yypt+1] + yyDollar = yyS[yypt-3 : yypt+1] //line parser.go.y:369 + { + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "%", Rhs: yyDollar[3].expr} + yyVAL.expr.SetLine(yyDollar[1].expr.Line()) + } + case 65: + yyDollar = yyS[yypt-3 : yypt+1] +//line parser.go.y:373 + { + yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "^", Rhs: yyDollar[3].expr} + yyVAL.expr.SetLine(yyDollar[1].expr.Line()) + } + case 66: + yyDollar = yyS[yypt-2 : yypt+1] +//line parser.go.y:377 { yyVAL.expr = &ast.UnaryMinusOpExpr{Expr: yyDollar[2].expr} yyVAL.expr.SetLine(yyDollar[2].expr.Line()) } - case 65: + case 67: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:373 +//line parser.go.y:381 { yyVAL.expr = &ast.UnaryNotOpExpr{Expr: yyDollar[2].expr} yyVAL.expr.SetLine(yyDollar[2].expr.Line()) } - case 66: + case 68: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:377 +//line parser.go.y:385 { yyVAL.expr = &ast.UnaryLenOpExpr{Expr: yyDollar[2].expr} yyVAL.expr.SetLine(yyDollar[2].expr.Line()) } - case 67: + case 69: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:383 +//line parser.go.y:391 { yyVAL.expr = &ast.StringExpr{Value: yyDollar[1].token.Str} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } - case 68: + case 70: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:389 +//line parser.go.y:397 { yyVAL.expr = yyDollar[1].expr } - case 69: + case 71: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:392 +//line parser.go.y:400 { yyVAL.expr = yyDollar[1].expr } - case 70: + case 72: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:395 +//line parser.go.y:403 { yyVAL.expr = yyDollar[1].expr } - case 71: + case 73: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:398 +//line parser.go.y:406 { if ex, ok := yyDollar[2].expr.(*ast.Comma3Expr); ok { ex.AdjustRet = true @@ -1197,161 +1222,161 @@ yydefault: yyVAL.expr = yyDollar[2].expr yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } - case 72: + case 74: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:407 +//line parser.go.y:415 { yyDollar[2].expr.(*ast.FuncCallExpr).AdjustRet = true yyVAL.expr = yyDollar[2].expr } - case 73: + case 75: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:413 +//line parser.go.y:421 { yyVAL.expr = &ast.FuncCallExpr{Func: yyDollar[1].expr, Args: yyDollar[2].exprlist} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } - case 74: + case 76: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:417 +//line parser.go.y:425 { yyVAL.expr = &ast.FuncCallExpr{Method: yyDollar[3].token.Str, Receiver: yyDollar[1].expr, Args: yyDollar[4].exprlist} yyVAL.expr.SetLine(yyDollar[1].expr.Line()) } - case 75: + case 77: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:423 +//line parser.go.y:431 { if yylex.(*Lexer).PNewLine { yylex.(*Lexer).TokenError(yyDollar[1].token, "ambiguous syntax (function call x new statement)") } yyVAL.exprlist = []ast.Expr{} } - case 76: + case 78: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:429 +//line parser.go.y:437 { if yylex.(*Lexer).PNewLine { yylex.(*Lexer).TokenError(yyDollar[1].token, "ambiguous syntax (function call x new statement)") } yyVAL.exprlist = yyDollar[2].exprlist } - case 77: + case 79: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:435 +//line parser.go.y:443 { yyVAL.exprlist = []ast.Expr{yyDollar[1].expr} } - case 78: + case 80: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:438 +//line parser.go.y:446 { yyVAL.exprlist = []ast.Expr{yyDollar[1].expr} } - case 79: + case 81: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:443 +//line parser.go.y:451 { yyVAL.expr = &ast.FunctionExpr{ParList: yyDollar[2].funcexpr.ParList, Stmts: yyDollar[2].funcexpr.Stmts} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) yyVAL.expr.SetLastLine(yyDollar[2].funcexpr.LastLine()) } - case 80: + case 82: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:450 +//line parser.go.y:458 { yyVAL.funcexpr = &ast.FunctionExpr{ParList: yyDollar[2].parlist, Stmts: yyDollar[4].stmts} yyVAL.funcexpr.SetLine(yyDollar[1].token.Pos.Line) yyVAL.funcexpr.SetLastLine(yyDollar[5].token.Pos.Line) } - case 81: + case 83: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:455 +//line parser.go.y:463 { yyVAL.funcexpr = &ast.FunctionExpr{ParList: &ast.ParList{HasVargs: false, Names: []string{}}, Stmts: yyDollar[3].stmts} yyVAL.funcexpr.SetLine(yyDollar[1].token.Pos.Line) yyVAL.funcexpr.SetLastLine(yyDollar[4].token.Pos.Line) } - case 82: + case 84: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:462 +//line parser.go.y:470 { yyVAL.parlist = &ast.ParList{HasVargs: true, Names: []string{}} } - case 83: + case 85: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:465 +//line parser.go.y:473 { yyVAL.parlist = &ast.ParList{HasVargs: false, Names: []string{}} yyVAL.parlist.Names = append(yyVAL.parlist.Names, yyDollar[1].namelist...) } - case 84: + case 86: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:469 +//line parser.go.y:477 { yyVAL.parlist = &ast.ParList{HasVargs: true, Names: []string{}} yyVAL.parlist.Names = append(yyVAL.parlist.Names, yyDollar[1].namelist...) } - case 85: + case 87: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:476 +//line parser.go.y:484 { yyVAL.expr = &ast.TableExpr{Fields: []*ast.Field{}} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } - case 86: + case 88: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:480 +//line parser.go.y:488 { yyVAL.expr = &ast.TableExpr{Fields: yyDollar[2].fieldlist} yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line) } - case 87: + case 89: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:487 +//line parser.go.y:495 { yyVAL.fieldlist = []*ast.Field{yyDollar[1].field} } - case 88: + case 90: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:490 +//line parser.go.y:498 { yyVAL.fieldlist = append(yyDollar[1].fieldlist, yyDollar[3].field) } - case 89: + case 91: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:493 +//line parser.go.y:501 { yyVAL.fieldlist = yyDollar[1].fieldlist } - case 90: + case 92: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:498 +//line parser.go.y:506 { yyVAL.field = &ast.Field{Key: &ast.StringExpr{Value: yyDollar[1].token.Str}, Value: yyDollar[3].expr} yyVAL.field.Key.SetLine(yyDollar[1].token.Pos.Line) } - case 91: + case 93: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:502 +//line parser.go.y:510 { yyVAL.field = &ast.Field{Key: yyDollar[2].expr, Value: yyDollar[5].expr} } - case 92: + case 94: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:505 +//line parser.go.y:513 { yyVAL.field = &ast.Field{Value: yyDollar[1].expr} } - case 93: + case 95: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:510 +//line parser.go.y:518 { yyVAL.fieldsep = "," } - case 94: + case 96: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:513 +//line parser.go.y:521 { yyVAL.fieldsep = ";" } diff --git a/vendor/github.com/yuin/gopher-lua/parse/parser.go.y b/vendor/github.com/yuin/gopher-lua/parse/parser.go.y index 9a9f831e611..52bcd55fab4 100644 --- a/vendor/github.com/yuin/gopher-lua/parse/parser.go.y +++ b/vendor/github.com/yuin/gopher-lua/parse/parser.go.y @@ -52,10 +52,10 @@ import ( } /* Reserved words */ -%token TAnd TBreak TDo TElse TElseIf TEnd TFalse TFor TFunction TIf TIn TLocal TNil TNot TOr TReturn TRepeat TThen TTrue TUntil TWhile +%token TAnd TBreak TDo TElse TElseIf TEnd TFalse TFor TFunction TIf TIn TLocal TNil TNot TOr TReturn TRepeat TThen TTrue TUntil TWhile TGoto /* Literals */ -%token TEqeq TNeq TLte TGte T2Comma T3Comma TIdent TNumber TString '{' '(' +%token TEqeq TNeq TLte TGte T2Comma T3Comma T2Colon TIdent TNumber TString '{' '(' /* Operators */ %left TOr @@ -187,6 +187,14 @@ stat: TLocal namelist { $$ = &ast.LocalAssignStmt{Names: $2, Exprs:[]ast.Expr{}} $$.SetLine($1.Pos.Line) + } | + T2Colon TIdent T2Colon { + $$ = &ast.LabelStmt{Name: $2.Str} + $$.SetLine($1.Pos.Line) + } | + TGoto TIdent { + $$ = &ast.GotoStmt{Label: $2.Str} + $$.SetLine($1.Pos.Line) } elseifs: diff --git a/vendor/github.com/yuin/gopher-lua/vm.go b/vendor/github.com/yuin/gopher-lua/vm.go index aaa04dc9aad..470855f2af6 100644 --- a/vendor/github.com/yuin/gopher-lua/vm.go +++ b/vendor/github.com/yuin/gopher-lua/vm.go @@ -1533,7 +1533,7 @@ func luaModulo(lhs, rhs LNumber) LNumber { flhs := float64(lhs) frhs := float64(rhs) v := math.Mod(flhs, frhs) - if flhs < 0 || frhs < 0 && !(flhs < 0 && frhs < 0) { + if frhs > 0 && v < 0 || frhs < 0 && v > 0 { v += frhs } return LNumber(v) diff --git a/vendor/modules.txt b/vendor/modules.txt index 22911c41c02..b0d6d68328a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -103,7 +103,7 @@ github.com/alecthomas/units # github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a ## explicit github.com/alicebob/gopher-json -# github.com/alicebob/miniredis/v2 v2.30.0 +# github.com/alicebob/miniredis/v2 v2.30.1 ## explicit; go 1.14 github.com/alicebob/miniredis/v2 github.com/alicebob/miniredis/v2/geohash @@ -935,7 +935,7 @@ github.com/weaveworks/common/user # github.com/weaveworks/promrus v1.2.0 ## explicit github.com/weaveworks/promrus -# github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 +# github.com/yuin/gopher-lua v1.1.0 ## explicit; go 1.17 github.com/yuin/gopher-lua github.com/yuin/gopher-lua/ast