- private SmartReader in;
- private boolean pushedBack = false;
-
- public int op;
- public int twoBack;
- public Number number;
- public String string;
-
- public Lexer(Reader r) throws IOException { in = new SmartReader(r); }
- public int peekToken() throws IOException { int ret = getToken(); pushBackToken(); return ret; }
- public void pushBackToken() { pushBackToken(op); }
- public void pushBackToken(int i) { if (pushedBack) throw new Error("can't push back twice"); pushedBack = true; op = i; }
-
- // 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
-
- public static final int MAX_TOKEN = ASSERT;
-
- 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" };