-
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
ANTLR4 grammar - JavaScript - Issues with quotes and comments #392
Comments
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 All the best |
Hi Mats, Thanks for your reply. I've uploaded a copy of my modified ANTLR grammar to: The main points are:
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
The text was updated successfully, but these errors were encountered: