blob: 7313c6ab8ee9cef157bfeede56a176b089c1e8d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
[](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")
}
}
```
|