Scala Programming Language
  1. Scala Programming Language
  2. SI-6478

JavaTokenParser.ident doesn't correctly parse Java identifiers

    Details

      Description

      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

        Activity

        Hide
        James Roper added a comment -
        Show
        James Roper added a comment - Pull request here: https://github.com/scala/scala/pull/1466
        Hide
        Jean-Remi Desjardins added a comment -

        I see the pull request got merged.

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

        Show
        Jean-Remi Desjardins added a comment - I see the pull request got merged. If the bug has been fixed we might want to go ahead and close this.
        Hide
        Adriaan Moors added a comment -

        reopening for 2.10.1-RC1 backport

        Show
        Adriaan Moors added a comment - reopening for 2.10.1-RC1 backport
        Show
        James Iry added a comment - https://github.com/scala/scala/pull/2091

          People

          • Assignee:
            James Iry
            Reporter:
            James Roper
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development