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

JavaTokenParser.ident doesn't correctly parse Java identifiers #6478

Closed
scabug opened this issue Oct 5, 2012 · 5 comments
Closed

JavaTokenParser.ident doesn't correctly parse Java identifiers #6478

scabug opened this issue Oct 5, 2012 · 5 comments

Comments

@scabug
Copy link

@scabug scabug commented Oct 5, 2012

I assume JavaTokenParser.ident is meant to parse all valid Java identifiers? If so, it doesn't. For example, MODULE$ is a valid Java identifier (that Scala itself uses extensively), and this won't parse. Also, Java identifiers can contain unicode characters, so is a valid identifier. Fortunately, Java provides a very simple way to parse Java identifiers, using the following regular expression:

\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*

It uses the Character.isJavaIdentifierStart and Character.isJavaIdentifierPart methods for the first and then subsequent letters, and is guaranteed to match all valid Java identifiers, as long as they don't clash with keywords.

For language spec nuts:

http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8

@scabug
Copy link
Author

@scabug scabug commented Oct 5, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6478?orig=1
Reporter: @jroper
Assignee: @JamesIry
Affected Versions: 2.9.2

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 5, 2012

@jroper said:
Pull request here: scala/scala#1466

Loading

@scabug
Copy link
Author

@scabug scabug commented Nov 15, 2012

@jedesah said:
I see the pull request got merged.

If the bug has been fixed we might want to go ahead and close this.

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 22, 2013

@adriaanm said:
reopening for 2.10.1-RC1 backport

Loading

@scabug
Copy link
Author

@scabug scabug commented Feb 7, 2013

Loading

@scabug scabug closed this Feb 8, 2013
@scabug scabug added this to the 2.10.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant