blob: 283b6c40d4754299eb2e2ba0d4cd8e6a3241e6fd [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.syntax;
16
17/**
18 * A TokenKind is an enumeration of each different kind of lexical symbol.
19 */
20public enum TokenKind {
21
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000022 ASSERT("assert"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010023 AND("and"),
24 AS("as"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000025 BREAK("break"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010026 CLASS("class"),
27 COLON(":"),
28 COMMA(","),
29 COMMENT("comment"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000030 CONTINUE("continue"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010031 DEF("def"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000032 DEL("del"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010033 DOT("."),
34 ELIF("elif"),
35 ELSE("else"),
36 EOF("EOF"),
37 EQUALS("="),
38 EQUALS_EQUALS("=="),
Laurent Le Brun5c8ea362015-03-18 19:03:57 +000039 EXCEPT("except"),
40 FINALLY("finally"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010041 FOR("for"),
Laurent Le Brun5c8ea362015-03-18 19:03:57 +000042 FROM("from"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000043 GLOBAL("global"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010044 GREATER(">"),
45 GREATER_EQUALS(">="),
46 IDENTIFIER("identifier"),
47 IF("if"),
48 ILLEGAL("illegal character"),
Laurent Le Brun5c8ea362015-03-18 19:03:57 +000049 IMPORT("import"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010050 IN("in"),
51 INDENT("indent"),
52 INT("integer"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000053 IS("is"),
54 LAMBDA("lambda"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010055 LBRACE("{"),
56 LBRACKET("["),
57 LESS("<"),
58 LESS_EQUALS("<="),
59 LPAREN("("),
60 MINUS("-"),
61 NEWLINE("newline"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000062 NONLOCAL("nonlocal"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010063 NOT("not"),
64 NOT_EQUALS("!="),
Laurent Le Brune3f4ed72015-05-08 14:47:26 +000065 NOT_IN("not in"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010066 OR("or"),
67 OUTDENT("outdent"),
Laurent Le Brun0942ee92015-03-17 20:22:16 +000068 PASS("pass"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010069 PERCENT("%"),
Laurent Le Brun092f13b2015-08-24 14:50:00 +000070 PIPE("|"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010071 PLUS("+"),
72 PLUS_EQUALS("+="),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000073 RAISE("raise"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010074 RBRACE("}"),
75 RBRACKET("]"),
76 RETURN("return"),
77 RPAREN(")"),
78 SEMI(";"),
Laurent Le Brun8a528262015-04-15 14:23:35 +000079 SLASH("/"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010080 STAR("*"),
Francois-Rene Rideau5dcdbf92015-02-19 18:36:17 +000081 STAR_STAR("**"),
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010082 STRING("string"),
Laurent Le Brunc9041bf2015-03-23 15:34:12 +000083 TRY("try"),
84 WHILE("while"),
85 WITH("with"),
86 YIELD("yield");
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010087
88 private final String prettyName;
89
90 private TokenKind(String prettyName) {
91 this.prettyName = prettyName;
92 }
93
94 /**
95 * Returns the pretty name for this token, for use in error messages for the user.
96 */
97 public String getPrettyName() {
98 return prettyName;
99 }
100}