go-toolsmith / astp

Package astp provides AST predicates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

astp

build-img pkg-img reportcard-img version-img

Package astp provides AST predicates.

Installation:

Go version 1.16+

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

License

MIT License.

About

Package astp provides AST predicates.

License:MIT License


Languages

Language:Go 100.0%