< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java

Print this page

        

@@ -82,12 +82,12 @@
         }
 
         key = new TokenKind[maxKey+1];
         for (int i = 0; i <= maxKey; i++) key[i] = TokenKind.IDENTIFIER;
         for (TokenKind t : TokenKind.values()) {
-            if (t.name != null)
-            key[tokenName[t.ordinal()].getIndex()] = t;
+            if (t.name != null && !t.reserved())
+                key[tokenName[t.ordinal()].getIndex()] = t;
         }
     }
 
     private void enterKeyword(String s, TokenKind token) {
         Name n = names.fromString(s);

@@ -224,10 +224,14 @@
         PERCENTEQ("%="),
         LTLTEQ("<<="),
         GTGTEQ(">>="),
         GTGTGTEQ(">>>="),
         MONKEYS_AT("@"),
+        VAR("var", Tag.RESERVED),
+        RECORD("record", Tag.RESERVED),
+        SEALED("sealed", Tag.RESERVED),
+        PERMITS("permits", Tag.RESERVED),
         CUSTOM;
 
         public final String name;
         public final Tag tag;
 

@@ -274,10 +278,14 @@
             default:
                 return name;
             }
         }
 
+        public boolean reserved() {
+            return tag == Tag.RESERVED;
+        }
+
         public String getKind() {
             return "Token";
         }
 
         public String toString(Locale locale, Messages messages) {

@@ -313,11 +321,12 @@
         /** tags constants **/
         enum Tag {
             DEFAULT,
             NAMED,
             STRING,
-            NUMERIC
+            NUMERIC,
+            RESERVED;
         }
 
         /** The token kind */
         public final TokenKind kind;
 
< prev index next >