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