opencypher / openCypher

Specification of the Cypher property graph query language
http://www.opencypher.org
Apache License 2.0
853 stars 150 forks source link

ID_Start and ID_Continue specification and regular expression #331

Open flip111 opened 5 years ago

flip111 commented 5 years ago

I'm looking at this https://github.com/opencypher/openCypher/blob/a514465ca5f1f975985c28d1c9db03c111791671/grammar/basic-grammar.xml#L718-L740 well actually the EBNF version that can be downloaded from the website (The legacy one).

How should i implement this? When you look for unicode ID_Start there a jungle of documentation. But i only need the regex of this. Fortunately unicode has made a tool for this https://unicode.org/cldr/utility/regex.jsp?a=%5B%3AID_Start%3A%5D&b=

That leaves the question what about And extended with a few characters?

So perhaps to clear up this section of the spec some of the following could be done:

  1. Specify the "extended few characters"
  2. Give regular expression in the comments.
  3. Links to the unicode tools.

I think the unicode tool gives the regular expression in some standard regex format, but there can be other engines like PCRE which can define other shorthand classes which could be used instead. Therefor it can be useful to include regular expressions in comments.

Mats-SX commented 5 years ago

I believe it is the Pc and Sc classes that are referred to when it says a few characters. So it's ID_Start plus Pc for IdentifierStart and ID_Continue plus Sc for IdentifierPart.

You can check this code for the model's definition of these constructs (derived from Unicode):

https://github.com/opencypher/openCypher/blob/4a2896e46b5a1ebbe52109c0decf249e7d96eacd/tools/grammar/src/main/java/org/opencypher/grammar/CharacterSet.java#L310-L314

flip111 commented 5 years ago

Will it be acceptable to change anything in the comments of the xml ?

Mats-SX commented 5 years ago

Sure, but please note that in order to accept contributions there is a CLA that must be signed.

flip111 commented 5 years ago

Ah ok, thank you for the notice. I won't sign anything so i won't make PR's here. If this isn't important for anyone else, this issue can be closed. Hopefully for other people they will be able to find this issue to get the information that is not (yet) in the xml ..

Mats-SX commented 5 years ago

I'll keep it open for a bit to see if someone (like me) decides to improve the comment, and will close at that point (or before if nothing happens).