els0r / goProbe

High-performance IP packet metadata aggregation and efficient storage and querying of flows
GNU General Public License v2.0
12 stars 4 forks source link

Use ANTLR for condition parsing #247

Open basman opened 11 months ago

basman commented 11 months ago

Looking at the complexity of the parser and the auto completion after we added the direction filter, using ANTLR as a lexer/parser could reduce code complexity.

Pro:

Con:

fako1024 commented 11 months ago

Off the top of my head I think introducing ANTLR as a dependency seems a bit of an overkill to me, for the following reasons:

That being said, I'm of course very opinionated on these things (mostly because of the point of minimizing dependencies, in particular seemingly complex ones like ANTLR) - If someone wants to take a shot at replacing the current lexer (while not introducing any red flags as hinted above), by all means.

@els0r What is your take? Anything to add?

els0r commented 11 months ago

I can totally follow the reasoning to use a grammar parser for the tcpdump-style syntax. Why reinvent the wheel? The support for it was discussed between basman and me previously. As it stands, most NOC engineers are still more familiar with the tcpdump syntax.

So why not support it?

After all, it’s just a subset of the rich query syntax we offer with goquery.

What I see as unreasonable overhead is to try to mold the current grammar into a format that ANTLR can use it. I’m also a burnt child regarding auto-generated code, so let’s proceed in an exploratory fashion and see if it’s worth it.

I don’t feel that strongly about introducing additional dependencies. But only if they don’t increase complexity in the build and later deployment of the software suite. Also, if they drag us back into C-Land, I’m less inclined.

basman commented 10 months ago

Just to complete my initial idea, after playing around with ANTLR. We could generate the parser once and commit the generated go files to the repo. This way we only need ANTLR on the developer's machine when changing the grammar, avoiding another build dependency on build hosts.

basman commented 10 months ago

Still the effort to replace the parser with ANTLR is significant and its not needed.

fako1024 commented 10 months ago

@basman Thanks a lot for putting in the effort and researching the potential impact - if it would only be required on a development machine (and even then only if the parser is touched) that would of course render most of my remarks irrelevant, so I'll leave it in your capable hands to decide whether it's worth the effort or not. If a different syntax makes more people / engineers use the tool then yay!