package rebelsky.compiler.pascal; import rebelsky.compiler.lexer.NamedToken; import rebelsky.compiler.lexer.ProgramSymbol; import rebelsky.compiler.lexer.Token; /** * A collection of the key tokens and token types for Pascal. * * @author Samuel A. Rebelsky * @version 1.0 of October 2002 */ public class PascalTokens { // +-------------------+------------------------------------------------- // | Helpful Variables | // +-------------------+ private static int tokType = 1; // +------------------------+-------------------------------------------- // | Constants: Token Types | // +------------------------+ /** General category: Idenifier. */ public static final int PIDENTIFIER = ++tokType; /** General category: String. */ public static final int PSTRING = ++tokType; /** General category: Integer. */ public static final int PINT = ++tokType; /** General category: Real. */ public static final int PREAL = ++tokType; /** Keyword: AND. */ public static final int AND = ++tokType; /** Keyword: ARRAY. */ public static final int ARRAY = ++tokType; /** Keyword: BEGIN. */ public static final int BEGIN = ++tokType; /** Keyword: CASE. */ public static final int CASE = ++tokType; /** Keyword: CONST. */ public static final int CONST = ++tokType; /** Keyword: DIV. */ public static final int DIV = ++tokType; /** Keyword: DO. */ public static final int DO = ++tokType; /** Keyword: DOWNTO.. */ public static final int DOWNTO= ++tokType; /** Keyword: ELSE. */ public static final int ELSE = ++tokType; /** Keyword: END. */ public static final int END = ++tokType; /** Keyword: FILE. */ public static final int FILE = ++tokType; /** Keyword: FOR. */ public static final int FOR = ++tokType; /** Keyword: FUNCTION. */ public static final int FUNCTION = ++tokType; /** Keyword: GOTO. */ public static final int GOTO = ++tokType; /** Keyword: IF. */ public static final int IF = ++tokType; /** Keyword: IN. */ public static final int IN = ++tokType; /** Keyword: LABEL. */ public static final int LABEL = ++tokType; /** Keyword: MAXINT2 */ public static final int MAXINT = ++tokType; /** Keyword: MOD. */ public static final int MOD = ++tokType; /** Keyword: NIL. */ public static final int NIL = ++tokType; /** Keyword: NOT. */ public static final int NOT = ++tokType; /** Keyword: OF. */ public static final int OF = ++tokType; /** Keyword: OR. */ public static final int OR = ++tokType; /** Keyword: PACKED. */ public static final int PACKED = ++tokType; /** Keyword: PROCEDURE . */ public static final int PROCEDURE = ++tokType; /** Keyword: PROGRAM. */ public static final int PROGRAM = ++tokType; /** Keyword: RECORD. */ public static final int RECORD = ++tokType; /** Keyword: REPEAT. */ public static final int REPEAT = ++tokType; /** Keyword: SET. */ public static final int SET = ++tokType; /** Keyword: TEXT. */ public static final int TEXT = ++tokType; /** Keyword: THEN. */ public static final int THEN = ++tokType; /** Keyword: TO. */ public static final int TO = ++tokType; /** Keyword: TYPE. */ public static final int TYPE = ++tokType; /** Keyword: UNTIL. */ public static final int UNTIL = ++tokType; /** Keyword: VAR. */ public static final int VAR = ++tokType; /** Keyword: WHILE. */ public static final int WHILE = ++tokType; /** Keyword: WITH. */ public static final int WITH = ++tokType; /** Operation: Assignment. */ public static final int ASSIGN = ++tokType; /** Operation: Addition. */ public static final int PLUS = ++tokType; /** Operation: Subtraction. */ public static final int MINUS = ++tokType; /** Operation: Multiplication . */ public static final int TIMES = ++tokType; /** Operation: Division . */ public static final int DIVIDE = ++tokType; /** Operation: Equality Comparison . */ public static final int EQUALS = ++tokType; /** Operation: Inequality . */ public static final int NOTEQUALS = ++tokType; /** Operation: Less-Than. */ public static final int LESSTHAN = ++tokType; /** Operation: Greater-Than. */ public static final int GREATERTHAN =++tokType; /** Operation: Less-Than-Or-Equal-To. */ public static final int LESSEQ = ++tokType; /** Operation: Greater-Than-Or-Equal-To. */ public static final int GREATEREQ = ++tokType; /** Operations: Ellipses. */ public static final int DOTDOT = ++tokType; /** Operation: Pointer To. */ public static final int POINTER = ++tokType; /** Notation: Open Parenthesis. */ public static final int OPENPAREN = ++tokType; /** Notation: Close Parenthesis. */ public static final int CLOSEPAREN = ++tokType; /** Notation: Period. */ public static final int PERIOD = ++tokType; /** Notation: Comma. */ public static final int COMMA = ++tokType; /** Notation: Semicolon. */ public static final int SEMI = ++tokType; /** Notation: Colon. */ public static final int COLON = ++tokType; /** Notation: Open Bracket. */ public static final int OPENBRACKET = ++tokType; /** Notation: Close Bracket. */ public static final int CLOSEBRACKET =++tokType; // +-------------------+------------------------------------------------- // | Constants: Tokens | // +-------------------+ /** Identifier: BOOLEAN. */ public static final Token TBOOLEAN = new PascalIdentifier("BOOLEAN"); /** Identifier: CHAR. */ public static final Token TCHAR = new PascalIdentifier("CHAR"); /** Identifier: INTEGER. */ public static final Token TINTEGER = new PascalIdentifier("INTEGER"); /** Identifier: REAL. */ public static final Token TREAL = new PascalIdentifier("REAL"); /** Identifier: FALSE. */ public static final Token TFALSE = new PascalIdentifier("FALSE"); /** Identifier: TRUE. */ public static final Token TTRUE = new PascalIdentifier("TRUE"); /** Keyword: AND. */ public static final Token TAND = new NamedToken("AND", AND); /** Keyword: ARRAY. */ public static final Token TARRAY = new NamedToken("ARRAY", ARRAY); /** Keyword: BEGIN. */ public static final Token TBEGIN = new NamedToken("BEGIN", BEGIN); /** Keyword: CASE. */ public static final Token TCASE = new NamedToken("CASE", CASE); /** Keyword: CONST. */ public static final Token TCONST = new NamedToken("CONST", CONST); /** Keyword: DIV. */ public static final Token TDIV = new NamedToken("DIV", DIV); /** Keyword: DO. */ public static final Token TDO = new NamedToken("DO", DO); /** Keyword: DOWNTO.. */ public static final Token TDOWNTO = new NamedToken("DOWNTO", DOWNTO); /** Keyword: ELSE. */ public static final Token TELSE = new NamedToken("ELSE", ELSE); /** Keyword: END. */ public static final Token TEND = new NamedToken("END", END); /** Keyword: FILE. */ public static final Token TFILE = new NamedToken("FILE", FILE); /** Keyword: FOR. */ public static final Token TFOR = new NamedToken("FOR", FOR); /** Keyword: FUNCTION. */ public static final Token TFUNCTION = new NamedToken("FUNCTION", FUNCTION); /** Keyword: GOTO. */ public static final Token TGOTO = new NamedToken("GOTO", GOTO); /** Keyword: IF. */ public static final Token TIF = new NamedToken("IF", IF); /** Keyword: IN. */ public static final Token TIN = new NamedToken("IN", IN); /** Keyword: LABEL. */ public static final Token TLABEL = new NamedToken("LABEL", LABEL); /** Keyword: MAXINT. */ public static final Token TMAXINT = new NamedToken("MAXINT", MAXINT); /** Keyword: MOD. */ public static final Token TMOD = new NamedToken("MOD", MOD); /** Keyword: NIL. */ public static final Token TNIL = new NamedToken("NIL", NIL); /** Keyword: NOT. */ public static final Token TNOT = new NamedToken("NOT", NOT); /** Keyword: OF. */ public static final Token TOF = new NamedToken("OF", OF); /** Keyword: OR. */ public static final Token TOR = new NamedToken("OR", OR); /** Keyword: PACKED. */ public static final Token TPACKED = new NamedToken("PACKED", PACKED); /** Keyword: PROCEDURE . */ public static final Token TPROCEDURE = new NamedToken("PROCEDURE", PROCEDURE); /** Keyword: PROGRAM. */ public static final Token TPROGRAM = new NamedToken("PROGRAM", PROGRAM); /** Keyword: RECORD. */ public static final Token TRECORD = new NamedToken("RECORD", RECORD); /** Keyword: REPEAT. */ public static final Token TREPEAT = new NamedToken("REPEAT", REPEAT); /** Keyword: SET. */ public static final Token TSET = new NamedToken("SET", SET); /** Keyword: TEXT. */ public static final Token TTEXT = new NamedToken("TEXT", TEXT); /** Keyword: THEN. */ public static final Token TTHEN = new NamedToken("THEN", THEN); /** Keyword: TO. */ public static final Token TTO = new NamedToken("TO", TO); /** Keyword: TYPE. */ public static final Token TTYPE = new NamedToken("TYPE", TYPE); /** Keyword: UNTIL. */ public static final Token TUNTIL = new NamedToken("UNTIL", UNTIL); /** Keyword: VAR. */ public static final Token TVAR = new NamedToken("VAR", VAR); /** Keyword: WHILE. */ public static final Token TWHILE = new NamedToken("WHILE", WHILE); /** Keyword: WITH. */ public static final Token TWITH = new NamedToken("WITH", WITH); /** Operation: Assignment. */ public static final Token TASSIGN = new ProgramSymbol(":=", ASSIGN); /** Operation: Addition. */ public static final Token TPLUS = new ProgramSymbol("+", PLUS); /** Operation: Subtraction. */ public static final Token TMINUS = new ProgramSymbol("-", MINUS); /** Operation: Multiplication . */ public static final Token TTIMES = new ProgramSymbol("*", TIMES); /** Operation: Division . */ public static final Token TDIVIDE = new ProgramSymbol("/", DIVIDE); /** Operation: Equality Comparison . */ public static final Token TEQUALS = new ProgramSymbol("=", EQUALS); /** Operation: Inequality . */ public static final Token TNOTEQUALS = new ProgramSymbol("<>", NOTEQUALS); /** Operation: Less-Than. */ public static final Token TLESSTHAN = new ProgramSymbol("<", LESSTHAN); /** Operation: Greater-Than. */ public static final Token TGREATERTHAN = new ProgramSymbol(">", GREATERTHAN); /** Operation: Less-Than-Or-Equal-To. */ public static final Token TLESSEQ = new ProgramSymbol("<=", LESSEQ); /** Operation: Greater-Than-Or-Equal-To. */ public static final Token TGREATEREQ = new ProgramSymbol(">=", GREATEREQ); /** Operations: Ellipses. */ public static final Token TDOTDOT = new ProgramSymbol("..", DOTDOT); /** Operation: PoTokener To. */ public static final Token TPOINTER = new ProgramSymbol("^", POINTER); /** Notation: Open Parenthesis. */ public static final Token TOPENPAREN = new ProgramSymbol("(", OPENPAREN); /** Notation: Close Parenthesis. */ public static final Token TCLOSEPAREN = new ProgramSymbol(")", CLOSEPAREN); /** Notation: Period. */ public static final Token TPERIOD = new ProgramSymbol(".", PERIOD); /** Notation: Comma. */ public static final Token TCOMMA = new ProgramSymbol(",", COMMA); /** Notation: Semicolon. */ public static final Token TSEMI = new ProgramSymbol(";", SEMI); /** Notation: Colon. */ public static final Token TCOLON = new ProgramSymbol(":", COLON); /** Notation: Open Bracket. */ public static final Token TOPENBRACKET = new ProgramSymbol("[", OPENBRACKET); /** Notation: Close Bracket. */ public static final Token TCLOSEBRACKET = new ProgramSymbol("]", CLOSEBRACKET); } // class PascalTokens