aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-toolsmith/strparse/strparse.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-01-22 16:07:17 +0100
committerTaras Madan <tarasmadan@google.com>2025-01-23 10:42:36 +0000
commit7b4377ad9d8a7205416df8d6217ef2b010f89481 (patch)
treee6fec4fd12ff807a16d847923f501075bf71d16c /vendor/github.com/go-toolsmith/strparse/strparse.go
parent475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff)
vendor: delete
Diffstat (limited to 'vendor/github.com/go-toolsmith/strparse/strparse.go')
-rw-r--r--vendor/github.com/go-toolsmith/strparse/strparse.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/vendor/github.com/go-toolsmith/strparse/strparse.go b/vendor/github.com/go-toolsmith/strparse/strparse.go
deleted file mode 100644
index 894c7ebac..000000000
--- a/vendor/github.com/go-toolsmith/strparse/strparse.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Package strparse provides convenience wrappers around `go/parser` for simple
-// expression, statement and declaration parsing from string.
-//
-// Can be used to construct AST nodes using source syntax.
-package strparse
-
-import (
- "go/ast"
- "go/parser"
- "go/token"
-)
-
-var (
- // BadExpr is returned as a parse result for malformed expressions.
- // Should be treated as constant or readonly variable.
- BadExpr = &ast.BadExpr{}
-
- // BadStmt is returned as a parse result for malformed statmenents.
- // Should be treated as constant or readonly variable.
- BadStmt = &ast.BadStmt{}
-
- // BadDecl is returned as a parse result for malformed declarations.
- // Should be treated as constant or readonly variable.
- BadDecl = &ast.BadDecl{}
-)
-
-// Expr parses single expression node from s.
-// In case of parse error, BadExpr is returned.
-func Expr(s string) ast.Expr {
- node, err := parser.ParseExpr(s)
- if err != nil {
- return BadExpr
- }
- return node
-}
-
-// Stmt parses single statement node from s.
-// In case of parse error, BadStmt is returned.
-func Stmt(s string) ast.Stmt {
- node, err := parser.ParseFile(token.NewFileSet(), "", "package main;func main() {"+s+"}", 0)
- if err != nil {
- return BadStmt
- }
- fn := node.Decls[0].(*ast.FuncDecl)
- if len(fn.Body.List) != 1 {
- return BadStmt
- }
- return fn.Body.List[0]
-}
-
-// Decl parses single declaration node from s.
-// In case of parse error, BadDecl is returned.
-func Decl(s string) ast.Decl {
- node, err := parser.ParseFile(token.NewFileSet(), "", "package main;"+s, 0)
- if err != nil || len(node.Decls) != 1 {
- return BadDecl
- }
- return node.Decls[0]
-}