Open kenwebb opened 4 years ago
Hello Ken and thanks for your report.
This is very odd. In our tests we are only using the Java target for testing the generated parser. It is able to parse your example queries just fine -- I wonder if there is some issue with JavaScript that we are not taking into account.
Which content edits did you perform in order to address the issue? I am not very familiar with JavaScript myself, so I don't know by heart if '
, "
or other characters require some specific treatment to be handled correctly (given that my hypothesis on JavaScript is correct).
All the best Mats
Hi Mats,
Thanks for your reply. I've uploaded a copy of my modified ANTLR grammar to: Cypher.g4 If you look at the History, you can see how my version differs from the official openCypher file.
The main points are:
StringLiteral : '"' ( '\\"' | . )*? '"' ;
COMMENT
: '/*' .*? '*/' -> skip
;
LINE_COMMENT
: '//' .*? '\r'? '\n' -> skip
;
I can't really speculate on exactly why my version works. My knowledge of ANTLR is limited. I decided to try substituting content from the grammar for DOT because I know that that grammar worked for me.
I program in Java and JavaScript, often both at the same time. I can't think off-hand of any specific difference that might be relevant here. Both languages use the same single line and multi-line comment characters. Java strings are delimited by double quotes, while JavaScript allows matching single or double quotes. Cypher looks pretty much the same as JavaScript in terms of comments and String quotes.
Ken
Hello @kenwebb and thanks for reaching back.
I will leave this topic here for now, but this is a useful point to pick up from when we next plan work on the openCypher grammar.
I'm also wondering what that problem was.
Hi,
I have downloaded the ANTLR4 grammar from:
I am able to process Cypher.g4 (JavaScript):
Antlr correctly generates five files:
My example web page (.html) includes the following JavaScript code:
In this simple example CREATE (fgh {ijk: 123.4}), I then process the Cypher tree and get the results that I expect (it creates a new node in my application).
BUT, it fails to work with any Cypher statement that contains single quotes (ex: 'abc'), double quotes (ex: "def"), or comments (ex: // this is a comment). For example:
or
ErrorListener.js (part of the ANTLR4 distribution) reports (in the browser console window):
I have developed a temporary work-around by replacing content in Cypher.g4 with content from DOT.g4 (Graphviz dot language), which is included with the ANTLR4 distribution. This lets me handle comments and double-quotes in openCypher, and allows me to continue exploring whether or not I will be able to use openCypher.
I hope this description of the issues I have found will be helpful, Ken Webb