home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / compilers / p5 / Token.java < prev   
Text File  |  2005-11-01  |  3KB  |  148 lines

  1. // -------------------------- Token ----------------------------
  2. //
  3. // This class encapsulates definitions related to tokens.
  4. // This class is never instantiated.
  5. //
  6. // Harry Porter -- 01/15/03
  7. //
  8.  
  9. class Token {
  10.  
  11.     //
  12.     // Constructor -- This makes creating instances impossible.
  13.     //
  14.     private Token () { }
  15.  
  16.     //
  17.     // Token kinds
  18.     //
  19.     // This list must match the "stringOf" array.
  20.     //
  21.     final static int 
  22.  
  23.         AND          = 0,
  24.         ARRAY        = 1,
  25.         BEGIN        = 2,
  26.         BY           = 3,
  27.         DIV          = 4,
  28.         DO           = 5,
  29.         ELSE         = 6,
  30.         ELSEIF       = 7,
  31.         END          = 8,
  32.         EXIT         = 9,
  33.         FOR          = 10,
  34.         IF           = 11,
  35.         IS           = 12,
  36.         LOOP         = 13,
  37.         MOD          = 14,
  38.         NOT          = 15,
  39.         OF           = 16,
  40.         OR           = 17,
  41.         PROCEDURE    = 18,
  42.         PROGRAM      = 19,
  43.         READ         = 20,
  44.         RECORD       = 21,
  45.         RETURN       = 22,
  46.         THEN         = 23,
  47.         TO           = 24,
  48.         TYPE         = 25,
  49.         VAR          = 26,
  50.         WHILE        = 27,
  51.         WRITE        = 28,
  52.  
  53.         ID           = 29,
  54.         INTEGER      = 30,
  55.         REAL         = 31,
  56.         STRING       = 32,
  57.  
  58.         PLUS         = 33,   // +
  59.         MINUS        = 34,   // -
  60.         STAR         = 35,   // *
  61.         SLASH        = 36,   // /
  62.         LESS         = 37,   // <
  63.         GREATER      = 38,   // >
  64.         EQUAL        = 39,   // =
  65.         COLON        = 40,   // :
  66.         SEMI         = 41,   // ;
  67.         COMMA        = 42,   // ,
  68.         PERIOD       = 43,   // .
  69.         LPAREN       = 44,   // (
  70.         RPAREN       = 45,   // )
  71.         LBRACK       = 46,   // [
  72.         RBRACK       = 47,   // ]
  73.         LBRACE       = 48,   // {
  74.         RBRACE       = 49,   // }
  75.         ASSIGN       = 50,   // :=
  76.         LEQ          = 51,   // <=
  77.         GEQ          = 52,   // >=
  78.         NEQ          = 53,   // <>
  79.  
  80.         EOF          = 54;
  81.  
  82.     //
  83.     // Printable representations of token kinds.    This list must match the
  84.     // token kind codes, above.
  85.     //
  86.     final static String [] stringOf = {
  87.         "AND",
  88.         "ARRAY",
  89.         "BEGIN",
  90.         "BY",
  91.         "DIV",
  92.         "DO",
  93.         "ELSE",
  94.         "ELSEIF",
  95.         "END",
  96.         "EXIT",
  97.         "FOR",
  98.         "IF",
  99.         "IS",
  100.         "LOOP",
  101.         "MOD",
  102.         "NOT",
  103.         "OF",
  104.         "OR",
  105.         "PROCEDURE",
  106.         "PROGRAM",
  107.         "READ",
  108.         "RECORD",
  109.         "RETURN",
  110.         "THEN",
  111.         "TO",
  112.         "TYPE",
  113.         "VAR",
  114.         "WHILE",
  115.         "WRITE",
  116.  
  117.         "ID",
  118.         "INTEGER",
  119.         "REAL",
  120.         "STRING",
  121.  
  122.         "+",
  123.         "-",
  124.         "*",
  125.         "/",
  126.         "<",
  127.         ">",
  128.         "=",
  129.         ":",
  130.         ";",
  131.         ",",
  132.         ".",
  133.         "(",
  134.         ")",
  135.         "[",
  136.         "]",
  137.         "{",
  138.         "}",
  139.         ":=",
  140.         "<=",
  141.         ">=",
  142.         "<>",
  143.  
  144.         "END-OF-FILE"
  145.     };
  146.  
  147. }
  148.