-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance filter parser #41
base: main
Are you sure you want to change the base?
Conversation
941daff
to
080e335
Compare
Have a look at |
2337de5
to
176b442
Compare
fuzz: elapsed: 3m30s, execs: 1483038 (7807/sec), new interesting: 94 (total: 1558)
fuzz: elapsed: 3m33s, execs: 1507525 (8160/sec), new interesting: 94 (total: 1558)
fuzz: elapsed: 3m36s, execs: 1530168 (7550/sec), new interesting: 94 (total: 1558)
fuzz: elapsed: 3m39s, execs: 1553639 (7821/sec), new interesting: 94 (total: 1558)
fuzz: elapsed: 3m42s, execs: 1576623 (7661/sec), new interesting: 94 (total: 1558)
fuzz: elapsed: 3m45s, execs: 1595193 (6190/sec), new interesting: 95 (total: 1559)
fuzz: elapsed: 3m48s, execs: 1609919 (4910/sec), new interesting: 97 (total: 1561)
fuzz: elapsed: 3m51s, execs: 1630670 (6917/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 3m54s, execs: 1648763 (6029/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 3m57s, execs: 1667104 (6113/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 4m0s, execs: 1685923 (6255/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 4m3s, execs: 1704380 (6154/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 4m6s, execs: 1723764 (6479/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 4m9s, execs: 1744018 (6752/sec), new interesting: 99 (total: 1563)
fuzz: elapsed: 4m12s, execs: 1758080 (5418/sec), new interesting: 100 (total: 1564)
--- PASS: FuzzParser (251.66s)
PASS
ok github.com/icinga/noma/internal/filter 251.870s |
089cfc5
to
877a020
Compare
6cbb497
to
67991f2
Compare
8b2c4eb
to
3603283
Compare
1ccb78e
to
e5cd4e2
Compare
e5cd4e2
to
98471a8
Compare
98471a8
to
af89454
Compare
By default, the scanner mode is set to `scanner.GoTokens` which contains way more flags than are actually needed. This commit now sets this to only recognize identifiers and `scanner#Scan()` will return all other unrecognized tokens as they are.
Otherwise the dwarf information of that parser will get messed up - incomplete and one will not be able to step into that source code using a debugger (tested it using delve).
af89454
to
7142584
Compare
After all the testing we did last week, it turns out that the current implementation of the filter
Parser
is very buggy and sometimes crashes with very simple filter strings. This PR solves this by usinggoyacc
generatedParser
. This is similar to how we parse Icinga2DSL
withflex/bison
. The grammar rules can be found in theparser.y
file and you can find theLexer
and other parsing utils in thelexer.go
file.For local testing/debugging purposes you can re-build the parser with the following command.
go env -w GOBIN=/Users/yhabteab/go/bin go install golang.org/x/tools/cmd/goyacc@latest go generate './...'
This will also generate a
parser.output
file which contains all the parser states and is useful to resolve someshift/reduce
conflicts.