blob: b9ef9b05cad659129f09cc83ad9ef0f8d0c1e8af [file] [log] [blame]
Chris Lattner8da0c282018-06-29 11:15:56 -07001//===- 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 Bondhugulafaf37dd2018-06-29 18:09:29 -070024 !defined(TOK_PUNCTUATION) && !defined(TOK_OPERATOR) && !defined(TOK_KEYWORD)
Chris Lattner8da0c282018-06-29 11:15:56 -070025# 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 Bondhugulafaf37dd2018-06-29 18:09:29 -070040#ifndef TOK_OPERATOR
41#define TOK_OPERATOR(NAME, SPELLING)
42#endif
Chris Lattner8da0c282018-06-29 11:15:56 -070043#ifndef TOK_KEYWORD
44#define TOK_KEYWORD(SPELLING)
45#endif
46
47
48// Markers
49TOK_MARKER(eof)
50TOK_MARKER(error)
51
52// Identifiers.
Chris Lattner78276e32018-07-07 15:48:26 -070053TOK_IDENTIFIER(bare_identifier) // foo
54TOK_IDENTIFIER(at_identifier) // @foo
55TOK_IDENTIFIER(hash_identifier) // #foo
56TOK_IDENTIFIER(percent_identifier) // %foo
Chris Lattner8da0c282018-06-29 11:15:56 -070057// TODO: @@foo, etc.
58
59// Literals
60TOK_LITERAL(integer) // 42
61TOK_LITERAL(string) // "foo"
Chris Lattnerf958bbe2018-06-29 22:08:05 -070062TOK_LITERAL(inttype) // i421
Chris Lattner8da0c282018-06-29 11:15:56 -070063
64// Punctuation.
65TOK_PUNCTUATION(arrow, "->")
66TOK_PUNCTUATION(colon, ":")
67TOK_PUNCTUATION(comma, ",")
68TOK_PUNCTUATION(question, "?")
69TOK_PUNCTUATION(questionquestion, "??")
70TOK_PUNCTUATION(l_paren, "(")
71TOK_PUNCTUATION(r_paren, ")")
72TOK_PUNCTUATION(l_brace, "{")
73TOK_PUNCTUATION(r_brace, "}")
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -070074TOK_PUNCTUATION(l_bracket, "[")
75TOK_PUNCTUATION(r_bracket, "]")
Chris Lattner8da0c282018-06-29 11:15:56 -070076TOK_PUNCTUATION(less, "<")
77TOK_PUNCTUATION(greater, ">")
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -070078TOK_PUNCTUATION(equal, "=")
Chris Lattner8da0c282018-06-29 11:15:56 -070079// TODO: More punctuation.
80
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -070081// Operators.
82TOK_OPERATOR(plus, "+")
Uday Bondhugula015cbb12018-07-03 20:16:08 -070083TOK_OPERATOR(minus, "-")
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -070084TOK_OPERATOR(star, "*")
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -070085// TODO: More operator tokens
86
Chris Lattner8da0c282018-06-29 11:15:56 -070087// Keywords. These turn "foo" into Token::kw_foo enums.
Chris Lattnerf958bbe2018-06-29 22:08:05 -070088TOK_KEYWORD(affineint)
Chris Lattner8da0c282018-06-29 11:15:56 -070089TOK_KEYWORD(bf16)
90TOK_KEYWORD(br)
Chris Lattner7121b802018-07-04 20:45:39 -070091TOK_KEYWORD(ceildiv)
Chris Lattner8da0c282018-06-29 11:15:56 -070092TOK_KEYWORD(cfgfunc)
James Molloy4f788372018-07-24 15:01:27 -070093TOK_KEYWORD(cond_br)
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -070094TOK_KEYWORD(else)
Chris Lattner8da0c282018-06-29 11:15:56 -070095TOK_KEYWORD(extfunc)
96TOK_KEYWORD(f16)
97TOK_KEYWORD(f32)
98TOK_KEYWORD(f64)
Chris Lattner7121b802018-07-04 20:45:39 -070099TOK_KEYWORD(false)
100TOK_KEYWORD(floordiv)
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700101TOK_KEYWORD(for)
102TOK_KEYWORD(if)
Chris Lattner8da0c282018-06-29 11:15:56 -0700103TOK_KEYWORD(memref)
104TOK_KEYWORD(mlfunc)
Chris Lattner7121b802018-07-04 20:45:39 -0700105TOK_KEYWORD(mod)
Chris Lattner8da0c282018-06-29 11:15:56 -0700106TOK_KEYWORD(return)
Uday Bondhugula0115dbb2018-07-11 21:31:07 -0700107TOK_KEYWORD(size)
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700108TOK_KEYWORD(step)
Chris Lattner8da0c282018-06-29 11:15:56 -0700109TOK_KEYWORD(tensor)
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700110TOK_KEYWORD(to)
Chris Lattner7121b802018-07-04 20:45:39 -0700111TOK_KEYWORD(true)
Chris Lattner8da0c282018-06-29 11:15:56 -0700112TOK_KEYWORD(vector)
113
114#undef TOK_MARKER
115#undef TOK_IDENTIFIER
116#undef TOK_LITERAL
117#undef TOK_PUNCTUATION
Uday Bondhugulafaf37dd2018-06-29 18:09:29 -0700118#undef TOK_OPERATOR
Chris Lattner8da0c282018-06-29 11:15:56 -0700119#undef TOK_KEYWORD