Skip to content
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

ID_Start and ID_Continue specification and regular expression #331

Open
flip111 opened this issue Oct 18, 2018 · 5 comments
Open

ID_Start and ID_Continue specification and regular expression #331

flip111 opened this issue Oct 18, 2018 · 5 comments

Comments

@flip111
Copy link

flip111 commented Oct 18, 2018

I'm looking at this

<production name="IdentifierStart" rr:inline="true" oc:lexer="true">
<description>
Based on the unicode identifier and pattern syntax
(http://www.unicode.org/reports/tr31/)
And extended with a few characters.
</description>
<alt>
<character set="ID_Start"/>
<character set="Pc"/> <!-- Punctuation connectors (underscores) -->
</alt>
</production>
<production name="IdentifierPart" rr:inline="true" oc:lexer="true">
<description>
Based on the unicode identifier and pattern syntax
(http://www.unicode.org/reports/tr31/)
And extended with a few characters.
</description>
<alt>
<character set="ID_Continue"/>
<character set="Sc"/> <!-- Currency symbols -->
</alt>
</production>
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
Copy link
Member

Mats-SX commented Oct 18, 2018

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

ID_Start( union( Ll.set, Lm.set, Lo.set, Lt.set, Lu.set, Nl.set, Other_ID_Start.set )
.except( Pattern_Syntax.set ).except( Pattern_White_Space.set ) ),
/** Characters allowed in an identifier. http://unicode.org/reports/tr31/ */
ID_Continue( union( ID_Start.set, Mn.set, Mc.set, Nd.set, Pc.set, Other_ID_Continue.set )
.except( Pattern_Syntax.set ).except( Pattern_White_Space.set ) ),;

@flip111
Copy link
Author

flip111 commented Oct 18, 2018

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

@Mats-SX
Copy link
Member

Mats-SX commented Oct 19, 2018

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

@flip111
Copy link
Author

flip111 commented Oct 19, 2018

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
Copy link
Member

Mats-SX commented Oct 19, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants