blob: 7eae4708792e7de3d10469cdaec62cdc1e7e1b1e [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)&&\
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
46TOK_MARKER(eof)
47TOK_MARKER(error)
48
49// Identifiers.
50TOK_IDENTIFIER(bare_identifier) // foo
51TOK_IDENTIFIER(at_identifier) // @foo
52TOK_IDENTIFIER(affine_map_identifier) // #foo
53// TODO: @@foo, etc.
54
55// Literals
56TOK_LITERAL(integer) // 42
57TOK_LITERAL(string) // "foo"
58
59// Punctuation.
60TOK_PUNCTUATION(arrow, "->")
61TOK_PUNCTUATION(colon, ":")
62TOK_PUNCTUATION(comma, ",")
63TOK_PUNCTUATION(question, "?")
64TOK_PUNCTUATION(questionquestion, "??")
65TOK_PUNCTUATION(l_paren, "(")
66TOK_PUNCTUATION(r_paren, ")")
67TOK_PUNCTUATION(l_brace, "{")
68TOK_PUNCTUATION(r_brace, "}")
69TOK_PUNCTUATION(less, "<")
70TOK_PUNCTUATION(greater, ">")
71// TODO: More punctuation.
72
73// Keywords. These turn "foo" into Token::kw_foo enums.
74TOK_KEYWORD(bf16)
75TOK_KEYWORD(br)
76TOK_KEYWORD(cfgfunc)
77TOK_KEYWORD(extfunc)
78TOK_KEYWORD(f16)
79TOK_KEYWORD(f32)
80TOK_KEYWORD(f64)
81TOK_KEYWORD(i1)
82TOK_KEYWORD(i16)
83TOK_KEYWORD(i32)
84TOK_KEYWORD(i64)
85TOK_KEYWORD(i8)
86TOK_KEYWORD(int)
87TOK_KEYWORD(memref)
88TOK_KEYWORD(mlfunc)
89TOK_KEYWORD(return)
90TOK_KEYWORD(tensor)
91TOK_KEYWORD(vector)
92
93#undef TOK_MARKER
94#undef TOK_IDENTIFIER
95#undef TOK_LITERAL
96#undef TOK_PUNCTUATION
97#undef TOK_KEYWORD