static { List<String> directives = new ArrayList<String>(); List<String> keywords = new ArrayList<String>(); List<String> pseudoKeywords = new ArrayList<String>(); List<String> operators = new ArrayList<String>(); com.google.dart.compiler.parser.Token[] tokens = com.google.dart.compiler.parser.Token.values(); for (int i = 0; i < tokens.length; i++) { com.google.dart.compiler.parser.Token token = tokens[i]; if ((BREAK.ordinal() <= token.ordinal() && token.ordinal() <= WITH.ordinal()) || token.ordinal() == AS.ordinal() || token.ordinal() == IS.ordinal()) { keywords.add(token.getSyntax()); } if ((LIBRARY.ordinal() <= token.ordinal()) && (token.ordinal() <= NATIVE.ordinal())) { String name = token.getSyntax(); directives.add(name.substring(1)); } if (token.isBinaryOperator() || token.isUnaryOperator()) { operators.add(token.getSyntax()); } } for (String kw : DartParser.PSEUDO_KEYWORDS) { pseudoKeywords.add(kw); } DIRECTIVES = directives.toArray(new String[directives.size()]); KEYWORDS = keywords.toArray(new String[keywords.size()]); PSEUDO_KEYWORDS = pseudoKeywords.toArray(new String[pseudoKeywords.size()]); OPERATORS = operators.toArray(new String[operators.size()]); }
public enum PascalTokenType implements TokenType { // Palavras reservadas AND, ARRAY, BEGIN, CASE, CONST, DIV, DO, DOWNTO, ELSE, END, FILE, FOR, FUNCTION, GOTO, IF, IN, LABEL, MOD, NIL, NOT, OF, OR, PACKED, PROCEDURE, PROGRAM, RECORD, REPEAT, SET, THEN, TO, TYPE, UNTIL, VAR, WHILE, WITH, // Símbolos especiais. PLUS("+"), MINUS("-"), STAR("*"), SLASH("/"), COLON_EQUALS(":="), DOT("."), COMMA(","), SEMICOLON(";"), COLON(":"), QUOTE("'"), EQUALS("="), NOT_EQUALS("<>"), LESS_THAN("<"), LESS_EQUALS("<="), GREATER_EQUALS(">="), GREATER_THAN(">"), LEFT_PAREN("("), RIGHT_PAREN(")"), LEFT_BRACKET("["), RIGHT_BRACKET("]"), LEFT_BRACE("{"), RIGHT_BRACE("}"), UP_ARROW("^"), DOT_DOT(".."), IDENTIFIER, INTEGER, REAL, STRING, ERROR, END_OF_FILE; private static final int FIRST_RESERVED_INDEX = AND.ordinal(); private static final int LAST_RESERVED_INDEX = WITH.ordinal(); private static final int FIRST_SPECIAL_INDEX = PLUS.ordinal(); private static final int LAST_SPECIAL_INDEX = DOT_DOT.ordinal(); // Set of lower-cased Pascal reserved word text strings. public static Set<String> RESERVED_WORDS = new HashSet<String>(); static { final PascalTokenType values[] = PascalTokenType.values(); for (int i = FIRST_RESERVED_INDEX; i <= LAST_RESERVED_INDEX; ++i) { RESERVED_WORDS.add(values[i].getText().toLowerCase()); } } // Hash table of Pascal special symbols. Each special symbol's text // is the key to its Pascal token type. public static Map<String, PascalTokenType> SPECIAL_SYMBOLS = new HashMap<String, PascalTokenType>(); static { final PascalTokenType values[] = PascalTokenType.values(); for (int i = FIRST_SPECIAL_INDEX; i <= LAST_SPECIAL_INDEX; ++i) { SPECIAL_SYMBOLS.put(values[i].getText(), values[i]); } } private String text; // token text /** Constructor. */ PascalTokenType() { this.text = this.toString().toLowerCase(); } PascalTokenType(final String text) { this.text = text; } public String getText() { return text; } }