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)&&\ |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 24 | !defined(TOK_PUNCTUATION) && !defined(TOK_OPERATOR) && !defined(TOK_KEYWORD) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 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 |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 40 | #ifndef TOK_OPERATOR |
| 41 | #define TOK_OPERATOR(NAME, SPELLING) |
| 42 | #endif |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 43 | #ifndef TOK_KEYWORD |
| 44 | #define TOK_KEYWORD(SPELLING) |
| 45 | #endif |
| 46 | |
| 47 | |
| 48 | // Markers |
| 49 | TOK_MARKER(eof) |
| 50 | TOK_MARKER(error) |
| 51 | |
| 52 | // Identifiers. |
Chris Lattner | 78276e3 | 2018-07-07 15:48:26 -0700 | [diff] [blame] | 53 | TOK_IDENTIFIER(bare_identifier) // foo |
| 54 | TOK_IDENTIFIER(at_identifier) // @foo |
| 55 | TOK_IDENTIFIER(hash_identifier) // #foo |
| 56 | TOK_IDENTIFIER(percent_identifier) // %foo |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 57 | // TODO: @@foo, etc. |
| 58 | |
| 59 | // Literals |
Jacques Pienaar | 8449109 | 2018-07-31 17:15:15 -0700 | [diff] [blame] | 60 | TOK_LITERAL(floatliteral) // 2.0 |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 61 | TOK_LITERAL(integer) // 42 |
| 62 | TOK_LITERAL(string) // "foo" |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 63 | TOK_LITERAL(inttype) // i421 |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 64 | |
| 65 | // Punctuation. |
| 66 | TOK_PUNCTUATION(arrow, "->") |
| 67 | TOK_PUNCTUATION(colon, ":") |
| 68 | TOK_PUNCTUATION(comma, ",") |
| 69 | TOK_PUNCTUATION(question, "?") |
| 70 | TOK_PUNCTUATION(questionquestion, "??") |
| 71 | TOK_PUNCTUATION(l_paren, "(") |
| 72 | TOK_PUNCTUATION(r_paren, ")") |
| 73 | TOK_PUNCTUATION(l_brace, "{") |
| 74 | TOK_PUNCTUATION(r_brace, "}") |
Chris Lattner | 85ee151 | 2018-07-25 11:15:20 -0700 | [diff] [blame] | 75 | TOK_PUNCTUATION(l_square, "[") |
| 76 | TOK_PUNCTUATION(r_square, "]") |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 77 | TOK_PUNCTUATION(less, "<") |
| 78 | TOK_PUNCTUATION(greater, ">") |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 79 | TOK_PUNCTUATION(equal, "=") |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 80 | // TODO: More punctuation. |
| 81 | |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 82 | // Operators. |
| 83 | TOK_OPERATOR(plus, "+") |
Uday Bondhugula | 015cbb1 | 2018-07-03 20:16:08 -0700 | [diff] [blame] | 84 | TOK_OPERATOR(minus, "-") |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 85 | TOK_OPERATOR(star, "*") |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 86 | // TODO: More operator tokens |
| 87 | |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 88 | // Keywords. These turn "foo" into Token::kw_foo enums. |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 89 | TOK_KEYWORD(affineint) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 90 | TOK_KEYWORD(bf16) |
| 91 | TOK_KEYWORD(br) |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 92 | TOK_KEYWORD(ceildiv) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 93 | TOK_KEYWORD(cfgfunc) |
James Molloy | 4f78837 | 2018-07-24 15:01:27 -0700 | [diff] [blame] | 94 | TOK_KEYWORD(cond_br) |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 95 | TOK_KEYWORD(else) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 96 | TOK_KEYWORD(extfunc) |
| 97 | TOK_KEYWORD(f16) |
| 98 | TOK_KEYWORD(f32) |
| 99 | TOK_KEYWORD(f64) |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 100 | TOK_KEYWORD(false) |
| 101 | TOK_KEYWORD(floordiv) |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 102 | TOK_KEYWORD(for) |
| 103 | TOK_KEYWORD(if) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 104 | TOK_KEYWORD(memref) |
| 105 | TOK_KEYWORD(mlfunc) |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 106 | TOK_KEYWORD(mod) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 107 | TOK_KEYWORD(return) |
Uday Bondhugula | 0115dbb | 2018-07-11 21:31:07 -0700 | [diff] [blame] | 108 | TOK_KEYWORD(size) |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 109 | TOK_KEYWORD(step) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 110 | TOK_KEYWORD(tensor) |
Jacques Pienaar | c0d6930 | 2018-07-27 11:07:12 -0700 | [diff] [blame] | 111 | TOK_KEYWORD(tf_control) |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 112 | TOK_KEYWORD(to) |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 113 | TOK_KEYWORD(true) |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 114 | TOK_KEYWORD(vector) |
| 115 | |
| 116 | #undef TOK_MARKER |
| 117 | #undef TOK_IDENTIFIER |
| 118 | #undef TOK_LITERAL |
| 119 | #undef TOK_PUNCTUATION |
Uday Bondhugula | faf37dd | 2018-06-29 18:09:29 -0700 | [diff] [blame] | 120 | #undef TOK_OPERATOR |
Chris Lattner | 8da0c28 | 2018-06-29 11:15:56 -0700 | [diff] [blame] | 121 | #undef TOK_KEYWORD |