mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-01 22:31:15 +00:00
c28f7cb29f
Initial part of #435 |
||
---|---|---|
.. | ||
.gitignore | ||
.travis.yml | ||
decl.go | ||
expr.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
README.md | ||
stmt.go |
astp
Package astp provides AST predicates.
Installation:
go get github.com/go-toolsmith/astp
Example
package main
import (
"fmt"
"github.com/go-toolsmith/astp"
"github.com/go-toolsmith/strparse"
)
func main() {
if astp.IsIdent(strparse.Expr(`x`)) {
fmt.Println("ident")
}
if astp.IsBlockStmt(strparse.Stmt(`{f()}`)) {
fmt.Println("block stmt")
}
if astp.IsGenDecl(strparse.Decl(`var x int = 10`)) {
fmt.Println("gen decl")
}
}