Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame^] | 1 | //===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Copyright 2019 The MLIR Authors. |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | // ============================================================================= |
| 17 | // |
| 18 | // This file is intended to be #include'd multiple times to extract information |
| 19 | // about tokens for various clients in the lexer. |
| 20 | // |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
| 23 | #if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) && !defined(TOK_LITERAL)&&\ |
| 24 | !defined(TOK_PUNCTUATION) && !defined(TOK_KEYWORD) |
| 25 | # error Must define one of the TOK_ macros. |
| 26 | #endif |
| 27 | |
| 28 | #ifndef TOK_MARKER |
| 29 | #define TOK_MARKER(X) |
| 30 | #endif |
| 31 | #ifndef TOK_IDENTIFIER |
| 32 | #define TOK_IDENTIFIER(NAME) |
| 33 | #endif |
| 34 | #ifndef TOK_LITERAL |
| 35 | #define TOK_LITERAL(NAME) |
| 36 | #endif |
| 37 | #ifndef TOK_PUNCTUATION |
| 38 | #define TOK_PUNCTUATION(NAME, SPELLING) |
| 39 | #endif |
| 40 | #ifndef TOK_KEYWORD |
| 41 | #define TOK_KEYWORD(SPELLING) |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | // Markers |
| 46 | TOK_MARKER(eof) |
| 47 | TOK_MARKER(error) |
| 48 | |
| 49 | // Identifiers. |
| 50 | TOK_IDENTIFIER(bare_identifier) // foo |
| 51 | TOK_IDENTIFIER(at_identifier) // @foo |
| 52 | TOK_IDENTIFIER(affine_map_identifier) // #foo |
| 53 | // TODO: @@foo, etc. |
| 54 | |
| 55 | // Literals |
| 56 | TOK_LITERAL(integer) // 42 |
| 57 | TOK_LITERAL(string) // "foo" |
| 58 | |
| 59 | // Punctuation. |
| 60 | TOK_PUNCTUATION(arrow, "->") |
| 61 | TOK_PUNCTUATION(colon, ":") |
| 62 | TOK_PUNCTUATION(comma, ",") |
| 63 | TOK_PUNCTUATION(question, "?") |
| 64 | TOK_PUNCTUATION(questionquestion, "??") |
| 65 | TOK_PUNCTUATION(l_paren, "(") |
| 66 | TOK_PUNCTUATION(r_paren, ")") |
| 67 | TOK_PUNCTUATION(l_brace, "{") |
| 68 | TOK_PUNCTUATION(r_brace, "}") |
| 69 | TOK_PUNCTUATION(less, "<") |
| 70 | TOK_PUNCTUATION(greater, ">") |
| 71 | // TODO: More punctuation. |
| 72 | |
| 73 | // Keywords. These turn "foo" into Token::kw_foo enums. |
| 74 | TOK_KEYWORD(bf16) |
| 75 | TOK_KEYWORD(br) |
| 76 | TOK_KEYWORD(cfgfunc) |
| 77 | TOK_KEYWORD(extfunc) |
| 78 | TOK_KEYWORD(f16) |
| 79 | TOK_KEYWORD(f32) |
| 80 | TOK_KEYWORD(f64) |
| 81 | TOK_KEYWORD(i1) |
| 82 | TOK_KEYWORD(i16) |
| 83 | TOK_KEYWORD(i32) |
| 84 | TOK_KEYWORD(i64) |
| 85 | TOK_KEYWORD(i8) |
| 86 | TOK_KEYWORD(int) |
| 87 | TOK_KEYWORD(memref) |
| 88 | TOK_KEYWORD(mlfunc) |
| 89 | TOK_KEYWORD(return) |
| 90 | TOK_KEYWORD(tensor) |
| 91 | TOK_KEYWORD(vector) |
| 92 | |
| 93 | #undef TOK_MARKER |
| 94 | #undef TOK_IDENTIFIER |
| 95 | #undef TOK_LITERAL |
| 96 | #undef TOK_PUNCTUATION |
| 97 | #undef TOK_KEYWORD |