Преглед изворни кода

+ list of keywords that are reserved in Java and the JVM, for future
checking by the parser

git-svn-id: branches/jvmbackend@18312 -

Jonas Maebe пре 14 година
родитељ
комит
20c577103f
1 измењених фајлова са 91 додато и 1 уклоњено
  1. 91 1
      compiler/tokens.pas

+ 91 - 1
compiler/tokens.pas

@@ -591,9 +591,82 @@ const
   );
 
 
+{$ifdef jvm}
+  { reserved JVM tokens: keywords, true/false, and "null"; the commented out
+    ones are also Pascal keywords in all modes }
+  njvmtokens = 40;
+  jvmreservedwords: array[1..njvmtokens] of string[12] =
+  (
+//    'DO',
+//    'IF',
+//    'FOR',
+    'INT',
+    'NEW',
+    'TRY',
+    'BYTE',
+//    'CASE',
+    'CHAR',
+//    'ELSE',
+//    'GOTO',
+    'LONG',
+    'NULL',
+    'THIS',
+    'VOID',
+    'BREAK',
+    'CATCH',
+    'CLASS',
+//    'CONST',
+    'FINAL',
+    'FLOAT',
+    'SHORT',
+    'SUPER',
+    'THROW',
+//    'WHILE',
+    'DOUBLE',
+    'IMPORT',
+    'NATIVE',
+    'PUBLIC',
+    'RETURN',
+    'STATIC',
+    'SWITCH',
+    'THROWS',
+    'BOOLEAN',
+    'DEFAULT',
+    'EXTENDS',
+    'FINALLY',
+    'PACKAGE',
+    'PRIVATE',
+    'ABSTRACT',
+    'CONTINUE',
+    'STRICTFP',
+    'VOLATILE',
+//    'INTERFACE',
+    'PROTECTED',
+    'TRANSIENT',
+    'IMPLEMENTS',
+    'INSTANCEOF',
+    'SYNCHRONIZED'
+  );
+
+  jvmtokenlenmin = 3;
+  jvmtokenlenmax = 12;
+
+type
+  tjvmtokenidxrec = record
+    first, last: longint;
+  end;
+  tjmvtokenarray=array[1..njvmtokens] of string[12];
+  pjvmtokenidx= ^tjvmtokenidx;
+  tjvmtokenidx=array[jvmtokenlenmin..jvmtokenlenmax] of tjvmtokenidxrec;
+{$endif jvm}
+
 var
   tokeninfo:ptokenarray;
   tokenidx:ptokenidx;
+{$ifdef jvm}
+  jvmtokenidx: pjvmtokenidx;
+{$endif jvm}
+
 
 procedure inittokens;
 procedure donetokens;
@@ -607,7 +680,7 @@ procedure create_tokenidx;
   length, so a search only will be done in that small part }
 var
   t : ttoken;
-  i : longint;
+  i, j : longint;
   c : char;
 begin
   fillchar(tokenidx^,sizeof(tokenidx^),0);
@@ -622,6 +695,16 @@ begin
         tokenidx^[i,c].last:=t;
       end;
    end;
+{$ifdef jvm}
+  fillchar(jvmtokenidx^,sizeof(jvmtokenidx^),0);
+  for j:=low(jvmreservedwords) to high(jvmreservedwords) do
+   begin
+     i:=length(jvmreservedwords[j]);
+     if jvmtokenidx^[i].first=0 then
+      jvmtokenidx^[i].first:=j;
+     jvmtokenidx^[i].last:=j;
+   end;
+{$endif jvm}
 end;
 
 
@@ -631,6 +714,9 @@ begin
   begin
     tokeninfo:=@arraytokeninfo;
     new(tokenidx);
+{$ifdef jvm}
+    new(jvmtokenidx);
+{$endif jvm}
     create_tokenidx;
   end;
 end;
@@ -643,6 +729,10 @@ begin
     tokeninfo:=nil;
     dispose(tokenidx);
     tokenidx:=nil;
+{$ifdef jvm}
+    dispose(jvmtokenidx);
+    jvmtokenidx:=nil;
+{$endif jvm}
   end;
 end;