opengeospatial / ogcapi-features

An open standard for querying geospatial information on the web.
https://ogcapi.ogc.org/features
Other
341 stars 85 forks source link

Simplify scalar expression #914

Closed cportele closed 8 months ago

cportele commented 8 months ago

When updating our CQL2 implementation to the current grammar, an issue was reported by ANTLR. ANTLR rejected the scalarExpression rule due to left recursion. The current rule is:

scalarExpression = characterClause
                 | numericLiteral
                 | instantInstance
                 | arithmeticExpression
                 | booleanExpression
                 | propertyName
                 | function;

The problem is the use of booleanExpression which is any CQL2 expression. All other options are comprised only of literals, property references or functions. It is also unclear why we included booleanExpression instead of booleanLiteral like for the other data types.

scalarExpression is used in binaryComparisonPredicate and isInListPredicate, so as a result, booleanExpression can be used as an operand with the following operators:

As a consequence, booleanExpression should be replaced by booleanLiteral to simplify the implementation of CQL2 (without loosing expressiveness).

I discussed this with @pvretano and we decided to implement the change. I will create a PR and merge it. If there are any concerns about this change, please let us know before the Features API SWG meeting this Wednesday at 3:30pm CET, so we can discuss and resolve it there, before the OGC TC Closing Plenary on Thursday this week.