openCypher icon indicating copy to clipboard operation
openCypher copied to clipboard

ID_Start and ID_Continue specification and regular expression

Open flip111 opened this issue 7 years ago • 5 comments

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.

flip111 avatar Oct 18 '18 12:10 flip111

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

Mats-SX avatar Oct 18 '18 14:10 Mats-SX

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

flip111 avatar Oct 18 '18 16:10 flip111

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

Mats-SX avatar Oct 19 '18 07:10 Mats-SX

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 ..

flip111 avatar Oct 19 '18 15:10 flip111

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).

Mats-SX avatar Oct 19 '18 15:10 Mats-SX