couchbaselabs / gojsonsm

Go implementation of my JSONSM algorithm.
9 stars 7 forks source link

Rewrite parser using BNF or other grammar grammar #20

Open brett19 opened 6 years ago

brett19 commented 6 years ago

There was a request that we rewrite the grammer into something more cross-platform so that it can be shared among the various implementations of JSONSM.

brett19 commented 6 years ago

I don't think this is a hard requirement and is considered more a case of code maintainability optimization. It's definitely something to look into, but it shouldn't be taken as a priority at this time.

brett19 commented 6 years ago

I started a bit of an experiment using BNF and gocc's lexer/parser generator:

Brett Lawson: 2018/07/18 04:07:21 Parsing: `name.first == 'Neil' && (isActive == true)` Brett Lawson: 2018/07/18 04:07:21 Result: (PredicateExpr) (ComparisonExpr) == | (FieldRef)name.first | (Literal)Neil && (ComparisonExpr) == | (FieldRef)isActive | (Literal)true` Brett Lawson: (made a little demo of an EBNF-based grammer lexer/parser) Brett Lawson: https://gist.github.com/brett19/9030d72afb6f063259aefda7aaf68ab1

brett19 commented 6 years ago

It appears that @dnault has begun a bit of the work on this using ANTLR4 for Javueh:

David Nault: Here's the Antlr4 grammar used by the Java implementation: https://github.com/couchbaselabs/java-jsonsm/blob/master/src/main/antlr/com/couchbase/jsonsm/JsonSm.g4 David Nault: Listener and driver are here: https://github.com/couchbaselabs/java-jsonsm/tree/master/src/main/java/com/couchbase/jsonsm/internal/grammar