-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Simplify the cql2-text grammar (future version improvements?) #705
Comments
Meeting 2022-06-20: It would be good to understand why this would result in an easier implementation. We need to discuss this in a meeting when @jerstlouis is present. |
Thanks @cportele . I should be attending the next meeting in a couple weeks. As a summary, from a syntactic point of view, I think the two things I suggested above would result in fewer grammar rules (simpler grammar), and parser node classes would be a more direct / natural match to the rules. We would implement the function/operator name validation / data types checking separately from the parsing, since some of it is only known at runtime (e.g., available functions, queryable data types). e.g., in our implementation we have a CQL2CallExp node class which we plan to use to handle the array / spatial / temporal operators which syntactically look like function calls. We are hand-writing a Recursive Descent parser, borrowing heavily from our ECCSS/CMSS parser. |
The following excerpt from our internal CQL2 design document mapping CQL2 conformance classes and providing a concise summary of the CQL2 syntax might be insightful. A simpler grammar could potentially closely match those Basic CQL2
Property-Property
Arithmetic Expressions
Advanced Comparison Operators
Functions
Case-insensitive Comparison
Accent-insensitive Comparison
Basic Spatial Operators
Spatial Operators
Temporal Operators
Array Operators
|
See first draft of proposed simpler grammar rules in #723 (comment). |
Note that in the approach I suggest in defining the grammar production rules, operators / functions are not really keywords, but regular identifiers used in function call expressions (or spatial/literal/array literals definitions using same syntax as function calls). For example, this means that a In my opinion this makes it much easier to extend the language with additional functions / operators, since those additions would not introduce additional keywords that break implementations not previously requiring queryables with the same name to be double-quoted. The list of keywords in 8.2 (which would need to be double-quoted, if allowed at all) would be reduced to:
All of the other ones would get tokenized by the lexer as an identifier which can be used as operators/function calls, or to define literals and only get resolved in the contexts where they apply. This is the approach taken in C-like languages where standard functions and data types/structs (or classes in C++) are not classified as keywords. Also note that SQL keywords (or "reserved" words) do not seem to include any function-like keywords either. Things like |
See somewhat related comment here: opengeospatial#705 (comment) that led me to this discovery.
See the CartoSym-CSS BNF lexer / grammar for ANTLR4 which should (in theory) be a true superset of CQL2: The starting rule for CQL2 is When I have a chance I will extract only the CQL2 relevant part. |
This is feedback from trying to implement cql2-text.
Implementers (or at least us) face struggles with the current grammar.
I think it comes down mainly to these two things:
I think simplifying these two aspects of the grammar would directly result in simpler parser implementations, greater ease of implementation and greater interoperability.
The text was updated successfully, but these errors were encountered: