https://github.com/jaqx0r/filterexpression
A parser for the AIP-160 filter expression language, implemented in Go
https://github.com/jaqx0r/filterexpression
aip api expression filter go google-aip parser rest
Last synced: 5 months ago
JSON representation
A parser for the AIP-160 filter expression language, implemented in Go
- Host: GitHub
- URL: https://github.com/jaqx0r/filterexpression
- Owner: jaqx0r
- License: apache-2.0
- Created: 2025-11-05T22:28:32.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-03T19:20:58.000Z (7 months ago)
- Last Synced: 2025-12-07T00:52:02.922Z (6 months ago)
- Topics: aip, api, expression, filter, go, google-aip, parser, rest
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# filterexpression
A parser for the [AIP-160 filter expression language](https://google.aip.dev/160) implemented in Go.
The EBNF specification is https://google.aip.dev/assets/misc/ebnf-filtering.txt
This library has minor modifications to the parse tree to avoid ambiguity and simplify Visitor implementations.
```go
import "github.com/jaqx0r/filterexpression"
...
ast, err := filterexpression.Parse(req.filter)
...
```
Visit the AST by implementing the `FilterVisitor` interface.
You can embed the existing `Visitor` as a base, so your implementation only needs to override the methods it cares about.
```go
type Visitor struct {
filtervisitor.Visitor
query query.Builder
}
func (v *Visitor) VisitFunction(ast *filterexpression.Function) error {
query.Function(ast.Name[0])
return nil
}
...
visitor = &Visitor{}
if err := filterexpression.Visit(ast, visitor); err != nil {
log.Errorf("Visit() failed: %v", err)
}
```