diff --git a/go.mod b/go.mod index 3777aad741..3bb4ba813a 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/DataDog/gopsutil v1.2.1 github.com/GuanceCloud/confd v0.1.101 github.com/GuanceCloud/grok v1.1.4 - github.com/GuanceCloud/platypus v0.2.9 + github.com/GuanceCloud/platypus v0.2.10-0.20240815092339-21f3924850ee github.com/GuanceCloud/timeout v0.0.0-20230216045952-48442c6fb747 github.com/IBM/sarama v1.41.2 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible @@ -349,7 +349,7 @@ require ( require ( github.com/DataDog/ebpf-manager v0.2.16 - github.com/GuanceCloud/cliutils v1.1.21-0.20240820061659-b3501c0f2e71 + github.com/GuanceCloud/cliutils v1.1.21-0.20240821062850-3079bb7ed98d github.com/andrewkroh/sys v0.0.0-20151128191922-287798fe3e43 github.com/brianvoe/gofakeit/v6 v6.28.0 github.com/cilium/ebpf v0.11.0 diff --git a/go.sum b/go.sum index ea63930294..0d45fb5ffb 100644 --- a/go.sum +++ b/go.sum @@ -143,10 +143,8 @@ github.com/DataDog/sketches-go v1.4.1 h1:j5G6as+9FASM2qC36lvpvQAj9qsv/jUs3FtO8Cw github.com/DataDog/sketches-go v1.4.1/go.mod h1:xJIXldczJyyjnbDop7ZZcLxJdV3+7Kra7H1KMgpgkLk= github.com/GuanceCloud/client_model v0.0.0-20230418154757-93bd4e878a5e h1:i34dA4kiRTfG+KdvkIXCLPDduarVeFlQhGDD3TefgS4= github.com/GuanceCloud/client_model v0.0.0-20230418154757-93bd4e878a5e/go.mod h1:PMnE48aPzuRu83FmWZugC0O3d54ZupJd/MmiaYxz8sM= -github.com/GuanceCloud/cliutils v1.1.21-0.20240724044511-a592422e3402 h1:14RV/0zUQEuBDVveaQjDdYP67cxaEO+roOCCCcpWrBA= -github.com/GuanceCloud/cliutils v1.1.21-0.20240724044511-a592422e3402/go.mod h1:JOSrgcF3LbVmicqC7gz2RDZ/U6hmJCKcfUhIQYTTeMQ= -github.com/GuanceCloud/cliutils v1.1.21-0.20240820061659-b3501c0f2e71 h1:2y+LooXu02ThgiANst2j/pjXapyVif+nw1NiUv1P8Z4= -github.com/GuanceCloud/cliutils v1.1.21-0.20240820061659-b3501c0f2e71/go.mod h1:JOSrgcF3LbVmicqC7gz2RDZ/U6hmJCKcfUhIQYTTeMQ= +github.com/GuanceCloud/cliutils v1.1.21-0.20240821062850-3079bb7ed98d h1:dM5YEBXuFuwiZ5roAzxfA8RK2VwE0TnHAl5zAsHSKFg= +github.com/GuanceCloud/cliutils v1.1.21-0.20240821062850-3079bb7ed98d/go.mod h1:Qbeedf/Ji3immd8Ka01NDQG6SP6j8JBnbZwsHTtxyqs= github.com/GuanceCloud/confd v0.1.101 h1:yjHgfl6YzAlTbFOFMTE4ERpFJzIyovOW7ZFc2/ZssL0= github.com/GuanceCloud/confd v0.1.101/go.mod h1:o0opIwOX+yNwV9nh56x5ymFMJ+YBD8JuPxBJ7a1mEmo= github.com/GuanceCloud/dockertest/v3 v3.9.4 h1:ScSNhfA2HSNLfrYoNd1KSRxkrymlKiBE60g4f6eUoOk= @@ -163,8 +161,8 @@ github.com/GuanceCloud/kubernetes v0.0.0-20230801080916-ca299820872b h1:9pkl38Cr github.com/GuanceCloud/kubernetes v0.0.0-20230801080916-ca299820872b/go.mod h1:Acv+3eRHxCb4Qvs1YQcZ17X/D0H7DArQrew+WJtsLiE= github.com/GuanceCloud/mdcheck v0.0.0-20230718065937-44c6728c995f h1:0+A0eeT48LSlnDpVOQ/sqoW/lbYmerKKF7NVNBlgnww= github.com/GuanceCloud/mdcheck v0.0.0-20230718065937-44c6728c995f/go.mod h1:xrC7I8mMBOD93+A7fLJXU1lBaej49hZj7DaaFXFdSBE= -github.com/GuanceCloud/platypus v0.2.9 h1:ZQNlg/r2HKFBUn5Yrzb0fmB15zhLBkiuQbe+yX6CBr4= -github.com/GuanceCloud/platypus v0.2.9/go.mod h1:H9Sol/SI+A9ppJUohdn9m/UA0aiNvh+G0/GnY6IVDnI= +github.com/GuanceCloud/platypus v0.2.10-0.20240815092339-21f3924850ee h1:UHnR2IVFcwCCqLp6iSsh4Xn6fX93hujzDOx6RdCwM9c= +github.com/GuanceCloud/platypus v0.2.10-0.20240815092339-21f3924850ee/go.mod h1:H9Sol/SI+A9ppJUohdn9m/UA0aiNvh+G0/GnY6IVDnI= github.com/GuanceCloud/promcommon v0.0.0-20230828165048-8a8ac696e616 h1:l2/OF8jg2mcvAv5OzJWyooCEEcL2b0yATSl/iXUrvQ8= github.com/GuanceCloud/promcommon v0.0.0-20230828165048-8a8ac696e616/go.mod h1:zuawsU7vK4z3rZC2qaOYnhJO2rHD0CIUAgbyJxpjIf0= github.com/GuanceCloud/pyroscope v0.36.3 h1:3ni9asu1zsxzT/Y8WdoqcTN3LiAuFbCqAUk4foz2EvM= @@ -1511,7 +1509,6 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= @@ -1645,7 +1642,6 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2 github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180717111219-efc7eb8984d6/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -1936,7 +1932,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -2180,7 +2175,6 @@ github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -2190,7 +2184,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8/go.mod h1:1WNBiOZtZQLpVAyu0iTduoJL9hEsMloAK5XWrtW0xdY= diff --git a/internal/plugins/externals/ebpf/internal/l4log/filter_blacklist.go b/internal/plugins/externals/ebpf/internal/l4log/filter_blacklist.go index 611a98e6d7..2673d97df8 100644 --- a/internal/plugins/externals/ebpf/internal/l4log/filter_blacklist.go +++ b/internal/plugins/externals/ebpf/internal/l4log/filter_blacklist.go @@ -192,7 +192,7 @@ func (g *filterRuntime) runNetFilterDrop(stmts ast.Stmts, elem netElem) bool { func (g *filterRuntime) _runStmt(node *ast.Node, elem netElem) (ast.DType, any, error) { switch node.NodeType { //nolint:exhaustive case ast.TypeConditionalExpr: - expr := node.ConditionalExpr + expr := node.ConditionalExpr() typL, valL, err := g._runStmt(expr.LHS, elem) if err != nil { return ast.Invalid, nil, err @@ -276,14 +276,14 @@ func (g *filterRuntime) _runStmt(node *ast.Node, elem netElem) (ast.DType, any, return ast.Bool, false, nil case ast.TypeUnaryExpr: - expr := node.UnaryExpr + expr := node.UnaryExpr() _, val, err := g._runStmt(expr.RHS, elem) if err != nil { return ast.Invalid, nil, err } return ast.Bool, !val.(bool), nil case ast.TypeCallExpr: - expr := node.CallExpr + expr := node.CallExpr() if g.fnG == nil { return ast.Invalid, nil, fmt.Errorf("no function group") @@ -300,17 +300,17 @@ func (g *filterRuntime) _runStmt(node *ast.Node, elem netElem) (ast.DType, any, } return fnD.ret, fnD.fn(p...), nil case ast.TypeParenExpr: - return g._runStmt(node.ParenExpr.Param, elem) + return g._runStmt(node.ParenExpr().Param, elem) case ast.TypeIdentifier: - expr := node.Identifier + expr := node.Identifier() dtyp, val := elem.get(expr.Name) return dtyp, val, nil case ast.TypeStringLiteral: - return ast.String, node.StringLiteral.Val, nil + return ast.String, node.StringLiteral().Val, nil case ast.TypeIntegerLiteral: - return ast.Int, node.IntegerLiteral.Val, nil + return ast.Int, node.IntegerLiteral().Val, nil case ast.TypeBoolLiteral: - return ast.Bool, node.BoolLiteral.Val, nil + return ast.Bool, node.BoolLiteral().Val, nil default: return ast.Invalid, nil, fmt.Errorf("unsupport type: %s", node.NodeType) } @@ -319,7 +319,7 @@ func (g *filterRuntime) _runStmt(node *ast.Node, elem netElem) (ast.DType, any, func (g *filterRuntime) _checkStmt(node *ast.Node, elem netElem) (ast.DType, error) { switch node.NodeType { //nolint:exhaustive case ast.TypeConditionalExpr: - expr := node.ConditionalExpr + expr := node.ConditionalExpr() switch expr.Op { //nolint:exhaustive case ast.AND, ast.OR, ast.EQEQ, ast.NEQ, @@ -361,7 +361,7 @@ func (g *filterRuntime) _checkStmt(node *ast.Node, elem netElem) (ast.DType, err } return ast.Bool, nil case ast.TypeUnaryExpr: - expr := node.UnaryExpr + expr := node.UnaryExpr() if expr.Op != ast.NOT { return ast.Invalid, fmt.Errorf("%d%d: unsupport operator: %s", expr.OpPos.Ln, expr.OpPos.Col, expr.Op) } @@ -374,7 +374,7 @@ func (g *filterRuntime) _checkStmt(node *ast.Node, elem netElem) (ast.DType, err } return ast.Bool, nil case ast.TypeCallExpr: - expr := node.CallExpr + expr := node.CallExpr() if g.fnG == nil { return ast.Invalid, fmt.Errorf("%d%d: unsupport function: %s", expr.NamePos.Ln, expr.NamePos.Col, expr.Name) } @@ -406,9 +406,9 @@ func (g *filterRuntime) _checkStmt(node *ast.Node, elem netElem) (ast.DType, err } return fnD.ret, nil case ast.TypeParenExpr: - return g._checkStmt(node.ParenExpr.Param, elem) + return g._checkStmt(node.ParenExpr().Param, elem) case ast.TypeIdentifier: - expr := node.Identifier + expr := node.Identifier() if v, _ := elem.get(expr.Name); v != ast.Invalid { switch v { //nolint:exhaustive case ast.Int, ast.Bool, ast.String: diff --git a/internal/plugins/inputs/dialtesting/input.go b/internal/plugins/inputs/dialtesting/input.go index 3febb5ae47..7da9c937c1 100644 --- a/internal/plugins/inputs/dialtesting/input.go +++ b/internal/plugins/inputs/dialtesting/input.go @@ -494,7 +494,6 @@ func (ipt *Input) dispatchTasks(j []byte) error { } else if k == "name_en" { ipt.regionNameEn = v_ } - } default: l.Warnf("ignore key `%s' of type %s", k, reflect.TypeOf(v).String()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/msgstatus.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/msgstatus.go index c4f9d87786..2990819f87 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/msgstatus.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/msgstatus.go @@ -52,7 +52,7 @@ func normalizeStatus(status string) string { if s, ok := statusMap[status]; ok { status = s - } else { + } else if status == "" { status = DefaultStatus } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/script.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/script.go index 9c93128e30..5f17a149c7 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/script.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/manager/script.go @@ -144,7 +144,7 @@ func (script *PlScript) Run(plpt ptinput.PlInputPt, signal plruntime.Signal, opt plpt.SetCache(script.cache) plpt.SetPtWinPool(script.ptWindow) - err := plengine.RunScriptWithRMapIn(script.proc, plpt, signal) + err := script.proc.Run(plpt, signal) if err != nil { stats.WriteMetric(script.tags, 1, 0, 1, time.Since(startTime)) return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all.go index 9b3cea1516..38ea5d62a9 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all.go @@ -8,6 +8,7 @@ package funcs import ( "github.com/GuanceCloud/cliutils/logger" + "github.com/GuanceCloud/platypus/pkg/ast" "github.com/GuanceCloud/platypus/pkg/engine/runtime" ) @@ -17,6 +18,30 @@ func InitLog() { l = logger.SLogger("pl-funcs") } +type Function struct { + Name string + Args []*Param + + // todo: check return type + // Return []ast.DType + + Call runtime.FuncCall + Check runtime.FuncCheck + + Doc [2]*PLDoc // zh, en + + Deprecated bool +} + +type Param struct { + Name string + Type []ast.DType + + DefaultVal func() (any, ast.DType) + Optional bool + VariableP bool +} + var FuncsMap = map[string]runtime.FuncCall{ "agg_create": AggCreate, "agg_metric": AggAddMetric, @@ -84,6 +109,11 @@ var FuncsMap = map[string]runtime.FuncCall{ "gjson": GJSON, "point_window": PtWindow, "window_hit": PtWindowHit, + "pt_kvs_set": FnPtKvsSet.Call, + "pt_kvs_get": FnPtKvsGet.Call, + "pt_kvs_del": FnPtKvsDel.Call, + "pt_kvs_keys": FnPtKvsKeys.Call, + "hash": FnHash.Call, // disable "json_all": JSONAll, @@ -156,6 +186,13 @@ var FuncsCheckMap = map[string]runtime.FuncCheck{ "gjson": GJSONChecking, "point_window": PtWindowChecking, "window_hit": PtWindowHitChecking, + + "pt_kvs_set": FnPtKvsSet.Check, + "pt_kvs_get": FnPtKvsGet.Check, + "pt_kvs_del": FnPtKvsDel.Check, + "pt_kvs_keys": FnPtKvsKeys.Check, + "hash": FnHash.Check, + // disable "json_all": JSONAllChecking, } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc.go index 200701344f..7effa4c3f1 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc.go @@ -10,6 +10,7 @@ import ( ) type PLDoc struct { + Language string `json:"language"` Doc string `json:"doc"` Prototype string `json:"prototype"` Description string `json:"description"` @@ -32,7 +33,7 @@ var PipelineFunctionDocs = map[string]*PLDoc{ "cidr()": &cidrMarkdown, "cover()": &coverMarkdown, "datetime()": &datetimeMarkdown, - "decode": &decodeMarkdown, + "decode()": &decodeMarkdown, "default_time()": &defaultTimeMarkdown, "drop()": &dropMarkdown, "drop_key()": &dropKeyMarkdown, @@ -59,7 +60,7 @@ var PipelineFunctionDocs = map[string]*PLDoc{ "replace()": &replaceMarkdown, "set_measurement()": &setMeasurementMarkdown, "set_tag()": &setTagMarkdown, - "sql_cover": &sqlCoverMarkdown, + "sql_cover()": &sqlCoverMarkdown, "strfmt()": &strfmtMarkdown, "trim()": &trimMarkdown, "uppercase()": &uppercaseMarkdown, @@ -83,6 +84,11 @@ var PipelineFunctionDocs = map[string]*PLDoc{ "gjson()": &gjsonMarkdown, "point_window()": &pointWinodoeMarkdown, "window_hit()": &winHitMarkdown, + "pt_kvs_set()": FnPtKvsSet.Doc[0], + "pt_kvs_get()": FnPtKvsGet.Doc[0], + "pt_kvs_del()": FnPtKvsDel.Doc[0], + "pt_kvs_keys()": FnPtKvsKeys.Doc[0], + "hash()": FnHash.Doc[0], } var PipelineFunctionDocsEN = map[string]*PLDoc{ @@ -99,7 +105,7 @@ var PipelineFunctionDocsEN = map[string]*PLDoc{ "cidr()": &cidrMarkdownEN, "cover()": &coverMarkdownEN, "datetime()": &datetimeMarkdownEN, - "decode": &decodeMarkdownEN, + "decode()": &decodeMarkdownEN, "default_time()": &defaultTimeMarkdownEN, "drop()": &dropMarkdownEN, "drop_key()": &dropKeyMarkdownEN, @@ -126,7 +132,7 @@ var PipelineFunctionDocsEN = map[string]*PLDoc{ "replace()": &replaceMarkdownEN, "set_measurement()": &setMeasurementMarkdownEN, "set_tag()": &setTagMarkdownEN, - "sql_cover": &sqlCoverMarkdownEN, + "sql_cover()": &sqlCoverMarkdownEN, "strfmt()": &strfmtMarkdownEN, "trim()": &trimMarkdownEN, "uppercase()": &uppercaseMarkdownEN, @@ -150,6 +156,11 @@ var PipelineFunctionDocsEN = map[string]*PLDoc{ "gjson()": &gjsonMarkdownEN, "point_window()": &pointWinodoeMarkdownEN, "window_hit()": &winHitMarkdownEN, + "pt_kvs_set()": FnPtKvsSet.Doc[1], + "pt_kvs_get()": FnPtKvsGet.Doc[1], + "pt_kvs_del()": FnPtKvsDel.Doc[1], + "pt_kvs_keys()": FnPtKvsKeys.Doc[1], + "hash()": FnHash.Doc[1], } // embed docs. @@ -349,12 +360,13 @@ var ( ) const ( + langTagEnUS = "en-US" langTagZhCN = "zh-CN" ) const ( cEncodeDecode = "编解码" - cMeasurementOp = "行协议操作" + cPointOp = "Point 操作" cRegExp = "RegExp" cGrok = "Grok" cJSON = "JSON" @@ -365,7 +377,7 @@ const ( cStringOp = "字符串操作" cDesensitization = "脱敏" cSample = "采样" - ea = "聚合" + cAgg = "聚合" cOther = "其他" ) @@ -379,19 +391,19 @@ var ( addKeyMarkdown = PLDoc{ Doc: docAddKey, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } aggCreateMarkdown = PLDoc{ Doc: docAggCreate, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {ea}, + langTagZhCN: {cAgg}, }, } aggMetricMarkdown = PLDoc{ Doc: docAggMetric, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {ea}, + langTagZhCN: {cAgg}, }, } @@ -464,31 +476,31 @@ var ( defaultTimeMarkdown = PLDoc{ Doc: docDefaultTime, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cTimeOp, cMeasurementOp}, + langTagZhCN: {cTimeOp, cPointOp}, }, } getKeyMarkdown = PLDoc{ Doc: docGetKey, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } dropKeyMarkdown = PLDoc{ Doc: docDropKey, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } dropMarkdown = PLDoc{ Doc: docDrop, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } dropOriginDataMarkdown = PLDoc{ Doc: docDropOriginData, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } durationPrecisionMarkdown = PLDoc{ @@ -590,7 +602,7 @@ var ( renameMarkdown = PLDoc{ Doc: docRename, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } replaceMarkdown = PLDoc{ @@ -609,13 +621,13 @@ var ( setMeasurementMarkdown = PLDoc{ Doc: docSetMeasurement, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } setTagMarkdown = PLDoc{ Doc: docSetTag, Deprecated: false, FnCategory: map[string][]string{ - langTagZhCN: {cMeasurementOp}, + langTagZhCN: {cPointOp}, }, } sqlCoverMarkdown = PLDoc{ @@ -724,7 +736,7 @@ var ( ptNameMarkdown = PLDoc{ Doc: docPtName, FnCategory: map[string][]string{ - langTagZhCN: {cOther}, + langTagZhCN: {cPointOp}, }, } @@ -759,14 +771,14 @@ var ( pointWinodoeMarkdown = PLDoc{ Doc: docPointWindow, FnCategory: map[string][]string{ - langTagZhCN: {eOther}, + langTagZhCN: {cOther}, }, } winHitMarkdown = PLDoc{ Doc: docWindowHit, FnCategory: map[string][]string{ - langTagZhCN: {eOther}, + langTagZhCN: {cOther}, }, } ) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc_en.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc_en.go index 8eed9ce1b9..cbed76fc3c 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc_en.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/all_doc_en.go @@ -205,13 +205,9 @@ var ( docWindowHitEN string ) -const ( - langTagEnUS = "en-US" -) - const ( eEncodeDecode = "Encode/Decode" - eMeasurementOp = "Point" + ePointOp = "Point Operations" eRegExp = "RegExp" eGrok = "Grok" eJSON = "JSON" @@ -236,7 +232,7 @@ var ( addKeyMarkdownEN = PLDoc{ Doc: docAddKeyEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } addPatternMarkdownEN = PLDoc{ @@ -323,31 +319,31 @@ var ( defaultTimeMarkdownEN = PLDoc{ Doc: docDefaultTimeEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eTimeOp, eMeasurementOp}, + langTagEnUS: {eTimeOp, ePointOp}, }, } getKeyMarkdownEN = PLDoc{ Doc: docGetKeyEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } dropKeyMarkdownEN = PLDoc{ Doc: docDropKeyEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } dropMarkdownEN = PLDoc{ Doc: docDropEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } dropOriginDataMarkdownEN = PLDoc{ Doc: docDropOriginDataEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } durationPrecisionMarkdownEN = PLDoc{ @@ -449,7 +445,7 @@ var ( renameMarkdownEN = PLDoc{ Doc: docRenameEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } replaceMarkdownEN = PLDoc{ @@ -468,13 +464,13 @@ var ( setMeasurementMarkdownEN = PLDoc{ Doc: docSetMeasurementEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } setTagMarkdownEN = PLDoc{ Doc: docSetTagEN, Deprecated: false, FnCategory: map[string][]string{ - langTagEnUS: {eMeasurementOp}, + langTagEnUS: {ePointOp}, }, } sqlCoverMarkdownEN = PLDoc{ @@ -584,7 +580,7 @@ var ( ptNameMarkdownEN = PLDoc{ Doc: docPtNameEN, FnCategory: map[string][]string{ - langTagEnUS: {eOther}, + langTagEnUS: {ePointOp}, }, } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addkey.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addkey.go index ca51a2438d..14ef38f70e 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addkey.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addkey.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func AddkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AddkeyChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) > 2 || len(funcExpr.Param) < 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) @@ -27,7 +27,7 @@ func AddkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func AddKey(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AddKey(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 && len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addpattern.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addpattern.go index 1d293a2d83..083f377967 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addpattern.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_addpattern.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func AddPatternChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AddPatternChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 2 args", funcExpr.Name), funcExpr.NamePos) @@ -23,7 +23,7 @@ func AddPatternChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain. var name, pattern string switch funcExpr.Param[0].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - name = funcExpr.Param[0].StringLiteral.Val + name = funcExpr.Param[0].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect StringLiteral, got %s", funcExpr.Param[0].NodeType), funcExpr.NamePos) @@ -31,7 +31,7 @@ func AddPatternChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain. switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - pattern = funcExpr.Param[1].StringLiteral.Val + pattern = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect StringLiteral, got %s", funcExpr.Param[1].NodeType), funcExpr.Param[1].StartPos()) @@ -45,6 +45,6 @@ func AddPatternChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain. return nil } -func AddPattern(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AddPattern(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_adjust_timezone.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_adjust_timezone.go index 495577ebdd..0de0cd8a08 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_adjust_timezone.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_adjust_timezone.go @@ -18,7 +18,7 @@ import ( const defaultMinuteDelta = int64(2) -func AdjustTimezoneChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AdjustTimezoneChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 arg", funcExpr.Name), @@ -32,7 +32,7 @@ func AdjustTimezoneChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errch return nil } -func AdjustTimezone(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AdjustTimezone(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { key, err := getKeyName(funcExpr.Param[0]) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) @@ -43,9 +43,9 @@ func AdjustTimezone(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr if len(funcExpr.Param) == 2 { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeFloatLiteral: - minuteAllow = int64(funcExpr.Param[1].FloatLiteral.Val) + minuteAllow = int64(funcExpr.Param[1].FloatLiteral().Val) case ast.TypeIntegerLiteral: - minuteAllow = funcExpr.Param[1].IntegerLiteral.Val + minuteAllow = funcExpr.Param[1].IntegerLiteral().Val default: } } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_agg.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_agg.go index 1a08154fd6..a3e85955dc 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_agg.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_agg.go @@ -16,8 +16,8 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func AggCreateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func AggCreateChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "bucket", "on_interval", "on_count", "keep_value", "const_tags", "category", }, 1); err != nil { @@ -36,7 +36,7 @@ func AggCreateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P if arg := funcExpr.Param[1]; arg != nil { switch arg.NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - ts := arg.StringLiteral.Val + ts := arg.StringLiteral().Val if v, err := time.ParseDuration(ts); err != nil { return runtime.NewRunError(ctx, fmt.Sprintf("parse on_interval: %s", err.Error()), arg.StartPos()) @@ -53,7 +53,7 @@ func AggCreateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P if arg := funcExpr.Param[2]; arg != nil { switch arg.NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - count = int(arg.IntegerLiteral.Val) + count = int(arg.IntegerLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf("param `on_count` expect IntegerLiteral, got %s", arg.NodeType), arg.StartPos()) @@ -77,7 +77,7 @@ func AggCreateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func AggCreate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AggCreate(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { pt, err := getPoint(ctx.InData()) if err != nil { return nil @@ -106,7 +106,7 @@ func AggCreate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { } } - bukName := funcExpr.Param[0].StringLiteral.Val + bukName := funcExpr.Param[0].StringLiteral().Val if _, ok := buks.GetBucket(ptCat, bukName); ok { return nil } @@ -116,15 +116,15 @@ func AggCreate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { keepValue := false if arg := funcExpr.Param[1]; arg != nil { - interval, _ = time.ParseDuration(arg.StringLiteral.Val) + interval, _ = time.ParseDuration(arg.StringLiteral().Val) } if arg := funcExpr.Param[2]; arg != nil { - count = int(arg.IntegerLiteral.Val) + count = int(arg.IntegerLiteral().Val) } if arg := funcExpr.Param[3]; arg != nil { - keepValue = arg.BoolLiteral.Val + keepValue = arg.BoolLiteral().Val } constTags := map[string]string{} @@ -145,8 +145,8 @@ func AggCreate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func AggAddMetricChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func AggAddMetricChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "bucket", "new_field", "agg_fn", "agg_by", "agg_field", "category", }, 5); err != nil { @@ -180,11 +180,11 @@ func AggAddMetricChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchai var tags []string arg4 := funcExpr.Param[3] switch arg4.NodeType { //nolint:exhaustive - case ast.TypeListInitExpr: - for _, v := range arg4.ListInitExpr.List { + case ast.TypeListLiteral: + for _, v := range arg4.ListLiteral().List { switch v.NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - tags = append(tags, v.StringLiteral.Val) + tags = append(tags, v.StringLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf("agg_by elem expect StringLiteral, got %s", arg4.NodeType), arg4.StartPos()) @@ -212,7 +212,7 @@ func AggAddMetricChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchai return nil } -func AggAddMetric(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AggAddMetric(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { pt, err := getPoint(ctx.InData()) if err != nil { return nil @@ -223,9 +223,9 @@ func AggAddMetric(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } - bukName := funcExpr.Param[0].StringLiteral.Val - newField := funcExpr.Param[1].StringLiteral.Val - aggFn := funcExpr.Param[2].StringLiteral.Val + bukName := funcExpr.Param[0].StringLiteral().Val + newField := funcExpr.Param[1].StringLiteral().Val + aggFn := funcExpr.Param[2].StringLiteral().Val aggBy, ok := funcExpr.PrivateData.([]string) if !ok { @@ -267,7 +267,7 @@ func AggAddMetric(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } - aggField := funcExpr.Param[4].StringLiteral.Val + aggField := funcExpr.Param[4].StringLiteral().Val fieldValue, err := ctx.GetKey(aggField) if err != nil { diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_append.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_append.go index 95f55178f4..d0a39ff2c1 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_append.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_append.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func doAppendChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func doAppendChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, "func %s expects 2 args", funcExpr.NamePos) } @@ -34,11 +34,11 @@ func doAppendChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func AppendChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func AppendChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return doAppendChecking(ctx, funcExpr) } -func Append(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Append(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if errR := doAppendChecking(ctx, funcExpr); errR != nil { return errR } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64dec.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64dec.go index e4f255404e..2c3c378bae 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64dec.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64dec.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func B64decChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func B64decChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -28,7 +28,7 @@ func B64decChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func B64dec(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func B64dec(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64enc.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64enc.go index 0634c709b7..cb4f82a058 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64enc.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_b64enc.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func B64encChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func B64encChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -28,7 +28,7 @@ func B64encChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func B64enc(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func B64enc(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cache.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cache.go index a7ae5dee7e..c652ac7833 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cache.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cache.go @@ -9,7 +9,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func CacheGetChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CacheGetChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -17,7 +17,7 @@ func CacheGetChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func CacheGet(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CacheGet(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err @@ -51,8 +51,8 @@ func CacheGet(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func CacheSetChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func CacheSetChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "key", "value", "exp", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -61,7 +61,7 @@ func CacheSetChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func CacheSet(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CacheSet(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { key, keyType, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cast.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cast.go index 20c10a0ce2..c5cfaf959f 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cast.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cast.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func CastChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CastChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 2 args", funcExpr.Name), funcExpr.NamePos) @@ -25,11 +25,11 @@ func CastChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - switch funcExpr.Param[1].StringLiteral.Val { + switch funcExpr.Param[1].StringLiteral().Val { case "bool", "int", "float", "str", "string": default: return runtime.NewRunError(ctx, fmt.Sprintf("unsupported data type: %s", - funcExpr.Param[1].StringLiteral.Val), funcExpr.Param[1].StartPos()) + funcExpr.Param[1].StringLiteral().Val), funcExpr.Param[1].StartPos()) } default: return runtime.NewRunError(ctx, fmt.Sprintf("param type expect StringLiteral, got `%s'", @@ -38,7 +38,7 @@ func CastChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } -func Cast(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Cast(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 2 args", funcExpr.Name), funcExpr.NamePos) @@ -53,7 +53,7 @@ func Cast(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - castType = funcExpr.Param[1].StringLiteral.Val + castType = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param type expect StringLiteral, got `%s'", funcExpr.Param[1].NodeType), funcExpr.Param[1].StartPos()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cidr.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cidr.go index 8430c3005e..9811bb808b 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cidr.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cidr.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func CIDRChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CIDRChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 2 args", funcExpr.Name), funcExpr.NamePos) @@ -38,7 +38,7 @@ func CIDRChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } -func CIDR(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CIDR(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { err := fmt.Errorf("func %s expects 2 args", funcExpr.Name) l.Debug(err) @@ -83,9 +83,9 @@ func CIDRContains(ipAddr, prefix string) (bool, error) { return network.Contains(ip), nil } -func getStr(ctx *runtime.Context, node *ast.Node) (string, error) { +func getStr(ctx *runtime.Task, node *ast.Node) (string, error) { if node.NodeType == ast.TypeStringLiteral { - return node.StringLiteral.Val, nil + return node.StringLiteral().Val, nil } keyName, err := getKeyName(node) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_conv_traceid_hex_to_dec.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_conv_traceid_hex_to_dec.go index b21310b733..abd4d3027c 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_conv_traceid_hex_to_dec.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_conv_traceid_hex_to_dec.go @@ -17,7 +17,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ConvTraceIDW3C2DDChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ConvTraceIDW3C2DDChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -30,7 +30,7 @@ func ConvTraceIDW3C2DDChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *er return nil } -func ConvTraceIDW3C2DD(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ConvTraceIDW3C2DD(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cover.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cover.go index ced2abce55..b02462d0ce 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cover.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_cover.go @@ -16,7 +16,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func CoverChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CoverChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 2 args", funcExpr.Name), funcExpr.NamePos) @@ -26,13 +26,13 @@ func CoverChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) } - if funcExpr.Param[1].NodeType != ast.TypeListInitExpr { + if funcExpr.Param[1].NodeType != ast.TypeListLiteral { return runtime.NewRunError(ctx, fmt.Sprintf( "param range expects ListInitExpr, got %s", funcExpr.Param[1].NodeType), funcExpr.Param[1].StartPos()) } - set := funcExpr.Param[1].ListInitExpr + set := funcExpr.Param[1].ListLiteral() if len(set.List) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( @@ -49,7 +49,7 @@ func CoverChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func Cover(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Cover(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 2 args", funcExpr.Name), funcExpr.NamePos) @@ -60,11 +60,11 @@ func Cover(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) } - if funcExpr.Param[1].NodeType != ast.TypeListInitExpr { + if funcExpr.Param[1].NodeType != ast.TypeListLiteral { return nil } - set := funcExpr.Param[1].ListInitExpr + set := funcExpr.Param[1].ListLiteral() var start, end int @@ -76,9 +76,9 @@ func Cover(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch set.List[0].NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - start = int(set.List[0].IntegerLiteral.Val) + start = int(set.List[0].IntegerLiteral().Val) case ast.TypeFloatLiteral: - start = int(set.List[0].FloatLiteral.Val) + start = int(set.List[0].FloatLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf( "range value `%v' is not expected", set), @@ -87,9 +87,9 @@ func Cover(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch set.List[1].NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - end = int(set.List[1].IntegerLiteral.Val) + end = int(set.List[1].IntegerLiteral().Val) case ast.TypeFloatLiteral: - end = int(set.List[1].FloatLiteral.Val) + end = int(set.List[1].FloatLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf( "range value `%v' is not expected", set), diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_create_point.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_create_point.go index c1462bdd35..b6affcd6c9 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_create_point.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_create_point.go @@ -18,8 +18,8 @@ import ( "github.com/spf13/cast" ) -func CreatePointChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func CreatePointChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "name", "tags", "fields", "ts", "category", "after_use", }, 3); err != nil { @@ -45,7 +45,7 @@ func CreatePointChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain return nil } -func CreatePoint(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func CreatePoint(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var ptName string var ptTags map[string]string ptFields := map[string]any{} @@ -154,7 +154,7 @@ func CreatePoint(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError if arg := funcExpr.Param[5]; arg != nil { if refCall, ok := funcExpr.PrivateData.(*ast.CallExpr); ok { if srcipt, ok := refCall.PrivateData.(*runtime.Script); ok { - if err := runtime.RunScriptWithRMapIn(srcipt, plpt, ctx.Signal()); err != nil { + if err := srcipt.Run(plpt, ctx.Signal()); err != nil { return err.ChainAppend(ctx.Name(), funcExpr.NamePos) } } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_datetime.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_datetime.go index 0849366c43..e5c38cf157 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_datetime.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_datetime.go @@ -17,8 +17,8 @@ import ( conv "github.com/spf13/cast" ) -func DateTimeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func DateTimeChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "key", "precision", "fmt", "tz", }, 3); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -58,7 +58,7 @@ func DateTimeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func DateTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DateTime(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 3 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 3 or 4 args", funcExpr.Name), funcExpr.NamePos) @@ -73,7 +73,7 @@ func DateTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - precision = funcExpr.Param[1].StringLiteral.Val + precision = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "param `precision` expect StringLiteral, got %s", @@ -82,7 +82,7 @@ func DateTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - fmts = funcExpr.Param[2].StringLiteral.Val + fmts = funcExpr.Param[2].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "param `fmt` expect StringLiteral, got %s", @@ -112,7 +112,7 @@ func DateTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { var tz string if funcExpr.Param[3] != nil { if funcExpr.Param[3].NodeType == ast.TypeStringLiteral { - tz = funcExpr.Param[3].StringLiteral.Val + tz = funcExpr.Param[3].StringLiteral().Val } else { return runtime.NewRunError(ctx, fmt.Sprintf( "param `tz` expect StringLiteral, got %s", diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_decoder.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_decoder.go index 93aadbe795..98e85f853a 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_decoder.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_decoder.go @@ -45,7 +45,7 @@ func NewDecoder(enc string) (*Decoder, error) { return &Decoder{decoder: decoder}, nil } -func Decode(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Decode(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var codeType string key, err := getKeyName(funcExpr.Param[0]) @@ -71,7 +71,7 @@ func Decode(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { } codeType = keyVal case ast.TypeStringLiteral: - codeType = funcExpr.Param[1].StringLiteral.Val + codeType = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "expect AttrExpr, Identifier or StringLiteral, got %s", @@ -99,7 +99,7 @@ func Decode(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func DecodeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DecodeChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 2 || len(funcExpr.Param) > 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 2", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time.go index d4101bdd1f..abe438c184 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func DefaultTimeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DefaultTimeChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s Expect at least one arg", funcExpr.Name), funcExpr.NamePos) @@ -36,7 +36,7 @@ func DefaultTimeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain return nil } -func DefaultTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DefaultTime(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expect at least one arg", funcExpr.Name), funcExpr.NamePos) @@ -57,7 +57,7 @@ func DefaultTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError if len(funcExpr.Param) > 1 { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - tz = funcExpr.Param[1].StringLiteral.Val + tz = funcExpr.Param[1].StringLiteral().Val default: err = fmt.Errorf("param key expect StringLiteral, got %s", funcExpr.Param[1].NodeType) @@ -78,7 +78,7 @@ func DefaultTime(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError return nil } -func usePointTime(ctx *runtime.Context, key string, err error) { +func usePointTime(ctx *runtime.Task, key string, err error) { _ = addKey2PtWithVal(ctx.InData(), runtime.PlRunInfoField, fmt.Sprintf("time convert failed: %v", err), ast.String, ptinput.KindPtDefault) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time_with_fmt.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time_with_fmt.go index b91adc239a..18cdc19c21 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time_with_fmt.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_default_time_with_fmt.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func DefaultTimeWithFmtChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DefaultTimeWithFmtChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected more than 2 args", funcExpr.Name), funcExpr.NamePos) @@ -50,7 +50,7 @@ func DefaultTimeWithFmtChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *e return nil } -func DefaultTimeWithFmt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DefaultTimeWithFmt(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var err error var goTimeFmt string var tz string @@ -69,7 +69,7 @@ func DefaultTimeWithFmt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain. switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - goTimeFmt = funcExpr.Param[1].StringLiteral.Val + goTimeFmt = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "param key expect StringLiteral, got %s", @@ -79,7 +79,7 @@ func DefaultTimeWithFmt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain. if len(funcExpr.Param) > 2 { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - tz = funcExpr.Param[2].StringLiteral.Val + tz = funcExpr.Param[2].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "param key expect StringLiteral, got %s", diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_delete.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_delete.go index 479f656424..05b168e1a4 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_delete.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_delete.go @@ -14,8 +14,8 @@ import ( "github.com/spf13/cast" ) -func DeleteMapItemChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{"src", "key"}, 2); err != nil { +func DeleteMapItemChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{"src", "key"}, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) } @@ -36,11 +36,11 @@ func DeleteMapItemChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errcha return nil } -func DeleteMapItem(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DeleteMapItem(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var keyName string switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - keyName = funcExpr.Param[1].StringLiteral.Val + keyName = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param key expect StringLiteral, got %s", funcExpr.Param[1].NodeType), funcExpr.Param[1].StartPos()) @@ -48,7 +48,7 @@ func DeleteMapItem(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr switch funcExpr.Param[0].NodeType { //nolint:exhaustive case ast.TypeIndexExpr: - indexExprDel(ctx, funcExpr.Param[0].IndexExpr, keyName) + indexExprDel(ctx, funcExpr.Param[0].IndexExpr(), keyName) return nil case ast.TypeIdentifier: key, err := getKeyName(funcExpr.Param[0]) @@ -78,7 +78,7 @@ func DeleteMapItem(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func indexExprDel(ctx *runtime.Context, expr *ast.IndexExpr, keyDel string) { +func indexExprDel(ctx *runtime.Task, expr *ast.IndexExpr, keyDel string) { key := expr.Obj.Name varb, err := ctx.GetKey(key) @@ -106,7 +106,7 @@ func indexExprDel(ctx *runtime.Context, expr *ast.IndexExpr, keyDel string) { searchListAndMap(ctx, varb.Value, expr.Index, keyDel) } -func searchListAndMap(ctx *runtime.Context, obj any, index []*ast.Node, keyDel string) { +func searchListAndMap(ctx *runtime.Task, obj any, index []*ast.Node, keyDel string) { cur := obj for _, i := range index { diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop.go index f26d8aaa71..af1e4f4d64 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop.go @@ -11,11 +11,11 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func DropChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DropChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func Drop(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Drop(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if err := markPtDrop(ctx.InData()); err != nil { l.Debug(err) } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop_origin_data.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop_origin_data.go index d525130c95..4ba77e3ac6 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop_origin_data.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_drop_origin_data.go @@ -11,11 +11,11 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func DropOriginDataChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DropOriginDataChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func DropOriginData(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DropOriginData(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { deletePtKey(ctx.InData(), "message") return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_dropkey.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_dropkey.go index 956793870c..6d22234352 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_dropkey.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_dropkey.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func DropkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DropkeyChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -26,7 +26,7 @@ func DropkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE return nil } -func Dropkey(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Dropkey(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_duration_precision.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_duration_precision.go index 0a2ff35d59..9c5add7a93 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_duration_precision.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_duration_precision.go @@ -17,11 +17,11 @@ import ( "github.com/spf13/cast" ) -func DurationPrecisionChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DurationPrecisionChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func DurationPrecision(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func DurationPrecision(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 3 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 3 args", funcExpr.Name), funcExpr.NamePos) @@ -48,7 +48,7 @@ func DurationPrecision(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P var err error switch funcExpr.Param[i].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - if oldNew[i-1], err = precision(funcExpr.Param[i].StringLiteral.Val); err != nil { + if oldNew[i-1], err = precision(funcExpr.Param[i].StringLiteral().Val); err != nil { l.Debug(err) return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_exit.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_exit.go index 9bd1a996ab..6a9a4088e5 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_exit.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_exit.go @@ -11,11 +11,11 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ExitChecking(ctx *runtime.Context, node *ast.CallExpr) *errchain.PlError { +func ExitChecking(ctx *runtime.Task, node *ast.CallExpr) *errchain.PlError { return nil } -func Exit(ctx *runtime.Context, node *ast.CallExpr) *errchain.PlError { +func Exit(ctx *runtime.Task, node *ast.CallExpr) *errchain.PlError { ctx.SetExit() return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_expr.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_expr.go index 0f583be3cc..dcc6784e60 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_expr.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_expr.go @@ -11,12 +11,12 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ExprChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ExprChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { l.Debugf("warning: expr() is disabled") return nil } -func Expr(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Expr(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { l.Debugf("warning: expr() is disabled") return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_geo_ip.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_geo_ip.go index 7096df5fa4..aa9bb6e856 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_geo_ip.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_geo_ip.go @@ -30,7 +30,7 @@ var geoDefaultVal = "unknown" // ipdbInstance = instance // } -func GeoIPChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GeoIPChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -43,7 +43,7 @@ func GeoIPChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func GeoIP(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GeoIP(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_getkey.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_getkey.go index df000a6971..62388b54bd 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_getkey.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_getkey.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func GetkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GetkeyChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -26,7 +26,7 @@ func GetkeyChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func Getkey(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Getkey(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr == nil { return runtime.NewRunError(ctx, "unreachable", funcExpr.NamePos) } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_gjson.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_gjson.go index 8fdae710dd..9ed5a8fe6f 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_gjson.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_gjson.go @@ -15,8 +15,8 @@ import ( "github.com/tidwall/gjson" ) -func GJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func GJSONChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "input", "json_path", "key_name", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -49,7 +49,7 @@ func GJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func GJSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GJSON(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { srcKey, err := getKeyName(funcExpr.Param[0]) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_grok.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_grok.go index 1da414e0cf..836c789943 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_grok.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_grok.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func GrokChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GrokChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Grok != nil { return nil } @@ -42,7 +42,7 @@ func GrokChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro var pattern string switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - pattern = funcExpr.Param[1].StringLiteral.Val + pattern = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "expect StringLiteral, got %s", @@ -57,7 +57,7 @@ func GrokChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } -func Grok(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Grok(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { grokRe := funcExpr.Grok if grokRe == nil { ctx.Regs.ReturnAppend(false, ast.Bool) @@ -81,7 +81,7 @@ func Grok(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) == 3 { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeBoolLiteral: - trimSpace = funcExpr.Param[2].BoolLiteral.Val + trimSpace = funcExpr.Param[2].BoolLiteral().Val default: ctx.Regs.ReturnAppend(false, ast.Bool) return runtime.NewRunError(ctx, fmt.Sprintf("param key expect BoolLiteral, got `%s'", diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group.go index 75f69c64c9..e1723ceefd 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func GroupChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GroupChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 3 || len(funcExpr.Param) > 4 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 3 or 4 args", funcExpr.Name), funcExpr.NamePos) @@ -33,8 +33,8 @@ func GroupChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr } var set []*ast.Node - if funcExpr.Param[1].NodeType == ast.TypeListInitExpr { - set = funcExpr.Param[1].ListInitExpr.List + if funcExpr.Param[1].NodeType == ast.TypeListLiteral { + set = funcExpr.Param[1].ListLiteral().List } if len(set) != 2 { @@ -45,9 +45,9 @@ func GroupChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr switch set[0].NodeType { //nolint:exhaustive case ast.TypeFloatLiteral: - start = set[0].FloatLiteral.Val + start = set[0].FloatLiteral().Val case ast.TypeIntegerLiteral: - start = float64(set[0].IntegerLiteral.Val) + start = float64(set[0].IntegerLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf( @@ -56,9 +56,9 @@ func GroupChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr switch set[1].NodeType { //nolint:exhaustive case ast.TypeFloatLiteral: - end = set[1].FloatLiteral.Val + end = set[1].FloatLiteral().Val case ast.TypeIntegerLiteral: - end = float64(set[1].IntegerLiteral.Val) + end = float64(set[1].IntegerLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf( "range value `%v' is not expected", set), set[1].StartPos()) @@ -72,7 +72,7 @@ func GroupChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func Group(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Group(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 3 || len(funcExpr.Param) > 4 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 3 or 4 args", funcExpr.Name), funcExpr.NamePos) @@ -92,8 +92,8 @@ func Group(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { var start, end float64 var set []*ast.Node - if funcExpr.Param[1].NodeType == ast.TypeListInitExpr { - set = funcExpr.Param[1].ListInitExpr.List + if funcExpr.Param[1].NodeType == ast.TypeListLiteral { + set = funcExpr.Param[1].ListLiteral().List } if len(set) != 2 { @@ -103,9 +103,9 @@ func Group(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch set[0].NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - start = float64(set[0].IntegerLiteral.Val) + start = float64(set[0].IntegerLiteral().Val) case ast.TypeFloatLiteral: - start = set[0].FloatLiteral.Val + start = set[0].FloatLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("range value `%v' is not expected", set), funcExpr.Param[1].StartPos()) @@ -113,9 +113,9 @@ func Group(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch set[1].NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - end = float64(set[1].IntegerLiteral.Val) + end = float64(set[1].IntegerLiteral().Val) case ast.TypeFloatLiteral: - end = set[1].FloatLiteral.Val + end = set[1].FloatLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("range value `%v' is not expected", set), funcExpr.Param[1].StartPos()) @@ -134,16 +134,16 @@ func Group(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch value.NodeType { //nolint:exhaustive case ast.TypeFloatLiteral: - val = value.FloatLiteral.Val + val = value.FloatLiteral().Val dtype = ast.Float case ast.TypeIntegerLiteral: - val = value.IntegerLiteral.Val + val = value.IntegerLiteral().Val dtype = ast.Int case ast.TypeStringLiteral: - val = value.StringLiteral.Val + val = value.StringLiteral().Val dtype = ast.String case ast.TypeBoolLiteral: - val = value.BoolLiteral.Val + val = value.BoolLiteral().Val dtype = ast.String default: l.Debugf("unknown group elements: %s", value.NodeType) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group_in.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group_in.go index 8e12f7c189..cac5c4f5ab 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group_in.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_group_in.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func GroupInChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GroupInChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 3 || len(funcExpr.Param) > 4 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 3 or 4 args", funcExpr.Name), funcExpr.NamePos) @@ -36,7 +36,7 @@ func GroupInChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE return nil } -func GroupIn(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func GroupIn(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 3 || len(funcExpr.Param) > 4 { return runtime.NewRunError(ctx, fmt.Sprintf("func %s expected 3 or 4 args", funcExpr.Name), funcExpr.NamePos) @@ -56,15 +56,15 @@ func GroupIn(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { var set []any switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeIdentifier: - if v, err := ctx.GetKey(funcExpr.Param[1].Identifier.Name); err == nil && + if v, err := ctx.GetKey(funcExpr.Param[1].Identifier().Name); err == nil && v.DType == ast.List { if v, ok := v.Value.([]any); ok { set = v } } - case ast.TypeListInitExpr: + case ast.TypeListLiteral: if v, dtype, err := runtime.RunListInitExpr(ctx, - funcExpr.Param[1].ListInitExpr); err == nil && dtype == ast.List { + funcExpr.Param[1].ListLiteral()); err == nil && dtype == ast.List { if v, ok := v.([]any); ok { set = v } @@ -79,16 +79,16 @@ func GroupIn(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch value.NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - val = value.IntegerLiteral.Val + val = value.IntegerLiteral().Val dtype = ast.Int case ast.TypeFloatLiteral: - val = value.FloatLiteral.Val + val = value.FloatLiteral().Val dtype = ast.Float case ast.TypeStringLiteral: - val = value.StringLiteral.Val + val = value.StringLiteral().Val dtype = ast.String case ast.TypeBoolLiteral: - val = value.BoolLiteral.Val + val = value.BoolLiteral().Val dtype = ast.String default: return nil diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_hash.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_hash.go new file mode 100644 index 0000000000..b400b20dfa --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_hash.go @@ -0,0 +1,88 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the MIT License. +// This product includes software developed at Guance Cloud (https://www.guance.com/). +// Copyright 2021-present Guance, Inc. + +package funcs + +import ( + "crypto/md5" + "crypto/sha1" + "crypto/sha256" + "crypto/sha512" + _ "embed" + "encoding/hex" + "unsafe" + + "github.com/GuanceCloud/platypus/pkg/ast" + "github.com/GuanceCloud/platypus/pkg/engine/runtime" + "github.com/GuanceCloud/platypus/pkg/errchain" +) + +// embed docs. +var ( + //go:embed md/hash.md + docHash string + + //go:embed md/hash.en.md + docHashEN string + + _ = "fn hash(text: str, method: str) -> str" + + FnHash = NewFunc( + "hash", + []*Param{ + { + Name: "text", + Type: []ast.DType{ast.String}, + }, + { + Name: "method", + Type: []ast.DType{ast.String}, + }, + }, + []ast.DType{ast.String}, + [2]*PLDoc{ + { + Language: langTagZhCN, Doc: docHash, + FnCategory: map[string][]string{ + langTagZhCN: {cStringOp}}, + }, + { + Language: langTagEnUS, Doc: docHashEN, + FnCategory: map[string][]string{ + langTagEnUS: {eStringOp}, + }, + }, + }, + hashFn, + ) +) + +func hashFn(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError { + text := vals[0].(string) + txt := *(*[]byte)(unsafe.Pointer(&text)) + // todo: go1.20+ + // textSlice := unsafe.Slice(unsafe.StringData(text), len(text)) + method := vals[1].(string) + + var sum string + switch method { + case "md5": + b := md5.Sum(txt) + sum = hex.EncodeToString(b[:]) + case "sha1": + b := sha1.Sum(txt) + sum = hex.EncodeToString(b[:]) + case "sha256": + b := sha256.Sum256(txt) + sum = hex.EncodeToString(b[:]) + case "sha512": + b := sha512.Sum512(txt) + sum = hex.EncodeToString(b[:]) + default: + } + + ctx.Regs.ReturnAppend(sum, ast.String) + return nil +} diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_http_request.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_http_request.go index 64cf56e509..453f82ddf7 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_http_request.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_http_request.go @@ -26,8 +26,8 @@ var defaultTransport http.RoundTripper = &http.Transport{ ExpectContinueTimeout: 1 * time.Second, } -func HTTPRequestChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func HTTPRequestChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "method", "url", "headers", "body", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -36,7 +36,7 @@ func HTTPRequestChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain return nil } -func HTTPRequest(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func HTTPRequest(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { // Acquire params method, methodType, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_json.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_json.go index d2237060fc..326809a275 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_json.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_json.go @@ -17,8 +17,8 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func JSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func JSONChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "input", "json_path", "newkey", "trim_space", "delete_after_extract", }, 2); err != nil { @@ -63,7 +63,7 @@ func JSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro if funcExpr.Param[4] != nil { switch funcExpr.Param[4].NodeType { //nolint:exhaustive case ast.TypeBoolLiteral: - if funcExpr.Param[4].BoolLiteral.Val == lastIdxExpr { + if funcExpr.Param[4].BoolLiteral().Val == lastIdxExpr { return runtime.NewRunError(ctx, "does not support deleting elements in the list", funcExpr.Param[4].StartPos()) } @@ -76,7 +76,7 @@ func JSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } -func JSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func JSON(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var jpath *ast.Node srcKey, err := getKeyName(funcExpr.Param[0]) @@ -115,7 +115,7 @@ func JSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[4] != nil { switch funcExpr.Param[4].NodeType { //nolint:exhaustive case ast.TypeBoolLiteral: - deleteAfterExtract = funcExpr.Param[4].BoolLiteral.Val + deleteAfterExtract = funcExpr.Param[4].BoolLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect BoolLiteral, got %s", funcExpr.Param[3].NodeType), funcExpr.Param[4].StartPos()) @@ -132,7 +132,7 @@ func JSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[3] != nil { switch funcExpr.Param[3].NodeType { //nolint:exhaustive case ast.TypeBoolLiteral: - trimSpace = funcExpr.Param[3].BoolLiteral.Val + trimSpace = funcExpr.Param[3].BoolLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect BoolLiteral, got %s", funcExpr.Param[3].NodeType), funcExpr.Param[3].StartPos()) @@ -202,20 +202,20 @@ func jsonGet(val any, node *ast.Node, deleteAfter bool) (any, error) { switch node.NodeType { //nolint:exhaustive case ast.TypeStringLiteral: return getByIdentifier(val, &ast.Identifier{ - Name: node.StringLiteral.Val, + Name: node.StringLiteral().Val, }, deleteAfter) case ast.TypeAttrExpr: - return getByAttr(val, node.AttrExpr, deleteAfter) + return getByAttr(val, node.AttrExpr(), deleteAfter) case ast.TypeIdentifier: - return getByIdentifier(val, node.Identifier, deleteAfter) + return getByIdentifier(val, node.Identifier(), deleteAfter) case ast.TypeIndexExpr: - child, err := getByIdentifier(val, node.IndexExpr.Obj, false) + child, err := getByIdentifier(val, node.IndexExpr().Obj, false) if err != nil { return nil, err } - return getByIndex(child, node.IndexExpr, 0, deleteAfter) + return getByIndex(child, node.IndexExpr(), 0, deleteAfter) default: return nil, fmt.Errorf("json unsupport get from %s", node.NodeType) } @@ -268,9 +268,9 @@ func getByIndex(val any, i *ast.IndexExpr, dimension int, deleteAfter bool) (any switch i.Index[dimension].NodeType { //nolint:exhaustive case ast.TypeIntegerLiteral: - index = int(i.Index[dimension].IntegerLiteral.Val) + index = int(i.Index[dimension].IntegerLiteral().Val) case ast.TypeFloatLiteral: - index = int(i.Index[dimension].FloatLiteral.Val) + index = int(i.Index[dimension].FloatLiteral().Val) default: return nil, fmt.Errorf("index value is not int") @@ -298,7 +298,7 @@ func getByIndex(val any, i *ast.IndexExpr, dimension int, deleteAfter bool) (any func lastIsIndex(expr *ast.Node) (bool, error) { switch expr.NodeType { //nolint:exhaustive case ast.TypeAttrExpr: - return lastIsIndex(expr.AttrExpr.Attr) + return lastIsIndex(expr.AttrExpr().Attr) case ast.TypeIdentifier: return false, nil case ast.TypeIndexExpr: diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_jsonall.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_jsonall.go index e8e6589177..f2e026a4e8 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_jsonall.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_jsonall.go @@ -11,12 +11,12 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func JSONAllChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func JSONAllChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { l.Debugf("warning: json_all() is disabled") return nil } -func JSONAll(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func JSONAll(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { l.Debugf("warning: json_all() is disabled") return nil } diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_kv.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_kv.go index f200a2c9ec..d2109c2959 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_kv.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_kv.go @@ -59,8 +59,8 @@ func (c *reCache) get(p string) (*regexp.Regexp, bool) { return nil, false } -func KVSplitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func KVSplitChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "key", "field_split_pattern", "value_split_pattern", "trim_key", "trim_value", "include_keys", "prefix", }, 1); err != nil { @@ -75,7 +75,7 @@ func KVSplitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE if funcExpr.Param[1] != nil { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - p := funcExpr.Param[1].StringLiteral.Val + p := funcExpr.Param[1].StringLiteral().Val if err := _regexpCache.set(p); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[1].StartPos()) } @@ -89,7 +89,7 @@ func KVSplitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE if funcExpr.Param[2] != nil { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - p := funcExpr.Param[2].StringLiteral.Val + p := funcExpr.Param[2].StringLiteral().Val if err := _regexpCache.set(p); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[2].StartPos()) } @@ -119,7 +119,7 @@ func KVSplitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE if funcExpr.Param[5] != nil { switch funcExpr.Param[5].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr, ast.TypeIdentifier: + case ast.TypeListLiteral, ast.TypeIdentifier: default: return runtime.NewRunError(ctx, fmt.Sprintf("param include_keys expect ListInitExpr or Identifier, got %s", funcExpr.Param[5].NodeType), funcExpr.NamePos) @@ -137,7 +137,7 @@ func KVSplitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE return nil } -func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func KVSplit(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { key, err := getKeyName(funcExpr.Param[0]) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) @@ -155,7 +155,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[1] != nil { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - p := funcExpr.Param[1].StringLiteral.Val + p := funcExpr.Param[1].StringLiteral().Val var ok bool fieldSplit, ok = _regexpCache.get(p) @@ -173,7 +173,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[2] != nil { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - p := funcExpr.Param[2].StringLiteral.Val + p := funcExpr.Param[2].StringLiteral().Val var ok bool @@ -193,7 +193,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[3] != nil { switch funcExpr.Param[3].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - trimKey = funcExpr.Param[3].StringLiteral.Val + trimKey = funcExpr.Param[3].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param trim_key expect StringLiteral, got %s", funcExpr.Param[3].NodeType), funcExpr.NamePos) @@ -203,7 +203,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[4] != nil { switch funcExpr.Param[4].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - trimValue = funcExpr.Param[4].StringLiteral.Val + trimValue = funcExpr.Param[4].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param trim_value expect StringLiteral, got %s", funcExpr.Param[4].NodeType), funcExpr.NamePos) @@ -213,7 +213,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { var includeKeys []string if funcExpr.Param[5] != nil { switch funcExpr.Param[5].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr, ast.TypeIdentifier: + case ast.TypeListLiteral, ast.TypeIdentifier: v, dt, err := runtime.RunStmt(ctx, funcExpr.Param[5]) if err != nil { return err @@ -246,7 +246,7 @@ func KVSplit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if funcExpr.Param[6] != nil { switch funcExpr.Param[6].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - prefix = funcExpr.Param[6].StringLiteral.Val + prefix = funcExpr.Param[6].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param prefix expect StringLiteral, got %s", funcExpr.Param[6].NodeType), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_len.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_len.go index bcd1be4c8a..e96bc9b851 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_len.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_len.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func LenChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func LenChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1", funcExpr.Name), funcExpr.NamePos) @@ -21,7 +21,7 @@ func LenChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError return nil } -func Len(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Len(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_load_json.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_load_json.go index cbd558e4dd..196503e39d 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_load_json.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_load_json.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func LoadJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func LoadJSONChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -22,7 +22,7 @@ func LoadJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func LoadJSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func LoadJSON(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_lowercase.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_lowercase.go index b74e55453d..3f64db2b16 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_lowercase.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_lowercase.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func LowercaseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func LowercaseChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -28,7 +28,7 @@ func LowercaseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func Lowercase(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Lowercase(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_match.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_match.go index 050b998573..3277ce0b11 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_match.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_match.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func MatchChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func MatchChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 2 args", funcExpr.Name), funcExpr.NamePos) @@ -28,7 +28,7 @@ func MatchChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr } // 预先编译正则表达式 - re, err := regexp.Compile(param0.StringLiteral.Val) + re, err := regexp.Compile(param0.StringLiteral().Val) if err != nil { return runtime.NewRunError(ctx, fmt.Sprintf( "func match: regexp compile failed: %s", err.Error()), param0.StartPos()) @@ -44,7 +44,7 @@ func MatchChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErr return nil } -func Match(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Match(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { err := fmt.Errorf("func %s expects 2 args", funcExpr.Name) l.Debug(err) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_nullif.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_nullif.go index 2e206c239d..5a5d586d09 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_nullif.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_nullif.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func NullIfChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func NullIfChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf("func %s expected 2 args", funcExpr.Name), funcExpr.NamePos) @@ -27,7 +27,7 @@ func NullIfChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func NullIf(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func NullIf(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 2 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_date.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_date.go index 5a13a25404..64f4387f9f 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_date.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_date.go @@ -16,8 +16,8 @@ import ( "github.com/spf13/cast" ) -func ParseDateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func ParseDateChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "key", "yy", "MM", "dd", "hh", "mm", "ss", "ms", "us", "ns", "zone", }, 0); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -25,7 +25,7 @@ func ParseDateChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func ParseDate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ParseDate(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { now := time.Now() var key string @@ -131,7 +131,7 @@ func ParseDate(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func getArgStr(ctx *runtime.Context, node *ast.Node) string { +func getArgStr(ctx *runtime.Task, node *ast.Node) string { if node == nil { return "" } @@ -144,7 +144,7 @@ func getArgStr(ctx *runtime.Context, node *ast.Node) string { return "" } -func getArgStrConv2Int(ctx *runtime.Context, node *ast.Node) int64 { +func getArgStrConv2Int(ctx *runtime.Task, node *ast.Node) int64 { str := getArgStr(ctx, node) if str == "" { return DefaultInt diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_duration.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_duration.go index cefbbb486e..a423aa59f8 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_duration.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_duration.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ParseDurationChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ParseDurationChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -26,7 +26,7 @@ func ParseDurationChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errcha return nil } -func ParseDuration(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ParseDuration(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { l.Debugf("parse_duration(): invalid param") diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_int.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_int.go index 57f573f09d..fd90c0b278 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_int.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_parse_int.go @@ -13,8 +13,8 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ParseIntChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func ParseIntChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "val", "base", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -23,7 +23,7 @@ func ParseIntChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func ParseInt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ParseInt(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, _, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err @@ -61,8 +61,8 @@ func ParseInt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func FormatIntChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func FormatIntChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "val", "base", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -71,7 +71,7 @@ func FormatIntChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func FormatInt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func FormatInt(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, _, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_kvs.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_kvs.go new file mode 100644 index 0000000000..3a39813a84 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_kvs.go @@ -0,0 +1,244 @@ +package funcs + +import ( + _ "embed" + + "github.com/GuanceCloud/platypus/pkg/ast" + "github.com/GuanceCloud/platypus/pkg/engine/runtime" + "github.com/GuanceCloud/platypus/pkg/errchain" +) + +// embed docs. +var ( + //go:embed md/pt_kvs_get.md + docPtKvsGet string + + //go:embed md/pt_kvs_get.en.md + docPtKvsGetEN string + + //go:embed md/pt_kvs_set.md + docKvsSet string + + //go:embed md/pt_kvs_set.en.md + docPtKvsSetEN string + + //go:embed md/pt_kvs_del.md + docKvsDel string + + //go:embed md/pt_kvs_del.en.md + docPtKvsDelEN string + + //go:embed md/pt_kvs_keys.md + docKvsKeys string + + //go:embed md/pt_kvs_keys.en.md + docPtKvsKeysEN string + + // todo: parse function definition + _ = "fn pt_kvs_get(name: str) -> any" + _ = "fn pt_kvs_set(name: str, value: any, as_tag: bool = false) -> bool" + _ = "fn pt_kvs_del(name: str)" + _ = "fn pt_kvs_keys(tags: bool = true, fields: bool = true) -> list" + + FnPtKvsGet = NewFunc( + "pt_kvs_get", + []*Param{ + { + Name: "name", + Type: []ast.DType{ast.String}, + }, + }, + []ast.DType{ast.Bool, ast.Int, ast.Float, ast.String, + ast.List, ast.Map, ast.Nil}, + [2]*PLDoc{ + { + Language: langTagZhCN, Doc: docPtKvsGet, + FnCategory: map[string][]string{ + langTagZhCN: {cPointOp}}, + }, + { + Language: langTagEnUS, Doc: docPtKvsGetEN, + FnCategory: map[string][]string{ + langTagEnUS: {ePointOp}}, + }, + }, + ptKvsGet, + ) + + FnPtKvsSet = NewFunc( + "pt_kvs_set", + []*Param{ + { + Name: "name", + Type: []ast.DType{ast.String}, + }, + { + Name: "value", + Type: []ast.DType{ast.Bool, ast.Int, ast.Float, ast.String, + ast.List, ast.Map, ast.Nil}, + }, + { + Name: "as_tag", + Type: []ast.DType{ast.Bool}, + Optional: true, + DefaultVal: func() (any, ast.DType) { + return false, ast.Bool + }, + }, + }, + []ast.DType{ast.Bool}, + [2]*PLDoc{ + { + Language: langTagZhCN, Doc: docKvsSet, + FnCategory: map[string][]string{ + langTagZhCN: {cPointOp}}, + }, + { + Language: langTagEnUS, Doc: docPtKvsSetEN, + FnCategory: map[string][]string{ + langTagEnUS: {ePointOp}}, + }, + }, + ptKvsSet, + ) + + FnPtKvsDel = NewFunc( + "pt_kvs_del", + []*Param{ + { + Name: "name", + Type: []ast.DType{ast.String}, + }, + }, + nil, + [2]*PLDoc{ + { + Language: langTagZhCN, Doc: docKvsDel, + FnCategory: map[string][]string{ + langTagZhCN: {cPointOp}}, + }, + { + Language: langTagEnUS, Doc: docPtKvsDelEN, + FnCategory: map[string][]string{ + langTagEnUS: {ePointOp}}, + }, + }, + ptKvsDel, + ) + + FnPtKvsKeys = NewFunc( + "pt_kvs_keys", + []*Param{ + { + Name: "tags", + Type: []ast.DType{ast.Bool}, + Optional: true, + DefaultVal: func() (any, ast.DType) { + return true, ast.Bool + }, + }, + { + Name: "fields", + Type: []ast.DType{ast.Bool}, + Optional: true, + DefaultVal: func() (any, ast.DType) { + return true, ast.Bool + }, + }, + }, + []ast.DType{ast.List}, + [2]*PLDoc{ + { + Language: langTagZhCN, Doc: docKvsKeys, + FnCategory: map[string][]string{ + langTagZhCN: {cPointOp}}, + }, + { + Language: langTagEnUS, Doc: docPtKvsKeysEN, + FnCategory: map[string][]string{ + langTagEnUS: {ePointOp}}, + }, + }, + ptKvsKeys, + ) +) + +func ptKvsGet(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError { + if val, dtype, err := getPtKey(ctx.InData(), vals[0].(string)); err != nil { + ctx.Regs.ReturnAppend(nil, ast.Nil) + } else { + ctx.Regs.ReturnAppend(val, dtype) + } + + return nil +} + +func ptKvsSet(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError { + name := vals[0].(string) + asTag := vals[2].(bool) + val := vals[1] + + pt, err := getPoint(ctx.InData()) + if err != nil { + ctx.Regs.ReturnAppend(false, ast.Bool) + return nil + } + + if asTag { + if err := pt.SetTag(name, val, getValDtype(val)); err != nil { + ctx.Regs.ReturnAppend(false, ast.Bool) + return nil + } + } else { + if err := pt.Set(name, val, getValDtype(val)); err != nil { + ctx.Regs.ReturnAppend(false, ast.Bool) + return nil + } + } + + ctx.Regs.ReturnAppend(true, ast.Bool) + return nil +} + +func ptKvsDel(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError { + name := vals[0].(string) + deletePtKey(ctx.InData(), name) + return nil +} + +func ptKvsKeys(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError { + tags := vals[0].(bool) + fields := vals[1].(bool) + + pt, err := getPoint(ctx.InData()) + if err != nil { + ctx.Regs.ReturnAppend(false, ast.Bool) + return nil + } + + var elemCount int + + if tags { + elemCount += len(pt.Tags()) + } + if fields { + elemCount += len(pt.Fields()) + } + + keyList := make([]any, 0, elemCount) + + if tags { + for k := range pt.Tags() { + keyList = append(keyList, k) + } + } + if fields { + for k := range pt.Fields() { + keyList = append(keyList, k) + } + } + + ctx.Regs.ReturnAppend(keyList, ast.List) + + return nil +} diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_name.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_name.go index e03ce9693e..bc81f49657 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_name.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_name.go @@ -8,7 +8,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func PtNameChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtNameChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) > 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' can have at most one parameter", funcExpr.Name), funcExpr.NamePos) @@ -17,7 +17,7 @@ func PtNameChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func PtName(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtName(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) == 1 { if val, _, err := runtime.RunStmt(ctx, funcExpr.Param[0]); err == nil { if val, ok := val.(string); ok { diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_window.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_window.go index ac7c4a5ec3..3aca3177fc 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_window.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_pt_window.go @@ -10,9 +10,9 @@ var ( defaultStreamTags = []string{"filepath", "host"} ) -func PtWindowChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtWindowChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { // fn pt_window(before, after, stream_tags := ["filepath", "host"]) - if err := reindexFuncArgs(funcExpr, []string{ + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "before", "after", "stream_tags", }, 2); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -21,7 +21,7 @@ func PtWindowChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func PtWindow(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtWindow(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { before, vtype, errP := runtime.RunStmt(ctx, funcExpr.Param[0]) if errP != nil { return errP @@ -90,11 +90,11 @@ func PtWindow(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func PtWindowHitChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtWindowHitChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { return nil } -func PtWindowHit(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func PtWindowHit(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { pt, err := getPoint(ctx.InData()) if err != nil { return nil diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_rename.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_rename.go index 538c446f4f..478712bfdf 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_rename.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_rename.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func RenameChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func RenameChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 2 args", funcExpr.Name), funcExpr.NamePos) @@ -33,7 +33,7 @@ func RenameChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func Rename(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Rename(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expected 2 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_replace.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_replace.go index 00ae073ff4..c5e4e14fbb 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_replace.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_replace.go @@ -16,7 +16,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ReplaceChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ReplaceChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 3 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 3 args", funcExpr.Name), funcExpr.NamePos) @@ -29,7 +29,7 @@ func ReplaceChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE var pattern string switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - pattern = funcExpr.Param[1].StringLiteral.Val + pattern = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "expect StringLiteral, got %s", @@ -54,7 +54,7 @@ func ReplaceChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE return nil } -func Replace(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Replace(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { reg, ok := funcExpr.PrivateData.(*regexp.Regexp) if !ok { return runtime.NewRunError(ctx, "regexp obj not found", funcExpr.Param[1].StartPos()) @@ -74,7 +74,7 @@ func Replace(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[2].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - dz = funcExpr.Param[2].StringLiteral.Val + dz = funcExpr.Param[2].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect StringLiteral, got %s", funcExpr.Param[2].NodeType), funcExpr.Param[2].StartPos()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sample.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sample.go index 9017825d36..c3763501a5 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sample.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sample.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func SampleChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SampleChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -31,7 +31,7 @@ func SampleChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func Sample(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Sample(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -41,7 +41,7 @@ func Sample(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[0].NodeType { //nolint:exhaustive case ast.TypeArithmeticExpr: - res, dtype, err := runtime.RunArithmeticExpr(ctx, funcExpr.Param[0].ArithmeticExpr) + res, dtype, err := runtime.RunArithmeticExpr(ctx, funcExpr.Param[0].ArithmeticExpr()) if err != nil { return err } @@ -58,9 +58,9 @@ func Sample(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { probability = p case ast.TypeFloatLiteral: - probability = funcExpr.Param[0].FloatLiteral.Val + probability = funcExpr.Param[0].FloatLiteral().Val case ast.TypeIntegerLiteral: - probability = float64(funcExpr.Param[0].IntegerLiteral.Val) + probability = float64(funcExpr.Param[0].IntegerLiteral().Val) default: return runtime.NewRunError(ctx, fmt.Sprintf( "expect NumberLiteral or ArithmeticExpr, got %s", funcExpr.Param[0].NodeType), diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_measurement.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_measurement.go index f93685881a..b9474920fd 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_measurement.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_measurement.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func SetMeasurementChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SetMeasurementChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 && len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) @@ -34,7 +34,7 @@ func SetMeasurementChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errch return nil } -func SetMeasurement(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SetMeasurement(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 && len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) @@ -52,7 +52,7 @@ func SetMeasurement(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr if len(funcExpr.Param) == 2 && funcExpr.Param[1].NodeType == ast.TypeBoolLiteral { - if funcExpr.Param[1].BoolLiteral.Val { + if funcExpr.Param[1].BoolLiteral().Val { switch funcExpr.Param[0].NodeType { //nolint:exhaustive case ast.TypeIdentifier, ast.TypeAttrExpr: if key, err := getKeyName(funcExpr.Param[0]); err == nil { diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_tag.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_tag.go index 2baa615995..725dbe7c33 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_tag.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_set_tag.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func SetTagChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SetTagChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 && len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) @@ -35,7 +35,7 @@ func SetTagChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func SetTag(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SetTag(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 2 && len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sql_cover.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sql_cover.go index db3bf3e04c..f31e7c3474 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sql_cover.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_sql_cover.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func SQLCoverChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SQLCoverChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 args", funcExpr.Name), funcExpr.NamePos) @@ -26,7 +26,7 @@ func SQLCoverChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func SQLCover(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func SQLCover(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { o := obfuscate.NewObfuscator(obfuscate.Config{}) if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_strfmt.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_strfmt.go index 2cd62c5720..c460414771 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_strfmt.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_strfmt.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func StrfmtChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func StrfmtChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expects more than 2 args", funcExpr.Name), funcExpr.NamePos) @@ -31,7 +31,7 @@ func StrfmtChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlEr return nil } -func Strfmt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Strfmt(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { outdata := make([]interface{}, 0) if len(funcExpr.Param) < 2 { @@ -48,7 +48,7 @@ func Strfmt(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - fmts = funcExpr.Param[1].StringLiteral.Val + fmts = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf( "param fmt expect StringLiteral, got `%s'", diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_timestamp.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_timestamp.go index 023cc76d44..cf90cd6b65 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_timestamp.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_timestamp.go @@ -13,15 +13,15 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func TimestampChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - err := reindexFuncArgs(funcExpr, []string{"precision"}, 0) +func TimestampChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + err := normalizeFuncArgsDeprecated(funcExpr, []string{"precision"}, 0) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) } return nil } -func Timestamp(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Timestamp(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var precision string if funcExpr.Param[0] != nil { v, _, err := runtime.RunStmt(ctx, funcExpr.Param[0]) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_trim.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_trim.go index 6d29e2ad07..72084bb8a7 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_trim.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_trim.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func TrimChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func TrimChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) < 1 || len(funcExpr.Param) > 2 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 or 2 args", funcExpr.Name), funcExpr.NamePos) @@ -34,7 +34,7 @@ func TrimChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlErro return nil } -func Trim(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Trim(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { key, err := getKeyName(funcExpr.Param[0]) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.Param[0].StartPos()) @@ -50,7 +50,7 @@ func Trim(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) == 2 { switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - cutset = funcExpr.Param[1].StringLiteral.Val + cutset = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("param type expect StringLiteral, got `%s'", funcExpr.Param[1].NodeType), funcExpr.Param[1].StartPos()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_uppercase.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_uppercase.go index 83fea9f72d..969ec47eb0 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_uppercase.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_uppercase.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func UppercaseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func UppercaseChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -26,7 +26,7 @@ func UppercaseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func Uppercase(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Uppercase(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_url_parse.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_url_parse.go index db0b79a1bb..8682767eda 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_url_parse.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_url_parse.go @@ -15,7 +15,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func URLParseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func URLParseChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -27,7 +27,7 @@ func URLParseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.Pl return nil } -func URLParse(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func URLParse(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_urldecode.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_urldecode.go index a7143b8bd3..3ab44c55ba 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_urldecode.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_urldecode.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func URLDecodeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func URLDecodeChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 args", funcExpr.Name), funcExpr.NamePos) @@ -25,7 +25,7 @@ func URLDecodeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func URLDecode(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func URLDecode(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expected 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_use.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_use.go index 8434791350..38dcc1f70f 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_use.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_use.go @@ -13,7 +13,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func UseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func UseChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 args", funcExpr.Name), funcExpr.NamePos) @@ -30,7 +30,7 @@ func UseChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError return nil } -func Use(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func Use(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 args", funcExpr.Name), funcExpr.NamePos) @@ -43,11 +43,11 @@ func Use(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { if s, ok := funcExpr.PrivateData.(*runtime.Script); ok { refScript = s } else { - l.Debugf("unknown error: %s", funcExpr.Param[0].StringLiteral.Val) + l.Debugf("unknown error: %s", funcExpr.Param[0].StringLiteral().Val) return nil } } else { - l.Debugf("script not found: %s", funcExpr.Param[0].StringLiteral.Val) + l.Debugf("script not found: %s", funcExpr.Param[0].StringLiteral().Val) return nil } default: @@ -56,7 +56,7 @@ func Use(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { funcExpr.Param[0].NodeType), funcExpr.Param[0].StartPos()) } - if err := runtime.RefRunScript(ctx, refScript); err != nil { + if err := refScript.RefRun(ctx); err != nil { return err.ChainAppend(ctx.Name(), funcExpr.NamePos) } return nil diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_useragent.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_useragent.go index f7cc9730df..7a8eb39568 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_useragent.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_useragent.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func UserAgentChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func UserAgentChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expects 1 args", funcExpr.Name), funcExpr.NamePos) @@ -25,7 +25,7 @@ func UserAgentChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func UserAgent(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func UserAgent(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func `%s' expects 1 args", funcExpr.Name), funcExpr.NamePos) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_valid_json.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_valid_json.go index 28efc7890a..3ee4ae78f3 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_valid_json.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_valid_json.go @@ -14,7 +14,7 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ValidJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ValidJSONChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 1 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 1 arg", funcExpr.Name), funcExpr.NamePos) @@ -22,7 +22,7 @@ func ValidJSONChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func ValidJSON(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ValidJSON(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { val, _, err := runtime.RunStmt(ctx, funcExpr.Param[0]) if err != nil { return err diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_value_type.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_value_type.go index 0fd56210ee..842332a9ae 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_value_type.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_value_type.go @@ -11,8 +11,8 @@ import ( "github.com/GuanceCloud/platypus/pkg/errchain" ) -func ValueTypeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - if err := reindexFuncArgs(funcExpr, []string{ +func ValueTypeChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncArgsDeprecated(funcExpr, []string{ "val", }, 1); err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) @@ -21,7 +21,7 @@ func ValueTypeChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.P return nil } -func ValueType(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func ValueType(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if _, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]); err != nil { ctx.Regs.ReturnAppend("", ast.String) return nil diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_xml.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_xml.go index be607a6a8d..c0ad876c46 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_xml.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/fn_xml.go @@ -17,7 +17,7 @@ import ( "github.com/antchfx/xmlquery" ) -func XMLChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func XMLChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { if len(funcExpr.Param) != 3 { return runtime.NewRunError(ctx, fmt.Sprintf( "func %s expects 3 args", funcExpr.Name), funcExpr.NamePos) @@ -48,7 +48,7 @@ func XMLChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError return nil } -func XML(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func XML(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var ( xmlKey, fieldName string xpathExpr string @@ -68,7 +68,7 @@ func XML(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { // XPath expression switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - xpathExpr = funcExpr.Param[1].StringLiteral.Val + xpathExpr = funcExpr.Param[1].StringLiteral().Val default: return runtime.NewRunError(ctx, fmt.Sprintf("expect StringLiteStringLiteral:ral, got %s", reflect.TypeOf(funcExpr.Param[1]).String()), funcExpr.Param[1].StartPos()) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_mquery_refer_table.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_mquery_refer_table.go index 36484d8454..7005e0218f 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_mquery_refer_table.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_mquery_refer_table.go @@ -16,8 +16,8 @@ import ( "github.com/spf13/cast" ) -func MQueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - err := reindexFuncArgs(funcExpr, []string{"table_name", "keys", "values"}, 3) +func MQueryReferTableChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + err := normalizeFuncArgsDeprecated(funcExpr, []string{"table_name", "keys", "values"}, 3) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) } @@ -27,8 +27,8 @@ func MQueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *err } switch funcExpr.Param[1].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr: - for _, v := range funcExpr.Param[1].ListInitExpr.List { + case ast.TypeListLiteral: + for _, v := range funcExpr.Param[1].ListLiteral().List { switch v.NodeType { //nolint:exhaustive case ast.TypeStringLiteral, ast.TypeIdentifier, ast.TypeAttrExpr: default: @@ -45,8 +45,8 @@ func MQueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *err } switch funcExpr.Param[2].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr: - for _, v := range funcExpr.Param[2].ListInitExpr.List { + case ast.TypeListLiteral: + for _, v := range funcExpr.Param[2].ListLiteral().List { switch v.NodeType { //nolint:exhaustive case ast.TypeIdentifier, ast.TypeAttrExpr, ast.TypeStringLiteral, ast.TypeBoolLiteral, @@ -68,7 +68,7 @@ func MQueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *err return nil } -func MQueryReferTableMulti(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func MQueryReferTableMulti(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var tableName string tname, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]) @@ -85,11 +85,11 @@ func MQueryReferTableMulti(ctx *runtime.Context, funcExpr *ast.CallExpr) *errcha var colName []string switch funcExpr.Param[1].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr: - for _, v := range funcExpr.Param[1].ListInitExpr.List { + case ast.TypeListLiteral: + for _, v := range funcExpr.Param[1].ListLiteral().List { switch v.NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - colName = append(colName, v.StringLiteral.Val) + colName = append(colName, v.StringLiteral().Val) case ast.TypeIdentifier, ast.TypeAttrExpr: key, _ := getKeyName(v) val, err := ctx.GetKey(key) @@ -127,17 +127,17 @@ func MQueryReferTableMulti(ctx *runtime.Context, funcExpr *ast.CallExpr) *errcha var colValue []any switch funcExpr.Param[2].NodeType { //nolint:exhaustive - case ast.TypeListInitExpr: - for _, v := range funcExpr.Param[2].ListInitExpr.List { + case ast.TypeListLiteral: + for _, v := range funcExpr.Param[2].ListLiteral().List { switch v.NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - colValue = append(colValue, v.StringLiteral.Val) + colValue = append(colValue, v.StringLiteral().Val) case ast.TypeFloatLiteral: - colValue = append(colValue, v.FloatLiteral.Val) + colValue = append(colValue, v.FloatLiteral().Val) case ast.TypeIntegerLiteral: - colValue = append(colValue, v.IntegerLiteral.Val) + colValue = append(colValue, v.IntegerLiteral().Val) case ast.TypeBoolLiteral: - colValue = append(colValue, v.BoolLiteral.Val) + colValue = append(colValue, v.BoolLiteral().Val) case ast.TypeIdentifier, ast.TypeAttrExpr: key, _ := getKeyName(v) val, err := ctx.GetKey(key) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_query_refer_table.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_query_refer_table.go index f36ed70d9d..529b9a56d4 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_query_refer_table.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/funcs_query_refer_table.go @@ -15,8 +15,8 @@ import ( "github.com/spf13/cast" ) -func QueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { - err := reindexFuncArgs(funcExpr, []string{"table_name", "key", "value"}, 3) +func QueryReferTableChecking(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + err := normalizeFuncArgsDeprecated(funcExpr, []string{"table_name", "key", "value"}, 3) if err != nil { return runtime.NewRunError(ctx, err.Error(), funcExpr.NamePos) } @@ -65,7 +65,7 @@ func QueryReferTableChecking(ctx *runtime.Context, funcExpr *ast.CallExpr) *errc return nil } -func QueryReferTable(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlError { +func QueryReferTable(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { var tableName string tname, dtype, err := runtime.RunStmt(ctx, funcExpr.Param[0]) @@ -81,7 +81,7 @@ func QueryReferTable(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE var colName string switch funcExpr.Param[1].NodeType { //nolint:exhaustive case ast.TypeStringLiteral: - colName = funcExpr.Param[1].StringLiteral.Val + colName = funcExpr.Param[1].StringLiteral().Val case ast.TypeIdentifier, ast.TypeAttrExpr: key, _ := getKeyName(funcExpr.Param[1]) val, err := ctx.GetKey(key) @@ -112,13 +112,13 @@ func QueryReferTable(ctx *runtime.Context, funcExpr *ast.CallExpr) *errchain.PlE colValue = val.Value } case ast.TypeStringLiteral: - colValue = funcExpr.Param[2].StringLiteral.Val + colValue = funcExpr.Param[2].StringLiteral().Val case ast.TypeIntegerLiteral: - colValue = funcExpr.Param[2].IntegerLiteral.Val + colValue = funcExpr.Param[2].IntegerLiteral().Val case ast.TypeFloatLiteral: - colValue = funcExpr.Param[2].FloatLiteral.Val + colValue = funcExpr.Param[2].FloatLiteral().Val case ast.TypeBoolLiteral: - colValue = funcExpr.Param[2].BoolLiteral.Val + colValue = funcExpr.Param[2].BoolLiteral().Val } // TODO: pos param 4: selected([]string) diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.en.md new file mode 100644 index 0000000000..c8436a0c47 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.en.md @@ -0,0 +1,16 @@ +### `hash()` {#fn_hash} + +Function prototype: `fn hash(text: str, method: str) -> str` + +Function description: Calculate the hash of the text + +Function parameters: + +- `text`: input text +- `method`: Hash algorithm, allowing values including `md5`, `sha1`, `sha256`, `sha512` + +Example: + +```python +pt_kvs_set("md5sum", hash("abc", "sha1")) +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.md new file mode 100644 index 0000000000..32148ce88f --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/hash.md @@ -0,0 +1,16 @@ +### `hash()` {#fn_hash} + +函数原型: `fn hash(text: str, method: str) -> str` + +函数说明: 计算文本的 hash + +函数参数: + +- `text`: 输入文本 +- `method`: hash 算法,允许的值包含 `md5`,`sha1`,`sha256`,`sha512` + +示例: + +```python +pt_kvs_set("md5sum", hash("abc", "sha1")) +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.en.md index 3667ae10b4..18e9ac70c1 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.en.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.en.md @@ -21,11 +21,11 @@ Function parameters: Example: ```python -parse_date(aa, "2021", "May", "12", "10", "10", "34", "", "Asia/Shanghai") # Result aa=1620785434000000000 +parse_date(aa, "2021", "May", "12", "10", "10", "34", zone="Asia/Shanghai") # Result aa=1620785434000000000 -parse_date(aa, "2021", "12", "12", "10", "10", "34", "", "Asia/Shanghai") # result aa=1639275034000000000 +parse_date(aa, "2021", "12", "12", "10", "10", "34", zone="Asia/Shanghai") # result aa=1639275034000000000 -parse_date(aa, "2021", "12", "12", "10", "10", "34", "100", "Asia/Shanghai") # Result aa=1639275034000000100 +parse_date(aa, "2021", "12", "12", "10", "10", "34", "100", zone="Asia/Shanghai") # Result aa=1639275034000000100 -parse_date(aa, "20", "February", "12", "10", "10", "34", "", "+8") result aa=1581473434000000000 +parse_date(aa, "20", "February", "12", "10", "10", "34", zone="+8") result aa=1581473434000000000 ``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.md index 8c9eb46f47..966d62bb84 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/parse_date.md @@ -21,11 +21,11 @@ 示例: ```python -parse_date(aa, "2021", "May", "12", "10", "10", "34", "", "Asia/Shanghai") # 结果 aa=1620785434000000000 +parse_date(aa, "2021", "May", "12", "10", "10", "34", zone="Asia/Shanghai") # 结果 aa=1620785434000000000 -parse_date(aa, "2021", "12", "12", "10", "10", "34", "", "Asia/Shanghai") # 结果 aa=1639275034000000000 +parse_date(aa, "2021", "12", "12", "10", "10", "34", zone="Asia/Shanghai") # 结果 aa=1639275034000000000 -parse_date(aa, "2021", "12", "12", "10", "10", "34", "100", "Asia/Shanghai") # 结果 aa=1639275034000000100 +parse_date(aa, "2021", "12", "12", "10", "10", "34", "100", zone="Asia/Shanghai") # 结果 aa=1639275034000000100 -parse_date(aa, "20", "February", "12", "10", "10", "34", "", "+8") 结果 aa=1581473434000000000 +parse_date(aa, "20", "February", "12", "10", "10", "34", zone="+8") 结果 aa=1581473434000000000 ``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.en.md index cf5c5e7b6b..9bb8294f6e 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.en.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.en.md @@ -1,4 +1,4 @@ -### `point_window` {fn-point-window} +### `point_window()` {fn-point-window} Function prototype: `fn point_window(before: int, after: int, stream_tags = ["filepath", "host"])` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.md index 9e409f1154..29cbcbbc73 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/point_window.md @@ -1,4 +1,4 @@ -### `point_window` {fn-point-window} +### `point_window()` {fn-point-window} 函数原型: `fn point_window(before: int, after: int, stream_tags = ["filepath", "host"])` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.en.md new file mode 100644 index 0000000000..471fa93188 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.en.md @@ -0,0 +1,20 @@ +### `pt_kvs_del()` {#fn_pt_kvs_del} + +Function prototype: `fn pt_kvs_del(name: str)` + +Function description: Delete the key specified in Point + +Function parameters: + +- `name`: Key to be deleted + +Example: + +```python +key_blacklist = ["k1", "k2", "k3"] +for k in pt_kvs_keys() { + if k in key_blacklist { + pt_kvs_del(k) + } +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.md new file mode 100644 index 0000000000..8aeffd8c0a --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_del.md @@ -0,0 +1,20 @@ +### `pt_kvs_del()` {#fn_pt_kvs_del} + +函数原型:`fn pt_kvs_del(name: str)` + +函数说明:删除 Point 中指定的 key + +函数参数: + +- `name`: 待删除的 key + +示例: + +```python +key_blacklist = ["k1", "k2", "k3"] +for k in pt_kvs_keys() { + if k in key_blacklist { + pt_kvs_del(k) + } +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.en.md new file mode 100644 index 0000000000..84b33058e5 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.en.md @@ -0,0 +1,15 @@ +### `pt_kvs_get()` {#fn_pt_kvs_get} + +Function prototype: `fn pt_kvs_get(name: str) -> any` + +Function description: Return the value of the specified key in Point + +Function parameters: + +- `name`: Key name + +Example: + +```python +host = pt_kvs_get("host") +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.md new file mode 100644 index 0000000000..4d8ad300c1 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_get.md @@ -0,0 +1,15 @@ +### `pt_kvs_get()` {#fn_pt_kvs_get} + +函数原型:`fn pt_kvs_get(name: str) -> any` + +函数说明:返回 Point 中指定 key 的值 + +函数参数: + +- `name`: Key 名 + +示例: + +```python +host = pt_kvs_get("host") +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.en.md new file mode 100644 index 0000000000..c6e1e87c8a --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.en.md @@ -0,0 +1,20 @@ +### `pt_kvs_keys()` {#fn_pt_kvs_keys} + +Function prototype: `fn pt_kvs_keys(tags: bool = true, fields: bool = true) -> list` + +Function description: Return the key list in Point + +Function parameters: + +- `tags`: Whether to include the names of all tags +- `fields`: Whether to include the names of all fields + +Example: + +```python +for k in pt_kvs_keys() { + if match("^prefix_", k) { + pt_kvs_del(k) + } +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.md new file mode 100644 index 0000000000..b6071c4898 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_keys.md @@ -0,0 +1,20 @@ +### `pt_kvs_keys()` {#fn_pt_kvs_keys} + +函数原型:`fn pt_kvs_keys(tags: bool = true, fields: bool = true) -> list` + +函数说明:返回 Point 中的 key 列表 + +函数参数: + +- `tags`: 是否包含所有标签的名 +- `fields`: 是否包含所有字段的名 + +示例: + +```python +for k in pt_kvs_keys() { + if match("^prefix_", k) { + pt_kvs_del(k) + } +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.en.md new file mode 100644 index 0000000000..4aea6399fe --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.en.md @@ -0,0 +1,24 @@ +### `pt_kvs_set()` {#fn_pt_kvs_set} + +Function prototype: `fn pt_kvs_set(name: str, value: any, as_tag: bool = false) -> bool` + +Function description: Add a key to a Point or modify the value of a key in a Point + +Function parameters: + +- `name`: The name of the field or label to be added or modified +- `value`: The value of a field or label +- `as_tag`: Set as tag or not + +Example: + +```python +kvs = { + "a": 1, + "b": 2 +} + +for k in kvs { + pt_kvs_set(k, kvs[k]) +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.md new file mode 100644 index 0000000000..890b8f3bf0 --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/pt_kvs_set.md @@ -0,0 +1,24 @@ +### `pt_kvs_set()` {#fn_pt_kvs_set} + +函数原型:`fn pt_kvs_set(name: str, value: any, as_tag: bool = false) -> bool` + +函数说明:往 Point 中添加 key 或修改 Point 中 key 的值 + +函数参数: + +- `name`: 待添加或修改的字段或标签的名 +- `value`: 字段或者标签的值 +- `as_tag`: 是否设置为标签 + +示例: + +```python +kvs = { + "a": 1, + "b": 2 +} + +for k in kvs { + pt_kvs_set(k, kvs[k]) +} +``` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.en.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.en.md index 07177f34c7..1ff3fcf93c 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.en.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.en.md @@ -1,4 +1,4 @@ -### `window_hit` {fn-window-hit} +### `window_hit()` {fn-window-hit} Function prototype: `fn window_hit()` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.md b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.md index dc75ecfb16..eb9c037dc4 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.md +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/md/window_hit.md @@ -1,4 +1,4 @@ -### `window_hit` {fn-window-hit} +### `window_hit()` {fn-window-hit} 函数原型: `fn window_hit()` diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils.go index a8943b2ea1..e6a6808e73 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils.go @@ -22,11 +22,11 @@ func getKeyName(node *ast.Node) (string, error) { switch node.NodeType { //nolint:exhaustive case ast.TypeIdentifier: - key = node.Identifier.Name + key = node.Identifier().Name case ast.TypeAttrExpr: - key = node.AttrExpr.String() + key = node.AttrExpr().String() case ast.TypeStringLiteral: - key = node.StringLiteral.Val + key = node.StringLiteral().Val default: return "", fmt.Errorf("expect StringLiteral or Identifier or AttrExpr, got %s", node.NodeType) @@ -174,59 +174,6 @@ func doCast(result interface{}, tInfo string) (interface{}, ast.DType) { return nil, ast.Nil } -func reindexFuncArgs(fnStmt *ast.CallExpr, keyList []string, reqParm int) error { - // reqParm >= 1, if < 0, no optional args - args := fnStmt.Param - - if reqParm < 0 || reqParm > len(keyList) { - reqParm = len(keyList) - } - - if len(args) > len(keyList) { - return fmt.Errorf("the number of parameters does not match") - } - - beforPosArg := true - - kMap := map[string]int{} - for k, v := range keyList { - kMap[v] = k - } - - ret := make([]*ast.Node, len(keyList)) - - for idx, arg := range args { - if arg.NodeType == ast.TypeAssignmentExpr { - if beforPosArg { - beforPosArg = false - } - kname, err := getKeyName(arg.AssignmentExpr.LHS) - if err != nil { - return err - } - kIndex, ok := kMap[kname] - if !ok { - return fmt.Errorf("argument %s does not exist", kname) - } - ret[kIndex] = arg.AssignmentExpr.RHS - } else { - if !beforPosArg { - return fmt.Errorf("positional arguments cannot follow keyword arguments") - } - ret[idx] = arg - } - } - - for i := 0; i < reqParm; i++ { - if v := ret[i]; v == nil { - return fmt.Errorf("parameter %s is required", keyList[i]) - } - } - - fnStmt.Param = ret - return nil -} - func getPoint(in any) (ptinput.PlInputPt, error) { if in == nil { return nil, fmt.Errorf("nil ptr: input") diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils_fn.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils_fn.go new file mode 100644 index 0000000000..06b00ef8db --- /dev/null +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/funcs/utils_fn.go @@ -0,0 +1,440 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the MIT License. +// This product includes software developed at Guance Cloud (https://www.guance.com/). +// Copyright 2021-present Guance, Inc. + +package funcs + +import ( + "fmt" + + "github.com/GuanceCloud/platypus/pkg/ast" + "github.com/GuanceCloud/platypus/pkg/engine/runtime" + "github.com/GuanceCloud/platypus/pkg/errchain" +) + +type FnCall func(ctx *runtime.Task, funcExpr *ast.CallExpr, vals ...any) *errchain.PlError + +func VarPDefaultVal() (any, ast.DType) { + return []any(nil), ast.List +} + +func NewFunc(name string, params []*Param, ret []ast.DType, doc [2]*PLDoc, run FnCall) *Function { + return &Function{ + Name: name, + Args: params, + // Return: ret, + Doc: doc, + Call: WrapFnCall(run, params), + Check: WrapFnCheck(params), + } +} + +func WrapFnCall(fn FnCall, paramDesc []*Param) runtime.FuncCall { + return func(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + // The parameters of the function call expression need to be normalized in advance. + + // Note that some functions do not take the value of the variable + // corresponding to the parameter, but its name. + + vals := make([]any, len(funcExpr.Param)) + + lenP := len(paramDesc) + varP := false + if lenP > 0 { + if paramDesc[lenP-1].VariableP { + lenP -= 1 + varP = true + } + + for i := 0; i < lenP; i++ { + if val, err := getParam(ctx, paramDesc[i], funcExpr.Param[i]); err != nil { + return err + } else { + vals[i] = val + } + } + + if varP { + if v, err := getVarParam(ctx, paramDesc[lenP], funcExpr.Param[lenP:]); err != nil { + return err + } else { + vals[lenP] = v + } + } + } + return fn(ctx, funcExpr, vals...) + } +} + +func WrapFnCheck(paramDesc []*Param) runtime.FuncCheck { + kIndex := map[string]int{} + + prvOptP := false + for i, p := range paramDesc { + if _, ok := kIndex[p.Name]; ok { + panic(fmt.Sprintf("duplicate parameter name: %s", p.Name)) + } else { + kIndex[p.Name] = i + } + + if p.VariableP { + if i != len(paramDesc)-1 { + panic(fmt.Sprintf("parameter %s: variable parameter should be the last one", + p.Name)) + } + if p.DefaultVal == nil { + panic(fmt.Sprintf("parameter %s: variable parameter should have default value", p.Name)) + } + + val, _ := p.DefaultVal() + switch val := val.(type) { + case []any: + for _, v := range val { + dtyp := getValDtype(v) + if !typInclude(dtyp, p.Type) { + panic(fmt.Sprintf("parameter %s: default value data type not match", p.Name)) + } + } + case nil: + default: + panic(fmt.Sprintf("parameter %s: default value type not match", p.Name)) + } + } else { + if p.Optional { + if p.DefaultVal == nil { + panic(fmt.Sprintf("parameter %s: optional parameter should have default value", + p.Name)) + } + val, dt := p.DefaultVal() + if getValDtype(val) != dt { + panic(fmt.Sprintf("parameter %s: value type not match", p.Name)) + } + if !typInclude(dt, p.Type) { + panic(fmt.Sprintf("parameter %s: default value data type not match", p.Name)) + } + } + } + + if !p.Optional && !p.VariableP { + if prvOptP { + panic(fmt.Sprintf("parameter %s: required parameter should not follow optional parameter", + p.Name)) + } + } else { + prvOptP = true + } + } + + return func(ctx *runtime.Task, funcExpr *ast.CallExpr) *errchain.PlError { + if err := normalizeFuncParams(ctx, kIndex, paramDesc, funcExpr); err != nil { + return err + } + if err := checkParams(ctx, funcExpr, paramDesc); err != nil { + return err + } + return nil + } +} + +func getValDtype(v any) ast.DType { + var dtyp ast.DType + switch v.(type) { + case string: + dtyp = ast.String + case int64: + dtyp = ast.Int + case float64: + dtyp = ast.Float + case bool: + dtyp = ast.Bool + case []any: + dtyp = ast.List + case map[string]any: + dtyp = ast.Map + case nil: + dtyp = ast.Nil + default: + } + return dtyp +} + +func checkParams(ctx *runtime.Task, funcExpr *ast.CallExpr, paramDesc []*Param) *errchain.PlError { + lenP := len(paramDesc) + varP := false + if paramDesc[lenP-1].VariableP { + lenP -= 1 + varP = true + } + + for i := 0; i < lenP; i++ { + if p := funcExpr.Param[i]; p != nil { + if ok := checkLiteralType(p.NodeType, paramDesc[i].Type); !ok { + return runtime.NewRunError(ctx, "unexpected data type", p.StartPos()) + } + } + } + if varP { + if p := funcExpr.Param[lenP]; p != nil { + if p.NodeType == ast.TypeAssignmentExpr { + expr := p.AssignmentExpr() + switch expr.RHS.NodeType { + case ast.TypeListLiteral: + for _, n := range expr.RHS.ListLiteral().List { + if ok := checkLiteralType(n.NodeType, paramDesc[lenP].Type); !ok { + return runtime.NewRunError(ctx, "unexpected data type", p.StartPos()) + } + } + case ast.TypeNilLiteral: + default: + return runtime.NewRunError(ctx, + "unexpected data type, for named variable parameter only list and nil are supported", + p.StartPos()) + } + } else { + for i := lenP; i < len(funcExpr.Param); i++ { + if ok := checkLiteralType(funcExpr.Param[i].NodeType, paramDesc[lenP].Type); !ok { + return runtime.NewRunError(ctx, "unexpected data type", p.StartPos()) + } + } + } + } + } + return nil +} + +func checkLiteralType(typ ast.NodeType, typs []ast.DType) bool { + var dtype ast.DType + switch typ { + case ast.TypeStringLiteral: + dtype = ast.String + case ast.TypeIntegerLiteral: + dtype = ast.Int + case ast.TypeFloatLiteral: + dtype = ast.Float + case ast.TypeBoolLiteral: + dtype = ast.Bool + case ast.TypeNilLiteral: + dtype = ast.Nil + case ast.TypeListLiteral: + dtype = ast.List + case ast.TypeMapLiteral: + dtype = ast.Map + } + + if dtype != ast.Invalid { + return typInclude(dtype, typs) + } + + return true +} + +func typInclude(typ ast.DType, typs []ast.DType) bool { + for _, dt := range typs { + if dt == typ { + return true + } + } + return false +} + +func normalizeFuncParams(ctx *runtime.Task, keyMapp map[string]int, + paramDesc []*Param, funcExpr *ast.CallExpr) *errchain.PlError { + includeVarP := false + if len(paramDesc) > 0 { + if paramDesc[len(paramDesc)-1].VariableP { + includeVarP = true + } + } + + if !includeVarP && len(funcExpr.Param) > len(keyMapp) { + return runtime.NewRunError(ctx, "too many parameters", funcExpr.NamePos) + } + + var dstArgs []*ast.Node + if len(funcExpr.Param) < len(keyMapp) { + dstArgs = make([]*ast.Node, len(keyMapp)) + } else { + dstArgs = make([]*ast.Node, len(funcExpr.Param)) + } + + includeNamedP := false + prvIsPosVar := true + for idx, arg := range funcExpr.Param { + if arg.NodeType == ast.TypeAssignmentExpr { + includeNamedP = true + if prvIsPosVar { + prvIsPosVar = false + } + if arg.AssignmentExpr().LHS.NodeType != ast.TypeIdentifier { + return runtime.NewRunError(ctx, "named parameter must be an identifier", arg.StartPos()) + } + + kname := arg.AssignmentExpr().LHS.Identifier().Name + + kIndex, ok := keyMapp[kname] + if !ok { + return runtime.NewRunError(ctx, "unknown named parameter", arg.StartPos()) + } + + dstArgs[kIndex] = arg + } else { + if !prvIsPosVar { + return runtime.NewRunError(ctx, "positional parameter should not follow keyword parameter", arg.StartPos()) + } + dstArgs[idx] = arg + } + } + + for i, v := range paramDesc { + if !v.Optional && !v.VariableP { + if dstArgs[i] == nil { + return runtime.NewRunError(ctx, fmt.Sprintf("missing required parameter `%s`", v.Name), funcExpr.NamePos) + } + } + } + + if includeNamedP && len(funcExpr.Param) > len(keyMapp) { + return runtime.NewRunError(ctx, "too many parameters", funcExpr.NamePos) + } + + funcExpr.Param = dstArgs + + return nil +} + +func normalizeFuncArgsDeprecated(fnStmt *ast.CallExpr, keyList []string, reqParm int) error { + // reqParm >= 1, if < 0, no optional args + args := fnStmt.Param + + if reqParm < 0 || reqParm > len(keyList) { + reqParm = len(keyList) + } + + if len(args) > len(keyList) { + return fmt.Errorf("the number of parameters does not match") + } + + beforPosArg := true + + kMap := map[string]int{} + for k, v := range keyList { + kMap[v] = k + } + + ret := make([]*ast.Node, len(keyList)) + + for idx, arg := range args { + if arg.NodeType == ast.TypeAssignmentExpr { + if beforPosArg { + beforPosArg = false + } + kname, err := getKeyName(arg.AssignmentExpr().LHS) + if err != nil { + return err + } + kIndex, ok := kMap[kname] + if !ok { + return fmt.Errorf("argument %s does not exist", kname) + } + ret[kIndex] = arg.AssignmentExpr().RHS + } else { + if !beforPosArg { + return fmt.Errorf("positional arguments cannot follow keyword arguments") + } + ret[idx] = arg + } + } + + for i := 0; i < reqParm; i++ { + if v := ret[i]; v == nil { + return fmt.Errorf("parameter %s is required", keyList[i]) + } + } + + fnStmt.Param = ret + return nil +} + +func getVarParam(ctx *runtime.Task, pDesc *Param, p []*ast.Node) ([]any, *errchain.PlError) { + if p[0] == nil { + if pDesc.DefaultVal != nil { + val, _ := pDesc.DefaultVal() + switch val := val.(type) { + case []any: + return val, nil + } + } + return nil, nil + } + + if p[0].NodeType == ast.TypeAssignmentExpr { + val, _, errR := runtime.RunStmt(ctx, p[0]) + if errR != nil { + return nil, errR + } + + switch val := val.(type) { + case []any: + return val, nil + case nil: + return nil, nil + default: + return nil, runtime.NewRunError(ctx, fmt.Sprintf("parameter %s: type not match", + pDesc.Name), p[0].StartPos()) + } + } else { + vals := make([]any, len(p)) + for i, v := range p { + val, dtype, errR := runtime.RunStmt(ctx, v) + if errR != nil { + return nil, errR + } + + typNotMatch := true + for _, d := range pDesc.Type { + if dtype == d { + typNotMatch = false + break + } + } + + if typNotMatch { + return nil, runtime.NewRunError(ctx, fmt.Sprintf("parameter %s element: type not match", + pDesc.Name), v.StartPos()) + } else { + vals[i] = val + } + } + return vals, nil + } +} + +func getParam(ctx *runtime.Task, pDesc *Param, p *ast.Node) (any, *errchain.PlError) { + var val any + var dtype ast.DType + if p == nil { + // not need to check type here + if pDesc.DefaultVal != nil { + val, _ = pDesc.DefaultVal() + return val, nil + } else { + return nil, nil + } + } else { + var errR *errchain.PlError + val, dtype, errR = runtime.RunStmt(ctx, p) + if errR != nil { + return nil, errR + } + } + + for _, d := range pDesc.Type { + if dtype == d { + return val, nil + } + } + + return nil, runtime.NewRunError(ctx, fmt.Sprintf("parameter %s: type not match", + pDesc.Name), p.StartPos()) +} diff --git a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/plcache/cache.go b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/plcache/cache.go index 0fd74e00a8..11ff718bb7 100644 --- a/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/plcache/cache.go +++ b/vendor/github.com/GuanceCloud/cliutils/pipeline/ptinput/plcache/cache.go @@ -40,7 +40,7 @@ type Cache struct { stopChannel chan struct{} } -// NewCache returns a Cache +// NewCache returns a Cache. func NewCache(interval time.Duration, numSlots int) (*Cache, error) { if interval <= 0 || numSlots <= 0 { return nil, ErrArg diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/ast/ast.go b/vendor/github.com/GuanceCloud/platypus/pkg/ast/ast.go index 3e780594e3..47ab922a01 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/ast/ast.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/ast/ast.go @@ -27,8 +27,9 @@ const ( TypeBoolLiteral TypeNilLiteral - TypeListInitExpr - TypeMapInitExpr + TypeListLiteral + TypeMapLiteral + TypeInExpr TypeParenExpr @@ -70,10 +71,10 @@ func (t NodeType) String() string { return "BoolLiteral" case TypeNilLiteral: return "NilLiteral" - case TypeListInitExpr: - return "ListInitExpr" - case TypeMapInitExpr: - return "MapInitExpr" + case TypeListLiteral: + return "ListLiteral" + case TypeMapLiteral: + return "MapLiteral" case TypeParenExpr: return "ParenExpr" case TypeAttrExpr: @@ -134,324 +135,322 @@ func (e Stmts) String() string { return strings.Join(arr, "\n") } +type AstNode interface { + String() string +} + type Node struct { // node type NodeType NodeType + elem AstNode +} - // expr - Identifier *Identifier - - StringLiteral *StringLiteral - IntegerLiteral *IntegerLiteral - FloatLiteral *FloatLiteral - BoolLiteral *BoolLiteral - NilLiteral *NilLiteral - - ListInitExpr *ListInitExpr - MapInitExpr *MapInitExpr - - ParenExpr *ParenExpr - - AttrExpr *AttrExpr - IndexExpr *IndexExpr - InExpr *InExpr - - UnaryExpr *UnaryExpr - ArithmeticExpr *ArithmeticExpr - ConditionalExpr *ConditionalExpr - AssignmentExpr *AssignmentExpr - - CallExpr *CallExpr - - // stmt - BlockStmt *BlockStmt +func (n *Node) String() string { + if n.elem != nil { + return n.elem.String() + } + return n.NodeType.String() +} - IfelseStmt *IfelseStmt - ForStmt *ForStmt - ForInStmt *ForInStmt - ContinueStmt *ContinueStmt - BreakStmt *BreakStmt +func (n *Node) Identifier() *Identifier { + return n.elem.(*Identifier) +} +func (n *Node) StringLiteral() *StringLiteral { + return n.elem.(*StringLiteral) +} +func (n *Node) IntegerLiteral() *IntegerLiteral { + return n.elem.(*IntegerLiteral) +} +func (n *Node) FloatLiteral() *FloatLiteral { + return n.elem.(*FloatLiteral) +} +func (n *Node) BoolLiteral() *BoolLiteral { + return n.elem.(*BoolLiteral) +} +func (n *Node) NilLiteral() *NilLiteral { + return n.elem.(*NilLiteral) +} +func (n *Node) ListLiteral() *ListLiteral { + return n.elem.(*ListLiteral) +} +func (n *Node) MapLiteral() *MapLiteral { + return n.elem.(*MapLiteral) +} +func (n *Node) ParenExpr() *ParenExpr { + return n.elem.(*ParenExpr) +} +func (n *Node) AttrExpr() *AttrExpr { + return n.elem.(*AttrExpr) +} +func (n *Node) IndexExpr() *IndexExpr { + return n.elem.(*IndexExpr) +} +func (n *Node) InExpr() *InExpr { + return n.elem.(*InExpr) +} +func (n *Node) UnaryExpr() *UnaryExpr { + return n.elem.(*UnaryExpr) +} +func (n *Node) ArithmeticExpr() *ArithmeticExpr { + return n.elem.(*ArithmeticExpr) +} +func (n *Node) ConditionalExpr() *ConditionalExpr { + return n.elem.(*ConditionalExpr) +} +func (n *Node) AssignmentExpr() *AssignmentExpr { + return n.elem.(*AssignmentExpr) +} +func (n *Node) CallExpr() *CallExpr { + return n.elem.(*CallExpr) +} +func (n *Node) BlockStmt() *BlockStmt { + return n.elem.(*BlockStmt) +} +func (n *Node) IfelseStmt() *IfelseStmt { + return n.elem.(*IfelseStmt) +} +func (n *Node) ForStmt() *ForStmt { + return n.elem.(*ForStmt) +} +func (n *Node) ForInStmt() *ForInStmt { + return n.elem.(*ForInStmt) +} +func (n *Node) ContinueStmt() *ContinueStmt { + return n.elem.(*ContinueStmt) +} +func (n *Node) BreakStmt() *BreakStmt { + return n.elem.(*BreakStmt) } -func (node *Node) String() string { - switch node.NodeType { //nolint:exhaustive - case TypeIdentifier: - return node.Identifier.String() - case TypeStringLiteral: - return node.StringLiteral.String() - case TypeIntegerLiteral: - return node.IntegerLiteral.String() - case TypeFloatLiteral: - return node.FloatLiteral.String() - case TypeBoolLiteral: - return node.BoolLiteral.String() - case TypeNilLiteral: - return node.NilLiteral.String() - case TypeListInitExpr: - return node.ListInitExpr.String() - case TypeMapInitExpr: - return node.MapInitExpr.String() - case TypeParenExpr: - return node.ParenExpr.String() - case TypeAttrExpr: - return node.AttrExpr.String() - case TypeIndexExpr: - return node.IndexExpr.String() - case TypeUnaryExpr: - return node.UnaryExpr.String() - case TypeArithmeticExpr: - return node.ArithmeticExpr.String() - case TypeConditionalExpr: - return node.ConditionalExpr.String() - case TypeAssignmentExpr: - return node.AssignmentExpr.String() - case TypeCallExpr: - return node.CallExpr.String() - case TypeIfelseStmt: - return node.IfelseStmt.String() - case TypeForStmt: - return node.ForStmt.String() - case TypeForInStmt: - return node.ForInStmt.String() - case TypeContinueStmt: - return node.ContinueStmt.String() - case TypeBreakStmt: - return node.BreakStmt.String() - case TypeInExpr: - return node.InExpr.String() - } - return "node conv to string failed" +func (n *Node) StartPos() token.LnColPos { + return NodeStartPos(n) } func WrapIdentifier(node *Identifier) *Node { return &Node{ - NodeType: TypeIdentifier, - Identifier: node, + NodeType: TypeIdentifier, + elem: node, } } func WrapStringLiteral(node *StringLiteral) *Node { return &Node{ - NodeType: TypeStringLiteral, - StringLiteral: node, + NodeType: TypeStringLiteral, + elem: node, } } func WrapIntegerLiteral(node *IntegerLiteral) *Node { return &Node{ - NodeType: TypeIntegerLiteral, - IntegerLiteral: node, + NodeType: TypeIntegerLiteral, + elem: node, } } func WrapFloatLiteral(node *FloatLiteral) *Node { return &Node{ - NodeType: TypeFloatLiteral, - FloatLiteral: node, + NodeType: TypeFloatLiteral, + elem: node, } } func WrapBoolLiteral(node *BoolLiteral) *Node { return &Node{ - NodeType: TypeBoolLiteral, - BoolLiteral: node, + NodeType: TypeBoolLiteral, + elem: node, } } func WrapNilLiteral(node *NilLiteral) *Node { return &Node{ - NodeType: TypeNilLiteral, - NilLiteral: node, + NodeType: TypeNilLiteral, + elem: node, } } -func WrapListInitExpr(node *ListInitExpr) *Node { +func WrapListInitExpr(node *ListLiteral) *Node { return &Node{ - NodeType: TypeListInitExpr, - ListInitExpr: node, + NodeType: TypeListLiteral, + elem: node, } } -func WrapMapInitExpr(node *MapInitExpr) *Node { +func WrapMapLiteral(node *MapLiteral) *Node { return &Node{ - NodeType: TypeMapInitExpr, - MapInitExpr: node, + NodeType: TypeMapLiteral, + elem: node, } } func WrapParenExpr(node *ParenExpr) *Node { return &Node{ - NodeType: TypeParenExpr, - ParenExpr: node, + NodeType: TypeParenExpr, + elem: node, } } func WrapAttrExpr(node *AttrExpr) *Node { return &Node{ NodeType: TypeAttrExpr, - AttrExpr: node, + elem: node, } } func WrapIndexExpr(node *IndexExpr) *Node { return &Node{ - NodeType: TypeIndexExpr, - IndexExpr: node, + NodeType: TypeIndexExpr, + elem: node, } } func WrapArithmeticExpr(node *ArithmeticExpr) *Node { return &Node{ - NodeType: TypeArithmeticExpr, - ArithmeticExpr: node, + NodeType: TypeArithmeticExpr, + elem: node, } } func WrapConditionExpr(node *ConditionalExpr) *Node { return &Node{ - NodeType: TypeConditionalExpr, - ConditionalExpr: node, + NodeType: TypeConditionalExpr, + elem: node, } } func WrapInExpr(node *InExpr) *Node { return &Node{ NodeType: TypeInExpr, - InExpr: node, + elem: node, } } func WrapUnaryExpr(node *UnaryExpr) *Node { return &Node{ - NodeType: TypeUnaryExpr, - UnaryExpr: node, + NodeType: TypeUnaryExpr, + elem: node, } } func WrapAssignmentStmt(node *AssignmentExpr) *Node { return &Node{ - NodeType: TypeAssignmentExpr, - AssignmentExpr: node, + NodeType: TypeAssignmentExpr, + elem: node, } } func WrapCallExpr(node *CallExpr) *Node { return &Node{ NodeType: TypeCallExpr, - CallExpr: node, + elem: node, } } func WrapIfelseStmt(node *IfelseStmt) *Node { return &Node{ - NodeType: TypeIfelseStmt, - IfelseStmt: node, + NodeType: TypeIfelseStmt, + elem: node, } } func WrapForStmt(node *ForStmt) *Node { return &Node{ NodeType: TypeForStmt, - ForStmt: node, + elem: node, } } func WrapForInStmt(node *ForInStmt) *Node { return &Node{ - NodeType: TypeForInStmt, - ForInStmt: node, + NodeType: TypeForInStmt, + elem: node, } } func WrapContinueStmt(node *ContinueStmt) *Node { return &Node{ - NodeType: TypeContinueStmt, - ContinueStmt: node, + NodeType: TypeContinueStmt, + elem: node, } } func WrapBreakStmt(node *BreakStmt) *Node { return &Node{ - NodeType: TypeBreakStmt, - BreakStmt: node, + NodeType: TypeBreakStmt, + elem: node, } } func WrapeBlockStmt(node *BlockStmt) *Node { return &Node{ - NodeType: TypeBlockStmt, - BlockStmt: node, + NodeType: TypeBlockStmt, + elem: node, } } -func (node *Node) StartPos() token.LnColPos { - return NodeStartPos(node) -} - func NodeStartPos(node *Node) token.LnColPos { - if node == nil { + if node == nil || node.elem == nil { return token.InvalidLnColPos } switch node.NodeType { case TypeInvalid: return token.InvalidLnColPos case TypeIdentifier: - return node.Identifier.Start + return node.Identifier().Start case TypeStringLiteral: - return node.StringLiteral.Start + return node.StringLiteral().Start case TypeIntegerLiteral: - return node.IntegerLiteral.Start + return node.IntegerLiteral().Start case TypeFloatLiteral: - return node.FloatLiteral.Start + return node.FloatLiteral().Start case TypeBoolLiteral: - return node.BoolLiteral.Start + return node.BoolLiteral().Start case TypeNilLiteral: - return node.NilLiteral.Start + return node.NilLiteral().Start - case TypeListInitExpr: - return node.ListInitExpr.LBracket - case TypeMapInitExpr: - return node.MapInitExpr.LBrace + case TypeListLiteral: + return node.ListLiteral().LBracket + case TypeMapLiteral: + return node.MapLiteral().LBrace case TypeParenExpr: - return node.ParenExpr.LParen + return node.ParenExpr().LParen case TypeAttrExpr: - return node.AttrExpr.Start + return node.AttrExpr().Start case TypeIndexExpr: - return node.IndexExpr.Obj.Start + return node.IndexExpr().Obj.Start case TypeUnaryExpr: - return node.UnaryExpr.OpPos + return node.UnaryExpr().OpPos case TypeArithmeticExpr: - return node.ArithmeticExpr.LHS.StartPos() + return node.ArithmeticExpr().LHS.StartPos() case TypeConditionalExpr: - return node.ConditionalExpr.LHS.StartPos() + return node.ConditionalExpr().LHS.StartPos() case TypeAssignmentExpr: - return node.AssignmentExpr.LHS.StartPos() + return node.AssignmentExpr().LHS.StartPos() case TypeCallExpr: - return node.CallExpr.NamePos + return node.CallExpr().NamePos case TypeBlockStmt: - return node.BlockStmt.LBracePos + return node.BlockStmt().LBracePos case TypeIfelseStmt: - if len(node.IfelseStmt.IfList) > 0 { - return node.IfelseStmt.IfList[0].Start + if len(node.IfelseStmt().IfList) > 0 { + return node.IfelseStmt().IfList[0].Start } else { return token.InvalidLnColPos } case TypeForStmt: - return node.ForStmt.ForPos + return node.ForStmt().ForPos case TypeForInStmt: - return node.ForInStmt.ForPos + return node.ForInStmt().ForPos case TypeContinueStmt: - return node.ContinueStmt.Start + return node.ContinueStmt().Start case TypeBreakStmt: - return node.BreakStmt.Start + return node.BreakStmt().Start } return token.InvalidLnColPos } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/ast/expr.go b/vendor/github.com/GuanceCloud/platypus/pkg/ast/expr.go index 87f29b0dec..809fef63ea 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/ast/expr.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/ast/expr.go @@ -126,17 +126,17 @@ func (e *NilLiteral) String() string { return "nil" } -type MapInitExpr struct { +type MapLiteral struct { KeyValeList [][2]*Node // key,value list LBrace token.LnColPos RBrace token.LnColPos } -func (e *MapInitExpr) IsExpr() bool { +func (e *MapLiteral) IsExpr() bool { return true } -func (e *MapInitExpr) String() string { +func (e *MapLiteral) String() string { v := "{" for i, item := range e.KeyValeList { if i == 0 { @@ -148,17 +148,17 @@ func (e *MapInitExpr) String() string { return v + "}" } -type ListInitExpr struct { +type ListLiteral struct { List []*Node LBracket token.LnColPos RBracket token.LnColPos } -func (e *ListInitExpr) IsExpr() bool { +func (e *ListLiteral) IsExpr() bool { return true } -func (e *ListInitExpr) String() string { +func (e *ListLiteral) String() string { arr := []string{} for _, x := range e.List { arr = append(arr, x.String()) @@ -292,7 +292,8 @@ type CallExpr struct { Name string - Param []*Node + Param []*Node + ParamNormalized []*Node PrivateData interface{} diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/callref.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/callref.go index 50d6721cc1..0406e46f60 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/callref.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/callref.go @@ -149,5 +149,5 @@ func getParamRefScript(expr *ast.CallExpr) (string, error) { return "", fmt.Errorf("param type expects StringLiteral got `%s`", expr.Param[0].NodeType) } - return expr.Param[0].StringLiteral.Val, nil + return expr.Param[0].StringLiteral().Val, nil } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/engine.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/engine.go index 6c6d066ece..77166ba7b4 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/engine.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/engine.go @@ -11,7 +11,6 @@ import ( "path/filepath" plruntime "github.com/GuanceCloud/platypus/pkg/engine/runtime" - "github.com/GuanceCloud/platypus/pkg/errchain" "github.com/GuanceCloud/platypus/pkg/parser" ) @@ -35,8 +34,7 @@ func ParseScript(scripts map[string]string, Ast: stmts, } - if err := CheckScript(p, check); err != nil { - // TODO + if err := p.Check(check); err != nil { retErrMap[name] = err continue } @@ -51,22 +49,6 @@ func ParseScript(scripts map[string]string, return retMap, retErrMap } -func RunScriptWithoutMapIn(proc *plruntime.Script, data plruntime.InputWithoutMap, signal plruntime.Signal) *errchain.PlError { - return plruntime.RunScriptWithoutMapIn(proc, data, signal) -} - -func RunScriptWithRMapIn(proc *plruntime.Script, data plruntime.InputWithRMap, signal plruntime.Signal) *errchain.PlError { - return plruntime.RunScriptWithRMapIn(proc, data, signal) -} - -func RunScriptRef(ctx *plruntime.Context, proc *plruntime.Script) *errchain.PlError { - return plruntime.RefRunScript(ctx, proc) -} - -func CheckScript(proc *plruntime.Script, funcsCheck map[string]plruntime.FuncCheck) *errchain.PlError { - return plruntime.CheckScript(proc, funcsCheck) -} - func ReadPlScriptFromDir(dirPath string) (map[string]string, map[string]string, error) { ret := map[string]string{} retPath := map[string]string{} diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/checkstmt.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/checkstmt.go index 5200bbdd83..cb010f9529 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/checkstmt.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/checkstmt.go @@ -19,7 +19,7 @@ type ContextCheck struct { continuestmt bool } -func RunStmtsCheck(ctx *Context, ctxCheck *ContextCheck, nodes ast.Stmts) *errchain.PlError { +func RunStmtsCheck(ctx *Task, ctxCheck *ContextCheck, nodes ast.Stmts) *errchain.PlError { for _, node := range nodes { if err := RunStmtCheck(ctx, ctxCheck, node); err != nil { return err @@ -28,7 +28,7 @@ func RunStmtsCheck(ctx *Context, ctxCheck *ContextCheck, nodes ast.Stmts) *errch return nil } -func RunStmtCheck(ctx *Context, ctxCheck *ContextCheck, node *ast.Node) *errchain.PlError { +func RunStmtCheck(ctx *Task, ctxCheck *ContextCheck, node *ast.Node) *errchain.PlError { if node == nil { return nil } @@ -47,47 +47,47 @@ func RunStmtCheck(ctx *Context, ctxCheck *ContextCheck, node *ast.Node) *errchai // skip case ast.TypeNilLiteral: // skip - case ast.TypeListInitExpr: - return RunListInitExprCheck(ctx, ctxCheck, node.ListInitExpr) - case ast.TypeMapInitExpr: - return RunMapInitExprCheck(ctx, ctxCheck, node.MapInitExpr) + case ast.TypeListLiteral: + return RunListInitExprCheck(ctx, ctxCheck, node.ListLiteral()) + case ast.TypeMapLiteral: + return RunMapInitExprCheck(ctx, ctxCheck, node.MapLiteral()) case ast.TypeParenExpr: - return RunParenExprCheck(ctx, ctxCheck, node.ParenExpr) + return RunParenExprCheck(ctx, ctxCheck, node.ParenExpr()) case ast.TypeAttrExpr: - return RunAttrExprCheck(ctx, ctxCheck, node.AttrExpr) + return RunAttrExprCheck(ctx, ctxCheck, node.AttrExpr()) case ast.TypeIndexExpr: - return RunIndexExprGetCheck(ctx, ctxCheck, node.IndexExpr) + return RunIndexExprGetCheck(ctx, ctxCheck, node.IndexExpr()) case ast.TypeArithmeticExpr: - return RunArithmeticExprCheck(ctx, ctxCheck, node.ArithmeticExpr) + return RunArithmeticExprCheck(ctx, ctxCheck, node.ArithmeticExpr()) case ast.TypeConditionalExpr: - return RunConditionExprCheck(ctx, ctxCheck, node.ConditionalExpr) + return RunConditionExprCheck(ctx, ctxCheck, node.ConditionalExpr()) case ast.TypeUnaryExpr: - return RunUnaryExprCheck(ctx, ctxCheck, node.UnaryExpr) + return RunUnaryExprCheck(ctx, ctxCheck, node.UnaryExpr()) case ast.TypeAssignmentExpr: - return RunAssignmentExprCheck(ctx, ctxCheck, node.AssignmentExpr) + return RunAssignmentExprCheck(ctx, ctxCheck, node.AssignmentExpr()) case ast.TypeCallExpr: - return RunCallExprCheck(ctx, ctxCheck, node.CallExpr) + return RunCallExprCheck(ctx, ctxCheck, node.CallExpr()) case ast.TypeIfelseStmt: - return RunIfElseStmtCheck(ctx, ctxCheck, node.IfelseStmt) + return RunIfElseStmtCheck(ctx, ctxCheck, node.IfelseStmt()) case ast.TypeForStmt: - return RunForStmtCheck(ctx, ctxCheck, node.ForStmt) + return RunForStmtCheck(ctx, ctxCheck, node.ForStmt()) case ast.TypeForInStmt: - return RunForInStmtCheck(ctx, ctxCheck, node.ForInStmt) + return RunForInStmtCheck(ctx, ctxCheck, node.ForInStmt()) case ast.TypeContinueStmt: - return RunContinueStmtCheck(ctx, ctxCheck, node.ContinueStmt) + return RunContinueStmtCheck(ctx, ctxCheck, node.ContinueStmt()) case ast.TypeBreakStmt: - return RunBreakStmtCheck(ctx, ctxCheck, node.BreakStmt) + return RunBreakStmtCheck(ctx, ctxCheck, node.BreakStmt()) } return nil } -func RunListInitExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.ListInitExpr) *errchain.PlError { +func RunListInitExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ListLiteral) *errchain.PlError { for _, v := range expr.List { if err := RunStmtCheck(ctx, ctxCheck, v); err != nil { return err.ChainAppend(ctx.name, expr.LBracket) @@ -96,12 +96,12 @@ func RunListInitExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.ListIn return nil } -func RunMapInitExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.MapInitExpr) *errchain.PlError { +func RunMapInitExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.MapLiteral) *errchain.PlError { for _, v := range expr.KeyValeList { switch v[0].NodeType { //nolint:exhaustive case ast.TypeFloatLiteral, ast.TypeIntegerLiteral, ast.TypeBoolLiteral, ast.TypeNilLiteral, - ast.TypeListInitExpr, ast.TypeMapInitExpr: + ast.TypeListLiteral, ast.TypeMapLiteral: return NewRunError(ctx, "map key expect string", ast.NodeStartPos(v[0])) default: @@ -116,11 +116,11 @@ func RunMapInitExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.MapInit return nil } -func RunParenExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.ParenExpr) *errchain.PlError { +func RunParenExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ParenExpr) *errchain.PlError { return RunStmtCheck(ctx, ctxCheck, expr.Param) } -func RunAttrExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.AttrExpr) *errchain.PlError { +func RunAttrExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.AttrExpr) *errchain.PlError { if err := RunStmtCheck(ctx, ctxCheck, expr.Obj); err != nil { return err } @@ -131,7 +131,7 @@ func RunAttrExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.AttrExpr) return nil } -func RunArithmeticExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.ArithmeticExpr) *errchain.PlError { +func RunArithmeticExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ArithmeticExpr) *errchain.PlError { if err := RunStmtCheck(ctx, ctxCheck, expr.LHS); err != nil { return err } @@ -145,7 +145,7 @@ func RunArithmeticExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.Arit return nil } -func RunConditionExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.ConditionalExpr) *errchain.PlError { +func RunConditionExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ConditionalExpr) *errchain.PlError { if err := RunStmtCheck(ctx, ctxCheck, expr.LHS); err != nil { return err } @@ -155,14 +155,14 @@ func RunConditionExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.Condi return nil } -func RunUnaryExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.UnaryExpr) *errchain.PlError { +func RunUnaryExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.UnaryExpr) *errchain.PlError { if err := RunStmtCheck(ctx, ctxCheck, expr.RHS); err != nil { return err } return nil } -func RunIndexExprGetCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.IndexExpr) *errchain.PlError { +func RunIndexExprGetCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.IndexExpr) *errchain.PlError { for _, v := range expr.Index { if err := RunStmtCheck(ctx, ctxCheck, v); err != nil { return err @@ -171,7 +171,7 @@ func RunIndexExprGetCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.IndexE return nil } -func RunCallExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.CallExpr) *errchain.PlError { +func RunCallExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.CallExpr) *errchain.PlError { _, ok := ctx.GetFuncCall(expr.Name) if !ok { return NewRunError(ctx, fmt.Sprintf( @@ -191,7 +191,7 @@ func RunCallExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.CallExpr) return funcCheck(ctx, expr) } -func RunAssignmentExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.AssignmentExpr) *errchain.PlError { +func RunAssignmentExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.AssignmentExpr) *errchain.PlError { if err := RunStmtCheck(ctx, ctxCheck, expr.RHS); err != nil { return err } @@ -201,7 +201,7 @@ func RunAssignmentExprCheck(ctx *Context, ctxCheck *ContextCheck, expr *ast.Assi return nil } -func RunIfElseStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.IfelseStmt) *errchain.PlError { +func RunIfElseStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.IfelseStmt) *errchain.PlError { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -230,7 +230,7 @@ func RunIfElseStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.IfelseSt return nil } -func RunForStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.ForStmt) *errchain.PlError { +func RunForStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ForStmt) *errchain.PlError { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -268,7 +268,7 @@ func RunForStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.ForStmt) *e return nil } -func RunForInStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.ForInStmt) *errchain.PlError { +func RunForInStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ForInStmt) *errchain.PlError { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -303,7 +303,7 @@ func RunForInStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.ForInStmt return nil } -func RunBreakStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.BreakStmt) *errchain.PlError { +func RunBreakStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.BreakStmt) *errchain.PlError { if len(ctxCheck.forstmt) == 0 { return NewRunError(ctx, "break not in loop", stmt.Start) } @@ -311,7 +311,7 @@ func RunBreakStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.BreakStmt return nil } -func RunContinueStmtCheck(ctx *Context, ctxCheck *ContextCheck, stmt *ast.ContinueStmt) *errchain.PlError { +func RunContinueStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ContinueStmt) *errchain.PlError { if len(ctxCheck.forstmt) == 0 { return NewRunError(ctx, "continue not in loop", stmt.Start) } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/context.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/context.go index 7b95d76a54..92796418e6 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/context.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/context.go @@ -7,7 +7,9 @@ package runtime import ( "encoding/json" + "errors" "fmt" + "reflect" "sync" "github.com/GuanceCloud/grok" @@ -20,26 +22,7 @@ const ( PlRunInfoField = "pl_msg" ) -type Script struct { - CallRef []*ast.CallExpr - - FuncCall map[string]FuncCall - - Name string - Namespace string - Category string - FilePath string - - Content string - - Ast ast.Stmts -} - -type Signal interface { - ExitSignal() bool -} - -type Context struct { +type Task struct { Regs PlReg stackHeader *PlProcStack @@ -48,9 +31,7 @@ type Context struct { funcCall map[string]FuncCall funcCheck map[string]FuncCheck - inType InType - inRMap InputWithRMap - inWithoutMap InputWithoutMap + input Input // for 循环结束后需要清理此标志 loopBreak bool @@ -60,82 +41,86 @@ type Context struct { procExit bool - callRCef []*ast.CallExpr + callRef []*ast.CallExpr - name string - content string - // namespace string - // filepath string -} + name string -func (ctx *Context) Name() string { - return ctx.name + withValue map[any]any } -func (ctx *Context) InData() any { - switch ctx.inType { - case InRMap: - return ctx.inRMap - default: - return ctx.inWithoutMap - } -} - -func (ctx *Context) Signal() Signal { - return ctx.signal +func (ctx *Task) Name() string { + return ctx.name } -func InitCtxWithoutMap(ctx *Context, inWithoutMap InputWithoutMap, funcs map[string]FuncCall, - callRef []*ast.CallExpr, signal Signal, name, content string, -) *Context { - ctx.Regs.Reset() +var ( + ErrNilKey = errors.New("key is nil") + ErrKeyNotComparable = errors.New("key is not comparable") + ErrKeyExists = errors.New("key exists") +) - ctx.inType = InWithoutMap - ctx.inWithoutMap = inWithoutMap +func (ctx *Task) WithVal(key, val any, force bool) error { + if key == nil { + return ErrNilKey + } + if !reflect.TypeOf(key).Comparable() { + return ErrKeyNotComparable + } + if ctx.withValue == nil { + ctx.withValue = map[any]any{ + key: val, + } + return nil + } - ctx.funcCall = funcs - ctx.funcCheck = nil + if _, ok := ctx.withValue[key]; !ok { + ctx.withValue[key] = val + } else { + if force { + ctx.withValue[key] = val + } else { + return ErrKeyExists + } + } - ctx.callRCef = callRef - ctx.loopBreak = false - ctx.loopContinue = false + return nil +} - ctx.signal = signal - ctx.procExit = false +func (ctx *Task) Val(key any) any { + if ctx.withValue == nil { + return nil + } + return ctx.withValue[key] +} - ctx.name = name - ctx.content = content +func (ctx *Task) InData() any { + return ctx.input +} - return ctx +func (ctx *Task) Signal() Signal { + return ctx.signal } -func InitCtxWithRMap(ctx *Context, inWithRMap InputWithRMap, funcs map[string]FuncCall, - callRef []*ast.CallExpr, signal Signal, name, content string, -) *Context { +func InitCtx(ctx *Task, input Input, script *Script, signal Signal) *Task { ctx.Regs.Reset() - ctx.inType = InRMap - ctx.inRMap = inWithRMap + ctx.input = input - ctx.funcCall = funcs + ctx.funcCall = script.FuncCall ctx.funcCheck = nil - ctx.callRCef = callRef + ctx.callRef = script.CallRef ctx.loopBreak = false ctx.loopContinue = false ctx.signal = signal ctx.procExit = false - ctx.name = name - ctx.content = content + ctx.name = script.Name return ctx } -func InitCtxForCheck(ctx *Context, funcs map[string]FuncCall, funcsCheck map[string]FuncCheck, - name, content string, -) *Context { +func InitCtxForCheck(ctx *Task, script *Script, checkFn map[string]FuncCheck) *Task { ctx.stackHeader = &PlProcStack{ data: map[string]*Varb{}, } @@ -143,22 +128,20 @@ func InitCtxForCheck(ctx *Context, funcs map[string]FuncCall, funcsCheck map[str ctx.Regs.Reset() - ctx.funcCall = funcs - ctx.funcCheck = funcsCheck + ctx.funcCall = script.FuncCall + ctx.funcCheck = checkFn - ctx.callRCef = []*ast.CallExpr{} + ctx.callRef = []*ast.CallExpr{} ctx.loopBreak = false ctx.loopContinue = false ctx.procExit = false - ctx.name = name - ctx.content = content - + ctx.name = script.Name return ctx } -func (ctx *Context) SetVarb(key string, value any, dtype ast.DType) error { +func (ctx *Task) SetVarb(key string, value any, dtype ast.DType) error { if key == "_" { key = ploriginkey } @@ -167,18 +150,18 @@ func (ctx *Context) SetVarb(key string, value any, dtype ast.DType) error { return nil } -func (ctx *Context) SetExit() { +func (ctx *Task) SetExit() { ctx.procExit = true } -func (ctx *Context) SetCallRef(expr *ast.CallExpr) { - if ctx.callRCef == nil { - ctx.callRCef = []*ast.CallExpr{} +func (ctx *Task) SetCallRef(expr *ast.CallExpr) { + if ctx.callRef == nil { + ctx.callRef = []*ast.CallExpr{} } - ctx.callRCef = append(ctx.callRCef, expr) + ctx.callRef = append(ctx.callRef, expr) } -func (ctx *Context) GetKey(key string) (*Varb, error) { +func (ctx *Task) GetKey(key string) (*Varb, error) { if key == "_" { key = ploriginkey } @@ -186,20 +169,17 @@ func (ctx *Context) GetKey(key string) (*Varb, error) { return v, nil } - switch ctx.inType { - case InRMap: - if v, t, err := ctx.inRMap.Get(key); err == nil { - return &Varb{ - Value: v, - DType: t, - }, nil - } + if v, t, err := ctx.input.Get(key); err == nil { + return &Varb{ + Value: v, + DType: t, + }, nil } return nil, fmt.Errorf("key not found") } -func (ctx *Context) GetKeyConv2Str(key string) (string, error) { +func (ctx *Task) GetKeyConv2Str(key string) (string, error) { if key == "_" { key = ploriginkey } @@ -208,17 +188,14 @@ func (ctx *Context) GetKeyConv2Str(key string) (string, error) { return Conv2String(v.Value, v.DType) } - switch ctx.inType { - case InRMap: - if v, t, err := ctx.inRMap.Get(key); err == nil { - return Conv2String(v, t) - } + if v, t, err := ctx.input.Get(key); err == nil { + return Conv2String(v, t) } return "", fmt.Errorf("nil") } -func (ctx *Context) GetFuncCall(key string) (FuncCall, bool) { +func (ctx *Task) GetFuncCall(key string) (FuncCall, bool) { if ctx.funcCall == nil { return nil, false } @@ -226,7 +203,7 @@ func (ctx *Context) GetFuncCall(key string) (FuncCall, bool) { return v, ok } -func (ctx *Context) GetFuncCheck(key string) (FuncCheck, bool) { +func (ctx *Task) GetFuncCheck(key string) (FuncCheck, bool) { if ctx.funcCheck == nil { return nil, false } @@ -234,7 +211,7 @@ func (ctx *Context) GetFuncCheck(key string) (FuncCheck, bool) { return v, ok } -func (ctx *Context) StackEnterNew() { +func (ctx *Task) StackEnterNew() { next := &PlProcStack{ data: map[string]*Varb{}, before: ctx.stackCur, @@ -243,18 +220,18 @@ func (ctx *Context) StackEnterNew() { ctx.stackCur = next } -func (ctx *Context) StackExitCur() { +func (ctx *Task) StackExitCur() { ctx.stackCur.data = nil ctx.stackCur.checkPattern = nil ctx.stackCur = ctx.stackCur.before } -func (ctx *Context) StackClear() { +func (ctx *Task) StackClear() { ctx.stackCur.Clear() } -func (ctx *Context) GetPattern(pattern string) (*grok.GrokPattern, bool) { +func (ctx *Task) GetPattern(pattern string) (*grok.GrokPattern, bool) { v, ok := ctx.stackCur.GetPattern(pattern) if ok { return v, ok @@ -268,18 +245,18 @@ func (ctx *Context) GetPattern(pattern string) (*grok.GrokPattern, bool) { return nil, false } -func (ctx *Context) SetPattern(patternAlias string, gPattern *grok.GrokPattern) { +func (ctx *Task) SetPattern(patternAlias string, gPattern *grok.GrokPattern) { ctx.stackCur.SetPattern(patternAlias, gPattern) } -func (ctx *Context) StmtRetrun() bool { +func (ctx *Task) StmtRetrun() bool { if ctx.ProcExit() || ctx.loopBreak || ctx.loopContinue { return true } return false } -func (ctx *Context) ProcExit() bool { +func (ctx *Task) ProcExit() bool { if !ctx.procExit && ctx.signal != nil { if ctx.signal.ExitSignal() { ctx.procExit = true @@ -290,12 +267,12 @@ func (ctx *Context) ProcExit() bool { var ctxPool sync.Pool = sync.Pool{ New: func() any { - return &Context{} + return &Task{} }, } -func GetContext() *Context { - ctx, _ := ctxPool.Get().(*Context) +func GetContext() *Task { + ctx, _ := ctxPool.Get().(*Task) ctx.stackHeader = &PlProcStack{ data: map[string]*Varb{}, @@ -304,25 +281,8 @@ func GetContext() *Context { return ctx } -func PutContext(ctx *Context) { - ctx.stackHeader = nil - ctx.stackCur = nil - - ctx.funcCall = nil - ctx.funcCheck = nil - - ctx.inRMap = nil - ctx.inRMap = nil - ctx.inWithoutMap = nil - ctx.inType = InNoSet - - ctx.loopBreak = false - ctx.loopContinue = false - - ctx.procExit = false - - ctx.callRCef = nil - +func PutContext(ctx *Task) { + *ctx = Task{} ctxPool.Put(ctx) } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/error.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/error.go index b5584e3619..83b945b660 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/error.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/error.go @@ -10,6 +10,6 @@ import ( "github.com/GuanceCloud/platypus/pkg/token" ) -func NewRunError(ctx *Context, err string, pos token.LnColPos) *errchain.PlError { +func NewRunError(ctx *Task, err string, pos token.LnColPos) *errchain.PlError { return errchain.NewErr(ctx.name, pos, err) } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/input.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/input.go index b9006bd1f9..34f265881e 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/input.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/input.go @@ -2,16 +2,6 @@ package runtime import "github.com/GuanceCloud/platypus/pkg/ast" -type InType uint8 - -const ( - InNoSet = iota - InWithoutMap - InRMap -) - -type InputWithRMap interface { +type Input interface { Get(key string) (any, ast.DType, error) } - -type InputWithoutMap interface{} diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/runtime.go b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/runtime.go index 6c1635448f..20b3348f2c 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/runtime.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/engine/runtime/runtime.go @@ -18,68 +18,83 @@ import ( ) type ( - FuncCheck func(*Context, *ast.CallExpr) *errchain.PlError - FuncCall func(*Context, *ast.CallExpr) *errchain.PlError + FuncCheck func(*Task, *ast.CallExpr) *errchain.PlError + FuncCall func(*Task, *ast.CallExpr) *errchain.PlError ) -func RunScriptWithoutMapIn(proc *Script, data InputWithoutMap, signal Signal) *errchain.PlError { - if proc == nil { - return nil - } +type Script struct { + CallRef []*ast.CallExpr - ctx := GetContext() - defer PutContext(ctx) + FuncCall map[string]FuncCall + + Name string + Namespace string + Category string + FilePath string + + Content string // deprecated + + Ast ast.Stmts +} + +type Signal interface { + ExitSignal() bool +} - ctx = InitCtxWithoutMap(ctx, data, proc.FuncCall, proc.CallRef, signal, proc.Name, proc.Content) - return RunStmts(ctx, proc.Ast) +func WithVal(key string, val any) TaskFn { + return func(ctx *Task) { + _ = ctx.WithVal(key, val, false) + } } -func RunScriptWithRMapIn(proc *Script, data InputWithRMap, signal Signal) *errchain.PlError { - if proc == nil { +type TaskFn func(ctx *Task) + +func (s *Script) Run(data Input, signal Signal, fn ...TaskFn) *errchain.PlError { + if s == nil { return nil } ctx := GetContext() defer PutContext(ctx) - ctx = InitCtxWithRMap(ctx, data, proc.FuncCall, proc.CallRef, signal, proc.Name, proc.Content) - return RunStmts(ctx, proc.Ast) + for _, fn := range fn { + fn(ctx) + } + + ctx = InitCtx(ctx, data, s, signal) + return RunStmts(ctx, s.Ast) } -func RefRunScript(ctx *Context, proc *Script) *errchain.PlError { - if proc == nil { +func (s *Script) RefRun(ctx *Task) *errchain.PlError { + if s == nil { return nil } newctx := GetContext() defer PutContext(newctx) - switch ctx.inType { - case InRMap: - InitCtxWithRMap(newctx, ctx.inRMap, proc.FuncCall, proc.CallRef, ctx.signal, proc.Name, proc.Content) - case InWithoutMap: - InitCtxWithoutMap(newctx, ctx.inWithoutMap, proc.FuncCall, proc.CallRef, ctx.signal, proc.Name, proc.Content) - default: - // TODO - return nil - } + InitCtx(newctx, ctx.input, s, ctx.signal) - return RunStmts(newctx, proc.Ast) + return RunStmts(newctx, s.Ast) } -func CheckScript(proc *Script, funcsCheck map[string]FuncCheck) *errchain.PlError { +func (s *Script) Check(funcsCheck map[string]FuncCheck) *errchain.PlError { + if s == nil { + return nil + } + ctx := GetContext() defer PutContext(ctx) - InitCtxForCheck(ctx, proc.FuncCall, funcsCheck, proc.Name, proc.Content) - if err := RunStmtsCheck(ctx, &ContextCheck{}, proc.Ast); err != nil { + InitCtxForCheck(ctx, s, funcsCheck) + if err := RunStmtsCheck(ctx, &ContextCheck{}, s.Ast); err != nil { return err } - proc.CallRef = ctx.callRCef + s.CallRef = ctx.callRef return nil } -func RunStmts(ctx *Context, nodes ast.Stmts) *errchain.PlError { +func RunStmts(ctx *Task, nodes ast.Stmts) *errchain.PlError { for _, node := range nodes { if _, _, err := RunStmt(ctx, node); err != nil { ctx.procExit = true @@ -93,7 +108,7 @@ func RunStmts(ctx *Context, nodes ast.Stmts) *errchain.PlError { return nil } -func RunIfElseStmt(ctx *Context, stmt *ast.IfelseStmt) (any, ast.DType, *errchain.PlError) { +func RunIfElseStmt(ctx *Task, stmt *ast.IfelseStmt) (any, ast.DType, *errchain.PlError) { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -169,7 +184,7 @@ func condTrue(val any, dtype ast.DType) bool { return true } -func RunForStmt(ctx *Context, stmt *ast.ForStmt) (any, ast.DType, *errchain.PlError) { +func RunForStmt(ctx *Task, stmt *ast.ForStmt) (any, ast.DType, *errchain.PlError) { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -226,7 +241,7 @@ func RunForStmt(ctx *Context, stmt *ast.ForStmt) (any, ast.DType, *errchain.PlEr return nil, ast.Void, nil } -func RunForInStmt(ctx *Context, stmt *ast.ForInStmt) (any, ast.DType, *errchain.PlError) { +func RunForInStmt(ctx *Task, stmt *ast.ForInStmt) (any, ast.DType, *errchain.PlError) { ctx.StackEnterNew() defer ctx.StackExitCur() @@ -249,7 +264,7 @@ func RunForInStmt(ctx *Context, stmt *ast.ForInStmt) (any, ast.DType, *errchain. if stmt.Varb.NodeType != ast.TypeIdentifier { return nil, ast.Invalid, err } - _ = ctx.SetVarb(stmt.Varb.Identifier.Name, char, ast.String) + _ = ctx.SetVarb(stmt.Varb.Identifier().Name, char, ast.String) if stmt.Body != nil { if err := RunStmts(ctx, stmt.Body.Stmts); err != nil { return nil, ast.Invalid, err @@ -273,7 +288,7 @@ func RunForInStmt(ctx *Context, stmt *ast.ForInStmt) (any, ast.DType, *errchain. } for x := range iter { ctx.stackCur.Clear() - _ = ctx.SetVarb(stmt.Varb.Identifier.Name, x, ast.String) + _ = ctx.SetVarb(stmt.Varb.Identifier().Name, x, ast.String) if stmt.Body != nil { if err := RunStmts(ctx, stmt.Body.Stmts); err != nil { return nil, ast.Invalid, err @@ -300,7 +315,7 @@ func RunForInStmt(ctx *Context, stmt *ast.ForInStmt) (any, ast.DType, *errchain. return nil, ast.Invalid, NewRunError(ctx, "inner type error", stmt.Iter.StartPos()) } - _ = ctx.SetVarb(stmt.Varb.Identifier.Name, x, dtype) + _ = ctx.SetVarb(stmt.Varb.Identifier().Name, x, dtype) if stmt.Body != nil { if err := RunStmts(ctx, stmt.Body.Stmts); err != nil { return nil, ast.Invalid, err @@ -322,7 +337,7 @@ func RunForInStmt(ctx *Context, stmt *ast.ForInStmt) (any, ast.DType, *errchain. return nil, ast.Void, nil } -func forbreak(ctx *Context) bool { +func forbreak(ctx *Task) bool { if ctx.loopBreak { ctx.loopBreak = false return true @@ -330,24 +345,24 @@ func forbreak(ctx *Context) bool { return false } -func forcontinue(ctx *Context) { +func forcontinue(ctx *Task) { if ctx.loopContinue { ctx.loopContinue = false } } -func RunBreakStmt(ctx *Context, stmt *ast.BreakStmt) (any, ast.DType, *errchain.PlError) { +func RunBreakStmt(ctx *Task, stmt *ast.BreakStmt) (any, ast.DType, *errchain.PlError) { ctx.loopBreak = true return nil, ast.Void, nil } -func RunContinueStmt(ctx *Context, stmt *ast.ContinueStmt) (any, ast.DType, *errchain.PlError) { +func RunContinueStmt(ctx *Task, stmt *ast.ContinueStmt) (any, ast.DType, *errchain.PlError) { ctx.loopContinue = true return nil, ast.Void, nil } // RunStmt for all expr. -func RunStmt(ctx *Context, node *ast.Node) (any, ast.DType, *errchain.PlError) { +func RunStmt(ctx *Task, node *ast.Node) (any, ast.DType, *errchain.PlError) { // TODO // 存在个别 node 为 nil 的情况 if node == nil { @@ -355,69 +370,69 @@ func RunStmt(ctx *Context, node *ast.Node) (any, ast.DType, *errchain.PlError) { } switch node.NodeType { //nolint:exhaustive case ast.TypeParenExpr: - return RunParenExpr(ctx, node.ParenExpr) + return RunParenExpr(ctx, node.ParenExpr()) case ast.TypeArithmeticExpr: - return RunArithmeticExpr(ctx, node.ArithmeticExpr) + return RunArithmeticExpr(ctx, node.ArithmeticExpr()) case ast.TypeConditionalExpr: - return RunConditionExpr(ctx, node.ConditionalExpr) + return RunConditionExpr(ctx, node.ConditionalExpr()) case ast.TypeUnaryExpr: - return RunUnaryExpr(ctx, node.UnaryExpr) + return RunUnaryExpr(ctx, node.UnaryExpr()) case ast.TypeAssignmentExpr: - return RunAssignmentExpr(ctx, node.AssignmentExpr) + return RunAssignmentExpr(ctx, node.AssignmentExpr()) case ast.TypeCallExpr: - return RunCallExpr(ctx, node.CallExpr) + return RunCallExpr(ctx, node.CallExpr()) case ast.TypeInExpr: - return RunInExpr(ctx, node.InExpr) - case ast.TypeListInitExpr: - return RunListInitExpr(ctx, node.ListInitExpr) + return RunInExpr(ctx, node.InExpr()) + case ast.TypeListLiteral: + return RunListInitExpr(ctx, node.ListLiteral()) case ast.TypeIdentifier: - if v, err := ctx.GetKey(node.Identifier.Name); err != nil { + if v, err := ctx.GetKey(node.Identifier().Name); err != nil { return nil, ast.Nil, nil } else { return v.Value, v.DType, nil } - case ast.TypeMapInitExpr: - return RunMapInitExpr(ctx, node.MapInitExpr) + case ast.TypeMapLiteral: + return RunMapInitExpr(ctx, node.MapLiteral()) // use for map, slice and array case ast.TypeIndexExpr: - return RunIndexExprGet(ctx, node.IndexExpr) + return RunIndexExprGet(ctx, node.IndexExpr()) // TODO case ast.TypeAttrExpr: return nil, ast.Void, nil case ast.TypeBoolLiteral: - return node.BoolLiteral.Val, ast.Bool, nil + return node.BoolLiteral().Val, ast.Bool, nil case ast.TypeIntegerLiteral: - return node.IntegerLiteral.Val, ast.Int, nil + return node.IntegerLiteral().Val, ast.Int, nil case ast.TypeFloatLiteral: - return node.FloatLiteral.Val, ast.Float, nil + return node.FloatLiteral().Val, ast.Float, nil case ast.TypeStringLiteral: - return node.StringLiteral.Val, ast.String, nil + return node.StringLiteral().Val, ast.String, nil case ast.TypeNilLiteral: return nil, ast.Nil, nil case ast.TypeIfelseStmt: - return RunIfElseStmt(ctx, node.IfelseStmt) + return RunIfElseStmt(ctx, node.IfelseStmt()) case ast.TypeForStmt: - return RunForStmt(ctx, node.ForStmt) + return RunForStmt(ctx, node.ForStmt()) case ast.TypeForInStmt: - return RunForInStmt(ctx, node.ForInStmt) + return RunForInStmt(ctx, node.ForInStmt()) case ast.TypeBreakStmt: - return RunBreakStmt(ctx, node.BreakStmt) + return RunBreakStmt(ctx, node.BreakStmt()) case ast.TypeContinueStmt: - return RunContinueStmt(ctx, node.ContinueStmt) + return RunContinueStmt(ctx, node.ContinueStmt()) default: return nil, ast.Invalid, NewRunError(ctx, fmt.Sprintf( "unsupported ast node: %s", reflect.TypeOf(node).String()), node.StartPos()) } } -func RunUnaryExpr(ctx *Context, expr *ast.UnaryExpr) (any, ast.DType, *errchain.PlError) { +func RunUnaryExpr(ctx *Task, expr *ast.UnaryExpr) (any, ast.DType, *errchain.PlError) { switch expr.Op { case ast.SUB, ast.ADD: v, dtype, err := RunStmt(ctx, expr.RHS) @@ -515,7 +530,7 @@ func RunUnaryExpr(ctx *Context, expr *ast.UnaryExpr) (any, ast.DType, *errchain. } } -func RunListInitExpr(ctx *Context, expr *ast.ListInitExpr) (any, ast.DType, *errchain.PlError) { +func RunListInitExpr(ctx *Task, expr *ast.ListLiteral) (any, ast.DType, *errchain.PlError) { ret := []any{} for _, v := range expr.List { v, _, err := RunStmt(ctx, v) @@ -527,7 +542,7 @@ func RunListInitExpr(ctx *Context, expr *ast.ListInitExpr) (any, ast.DType, *err return ret, ast.List, nil } -func RunMapInitExpr(ctx *Context, expr *ast.MapInitExpr) (any, ast.DType, *errchain.PlError) { +func RunMapInitExpr(ctx *Task, expr *ast.MapLiteral) (any, ast.DType, *errchain.PlError) { ret := map[string]any{} for _, v := range expr.KeyValeList { @@ -567,7 +582,7 @@ func RunMapInitExpr(ctx *Context, expr *ast.MapInitExpr) (any, ast.DType, *errch // } // } -func RunIndexExprGet(ctx *Context, expr *ast.IndexExpr) (any, ast.DType, *errchain.PlError) { +func RunIndexExprGet(ctx *Task, expr *ast.IndexExpr) (any, ast.DType, *errchain.PlError) { key := expr.Obj.Name varb, err := ctx.GetKey(key) @@ -597,7 +612,7 @@ func RunIndexExprGet(ctx *Context, expr *ast.IndexExpr) (any, ast.DType, *errcha return searchListAndMap(ctx, varb.Value, expr.Index) } -func searchListAndMap(ctx *Context, obj any, index []*ast.Node) (any, ast.DType, *errchain.PlError) { +func searchListAndMap(ctx *Task, obj any, index []*ast.Node) (any, ast.DType, *errchain.PlError) { cur := obj for _, i := range index { @@ -643,13 +658,13 @@ func searchListAndMap(ctx *Context, obj any, index []*ast.Node) (any, ast.DType, return cur, dtype, nil } -func RunParenExpr(ctx *Context, expr *ast.ParenExpr) (any, ast.DType, *errchain.PlError) { +func RunParenExpr(ctx *Task, expr *ast.ParenExpr) (any, ast.DType, *errchain.PlError) { return RunStmt(ctx, expr.Param) } // BinarayExpr -func RunInExpr(ctx *Context, expr *ast.InExpr) (any, ast.DType, *errchain.PlError) { +func RunInExpr(ctx *Task, expr *ast.InExpr) (any, ast.DType, *errchain.PlError) { lhs, lhsT, err := RunStmt(ctx, expr.LHS) if err != nil { return nil, ast.Invalid, err @@ -702,7 +717,7 @@ func RunInExpr(ctx *Context, expr *ast.InExpr) (any, ast.DType, *errchain.PlErro } } -func RunConditionExpr(ctx *Context, expr *ast.ConditionalExpr) (any, ast.DType, *errchain.PlError) { +func RunConditionExpr(ctx *Task, expr *ast.ConditionalExpr) (any, ast.DType, *errchain.PlError) { lhs, lhsT, err := RunStmt(ctx, expr.LHS) if err != nil { return nil, ast.Invalid, err @@ -733,7 +748,7 @@ func RunConditionExpr(ctx *Context, expr *ast.ConditionalExpr) (any, ast.DType, } } -func RunArithmeticExpr(ctx *Context, expr *ast.ArithmeticExpr) (any, ast.DType, *errchain.PlError) { +func RunArithmeticExpr(ctx *Task, expr *ast.ArithmeticExpr) (any, ast.DType, *errchain.PlError) { // 允许字符串通过操作符 '+' 进行拼接 lhsVal, lhsValType, errOpInt := RunStmt(ctx, expr.LHS) @@ -791,7 +806,7 @@ func RunArithmeticExpr(ctx *Context, expr *ast.ArithmeticExpr) (any, ast.DType, return v, dtype, nil } -func runAssignArith(ctx *Context, l, r *Varb, op ast.Op, pos token.LnColPos) ( +func runAssignArith(ctx *Task, l, r *Varb, op ast.Op, pos token.LnColPos) ( any, ast.DType, *errchain.PlError) { arithOp, ok := assign2arithOp(op) @@ -845,7 +860,8 @@ func runAssignArith(ctx *Context, l, r *Varb, op ast.Op, pos token.LnColPos) ( return v, dtype, nil } -func RunAssignmentExpr(ctx *Context, expr *ast.AssignmentExpr) (any, ast.DType, *errchain.PlError) { +// RunAssignmentExpr runs assignment expression, but actually it is a stmt +func RunAssignmentExpr(ctx *Task, expr *ast.AssignmentExpr) (any, ast.DType, *errchain.PlError) { v, dtype, err := RunStmt(ctx, expr.RHS) if err != nil { return nil, ast.Invalid, err @@ -856,7 +872,7 @@ func RunAssignmentExpr(ctx *Context, expr *ast.AssignmentExpr) (any, ast.DType, case ast.TypeIdentifier: switch expr.Op { case ast.EQ: - _ = ctx.SetVarb(expr.LHS.Identifier.Name, v, dtype) + _ = ctx.SetVarb(expr.LHS.Identifier().Name, v, dtype) return v, dtype, nil case ast.SUBEQ, @@ -864,14 +880,14 @@ func RunAssignmentExpr(ctx *Context, expr *ast.AssignmentExpr) (any, ast.DType, ast.MULEQ, ast.DIVEQ, ast.MODEQ: - lVarb, err := ctx.GetKey(expr.LHS.Identifier.Name) + lVarb, err := ctx.GetKey(expr.LHS.Identifier().Name) if err != nil { return nil, ast.Nil, nil } if v, dt, errR := runAssignArith(ctx, lVarb, rVarb, expr.Op, expr.OpPos); errR != nil { return nil, ast.Void, errR } else { - _ = ctx.SetVarb(expr.LHS.Identifier.Name, v, dt) + _ = ctx.SetVarb(expr.LHS.Identifier().Name, v, dt) return v, dt, nil } @@ -882,29 +898,29 @@ func RunAssignmentExpr(ctx *Context, expr *ast.AssignmentExpr) (any, ast.DType, case ast.TypeIndexExpr: switch expr.Op { case ast.EQ: - varb, err := ctx.GetKey(expr.LHS.IndexExpr.Obj.Name) + varb, err := ctx.GetKey(expr.LHS.IndexExpr().Obj.Name) if err != nil { - return nil, ast.Invalid, NewRunError(ctx, err.Error(), expr.LHS.IndexExpr.Obj.Start) + return nil, ast.Invalid, NewRunError(ctx, err.Error(), expr.LHS.IndexExpr().Obj.Start) } - return changeListOrMapValue(ctx, varb.Value, expr.LHS.IndexExpr.Index, + return changeListOrMapValue(ctx, varb.Value, expr.LHS.IndexExpr().Index, v, dtype) case ast.ADDEQ, ast.SUBEQ, ast.MULEQ, ast.DIVEQ, ast.MODEQ: - varb, err := ctx.GetKey(expr.LHS.IndexExpr.Obj.Name) + varb, err := ctx.GetKey(expr.LHS.IndexExpr().Obj.Name) if err != nil { - return nil, ast.Invalid, NewRunError(ctx, err.Error(), expr.LHS.IndexExpr.Obj.Start) + return nil, ast.Invalid, NewRunError(ctx, err.Error(), expr.LHS.IndexExpr().Obj.Start) } - if v, dt, errR := searchListAndMap(ctx, varb.Value, expr.LHS.IndexExpr.Index); err != nil { + if v, dt, errR := searchListAndMap(ctx, varb.Value, expr.LHS.IndexExpr().Index); errR != nil { return nil, ast.Invalid, errR } else { v, dt, err := runAssignArith(ctx, &Varb{Value: v, DType: dt}, rVarb, expr.Op, expr.OpPos) if err != nil { return nil, ast.Invalid, err } - return changeListOrMapValue(ctx, varb.Value, expr.LHS.IndexExpr.Index, + return changeListOrMapValue(ctx, varb.Value, expr.LHS.IndexExpr().Index, v, dt) } default: @@ -917,7 +933,7 @@ func RunAssignmentExpr(ctx *Context, expr *ast.AssignmentExpr) (any, ast.DType, } } -func changeListOrMapValue(ctx *Context, obj any, index []*ast.Node, val any, dtype ast.DType) (any, ast.DType, *errchain.PlError) { +func changeListOrMapValue(ctx *Task, obj any, index []*ast.Node, val any, dtype ast.DType) (any, ast.DType, *errchain.PlError) { cur := obj lenIdx := len(index) @@ -974,7 +990,7 @@ func changeListOrMapValue(ctx *Context, obj any, index []*ast.Node, val any, dty return nil, ast.Nil, nil } -func RunCallExpr(ctx *Context, expr *ast.CallExpr) (any, ast.DType, *errchain.PlError) { +func RunCallExpr(ctx *Task, expr *ast.CallExpr) (any, ast.DType, *errchain.PlError) { defer ctx.Regs.Reset() if funcCall, ok := ctx.GetFuncCall(expr.Name); ok { if err := funcCall(ctx, expr); err != nil { diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram.y b/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram.y index 80fba10e92..b03b3f8279 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram.y +++ b/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram.y @@ -100,16 +100,12 @@ NIL NULL IF ELIF ELSE attr_expr in_expr expr - map_init - map_init_start - list_init - list_init_start + map_literal + map_literal_start + list_literal + list_literal_start basic_literal for_stmt_elem - /* bool_literal */ - /* string_literal */ - /* nil_literal */ - /* number_literal */ value_stmt //columnref @@ -134,10 +130,23 @@ sep: SEMICOLON | sep EOL ; +sem: SEMICOLON +| sem EOL +| sem SEMICOLON +; + start: START_STMTS stmts { yylex.(*parser).parseResult = $2 } +| START_STMTS EOLS +{ + yylex.(*parser).parseResult = ast.Stmts{} +} +| START_STMTS EOLS stmts +{ + yylex.(*parser).parseResult = $3 +} | start EOF | error { @@ -163,7 +172,7 @@ stmts_list: stmt sep { $$ = ast.Stmts{$1} } -| sep +| sem { $$ = ast.Stmts{} } @@ -186,8 +195,8 @@ stmt: ifelse_stmt /* expression */ expr: basic_literal -| list_init -| map_init +| list_literal +| map_literal | paren_expr | call_expr | unary_expr @@ -201,36 +210,44 @@ expr: basic_literal value_stmt: expr ; -assignment_stmt: expr EQ expr +EOLS: EOL +| EOLS EOL +; + +SPACE_EOLS: EOLS +| +; + +assignment_stmt: expr EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } -| expr ADD_EQ expr +| expr ADD_EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } -| expr SUB_EQ expr +| expr SUB_EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } -| expr MUL_EQ expr +| expr MUL_EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } -| expr DIV_EQ expr +| expr DIV_EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } -| expr MOD_EQ expr +| expr MOD_EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } ; -in_expr: expr IN expr +in_expr: expr IN SPACE_EOLS expr { - $$ = yylex.(*parser).newInExpr($1, $3, $2) + $$ = yylex.(*parser).newInExpr($1, $4, $2) } break_stmt: BREAK @@ -333,54 +350,41 @@ elif_elem: ELIF expr stmt_block stmt_block: empty_block -| LEFT_BRACE stmts RIGHT_BRACE +| LEFT_BRACE SPACE_EOLS stmts RIGHT_BRACE { - $$ = yylex.(*parser).newBlockStmt($1, $2, $3) + $$ = yylex.(*parser).newBlockStmt($1, $3, $4) } ; -empty_block : LEFT_BRACE RIGHT_BRACE +empty_block : LEFT_BRACE SPACE_EOLS RIGHT_BRACE { - $$ = yylex.(*parser).newBlockStmt($1, ast.Stmts{} , $2) + $$ = yylex.(*parser).newBlockStmt($1, ast.Stmts{} , $3) } ; -call_expr: identifier LEFT_PAREN function_args RIGHT_PAREN +call_expr: identifier LEFT_PAREN SPACE_EOLS function_args SPACE_EOLS RIGHT_PAREN { - $$ = yylex.(*parser).newCallExpr($1, $3, $2, $4) + $$ = yylex.(*parser).newCallExpr($1, $4, $2, $6) } -| identifier LEFT_PAREN function_args COMMA RIGHT_PAREN +| identifier LEFT_PAREN SPACE_EOLS function_args COMMA SPACE_EOLS RIGHT_PAREN { - $$ = yylex.(*parser).newCallExpr($1, $3, $2, $5) + $$ = yylex.(*parser).newCallExpr($1, $4, $2, $7) } -| identifier LEFT_PAREN RIGHT_PAREN -{ - $$ = yylex.(*parser).newCallExpr($1, nil, $2, $3) -} -| identifier LEFT_PAREN function_args EOLS RIGHT_PAREN -{ - $$ = yylex.(*parser).newCallExpr($1, $3, $2, $5) -} -| identifier LEFT_PAREN function_args COMMA EOLS RIGHT_PAREN -{ - $$ = yylex.(*parser).newCallExpr($1, $3, $2, $6) -} -| identifier LEFT_PAREN EOLS RIGHT_PAREN +| identifier LEFT_PAREN SPACE_EOLS RIGHT_PAREN { $$ = yylex.(*parser).newCallExpr($1, nil, $2, $4) } ; -function_args: function_args COMMA expr +function_args: function_args COMMA SPACE_EOLS expr { - $$ = append($$, $3) + $$ = append($$, $4) } -| function_args COMMA named_arg +| function_args COMMA SPACE_EOLS named_arg { - $$ = append($$, $3) + $$ = append($$, $4) } - | named_arg { $$ = []*ast.Node{$1} @@ -391,9 +395,9 @@ function_args: function_args COMMA expr } ; -named_arg: identifier EQ expr +named_arg: identifier EQ SPACE_EOLS expr { - $$ = yylex.(*parser).newAssignmentStmt($1, $3, $2) + $$ = yylex.(*parser).newAssignmentStmt($1, $4, $2) } ; @@ -413,91 +417,83 @@ unary_expr: ADD expr %prec UMINUS binary_expr: conditional_expr | arithmeticExpr ; -conditional_expr: expr GTE expr +conditional_expr: expr GTE SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr GT expr +| expr GT SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr OR expr +| expr OR SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr AND expr +| expr AND SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr LT expr +| expr LT SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr LTE expr +| expr LTE SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr NEQ expr +| expr NEQ SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } -| expr EQEQ expr +| expr EQEQ SPACE_EOLS expr { - $$ = yylex.(*parser).newConditionalExpr($1, $3, $2) + $$ = yylex.(*parser).newConditionalExpr($1, $4, $2) } ; -arithmeticExpr: expr ADD expr +arithmeticExpr: expr ADD SPACE_EOLS expr { - $$ = yylex.(*parser).newArithmeticExpr($1, $3, $2) + $$ = yylex.(*parser).newArithmeticExpr($1, $4, $2) } -| expr SUB expr +| expr SUB SPACE_EOLS expr { - $$ = yylex.(*parser).newArithmeticExpr($1, $3, $2) + $$ = yylex.(*parser).newArithmeticExpr($1, $4, $2) } -| expr MUL expr +| expr MUL SPACE_EOLS expr { - $$ = yylex.(*parser).newArithmeticExpr($1, $3, $2) + $$ = yylex.(*parser).newArithmeticExpr($1, $4, $2) } -| expr DIV expr +| expr DIV SPACE_EOLS expr { - $$ = yylex.(*parser).newArithmeticExpr($1, $3, $2) + $$ = yylex.(*parser).newArithmeticExpr($1, $4, $2) } -| expr MOD expr +| expr MOD SPACE_EOLS expr { - $$ = yylex.(*parser).newArithmeticExpr($1, $3, $2) + $$ = yylex.(*parser).newArithmeticExpr($1, $4, $2) } ; // TODO: 支持多个表达式构成的括号表达式 -paren_expr: LEFT_PAREN expr RIGHT_PAREN +paren_expr: LEFT_PAREN SPACE_EOLS expr SPACE_EOLS RIGHT_PAREN { - $$ = yylex.(*parser).newParenExpr($1, $2, $3) -} -| LEFT_PAREN expr EOLS RIGHT_PAREN -{ - $$ = yylex.(*parser).newParenExpr($1, $2, $4) + $$ = yylex.(*parser).newParenExpr($1, $3, $5) } ; -EOLS: EOL -| EOLS EOL -; - -index_expr: identifier LEFT_BRACKET expr RIGHT_BRACKET +index_expr: identifier LEFT_BRACKET SPACE_EOLS expr SPACE_EOLS RIGHT_BRACKET { - $$ = yylex.(*parser).newIndexExpr($1, $2 ,$3, $4) + $$ = yylex.(*parser).newIndexExpr($1, $2 ,$4, $6) } -| DOT LEFT_BRACKET expr RIGHT_BRACKET +| DOT LEFT_BRACKET SPACE_EOLS expr SPACE_EOLS RIGHT_BRACKET // 兼容原有语法,仅作为 json 函数的第二个参数 { - $$ = yylex.(*parser).newIndexExpr(nil, $2, $3, $4) + $$ = yylex.(*parser).newIndexExpr(nil, $2, $4, $6) } -| index_expr LEFT_BRACKET expr RIGHT_BRACKET +| index_expr LEFT_BRACKET SPACE_EOLS expr SPACE_EOLS RIGHT_BRACKET { - $$ = yylex.(*parser).newIndexExpr($1, $2, $3, $4) + $$ = yylex.(*parser).newIndexExpr($1, $2, $4, $6) } ; @@ -531,59 +527,58 @@ attr_expr: identifier DOT index_expr ; -list_init : list_init_start RIGHT_BRACKET +list_literal : list_literal_start RIGHT_BRACKET { - $$ = yylex.(*parser).newListInitEndExpr($$, $2.Pos) + $$ = yylex.(*parser).newListLiteralEnd($$, $2.Pos) } -| list_init_start COMMA RIGHT_BRACKET +| list_literal_start COMMA SPACE_EOLS RIGHT_BRACKET { - $$ = yylex.(*parser).newListInitEndExpr($$, $2.Pos) + $$ = yylex.(*parser).newListLiteralEnd($$, $4.Pos) } -| LEFT_BRACKET RIGHT_BRACKET +| LEFT_BRACKET SPACE_EOLS RIGHT_BRACKET { - $$ = yylex.(*parser).newListInitStartExpr($1.Pos) - $$ = yylex.(*parser).newListInitEndExpr($$, $2.Pos) + $$ = yylex.(*parser).newListLiteralStart($1.Pos) + $$ = yylex.(*parser).newListLiteralEnd($$, $3.Pos) } ; -list_init_start : LEFT_BRACKET expr +list_literal_start : LEFT_BRACKET SPACE_EOLS expr { - $$ = yylex.(*parser).newListInitStartExpr($1.Pos) - $$ = yylex.(*parser).newListInitAppendExpr($$, $2) + $$ = yylex.(*parser).newListLiteralStart($1.Pos) + $$ = yylex.(*parser).newListLiteralAppendExpr($$, $3) } -| list_init_start COMMA expr +| list_literal_start COMMA SPACE_EOLS expr { - $$ = yylex.(*parser).newListInitAppendExpr($$, $3) + $$ = yylex.(*parser).newListLiteralAppendExpr($$, $4) } -| list_init_start EOL +| list_literal_start EOL ; -map_init : map_init_start RIGHT_BRACE +map_literal : map_literal_start SPACE_EOLS RIGHT_BRACE { - $$ = yylex.(*parser).newMapInitEndExpr($$, $2.Pos) + $$ = yylex.(*parser).newMapLiteralEnd($$, $3.Pos) } -| map_init_start COMMA RIGHT_BRACE +| map_literal_start COMMA SPACE_EOLS RIGHT_BRACE { - $$ = yylex.(*parser).newMapInitEndExpr($$, $3.Pos) + $$ = yylex.(*parser).newMapLiteralEnd($$, $4.Pos) } | empty_block { - $$ = yylex.(*parser).newMapInitStartExpr($1.LBracePos.Pos) - $$ = yylex.(*parser).newMapInitEndExpr($$, $1.RBracePos.Pos) + $$ = yylex.(*parser).newMapLiteralStart($1.LBracePos.Pos) + $$ = yylex.(*parser).newMapLiteralEnd($$, $1.RBracePos.Pos) } ; -map_init_start: LEFT_BRACE expr COLON expr +map_literal_start: LEFT_BRACE SPACE_EOLS expr COLON SPACE_EOLS expr { - $$ = yylex.(*parser).newMapInitStartExpr($1.Pos) - $$ = yylex.(*parser).newMapInitAppendExpr($$, $2, $4) + $$ = yylex.(*parser).newMapLiteralStart($1.Pos) + $$ = yylex.(*parser).newMapLiteralAppendExpr($$, $3, $6) } -| map_init_start COMMA expr COLON expr +| map_literal_start COMMA SPACE_EOLS expr COLON SPACE_EOLS expr { - $$ = yylex.(*parser).newMapInitAppendExpr($1, $3, $5) + $$ = yylex.(*parser).newMapLiteralAppendExpr($1, $4, $7) } -| map_init_start EOL ; diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram_y.go b/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram_y.go index 44ac682577..8e6292ee46 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram_y.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/parser/gram_y.go @@ -173,7 +173,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line gram.y:633 +//line gram.y:628 //line yacctab:1 var yyExca = [...]int16{ @@ -181,239 +181,252 @@ var yyExca = [...]int16{ 1, -1, -2, 0, -1, 171, - 1, 59, - 4, 59, - 8, 59, - 15, 59, - 28, 59, - -2, 112, + 1, 68, + 4, 68, + 8, 68, + 15, 68, + 28, 68, + -2, 115, } const yyPrivate = 57344 -const yyLast = 1084 +const yyLast = 1099 var yyAct = [...]uint8{ - 67, 46, 147, 22, 8, 148, 65, 22, 97, 34, - 68, 160, 58, 15, 63, 61, 32, 15, 75, 94, - 96, 185, 114, 150, 92, 93, 93, 112, 90, 3, - 108, 98, 84, 87, 76, 77, 95, 80, 81, 88, - 86, 82, 102, 83, 85, 100, 84, 87, 104, 105, - 106, 107, 101, 88, 86, 79, 78, 110, 85, 179, - 4, 89, 111, 113, 115, 103, 113, 118, 117, 1, - 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 72, 9, 35, 23, 196, 59, 3, 23, 23, 68, + 66, 33, 54, 61, 236, 55, 37, 48, 45, 57, + 217, 239, 89, 92, 40, 56, 41, 34, 234, 93, + 91, 115, 17, 62, 90, 99, 70, 100, 92, 230, + 97, 98, 49, 9, 93, 91, 51, 102, 69, 231, + 109, 110, 111, 73, 50, 116, 107, 63, 119, 101, + 65, 221, 38, 39, 224, 158, 80, 42, 43, 120, + 103, 9, 123, 2, 114, 218, 98, 95, 112, 9, + 89, 92, 81, 82, 64, 85, 86, 93, 91, 87, + 99, 88, 90, 4, 94, 97, 98, 146, 122, 149, + 104, 47, 153, 84, 83, 157, 145, 54, 148, 160, + 55, 152, 96, 8, 163, 10, 105, 1, 95, 6, + 56, 60, 16, 166, 25, 44, 173, 174, 175, 176, + 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, + 187, 188, 189, 190, 191, 192, 26, 106, 193, 108, + 46, 197, 199, 198, 27, 117, 201, 73, 113, 32, + 203, 169, 205, 207, 28, 23, 5, 53, 118, 52, + 58, 118, 31, 30, 29, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 14, 142, 116, 149, 152, 186, 2, 113, 157, 141, - 204, 144, 151, 159, 154, 24, 140, 161, 143, 162, - 197, 153, 178, 87, 75, 22, 43, 113, 166, 88, - 86, 171, 178, 155, 25, 15, 169, 175, 84, 87, - 76, 77, 182, 80, 81, 88, 86, 82, 174, 83, - 85, 177, 7, 165, 178, 45, 26, 170, 176, 57, - 150, 79, 78, 178, 84, 87, 76, 77, 31, 80, - 81, 88, 86, 82, 184, 83, 85, 27, 59, 171, - 171, 113, 52, 192, 187, 189, 195, 51, 194, 30, - 198, 196, 199, 15, 75, 151, 29, 16, 171, 113, - 28, 113, 60, 200, 9, 188, 190, 191, 84, 87, - 76, 77, 113, 80, 81, 88, 86, 82, 13, 83, - 85, 17, 91, 12, 201, 202, 16, 203, 90, 53, - 11, 79, 54, 36, 47, 44, 56, 109, 205, 10, - 33, 39, 55, 40, 19, 145, 18, 21, 20, 53, - 17, 94, 54, 62, 23, 164, 92, 93, 5, 48, - 64, 6, 55, 50, 0, 0, 0, 0, 0, 0, - 0, 49, 0, 0, 0, 0, 0, 0, 0, 37, - 38, 0, 0, 0, 41, 42, 35, 16, 0, 0, - 53, 0, 0, 54, 36, 47, 44, 56, 0, 0, - 0, 0, 39, 55, 40, 19, 0, 0, 21, 20, - 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, - 48, 0, 0, 0, 50, 0, 0, 0, 0, 0, - 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, - 37, 38, 0, 0, 0, 41, 42, 35, 53, 0, - 0, 54, 36, 47, 44, 56, 0, 0, 0, 0, - 39, 55, 40, 19, 0, 0, 21, 20, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, - 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, - 49, 0, 0, 0, 75, 0, 0, 0, 37, 38, - 163, 0, 0, 41, 42, 35, 0, 0, 84, 87, - 76, 77, 0, 80, 81, 88, 86, 82, 69, 83, - 85, 70, 71, 73, 72, 74, 0, 0, 0, 0, - 53, 79, 78, 54, 36, 47, 44, 56, 0, 193, - 0, 0, 39, 55, 40, 0, 0, 0, 0, 53, - 0, 150, 54, 36, 47, 44, 56, 0, 146, 0, - 48, 39, 55, 40, 50, 0, 0, 0, 0, 0, - 150, 0, 49, 0, 0, 0, 0, 0, 0, 48, - 37, 38, 0, 50, 0, 41, 42, 0, 0, 0, - 0, 49, 75, 0, 0, 0, 0, 0, 0, 37, - 38, 0, 0, 0, 41, 42, 84, 87, 76, 77, - 0, 80, 81, 88, 86, 82, 69, 83, 85, 70, - 71, 73, 72, 74, 0, 167, 0, 0, 53, 79, - 78, 54, 36, 47, 44, 56, 0, 0, 0, 0, - 39, 55, 40, 53, 0, 0, 54, 36, 47, 44, - 56, 158, 0, 0, 0, 39, 55, 40, 48, 0, + 140, 141, 142, 143, 144, 11, 147, 15, 150, 151, + 73, 73, 118, 155, 209, 211, 14, 13, 159, 12, + 194, 19, 67, 161, 24, 229, 7, 0, 0, 0, + 164, 0, 118, 0, 237, 121, 171, 0, 0, 0, + 0, 0, 80, 240, 242, 198, 243, 241, 0, 0, + 0, 73, 0, 0, 0, 225, 89, 92, 81, 82, + 0, 85, 86, 93, 91, 87, 154, 88, 90, 0, + 0, 204, 0, 0, 0, 0, 0, 0, 0, 171, + 171, 118, 0, 214, 0, 18, 165, 0, 54, 0, + 170, 55, 37, 48, 45, 57, 162, 0, 0, 0, + 40, 56, 41, 20, 215, 216, 22, 21, 0, 0, + 219, 0, 0, 0, 0, 0, 222, 223, 49, 0, + 171, 118, 51, 118, 0, 0, 0, 0, 232, 233, + 50, 235, 0, 210, 212, 213, 0, 118, 38, 39, + 0, 0, 0, 42, 43, 36, 0, 18, 0, 0, + 54, 0, 0, 55, 37, 48, 45, 57, 0, 0, + 0, 0, 40, 56, 41, 20, 0, 0, 22, 21, + 0, 59, 0, 0, 226, 227, 0, 228, 0, 0, + 49, 0, 0, 0, 51, 0, 0, 0, 0, 0, + 0, 238, 50, 0, 0, 0, 0, 0, 0, 0, + 38, 39, 0, 0, 0, 42, 43, 36, 18, 0, + 0, 54, 0, 0, 55, 37, 48, 45, 57, 0, + 0, 0, 0, 40, 56, 41, 20, 0, 0, 22, + 21, 0, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 49, 0, 0, 0, 51, 0, 0, 0, 0, + 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, + 0, 38, 39, 0, 0, 0, 42, 43, 36, 54, + 0, 0, 55, 37, 48, 45, 57, 0, 0, 0, + 0, 40, 56, 41, 20, 0, 0, 22, 21, 89, + 92, 81, 82, 0, 85, 86, 93, 91, 87, 49, + 88, 90, 0, 51, 0, 0, 0, 0, 0, 0, + 0, 50, 0, 0, 0, 80, 0, 0, 0, 38, + 39, 206, 0, 0, 42, 43, 36, 0, 0, 89, + 92, 81, 82, 0, 85, 86, 93, 91, 87, 74, + 88, 90, 75, 76, 78, 77, 79, 80, 0, 0, + 0, 0, 84, 83, 0, 0, 0, 0, 0, 0, + 0, 89, 92, 81, 82, 0, 85, 86, 93, 91, + 87, 74, 88, 90, 75, 76, 78, 77, 79, 0, + 0, 0, 0, 54, 84, 83, 55, 37, 48, 45, + 57, 202, 0, 0, 0, 40, 56, 41, 54, 0, + 0, 55, 37, 48, 45, 57, 0, 0, 200, 0, + 40, 56, 41, 49, 0, 0, 0, 51, 0, 0, + 0, 0, 0, 0, 0, 50, 0, 0, 49, 0, + 0, 0, 51, 38, 39, 0, 0, 0, 42, 43, + 50, 0, 0, 0, 0, 0, 0, 0, 38, 39, + 0, 0, 54, 42, 43, 55, 37, 48, 45, 57, + 0, 195, 0, 0, 40, 56, 41, 0, 167, 0, + 0, 54, 0, 0, 55, 37, 48, 45, 57, 0, + 0, 0, 49, 40, 56, 41, 51, 0, 0, 0, + 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, + 0, 49, 38, 39, 0, 51, 0, 42, 43, 0, + 0, 54, 0, 50, 55, 37, 48, 45, 57, 162, + 0, 38, 39, 40, 56, 41, 42, 43, 0, 0, + 54, 0, 0, 55, 37, 48, 45, 57, 0, 0, + 156, 49, 40, 56, 41, 51, 0, 0, 0, 0, + 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, + 49, 38, 39, 0, 51, 0, 42, 43, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, - 49, 0, 0, 48, 0, 0, 0, 50, 37, 38, - 0, 0, 0, 41, 42, 49, 0, 0, 0, 0, - 0, 0, 0, 37, 38, 0, 0, 53, 41, 42, - 54, 36, 47, 44, 56, 0, 0, 156, 0, 39, - 55, 40, 0, 119, 0, 0, 53, 0, 0, 54, - 36, 47, 44, 56, 0, 0, 0, 48, 39, 55, - 40, 50, 0, 0, 0, 0, 0, 0, 0, 49, - 0, 0, 0, 0, 0, 0, 48, 37, 38, 0, - 50, 0, 41, 42, 0, 0, 53, 0, 49, 54, - 36, 47, 44, 56, 109, 0, 37, 38, 39, 55, - 40, 41, 42, 0, 0, 53, 0, 0, 54, 36, - 47, 44, 56, 0, 0, 99, 48, 39, 55, 40, - 50, 0, 0, 0, 0, 0, 0, 0, 49, 0, - 0, 0, 0, 0, 0, 48, 37, 38, 0, 50, - 0, 41, 42, 0, 0, 0, 0, 49, 0, 0, - 0, 0, 0, 0, 0, 37, 38, 0, 0, 66, - 41, 42, 53, 0, 0, 54, 36, 47, 44, 56, - 0, 0, 0, 0, 39, 55, 40, 53, 0, 0, - 54, 36, 47, 44, 172, 0, 0, 0, 0, 39, - 55, 40, 48, 0, 0, 0, 50, 0, 0, 0, - 0, 0, 0, 0, 49, 0, 0, 48, 0, 0, - 0, 50, 37, 38, 0, 0, 0, 41, 42, 49, - 0, 0, 0, 0, 0, 0, 0, 37, 38, 0, - 0, 53, 41, 42, 54, 36, 47, 44, 56, 0, - 0, 0, 0, 39, 55, 40, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 48, 0, 0, 0, 50, 0, 0, 183, 0, - 0, 0, 0, 49, 75, 0, 0, 0, 0, 0, - 0, 37, 38, 0, 0, 0, 41, 42, 84, 87, - 76, 77, 0, 80, 81, 88, 86, 82, 0, 83, - 85, 75, 0, 0, 0, 0, 0, 181, 0, 0, - 0, 79, 78, 0, 0, 84, 87, 76, 77, 0, - 80, 81, 88, 86, 82, 180, 83, 85, 0, 0, - 0, 75, 0, 0, 0, 0, 0, 0, 79, 78, - 0, 0, 0, 0, 0, 84, 87, 76, 77, 0, - 80, 81, 88, 86, 82, 173, 83, 85, 0, 0, - 0, 75, 0, 0, 0, 0, 0, 0, 79, 78, - 168, 0, 0, 0, 0, 84, 87, 76, 77, 0, - 80, 81, 88, 86, 82, 0, 83, 85, 0, 75, - 0, 0, 0, 0, 0, 0, 0, 0, 79, 78, - 0, 0, 0, 84, 87, 76, 77, 114, 80, 81, - 88, 86, 82, 0, 83, 85, 75, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 79, 78, 0, 0, - 84, 87, 76, 77, 0, 80, 81, 88, 86, 82, - 0, 83, 85, 75, 0, 0, 0, 0, 0, 163, - 0, 0, 0, 79, 78, 0, 0, 84, 87, 76, - 77, 0, 80, 81, 88, 86, 82, 0, 83, 85, - 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 79, 78, 0, 0, 84, 87, 76, 77, 0, 80, - 81, 88, 86, 82, 0, 83, 85, 75, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 79, 78, 0, - 0, 84, 87, 76, 77, 0, 80, 81, 88, 86, - 82, 0, 83, 85, + 38, 39, 0, 0, 124, 42, 43, 54, 0, 0, + 55, 37, 48, 45, 57, 0, 0, 0, 0, 40, + 56, 41, 0, 71, 0, 0, 54, 0, 0, 55, + 37, 48, 45, 57, 0, 0, 0, 49, 40, 56, + 41, 51, 0, 0, 0, 0, 0, 0, 0, 50, + 0, 0, 0, 0, 0, 0, 49, 38, 39, 0, + 51, 0, 42, 43, 0, 0, 54, 0, 50, 55, + 37, 48, 45, 57, 0, 0, 38, 39, 40, 56, + 41, 42, 43, 0, 0, 54, 0, 0, 55, 37, + 48, 45, 172, 0, 0, 0, 49, 40, 56, 41, + 51, 0, 0, 0, 0, 0, 0, 0, 50, 0, + 0, 0, 0, 0, 0, 49, 38, 39, 0, 51, + 0, 42, 43, 0, 0, 0, 0, 50, 80, 0, + 0, 0, 0, 0, 220, 38, 39, 208, 0, 0, + 42, 43, 89, 92, 81, 82, 0, 85, 86, 93, + 91, 87, 0, 88, 90, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 84, 83, 0, 0, 0, + 89, 92, 81, 82, 0, 85, 86, 93, 91, 87, + 0, 88, 90, 80, 0, 0, 0, 0, 0, 206, + 0, 168, 0, 84, 83, 0, 0, 89, 92, 81, + 82, 0, 85, 86, 93, 91, 87, 0, 88, 90, + 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 84, 83, 0, 0, 89, 92, 81, 82, 119, 85, + 86, 93, 91, 87, 0, 88, 90, 80, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 84, 83, 0, + 0, 89, 92, 81, 82, 0, 85, 86, 93, 91, + 87, 0, 88, 90, 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 84, 83, 0, 0, 89, 92, + 81, 82, 0, 85, 86, 93, 91, 87, 0, 88, + 90, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 84, 83, 0, 0, 89, 92, 81, 82, 0, + 85, 86, 93, 91, 87, 0, 88, 90, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 84, } var yyPact = [...]int16{ - 27, 52, 273, -1000, -1000, -1000, 331, 183, 164, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -51, 715, - -1000, -1000, 459, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, 54, 205, -1000, 234, 784, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 3, 658, 37, -1000, 784, 784, 784, - 784, -1000, -1000, 17, -1000, -1000, 639, 183, 164, -1000, - -1000, 8, -1000, 784, 8, 64, 599, 459, -1000, 784, - 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, - 784, 784, 784, 784, 784, 784, 784, 784, 784, 232, - 784, 232, 432, 784, 232, 953, -1000, 580, -1000, -1000, - 1007, -1000, 526, -1000, -5, -1000, -1000, -1000, 784, -1000, - 980, 164, -1000, -1000, 212, 953, -1000, 511, 926, 730, - 1007, 1007, 1007, 1007, 1007, 1007, 117, 9, 9, 161, - 1034, 9, 9, 9, 9, 75, 75, -1000, -1000, -1000, - 15, 13, 898, 15, 13, 122, -1000, 125, -1000, 1007, - -1000, 12, 868, 15, 13, -1000, -1000, 1007, -1000, 838, - -1000, 116, 811, 784, 6, -1000, 91, 730, 730, 8, - -1000, -1000, 212, -1000, -1000, 413, 94, -1000, -1000, 784, - -1000, 784, -1000, -1000, 1007, -1000, 730, 8, -1000, 8, - -1000, -1000, 361, -1000, 84, 1007, -1000, -1000, 1007, 1007, - 8, -1000, -1000, -1000, -1000, -1000, + 4, 85, 394, -1000, -1000, -1000, 333, 452, 29, -1000, + 56, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -56, + 789, -1000, -1000, 514, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, 87, 105, -1000, 83, 829, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, 42, -27, 51, -1000, -27, 829, + 829, 829, -1000, -1000, 65, -1000, -1000, -27, -1000, -1000, + 29, 27, -1000, -1000, -1000, -1000, 44, -1000, 829, 44, + 94, 770, 514, -1000, -27, -27, -27, -27, -27, -27, + -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, -27, 100, -27, 100, -27, -27, 100, + 984, -1000, -27, -1000, 713, -23, 50, -27, 829, -1000, + -1000, -1000, -27, 694, 27, -1000, -1000, -1000, -1000, -27, + 984, -1000, 654, 957, 848, 829, 829, 829, 829, 829, + 829, 829, 829, 829, 829, 829, 829, 829, 829, 829, + 829, 829, 829, 829, 829, 64, 63, 829, 64, 63, + 635, 829, 64, 63, -1000, 581, -1000, 1011, -1000, 566, + 43, 829, -1000, 930, 271, -1000, 903, 848, 848, 44, + -1000, -1000, -27, 1011, 1011, 1011, 1011, 1011, 1011, 442, + -15, -15, 1038, 209, -15, -15, -15, -15, 0, 0, + -1000, -1000, -1000, 43, 15, -1000, -1000, 1011, 28, 43, + -1000, 1011, -1000, 875, 45, 43, -27, 49, 848, 44, + -1000, 44, -1000, -1000, 271, 22, 33, -27, -27, 11, + -27, -1000, -3, 829, -1000, 44, -1000, -1000, -1000, 482, + -1000, -1000, 5, 829, -1000, 829, -1000, 1011, -1000, -1000, + 1011, -1000, 1011, 1011, } var yyPgo = [...]uint8{ - 0, 27, 1, 245, 251, 244, 243, 236, 235, 142, - 10, 229, 220, 213, 208, 194, 190, 5, 9, 186, - 179, 177, 172, 167, 16, 158, 230, 0, 146, 145, - 124, 116, 105, 6, 90, 69, 4, 2, + 0, 155, 101, 163, 216, 214, 212, 211, 210, 113, + 32, 209, 207, 206, 197, 195, 174, 4, 2, 173, + 172, 169, 167, 164, 11, 159, 27, 0, 154, 150, + 146, 125, 124, 36, 122, 117, 13, 115, 116, 100, } var yyR1 = [...]int8{ - 0, 36, 36, 36, 36, 35, 35, 35, 3, 3, - 3, 4, 4, 4, 9, 9, 9, 9, 9, 9, - 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 34, 10, 10, 10, 10, 10, 10, 26, - 14, 13, 11, 12, 12, 12, 12, 12, 12, 12, - 12, 33, 33, 15, 15, 5, 7, 7, 6, 1, - 1, 2, 16, 16, 16, 16, 16, 16, 8, 8, - 8, 8, 17, 19, 19, 19, 20, 20, 21, 21, - 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, - 22, 23, 23, 37, 37, 24, 24, 24, 25, 25, - 25, 25, 25, 25, 30, 30, 30, 31, 31, 31, - 28, 28, 28, 29, 29, 29, 18, 18, 32, 32, - 32, 32, 32, 32, 32, + 0, 36, 36, 36, 36, 37, 37, 37, 35, 35, + 35, 35, 35, 3, 3, 3, 4, 4, 4, 9, + 9, 9, 9, 9, 9, 9, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 34, 38, 38, + 39, 39, 10, 10, 10, 10, 10, 10, 26, 14, + 13, 11, 12, 12, 12, 12, 12, 12, 12, 12, + 33, 33, 15, 15, 5, 7, 7, 6, 1, 1, + 2, 16, 16, 16, 8, 8, 8, 8, 17, 19, + 19, 19, 20, 20, 21, 21, 21, 21, 21, 21, + 21, 21, 22, 22, 22, 22, 22, 23, 24, 24, + 24, 25, 25, 25, 25, 25, 25, 30, 30, 30, + 31, 31, 31, 28, 28, 28, 29, 29, 18, 18, + 32, 32, 32, 32, 32, 32, 32, } var yyR2 = [...]int8{ - 0, 1, 1, 2, 2, 2, 2, 1, 2, 1, - 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 2, 2, 1, 2, 2, 2, 2, + 3, 2, 1, 2, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, - 1, 1, 3, 7, 6, 6, 5, 6, 5, 5, - 4, 1, 1, 1, 3, 3, 1, 2, 3, 1, - 3, 2, 4, 5, 3, 5, 6, 4, 3, 3, - 1, 1, 3, 2, 2, 2, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 4, 1, 2, 4, 4, 4, 3, 3, - 3, 3, 3, 3, 2, 3, 2, 2, 3, 2, - 2, 3, 1, 4, 5, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 0, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 3, 7, 6, 6, 5, 6, 5, 5, 4, + 1, 1, 1, 3, 3, 1, 2, 3, 1, 4, + 3, 6, 7, 4, 4, 4, 1, 1, 4, 2, + 2, 2, 1, 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, + 6, 3, 3, 3, 3, 3, 3, 2, 4, 3, + 3, 4, 2, 3, 4, 1, 6, 7, 1, 1, + 1, 1, 1, 1, 1, 1, 1, } var yyChk = [...]int16{ - -1000, -35, 69, 2, 8, -3, -4, -9, -36, -15, - -11, -12, -13, -14, -34, -10, 4, 28, -7, 22, - 26, 25, -27, -5, -32, -30, -28, -23, -16, -19, - -20, -25, -24, -26, -18, 64, 11, 57, 58, 19, - 21, 62, 63, -31, 13, -29, -2, 12, 37, 49, - 41, -21, -22, 7, 10, 20, 14, -9, -36, 4, - 28, 66, -6, 65, -26, -33, 4, -27, -10, 47, - 50, 51, 53, 52, 54, 23, 39, 40, 61, 60, - 42, 43, 46, 48, 37, 49, 45, 38, 44, 7, - 13, 7, 12, 13, 7, -27, 17, 5, 28, 17, - -27, 15, 5, 28, -27, -27, -27, -27, 13, 15, - -27, -36, -1, -2, 14, -27, -1, 4, -27, 4, - -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -1000, -35, 69, 2, 8, -3, -38, -4, -9, 28, + -37, -15, -11, -12, -13, -14, -34, -10, 4, -7, + 22, 26, 25, -27, -5, -32, -30, -28, -23, -16, + -19, -20, -25, -24, -26, -18, 64, 11, 57, 58, + 19, 21, 62, 63, -31, 13, -29, -2, 12, 37, + 49, 41, -21, -22, 7, 10, 20, 14, -3, 28, + -9, -36, 4, 28, 28, 4, 66, -6, 65, -26, + -33, 4, -27, -10, 47, 50, 51, 53, 52, 54, + 23, 39, 40, 61, 60, 42, 43, 46, 48, 37, + 49, 45, 38, 44, 7, 13, 7, 12, 13, 7, + -27, 17, 5, 28, -39, -38, -39, 5, -39, -27, + -27, -27, 13, -39, -36, 4, 28, -1, -2, 14, + -27, -1, 4, -27, 4, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -24, -18, -39, -24, -18, + -39, -39, -24, -18, -1, -39, 17, -27, 15, -39, + -27, -39, 15, -27, -39, -1, -27, 4, 4, -33, + -1, -2, 14, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -24, -18, -27, -24, -18, -8, 16, -37, -17, -27, - 28, -18, -27, -24, -18, -1, 17, -27, 15, -27, - 16, -37, -27, 29, -3, -1, -27, 4, 4, -33, - -1, -2, 14, 17, 16, 5, -37, 16, 28, 47, - 17, 29, 16, 17, -27, 15, 4, -33, -1, -33, - -1, -1, -27, 16, -37, -27, -17, 16, -27, -27, - -33, -1, -1, -1, 16, -1, + -27, -27, -27, -27, -8, 16, -17, -27, -18, -27, + 17, -27, 15, -27, -39, -27, 29, -3, 4, -33, + -1, -33, -1, -1, -39, -39, -39, 5, 47, -39, + 29, 16, -39, -39, 15, -33, -1, -1, -1, -27, + 17, 16, -39, -39, 17, -39, 17, -27, -1, 16, + -27, -17, -27, -27, } var yyDef = [...]int8{ - 0, -2, 0, 7, 6, 5, 9, 10, 12, 14, - 15, 16, 17, 18, 19, 20, 1, 2, 53, 0, - 41, 40, 32, 56, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 0, 118, 119, 120, 121, - 122, 123, 124, 0, 0, 0, 112, 0, 0, 0, - 0, 76, 77, 0, 116, 117, 0, 8, 11, 3, - 4, 0, 57, 0, 30, 0, 0, 51, 52, 0, + 0, -2, 0, 12, 11, 8, 9, 14, 15, 38, + 17, 19, 20, 21, 22, 23, 24, 25, 5, 62, + 0, 50, 49, 37, 65, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 0, 120, 121, 122, + 123, 124, 125, 126, 0, 41, 41, 115, 41, 0, + 0, 0, 82, 83, 0, 118, 119, 41, 10, 39, + 13, 16, 1, 2, 6, 7, 0, 66, 0, 35, + 0, 0, 60, 61, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 0, 41, 0, 41, 41, 0, + 0, 107, 41, 112, 0, 40, 0, 41, 0, 79, + 80, 81, 41, 0, 18, 3, 4, 63, 68, 41, + 0, 51, 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, 104, 0, 109, 106, - 107, 110, 0, 115, 0, 73, 74, 75, 0, 61, - 0, 13, 54, 59, 0, 0, 42, 0, 0, 0, - 33, 34, 35, 36, 37, 38, 39, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 102, 103, 0, 100, 101, 0, 64, 0, 70, 71, - 93, 31, 0, 98, 99, 55, 105, 108, 111, 0, - 91, 0, 0, 0, 0, 58, 0, 0, 0, 0, - 50, -2, 0, 97, 62, 0, 0, 67, 94, 0, - 95, 0, 92, 96, 113, 60, 0, 0, 48, 0, - 46, 49, 32, 63, 0, 68, 69, 65, 72, 114, - 0, 44, 47, 45, 66, 43, + 0, 0, 0, 0, 0, 105, 106, 0, 103, 104, + 0, 0, 101, 102, 64, 0, 109, 110, 113, 0, + 41, 0, 70, 0, 0, 67, 0, 0, 0, 0, + 59, -2, 41, 42, 43, 44, 45, 46, 47, 48, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 94, 95, 96, 41, 41, 73, 76, 77, 36, 41, + 108, 111, 114, 0, 0, 41, 41, 0, 0, 0, + 57, 0, 55, 58, 0, 0, 0, 41, 41, 0, + 41, 97, 0, 0, 69, 0, 53, 56, 54, 37, + 100, 71, 0, 0, 98, 0, 99, 116, 52, 72, + 74, 75, 78, 117, } var yyTok1 = [...]int8{ @@ -771,554 +784,542 @@ yydefault: // dummy call; replaced with literal code switch yynt { - case 5: + case 8: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:138 +//line gram.y:139 { yylex.(*parser).parseResult = yyDollar[2].aststmts } - case 7: - yyDollar = yyS[yypt-1 : yypt+1] + case 9: + yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:143 + { + yylex.(*parser).parseResult = ast.Stmts{} + } + case 10: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:147 + { + yylex.(*parser).parseResult = yyDollar[3].aststmts + } + case 12: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:152 { yylex.(*parser).unexpected("", "") } - case 8: + case 13: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:150 +//line gram.y:159 { s := yyDollar[1].aststmts s = append(s, yyDollar[2].node) yyVAL.aststmts = s } - case 10: + case 15: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:157 +//line gram.y:166 { yyVAL.aststmts = ast.Stmts{yyDollar[1].node} } - case 11: + case 16: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:163 +//line gram.y:172 { yyVAL.aststmts = ast.Stmts{yyDollar[1].node} } - case 12: + case 17: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:167 +//line gram.y:176 { yyVAL.aststmts = ast.Stmts{} } - case 13: + case 18: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:171 +//line gram.y:180 { s := yyDollar[1].aststmts s = append(s, yyDollar[2].node) yyVAL.aststmts = s } - case 33: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:205 + case 42: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:222 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 34: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:209 + case 43: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:226 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 35: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:213 + case 44: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:230 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 36: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:217 + case 45: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:234 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 37: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:221 + case 46: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:238 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 38: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:225 + case 47: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:242 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 39: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:232 + case 48: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:249 { - yyVAL.node = yylex.(*parser).newInExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newInExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 40: + case 49: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:237 +//line gram.y:254 { yyVAL.node = yylex.(*parser).newBreakStmt(yyDollar[1].item.Pos) } - case 41: + case 50: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:243 +//line gram.y:260 { yyVAL.node = yylex.(*parser).newContinueStmt(yyDollar[1].item.Pos) } - case 42: + case 51: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:254 +//line gram.y:271 { yyVAL.node = yylex.(*parser).newForInStmt(yyDollar[2].node, yyDollar[3].astblock, yyDollar[1].item) } - case 43: + case 52: yyDollar = yyS[yypt-7 : yypt+1] -//line gram.y:266 +//line gram.y:283 { yyVAL.node = yylex.(*parser).newForStmt(yyDollar[2].node, yyDollar[4].node, yyDollar[6].node, yyDollar[7].astblock) } - case 44: + case 53: yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:270 +//line gram.y:287 { yyVAL.node = yylex.(*parser).newForStmt(yyDollar[2].node, yyDollar[4].node, nil, yyDollar[6].astblock) } - case 45: + case 54: yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:274 +//line gram.y:291 { yyVAL.node = yylex.(*parser).newForStmt(nil, yyDollar[3].node, yyDollar[5].node, yyDollar[6].astblock) } - case 46: + case 55: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:278 +//line gram.y:295 { yyVAL.node = yylex.(*parser).newForStmt(nil, yyDollar[3].node, nil, yyDollar[5].astblock) } - case 47: + case 56: yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:282 +//line gram.y:299 { yyVAL.node = yylex.(*parser).newForStmt(yyDollar[2].node, nil, yyDollar[5].node, yyDollar[6].astblock) } - case 48: + case 57: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:286 +//line gram.y:303 { yyVAL.node = yylex.(*parser).newForStmt(yyDollar[2].node, nil, nil, yyDollar[5].astblock) } - case 49: + case 58: yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:290 +//line gram.y:307 { yyVAL.node = yylex.(*parser).newForStmt(nil, nil, yyDollar[4].node, yyDollar[5].astblock) } - case 50: + case 59: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:294 +//line gram.y:311 { yyVAL.node = yylex.(*parser).newForStmt(nil, nil, nil, yyDollar[4].astblock) } - case 53: + case 62: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:303 +//line gram.y:320 { yyVAL.node = yylex.(*parser).newIfElifStmt(yyDollar[1].iflist) } - case 54: + case 63: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:307 +//line gram.y:324 { yyVAL.node = yylex.(*parser).newIfElifelseStmt(yyDollar[1].iflist, yyDollar[2].item, yyDollar[3].astblock) } - case 55: + case 64: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:313 +//line gram.y:330 { yyVAL.ifitem = yylex.(*parser).newIfElem(yyDollar[1].item, yyDollar[2].node, yyDollar[3].astblock) } - case 56: + case 65: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:319 +//line gram.y:336 { yyVAL.iflist = []*ast.IfStmtElem{yyDollar[1].ifitem} } - case 57: + case 66: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:323 +//line gram.y:340 { yyVAL.iflist = append(yyDollar[1].iflist, yyDollar[2].ifitem) } - case 58: + case 67: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:329 +//line gram.y:346 { yyVAL.ifitem = yylex.(*parser).newIfElem(yyDollar[1].item, yyDollar[2].node, yyDollar[3].astblock) } - case 60: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:337 - { - yyVAL.astblock = yylex.(*parser).newBlockStmt(yyDollar[1].item, yyDollar[2].aststmts, yyDollar[3].item) - } - case 61: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:343 - { - yyVAL.astblock = yylex.(*parser).newBlockStmt(yyDollar[1].item, ast.Stmts{}, yyDollar[2].item) - } - case 62: + case 69: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:349 - { - yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[3].nodes, yyDollar[2].item, yyDollar[4].item) - } - case 63: - yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:353 +//line gram.y:354 { - yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[3].nodes, yyDollar[2].item, yyDollar[5].item) + yyVAL.astblock = yylex.(*parser).newBlockStmt(yyDollar[1].item, yyDollar[3].aststmts, yyDollar[4].item) } - case 64: + case 70: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:357 +//line gram.y:360 { - yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, nil, yyDollar[2].item, yyDollar[3].item) + yyVAL.astblock = yylex.(*parser).newBlockStmt(yyDollar[1].item, ast.Stmts{}, yyDollar[3].item) } - case 65: - yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:361 + case 71: + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:366 { - yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[3].nodes, yyDollar[2].item, yyDollar[5].item) + yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[4].nodes, yyDollar[2].item, yyDollar[6].item) } - case 66: - yyDollar = yyS[yypt-6 : yypt+1] -//line gram.y:365 + case 72: + yyDollar = yyS[yypt-7 : yypt+1] +//line gram.y:370 { - yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[3].nodes, yyDollar[2].item, yyDollar[6].item) + yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, yyDollar[4].nodes, yyDollar[2].item, yyDollar[7].item) } - case 67: + case 73: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:369 +//line gram.y:374 { yyVAL.node = yylex.(*parser).newCallExpr(yyDollar[1].node, nil, yyDollar[2].item, yyDollar[4].item) } - case 68: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:376 - { - yyVAL.nodes = append(yyVAL.nodes, yyDollar[3].node) - } - case 69: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:380 + case 74: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:381 { - yyVAL.nodes = append(yyVAL.nodes, yyDollar[3].node) + yyVAL.nodes = append(yyVAL.nodes, yyDollar[4].node) } - case 70: - yyDollar = yyS[yypt-1 : yypt+1] + case 75: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:385 { - yyVAL.nodes = []*ast.Node{yyDollar[1].node} + yyVAL.nodes = append(yyVAL.nodes, yyDollar[4].node) } - case 71: + case 76: yyDollar = yyS[yypt-1 : yypt+1] //line gram.y:389 { yyVAL.nodes = []*ast.Node{yyDollar[1].node} } - case 72: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:395 + case 77: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:393 { - yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.nodes = []*ast.Node{yyDollar[1].node} } - case 73: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:401 + case 78: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:399 { - yyVAL.node = yylex.(*parser).newUnaryExpr(yyDollar[1].item, yyDollar[2].node) + yyVAL.node = yylex.(*parser).newAssignmentStmt(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 74: + case 79: yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:405 { yyVAL.node = yylex.(*parser).newUnaryExpr(yyDollar[1].item, yyDollar[2].node) } - case 75: + case 80: yyDollar = yyS[yypt-2 : yypt+1] //line gram.y:409 { yyVAL.node = yylex.(*parser).newUnaryExpr(yyDollar[1].item, yyDollar[2].node) } - case 78: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:417 + case 81: + yyDollar = yyS[yypt-2 : yypt+1] +//line gram.y:413 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newUnaryExpr(yyDollar[1].item, yyDollar[2].node) } - case 79: - yyDollar = yyS[yypt-3 : yypt+1] + case 84: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:421 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 80: - yyDollar = yyS[yypt-3 : yypt+1] + case 85: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:425 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 81: - yyDollar = yyS[yypt-3 : yypt+1] + case 86: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:429 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 82: - yyDollar = yyS[yypt-3 : yypt+1] + case 87: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:433 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 83: - yyDollar = yyS[yypt-3 : yypt+1] + case 88: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:437 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 84: - yyDollar = yyS[yypt-3 : yypt+1] + case 89: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:441 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 85: - yyDollar = yyS[yypt-3 : yypt+1] + case 90: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:445 { - yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 86: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:452 + case 91: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:449 { - yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newConditionalExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 87: - yyDollar = yyS[yypt-3 : yypt+1] + case 92: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:456 { - yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 88: - yyDollar = yyS[yypt-3 : yypt+1] + case 93: + yyDollar = yyS[yypt-4 : yypt+1] //line gram.y:460 { - yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) + yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } - case 89: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:464 - { - yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) - } - case 90: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:468 - { - yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[2].item) - } - case 91: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:475 - { - yyVAL.node = yylex.(*parser).newParenExpr(yyDollar[1].item, yyDollar[2].node, yyDollar[3].item) - } - case 92: + case 94: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:479 +//line gram.y:464 { - yyVAL.node = yylex.(*parser).newParenExpr(yyDollar[1].item, yyDollar[2].node, yyDollar[4].item) + yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } case 95: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:490 +//line gram.y:468 { - yyVAL.node = yylex.(*parser).newIndexExpr(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].item) + yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } case 96: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:495 +//line gram.y:472 { - yyVAL.node = yylex.(*parser).newIndexExpr(nil, yyDollar[2].item, yyDollar[3].node, yyDollar[4].item) + yyVAL.node = yylex.(*parser).newArithmeticExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[2].item) } case 97: - yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:499 + yyDollar = yyS[yypt-5 : yypt+1] +//line gram.y:479 { - yyVAL.node = yylex.(*parser).newIndexExpr(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].item) + yyVAL.node = yylex.(*parser).newParenExpr(yyDollar[1].item, yyDollar[3].node, yyDollar[5].item) } case 98: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:508 + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:486 { - yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) + yyVAL.node = yylex.(*parser).newIndexExpr(yyDollar[1].node, yyDollar[2].item, yyDollar[4].node, yyDollar[6].item) } case 99: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:512 + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:491 { - yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) + yyVAL.node = yylex.(*parser).newIndexExpr(nil, yyDollar[2].item, yyDollar[4].node, yyDollar[6].item) } case 100: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:516 + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:495 { - yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) + yyVAL.node = yylex.(*parser).newIndexExpr(yyDollar[1].node, yyDollar[2].item, yyDollar[4].node, yyDollar[6].item) } case 101: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:520 +//line gram.y:504 { yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 102: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:524 +//line gram.y:508 { yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 103: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:528 +//line gram.y:512 { yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 104: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:535 + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:516 { - yyVAL.node = yylex.(*parser).newListInitEndExpr(yyVAL.node, yyDollar[2].item.Pos) + yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 105: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:539 +//line gram.y:520 { - yyVAL.node = yylex.(*parser).newListInitEndExpr(yyVAL.node, yyDollar[2].item.Pos) + yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 106: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:543 + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:524 { - yyVAL.node = yylex.(*parser).newListInitStartExpr(yyDollar[1].item.Pos) - yyVAL.node = yylex.(*parser).newListInitEndExpr(yyVAL.node, yyDollar[2].item.Pos) + yyVAL.node = yylex.(*parser).newAttrExpr(yyDollar[1].node, yyDollar[3].node) } case 107: yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:550 +//line gram.y:531 { - yyVAL.node = yylex.(*parser).newListInitStartExpr(yyDollar[1].item.Pos) - yyVAL.node = yylex.(*parser).newListInitAppendExpr(yyVAL.node, yyDollar[2].node) + yyVAL.node = yylex.(*parser).newListLiteralEnd(yyVAL.node, yyDollar[2].item.Pos) } case 108: + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:535 + { + yyVAL.node = yylex.(*parser).newListLiteralEnd(yyVAL.node, yyDollar[4].item.Pos) + } + case 109: yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:555 +//line gram.y:539 { - yyVAL.node = yylex.(*parser).newListInitAppendExpr(yyVAL.node, yyDollar[3].node) + yyVAL.node = yylex.(*parser).newListLiteralStart(yyDollar[1].item.Pos) + yyVAL.node = yylex.(*parser).newListLiteralEnd(yyVAL.node, yyDollar[3].item.Pos) } case 110: - yyDollar = yyS[yypt-2 : yypt+1] -//line gram.y:563 + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:546 { - yyVAL.node = yylex.(*parser).newMapInitEndExpr(yyVAL.node, yyDollar[2].item.Pos) + yyVAL.node = yylex.(*parser).newListLiteralStart(yyDollar[1].item.Pos) + yyVAL.node = yylex.(*parser).newListLiteralAppendExpr(yyVAL.node, yyDollar[3].node) } case 111: - yyDollar = yyS[yypt-3 : yypt+1] -//line gram.y:567 + yyDollar = yyS[yypt-4 : yypt+1] +//line gram.y:551 { - yyVAL.node = yylex.(*parser).newMapInitEndExpr(yyVAL.node, yyDollar[3].item.Pos) + yyVAL.node = yylex.(*parser).newListLiteralAppendExpr(yyVAL.node, yyDollar[4].node) } - case 112: - yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:571 + case 113: + yyDollar = yyS[yypt-3 : yypt+1] +//line gram.y:559 { - yyVAL.node = yylex.(*parser).newMapInitStartExpr(yyDollar[1].astblock.LBracePos.Pos) - yyVAL.node = yylex.(*parser).newMapInitEndExpr(yyVAL.node, yyDollar[1].astblock.RBracePos.Pos) + yyVAL.node = yylex.(*parser).newMapLiteralEnd(yyVAL.node, yyDollar[3].item.Pos) } - case 113: + case 114: yyDollar = yyS[yypt-4 : yypt+1] -//line gram.y:578 +//line gram.y:563 { - yyVAL.node = yylex.(*parser).newMapInitStartExpr(yyDollar[1].item.Pos) - yyVAL.node = yylex.(*parser).newMapInitAppendExpr(yyVAL.node, yyDollar[2].node, yyDollar[4].node) + yyVAL.node = yylex.(*parser).newMapLiteralEnd(yyVAL.node, yyDollar[4].item.Pos) } - case 114: - yyDollar = yyS[yypt-5 : yypt+1] -//line gram.y:583 + case 115: + yyDollar = yyS[yypt-1 : yypt+1] +//line gram.y:567 { - yyVAL.node = yylex.(*parser).newMapInitAppendExpr(yyDollar[1].node, yyDollar[3].node, yyDollar[5].node) + yyVAL.node = yylex.(*parser).newMapLiteralStart(yyDollar[1].astblock.LBracePos.Pos) + yyVAL.node = yylex.(*parser).newMapLiteralEnd(yyVAL.node, yyDollar[1].astblock.RBracePos.Pos) } case 116: + yyDollar = yyS[yypt-6 : yypt+1] +//line gram.y:574 + { + yyVAL.node = yylex.(*parser).newMapLiteralStart(yyDollar[1].item.Pos) + yyVAL.node = yylex.(*parser).newMapLiteralAppendExpr(yyVAL.node, yyDollar[3].node, yyDollar[6].node) + } + case 117: + yyDollar = yyS[yypt-7 : yypt+1] +//line gram.y:579 + { + yyVAL.node = yylex.(*parser).newMapLiteralAppendExpr(yyDollar[1].node, yyDollar[4].node, yyDollar[7].node) + } + case 118: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:591 +//line gram.y:586 { yyVAL.node = yylex.(*parser).newIdentifierLiteral(yyDollar[1].item) } - case 117: + case 119: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:595 +//line gram.y:590 { yyDollar[1].item.Val = yylex.(*parser).unquoteString(yyDollar[1].item.Val) yyVAL.node = yylex.(*parser).newIdentifierLiteral(yyDollar[1].item) } - case 118: + case 120: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:602 +//line gram.y:597 { yyVAL.node = yylex.(*parser).newNumberLiteral(yyDollar[1].item) } - case 119: + case 121: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:606 +//line gram.y:601 { yyVAL.node = yylex.(*parser).newBoolLiteral(yyDollar[1].item.Pos, true) } - case 120: + case 122: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:610 +//line gram.y:605 { yyVAL.node = yylex.(*parser).newBoolLiteral(yyDollar[1].item.Pos, false) } - case 121: + case 123: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:614 +//line gram.y:609 { yyDollar[1].item.Val = yylex.(*parser).unquoteString(yyDollar[1].item.Val) yyVAL.node = yylex.(*parser).newStringLiteral(yyDollar[1].item) } - case 122: + case 124: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:619 +//line gram.y:614 { yyDollar[1].item.Val = yylex.(*parser).unquoteMultilineString(yyDollar[1].item.Val) yyVAL.node = yylex.(*parser).newStringLiteral(yyDollar[1].item) } - case 123: + case 125: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:624 +//line gram.y:619 { yyVAL.node = yylex.(*parser).newNilLiteral(yyDollar[1].item.Pos) } - case 124: + case 126: yyDollar = yyS[yypt-1 : yypt+1] -//line gram.y:628 +//line gram.y:623 { yyVAL.node = yylex.(*parser).newNilLiteral(yyDollar[1].item.Pos) } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/parser/lex.go b/vendor/github.com/GuanceCloud/platypus/pkg/parser/lex.go index 20db4c0711..735338af62 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/parser/lex.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/parser/lex.go @@ -248,7 +248,6 @@ func lexStatements(l *Lexer) stateFn { switch r := l.next(); { case r == ',': l.emit(COMMA) - return lexSpace case isSpaceNotEOL(r): return lexSpaceNotEOL @@ -259,16 +258,13 @@ func lexStatements(l *Lexer) stateFn { l.emit(MUL_EQ) } else { l.emit(MUL) - return lexSpace } - case r == '/': if t := l.peek(); t == '=' { l.next() l.emit(DIV_EQ) } else { l.emit(DIV) - return lexSpace } case r == '%': if t := l.peek(); t == '=' { @@ -276,7 +272,6 @@ func lexStatements(l *Lexer) stateFn { l.emit(MOD_EQ) } else { l.emit(MOD) - return lexSpace } case r == '+': if t := l.peek(); t == '=' { @@ -284,7 +279,6 @@ func lexStatements(l *Lexer) stateFn { l.emit(ADD_EQ) } else { l.emit(ADD) - return lexSpace } case r == '-': @@ -293,12 +287,10 @@ func lexStatements(l *Lexer) stateFn { l.emit(SUB_EQ) } else { l.emit(SUB) - return lexSpace } // case r == '^': // l.emit(XOR) - // return lexSpace case r == '=': if t := l.peek(); t == '=' { @@ -307,11 +299,9 @@ func lexStatements(l *Lexer) stateFn { } else { l.emit(EQ) } - return lexSpace case r == ':': l.emit(COLON) - return lexSpace case r == ';': l.emit(SEMICOLON) @@ -330,7 +320,6 @@ func lexStatements(l *Lexer) stateFn { // TODO: add bit-or operator return l.errorf("unexpected character `%q' after `!'", r) } - return lexSpace case r == '&': if t := l.peek(); t == '&' { @@ -340,7 +329,6 @@ func lexStatements(l *Lexer) stateFn { // TODO: add bit-and operator return l.errorf("unexpected character `%q' after `!'", r) } - return lexSpace case r == '!': switch nr := l.peek(); { @@ -350,7 +338,6 @@ func lexStatements(l *Lexer) stateFn { default: l.emit(NOT) } - return lexSpace case r == '<': if t := l.peek(); t == '=' { @@ -359,7 +346,6 @@ func lexStatements(l *Lexer) stateFn { } else { l.emit(LT) } - return lexSpace case r == '>': if t := l.peek(); t == '=' { @@ -368,7 +354,6 @@ func lexStatements(l *Lexer) stateFn { } else { l.emit(GT) } - return lexSpace case isDigit(r) || (r == '.' && isDigit(l.peek())): l.backup() @@ -413,7 +398,6 @@ func lexStatements(l *Lexer) stateFn { case r == '(': l.emit(LEFT_PAREN) l.parenDepth++ - return lexSpace case r == ')': l.emit(RIGHT_PAREN) @@ -426,7 +410,6 @@ func lexStatements(l *Lexer) stateFn { case r == '{': l.emit(LEFT_BRACE) l.braceDepth++ - return lexSpace case r == '}': l.emit(RIGHT_BRACE) @@ -438,7 +421,6 @@ func lexStatements(l *Lexer) stateFn { case r == '[': l.bracketDepth++ l.emit(LEFT_BRACKET) - return lexSpace case r == ']': l.bracketDepth-- @@ -489,15 +471,6 @@ __goon: return lexStatements } -func lexSpace(l *Lexer) stateFn { - for isSpace(l.peek()) { - l.next() - } - - l.ignore() - return lexStatements -} - func lexSpaceNotEOL(l *Lexer) stateFn { for isSpaceNotEOL(l.peek()) { l.next() @@ -749,7 +722,6 @@ func isAlphaNumeric(r rune) bool { return isAlpha(r) || isDigit(r) } func isAlpha(r rune) bool { return r == '_' || ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z') } func isUTF8(r rune) bool { return utf8.RuneLen(r) > 1 } func isDigit(r rune) bool { return '0' <= r && r <= '9' } -func isSpace(r rune) bool { return r == ' ' || r == '\t' || r == '\n' || r == '\r' } func isSpaceNotEOL(r rune) bool { return r == ' ' || r == '\t' || r == '\r' } func isEOL(r rune) bool { return r == '\r' || r == '\n' } diff --git a/vendor/github.com/GuanceCloud/platypus/pkg/parser/parser.go b/vendor/github.com/GuanceCloud/platypus/pkg/parser/parser.go index 942bd4dfeb..91e1933a8a 100644 --- a/vendor/github.com/GuanceCloud/platypus/pkg/parser/parser.go +++ b/vendor/github.com/GuanceCloud/platypus/pkg/parser/parser.go @@ -184,60 +184,60 @@ func (p *parser) newParenExpr(lParen Item, node *ast.Node, rParen Item) *ast.Nod }) } -func (p *parser) newListInitStartExpr(pos plToken.Pos) *ast.Node { - return ast.WrapListInitExpr(&ast.ListInitExpr{ +func (p *parser) newListLiteralStart(pos plToken.Pos) *ast.Node { + return ast.WrapListInitExpr(&ast.ListLiteral{ List: []*ast.Node{}, LBracket: p.posCache.LnCol(pos), }) } -func (p *parser) newListInitAppendExpr(initExpr *ast.Node, elem *ast.Node) *ast.Node { - if initExpr.NodeType != ast.TypeListInitExpr { +func (p *parser) newListLiteralAppendExpr(initExpr *ast.Node, elem *ast.Node) *ast.Node { + if initExpr.NodeType != ast.TypeListLiteral { p.addParseErrf(p.yyParser.lval.item.PositionRange(), - "%s object is not ListInitExpr", initExpr.NodeType) + "%s object is not ListLiteral", initExpr.NodeType) return nil } - initExpr.ListInitExpr.List = append(initExpr.ListInitExpr.List, elem) + initExpr.ListLiteral().List = append(initExpr.ListLiteral().List, elem) return initExpr } -func (p *parser) newListInitEndExpr(initExpr *ast.Node, pos plToken.Pos) *ast.Node { - if initExpr.NodeType != ast.TypeListInitExpr { +func (p *parser) newListLiteralEnd(initExpr *ast.Node, pos plToken.Pos) *ast.Node { + if initExpr.NodeType != ast.TypeListLiteral { p.addParseErrf(p.yyParser.lval.item.PositionRange(), - "%s object is not ListInitExpr", initExpr.NodeType) + "%s object is not ListLiteral", initExpr.NodeType) return nil } - initExpr.ListInitExpr.RBracket = p.posCache.LnCol(pos) + initExpr.ListLiteral().RBracket = p.posCache.LnCol(pos) return initExpr } -func (p *parser) newMapInitStartExpr(pos plToken.Pos) *ast.Node { - return ast.WrapMapInitExpr(&ast.MapInitExpr{ +func (p *parser) newMapLiteralStart(pos plToken.Pos) *ast.Node { + return ast.WrapMapLiteral(&ast.MapLiteral{ KeyValeList: [][2]*ast.Node{}, LBrace: p.posCache.LnCol(pos), }) } -func (p *parser) newMapInitAppendExpr(initExpr *ast.Node, keyNode *ast.Node, valueNode *ast.Node) *ast.Node { - if initExpr.NodeType != ast.TypeMapInitExpr { +func (p *parser) newMapLiteralAppendExpr(initExpr *ast.Node, keyNode *ast.Node, valueNode *ast.Node) *ast.Node { + if initExpr.NodeType != ast.TypeMapLiteral { p.addParseErrf(p.yyParser.lval.item.PositionRange(), - "%s object is not MapInitExpr", initExpr.NodeType) + "%s object is not MapLiteral", initExpr.NodeType) return nil } - initExpr.MapInitExpr.KeyValeList = append(initExpr.MapInitExpr.KeyValeList, + initExpr.MapLiteral().KeyValeList = append(initExpr.MapLiteral().KeyValeList, [2]*ast.Node{keyNode, valueNode}) return initExpr } -func (p *parser) newMapInitEndExpr(initExpr *ast.Node, pos plToken.Pos) *ast.Node { - if initExpr.NodeType != ast.TypeMapInitExpr { +func (p *parser) newMapLiteralEnd(initExpr *ast.Node, pos plToken.Pos) *ast.Node { + if initExpr.NodeType != ast.TypeMapLiteral { p.addParseErrf(p.yyParser.lval.item.PositionRange(), - "%s object is not MapInitExpr", initExpr.NodeType) + "%s object is not MapLiteral", initExpr.NodeType) return nil } - initExpr.MapInitExpr.RBrace = p.posCache.LnCol(pos) + initExpr.MapLiteral().RBrace = p.posCache.LnCol(pos) return initExpr } @@ -299,7 +299,7 @@ func (p *parser) newForInStmt(inExpr *ast.Node, body *ast.BlockStmt, forTk Item) switch inExpr.NodeType { //nolint:exhaustive case ast.TypeInExpr: - expr = inExpr.InExpr + expr = inExpr.InExpr() default: p.addParseErrf(p.yyParser.lval.item.PositionRange(), "%s object is not identifier", inExpr.NodeType) return nil @@ -380,15 +380,15 @@ func (p *parser) newUnaryExpr(op Item, r *ast.Node) *ast.Node { switch r.NodeType { case ast.TypeFloatLiteral: if op.Typ == SUB { - r.FloatLiteral.Val = -r.FloatLiteral.Val + r.FloatLiteral().Val = -r.FloatLiteral().Val } - r.FloatLiteral.Start = p.posCache.LnCol(op.Pos) + r.FloatLiteral().Start = p.posCache.LnCol(op.Pos) return r case ast.TypeIntegerLiteral: if op.Typ == SUB { - r.IntegerLiteral.Val = -r.IntegerLiteral.Val + r.IntegerLiteral().Val = -r.IntegerLiteral().Val } - r.IntegerLiteral.Start = p.posCache.LnCol(op.Pos) + r.IntegerLiteral().Start = p.posCache.LnCol(op.Pos) return r } } @@ -431,12 +431,12 @@ func (p *parser) newArithmeticExpr(l, r *ast.Node, op Item) *ast.Node { case DIV, MOD: // div 0 or mod 0 switch r.NodeType { //nolint:exhaustive case ast.TypeFloatLiteral: - if r.FloatLiteral.Val == 0 { + if r.FloatLiteral().Val == 0 { p.addParseErrf(p.yyParser.lval.item.PositionRange(), "division or modulo by zero") return nil } case ast.TypeIntegerLiteral: - if r.IntegerLiteral.Val == 0 { + if r.IntegerLiteral().Val == 0 { p.addParseErrf(p.yyParser.lval.item.PositionRange(), "division or modulo by zero") return nil } @@ -482,14 +482,14 @@ func (p *parser) newIndexExpr(obj *ast.Node, lBracket Item, index *ast.Node, rBr switch obj.NodeType { //nolint:exhaustive case ast.TypeIdentifier: return ast.WrapIndexExpr(&ast.IndexExpr{ - Obj: obj.Identifier, Index: []*ast.Node{index}, + Obj: obj.Identifier(), Index: []*ast.Node{index}, LBracket: []plToken.LnColPos{p.posCache.LnCol(lBracket.Pos)}, RBracket: []plToken.LnColPos{p.posCache.LnCol(rBracket.Pos)}, }) case ast.TypeIndexExpr: - obj.IndexExpr.Index = append(obj.IndexExpr.Index, index) - obj.IndexExpr.LBracket = append(obj.IndexExpr.LBracket, p.posCache.LnCol(lBracket.Pos)) - obj.IndexExpr.RBracket = append(obj.IndexExpr.RBracket, p.posCache.LnCol(rBracket.Pos)) + obj.IndexExpr().Index = append(obj.IndexExpr().Index, index) + obj.IndexExpr().LBracket = append(obj.IndexExpr().LBracket, p.posCache.LnCol(lBracket.Pos)) + obj.IndexExpr().RBracket = append(obj.IndexExpr().RBracket, p.posCache.LnCol(rBracket.Pos)) return obj default: p.addParseErrf(p.yyParser.lval.item.PositionRange(), @@ -503,7 +503,7 @@ func (p *parser) newCallExpr(fn *ast.Node, args []*ast.Node, lParen, rParen Item switch fn.NodeType { //nolint:exhaustive case ast.TypeIdentifier: - fname = fn.Identifier.Name + fname = fn.Identifier().Name default: p.addParseErrf(p.yyParser.lval.item.PositionRange(), fmt.Sprintf("invalid fn name object type %s", fn.NodeType)) @@ -511,7 +511,7 @@ func (p *parser) newCallExpr(fn *ast.Node, args []*ast.Node, lParen, rParen Item } f := &ast.CallExpr{ Name: fname, - NamePos: fn.Identifier.Start, + NamePos: fn.Identifier().Start, LParen: p.posCache.LnCol(lParen.Pos), RParen: p.posCache.LnCol(rParen.Pos), } diff --git a/vendor/modules.txt b/vendor/modules.txt index f757009c0e..66ed98fe3c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -37,7 +37,7 @@ github.com/DataDog/sketches-go/ddsketch/mapping github.com/DataDog/sketches-go/ddsketch/pb/sketchpb github.com/DataDog/sketches-go/ddsketch/stat github.com/DataDog/sketches-go/ddsketch/store -# github.com/GuanceCloud/cliutils v1.1.21-0.20240820061659-b3501c0f2e71 +# github.com/GuanceCloud/cliutils v1.1.21-0.20240821062850-3079bb7ed98d ## explicit; go 1.19 github.com/GuanceCloud/cliutils github.com/GuanceCloud/cliutils/dialtesting @@ -99,7 +99,7 @@ github.com/GuanceCloud/kubernetes/pkg/probe/exec # github.com/GuanceCloud/mdcheck v0.0.0-20230718065937-44c6728c995f ## explicit; go 1.18 github.com/GuanceCloud/mdcheck/check -# github.com/GuanceCloud/platypus v0.2.9 +# github.com/GuanceCloud/platypus v0.2.10-0.20240815092339-21f3924850ee ## explicit; go 1.19 github.com/GuanceCloud/platypus/internal/logger github.com/GuanceCloud/platypus/pkg/ast