mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-28 09:06:43 +00:00
39 lines
861 B
Markdown
39 lines
861 B
Markdown
[](https://goreportcard.com/report/github.com/go-toolsmith/astp)
|
|
[](https://godoc.org/github.com/go-toolsmith/astp)
|
|
[](https://travis-ci.org/go-toolsmith/astp)
|
|
|
|
|
|
# astp
|
|
|
|
Package astp provides AST predicates.
|
|
|
|
## Installation:
|
|
|
|
```bash
|
|
go get github.com/go-toolsmith/astp
|
|
```
|
|
|
|
## Example
|
|
|
|
```go
|
|
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")
|
|
}
|
|
}
|
|
```
|