couchbaselabs / gojsonsm

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

Fixes #111: Reorganize FilterExpressionParser grammar to allow recurs… #112

Closed nelio2k closed 5 years ago

nelio2k commented 5 years ago

…ive parsing of parenthesis

Previous grammar led to incorrectly parsed logic With the new logic, it should output the correct AST based on correctly parsing all of the parenthesis

Example output:

(country == "United States" OR country = "Canada" AND type="brewery") OR (type="beer" AND DATE(updated) >= DATE("2019-01-18"))

ND Entry:
( country = United States OR country = Canada AND type = brewery ) OR ( type = beer AND DATE( updated ) >= DATE( 2019-01-18 ) )
ND ActualOutput:
    $doc.country = United States
  OR
      $doc.country = Canada
    AND
      $doc.type = brewery
OR
    $doc.type = beer
  AND
    func:date($doc.updated) >= func:date(2019-01-18)

and

((country == "United States" OR country = "Canada") AND type="brewery") OR (type="beer" AND DATE(updated) >= DATE("2019-01-18"))

ND Entry:
( ( county = United States OR country = Canada ) AND type = brewery ) OR ( type = beer AND DATE( updated ) >= DATE( 2019-01-01 ) )
ND ActualOutput:
      $doc.county = United States
    OR
      $doc.country = Canada
  AND
    $doc.type = brewery
OR
    $doc.type = beer
  AND
    func:date($doc.updated) >= func:date(2019-01-01)
nelio2k commented 5 years ago

Latest push - fixed grammar to ensure it is recursive descendent.