dnscrypt-proxy/vendor/github.com/go-toolsmith/astp
Frank Denis 5a091c6da4 Update deps 2021-07-03 10:56:53 +02:00
..
.gitignore Update deps 2021-07-03 10:56:53 +02:00
.travis.yml Update deps 2021-07-03 10:56:53 +02:00
LICENSE Update deps 2021-07-03 10:56:53 +02:00
README.md Update deps 2021-07-03 10:56:53 +02:00
decl.go Update deps 2021-07-03 10:56:53 +02:00
expr.go Update deps 2021-07-03 10:56:53 +02:00
go.mod Update deps 2021-07-03 10:56:53 +02:00
go.sum Update deps 2021-07-03 10:56:53 +02:00
stmt.go Update deps 2021-07-03 10:56:53 +02:00

README.md

Go Report Card GoDoc Build Status

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")
	}
}