-
Notifications
You must be signed in to change notification settings - Fork 740
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
Add a Cypher (Neo4j) lexer #1423
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mogztter Sorry it's taken such a long time to get to this. Since it's been here for so long, I took the liberty of making the changes myself rather than just ask you to do it. I did have two questions to which I wasn't sure of the answers.
If anything is unclear, let me know!
Your edits look great, thanks! 👌 |
Co-Authored-By: Michael Camilleri <mike@inqk.net>
Co-Authored-By: Michael Camilleri <mike@inqk.net>
@pyrmont I've merged your edits since number can be negative. Please let me know if there anything else that needs to be fixed. |
@Mogztter I just tested with the code sample |
@pyrmont I will also have a look 🧐 |
The MERGE (p)-[:DIRECTED]->(m)
RETURN [(a)-->(b) WHERE b:Movie | b.released] AS years
MATCH (joe { name: 'Joe' })-[:knows*2..2]-(friend_of_friend) But also as a math operator: [x IN Released | date().year - x + 1] AS YearsAgo (not sure if the space is mandatory or if we can write And in number literal: RETURN sign(-17), sign(0.1) Interestingly, the current highlighter in https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-sign ignores the |
Yes, it's treated different in the cypher parser if it's part of a pattern see the grammars here: https://www.opencypher.org/resources |
Thanks @jexp that's very valuable!
The answer from the EBNF is no, the space is not mandatory:
|
@Mogztter I added some rules for numbers. Let me know what you think. |
@pyrmont That's great thanks Michael! Unless I'm missing something in the grammar,
I think we should also add the Unicode symbols for dash, right arrow head and left arrow head no?
Should we add the unicode reference or the symbol? I believe that the unicode reference is easier to edit (but less visual)
|
@Mogztter Yeah, I agree—it doesn't look to me like the grammar specifies negative numbers. I would suggest reverting the changes to the Unicode arrows and dashes. Unless that's actually something that's commonly used in Cypher code, it adds additional overhead to the lexer. Are these characters people use in practice? |
@pyrmont You're right, I've checked with Neo4j and unicode arrows and dashes are not commonly used as it's really hard to input them anyway. I think we are now ready to go? Should I squash my commits? |
This reverts commit f2bbe3c.
@Mogztter Thanks for all your work and, especially, your patience. I realise it took quite a while but it's in master now and will go out in the next version, v3.18.0 :) That's scheduled for release later today! 🎉 |
Yay! Thanks 👍 |
Super, thanks so much @pyrmont and @Mogztter !! <3 |
This commit adds a lexer for Cypher. Co-authored-by: Michael Camilleri <mike@inqk.net>
References:
//cc @jexp @ElaineRosenberg
This fixes #1266.