-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem parsing oC_MultiPartQuery with ANTLR4 #508
Comments
Hi Daniel, thanks for your question and for using the openCypher artifacts. I understand, you have some trouble consuming the parsing result from Antlr. I am not an Antlr expert by any means. According to my thin understanding, the parser gives you a parse tree back, which contains all the necessary information. The tree knows the order in which the grammar rules have parse which parts of the input. This information clear allows to decide to which MATCH clause a pattern belongs and if that MATCH clause appears before or after a WITH clause. A sample output of the parse tree for your query looks like this:
I have written some demo code for how to use the Antlr parser (which produced the above output). See PR #518. There are two ways to consume the parse tree: Either with a tree listener or by manually walking the tree structure. I guess, the first is preferable. There are two ways get the parser: Either you build directly from the g4 grammar published on the oC webpage or you create the parser from the grammar xml files in this repository (which generate the g4 grammar as an intermediate step). I guess, the first is preferable. The demo shows all four possible combination of these options. |
Hi hvub, I am very sorry, I obviously messed up the example. Therefore, I created repository https://github.com/dahoat/OpenCypherExperiments with an running example (Maven/Spring). I also have to mention, I am using The query MATCH (a) WITH a MATCH (b) SET a.prop = 'match 2' WITH a, b MATCH (c) WITH a, b, c MATCH (d) RETURN * is a much better example to my problem. All the best, |
Hi Daniel, I have modified your visitor here Hope it helps. |
Hi to all,
I am using the ANTLR4 grammar in version M16 (https://s3.amazonaws.com/artifacts.opencypher.org/M16/Cypher.g4) and have an issue with
oC_MultiPartQuery
:In the grammar, it says:
To my understanding, it is therefore possible to write something like this
However, in the ANTLR4 parser (Java), i only get
List<oC_ReadingClause>
,List<oC_UpdatingClause>
andList<oC_With>
. Therefore, I cannot distinguish whether(e:Label3 {name: c.name})
belongs before which entry inList<oC_With>
or after any entry.Therfore, I propose changing the grammar to something like
I am no expert in grammars so please excuse me if I missed something here.
All the best,
Daniel
The text was updated successfully, but these errors were encountered: