1    // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
2    package org.xwt.js;
3    
4    /** this class contains a <tt>public static final int</tt> for each valid token */
5    interface Tokens {
6    
7        // Token Constants //////////////////////////////////////////////////////////
8    
9        // arithmetic operations; also valid as bytecodes
10       public static final int BITOR         = 0;   // |
11       public static final int ASSIGN_BITOR  = 1;   // |=
12       public static final int BITXOR        = 2;   // ^
13       public static final int ASSIGN_BITXOR = 3;   // ^=
14       public static final int BITAND        = 4;   // &
15       public static final int ASSIGN_BITAND = 5;   // &=
16       public static final int LSH           = 6;   // <<
17       public static final int ASSIGN_LSH    = 7;   // <<=
18       public static final int RSH           = 8;   // >>
19       public static final int ASSIGN_RSH    = 9;   // >>=
20       public static final int URSH          = 10;  // >>>
21       public static final int ASSIGN_URSH   = 11;  // >>>=
22       public static final int ADD           = 12;  // +
23       public static final int ASSIGN_ADD    = 13;  // +=
24       public static final int SUB           = 14;  // -
25       public static final int ASSIGN_SUB    = 15;  // -=
26       public static final int MUL           = 16;  // *
27       public static final int ASSIGN_MUL    = 17;  // *=
28       public static final int DIV           = 18;  // /
29       public static final int ASSIGN_DIV    = 19;  // /=
30       public static final int MOD           = 20;  // %
31       public static final int ASSIGN_MOD    = 21;  // %=
32       public static final int BITNOT        = 22;  // ~
33       public static final int ASSIGN_BITNOT = 23;  // ~=
34   
35       // logical operations; also valid as bytecodes
36       public static final int OR            = 24;  // ||
37       public static final int AND           = 25;  // &&
38       public static final int BANG          = 26;  // !
39   
40       // equality operations; also valid as bytecodes
41       public static final int EQ            = 27;  // ==
42       public static final int NE            = 28;  // !=
43       public static final int LT            = 29;  // <
44       public static final int LE            = 30;  // <=
45       public static final int GT            = 31;  // >
46       public static final int GE            = 32;  // >=
47       public static final int SHEQ          = 33;  // ===
48       public static final int SHNE          = 34;  // !==
49   
50       // other permissible bytecode tokens
51       public static final int RETURN        = 35;  // return
52       public static final int TYPEOF        = 36;  // typeof
53       public static final int BREAK         = 37;  // break keyword
54       public static final int CONTINUE      = 38;  // continue keyword
55       public static final int TRY           = 39;  // try
56       public static final int THROW         = 40;  // throw
57       public static final int ASSERT        = 41;  // assert keyword
58   
59       public static final int NAME          = 42;  // *** identifiers ***
60       public static final int NUMBER        = 43;  // *** numeric literals ***
61       public static final int STRING        = 44;  // *** string literals ***
62       public static final int NULL          = 45;  // null
63       public static final int THIS          = 46;  // this
64       public static final int FALSE         = 47;  // false
65       public static final int TRUE          = 48;  // true
66       public static final int IN            = 49;  // in
67   
68       public static final int SEMI          = 50;  // ;
69       public static final int LB            = 51;  // [
70       public static final int RB            = 52;  // ]
71       public static final int LC            = 53;  // {
72       public static final int RC            = 54;  // }
73       public static final int LP            = 55;  // (
74       public static final int RP            = 56;  // )
75       public static final int COMMA         = 57;  // ,
76       public static final int ASSIGN        = 58;  // =
77       public static final int HOOK          = 59;  // ?
78       public static final int COLON         = 60;  // :
79       public static final int INC           = 61;  // ++
80       public static final int DEC           = 62;  // --
81       public static final int DOT           = 63;  // .
82       public static final int FUNCTION      = 64;  // function
83       public static final int IF            = 65;  // if keyword
84       public static final int ELSE          = 66;  // else keyword
85       public static final int SWITCH        = 67;  // switch keyword
86       public static final int CASE          = 68;  // case keyword
87       public static final int DEFAULT       = 69;  // default keyword
88       public static final int WHILE         = 70;  // while keyword
89       public static final int DO            = 71;  // do keyword
90       public static final int FOR           = 72;  // for keyword
91       public static final int VAR           = 73;  // var keyword
92       public static final int WITH          = 74;  // with keyword
93       public static final int CATCH         = 75;  // catch keyword
94       public static final int FINALLY       = 76;  // finally keyword
95       public static final int RESERVED      = 77;  // reserved keyword
96       public static final int GRAMMAR       = 78;  // the grammar-definition operator (::=)
97    
98       public static final int MAX_TOKEN = GRAMMAR;
99   
100      public final static String[] codeToString = new String[] {
101          "BITOR", "ASSIGN_BITOR", "BITXOR", "ASSIGN_BITXOR", "BITAND",
102          "ASSIGN_BITAND", "LSH", "ASSIGN_LSH", "RSH", "ASSIGN_RSH",
103          "URSH", "ASSIGN_URSH", "ADD", "ASSIGN_ADD", "SUB",
104          "ASSIGN_SUB", "MUL", "ASSIGN_MUL", "DIV", "ASSIGN_DIV", "MOD",
105          "ASSIGN_MOD", "BITNOT", "ASSIGN_BITNOT", "OR", "AND", "BANG",
106          "EQ", "NE", "LT", "LE", "GT", "GE", "SHEQ", "SHNE", "RETURN",
107          "TYPEOF", "BREAK", "CONTINUE", "TRY", "THROW", "ASSERT", "NAME",
108          "NUMBER", "STRING", "NULL", "THIS", "FALSE", "TRUE", "IN",
109          "SEMI", "LB", "RB", "LC", "RC", "LP", "RP", "COMMA", "ASSIGN",
110          "HOOK", "COLON", "INC", "DEC", "DOT", "FUNCTION", "IF",
111          "ELSE", "SWITCH", "CASE", "DEFAULT", "WHILE", "DO", "FOR",
112          "VAR", "WITH", "CATCH", "FINALLY", "RESERVED", "GRAMMAR"
113      };
114  
115  }
116  
117  
118