Golang Go parser for the Bule Language.
package main
import (
"log"
"os"
"github.com/udhos/gobule/parser"
)
func main() {
vars := map[string]interface{}{
"platform": "android",
}
envDebug := os.Getenv("DEBUG")
debug := envDebug != ""
log.Printf("DEBUG=[%s] debug=%v", envDebug, debug)
result := parser.RunString("platform = 'android'", vars, debug)
if result.IsError() {
log.Printf("ERROR status=%d errors=%d last_error: [%s]\n", result.Status, result.Errors, result.LastError)
return
}
log.Printf("result: %v", result.Eval)
}
Use this recipe if you need to build the parser for development.
git clone https://github.com/udhos/gobule
cd gobule
go generate ./parser ;# generate parser
go test ./parser ;# run tests
go install ./parser ;# build
https://github.com/johnowl/owl-rules
go get modernc.org/goyacc
https://gitlab.com/cznic/goyacc
go get golang.org/x/tools/cmd/goyacc