hg: lambda/lambda/langtools: Fix: generalize parser treatment of keyword as identifiers

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Jan 14 00:51:46 PST 2013


On 12/01/13 11:42, bitter_fox wrote:
>
> Hi, Maurizio.
>
> Thank you for your fix.
>
> However there is a new problem. It is about package private enum.
> The compiler has to consider it as a declaration of package private enum:
>
> package enum E
> {
>     ...
> }
>
> However the compiler considers it as a declaration of package and 
> makes a compiler error.
>
> I think the condition expression for PACKAGE ... in 
> JavacParser#parseCompilationUnit would be such as:
Nicely spotted - we can use another OR filter to lookahead something like:

peekToken(EXT_IDENTIFIER, OR(SEMI, DOT)) ...

Maurizio
>
>          if (token.kind == PACKAGE) {
> -            if (peekToken(EXT_IDENTIFIER)) {
> +            if (peekToken(EXT_IDENTIFIER) && !(allowPackageModifier 
> && peekToken(ENUM))) {
>                  seenPackage = true;
>                  if (mods != null) {
>                      checkNoMods(mods.flags);
>
> or
>
> @@ -2692,7 +2692,7 @@
>              mods = modifiersOpt(true);
>
>          if (token.kind == PACKAGE) {
> -            if (peekToken(EXT_IDENTIFIER)) {
> +            if (peekToken(EXT_IDENTIFIER, DOT) || 
> peekToken(EXT_IDENTIFIER, SEMI)) {
>                  seenPackage = true;
>                  if (mods != null) {
>                      checkNoMods(mods.flags);
>
> Regards,
> bitter_fox
>
>
> 2013/1/9 <maurizio.cimadamore at oracle.com 
> <mailto:maurizio.cimadamore at oracle.com>>
>
>     Changeset: 867db5e69121
>     Author:    mcimadamore
>     Date:      2013-01-09 11:43 +0100
>     URL:
>     http://hg.openjdk.java.net/lambda/lambda/langtools/rev/867db5e69121
>
>     Fix: generalize parser treatment of keyword as identifiers
>
>     ! src/share/classes/com/sun/tools/javac/parser/JavacParser.java
>     ! src/share/classes/com/sun/tools/javac/parser/Tokens.java
>     ! test/tools/javac/lambda/WarnUnderscoreAsIdent.java
>     ! test/tools/javac/lambda/WarnUnderscoreAsIdent.out
>
>
>



More information about the lambda-dev mailing list