1//===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file is intended to be #include'd multiple times to extract information 10// about tokens for various clients in the lexer. 11// 12//===----------------------------------------------------------------------===// 13 14#if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) && \ 15 !defined(TOK_LITERAL) && !defined(TOK_PUNCTUATION) && \ 16 !defined(TOK_KEYWORD) 17#error Must define one of the TOK_ macros. 18#endif 19 20#ifndef TOK_MARKER 21#define TOK_MARKER(X) 22#endif 23#ifndef TOK_IDENTIFIER 24#define TOK_IDENTIFIER(NAME) 25#endif 26#ifndef TOK_LITERAL 27#define TOK_LITERAL(NAME) 28#endif 29#ifndef TOK_PUNCTUATION 30#define TOK_PUNCTUATION(NAME, SPELLING) 31#endif 32#ifndef TOK_KEYWORD 33#define TOK_KEYWORD(SPELLING) 34#endif 35 36// Markers 37TOK_MARKER(eof) 38TOK_MARKER(error) 39 40// Identifiers. 41TOK_IDENTIFIER(bare_identifier) // foo 42TOK_IDENTIFIER(at_identifier) // @foo 43TOK_IDENTIFIER(hash_identifier) // #foo 44TOK_IDENTIFIER(percent_identifier) // %foo 45TOK_IDENTIFIER(caret_identifier) // ^foo 46TOK_IDENTIFIER(exclamation_identifier) // !foo 47 48// Literals 49TOK_LITERAL(floatliteral) // 2.0 50TOK_LITERAL(integer) // 42 51TOK_LITERAL(string) // "foo" 52TOK_LITERAL(inttype) // i4, si8, ui16 53 54// Punctuation. 55TOK_PUNCTUATION(arrow, "->") 56TOK_PUNCTUATION(at, "@") 57TOK_PUNCTUATION(colon, ":") 58TOK_PUNCTUATION(comma, ",") 59TOK_PUNCTUATION(ellipsis, "...") 60TOK_PUNCTUATION(equal, "=") 61TOK_PUNCTUATION(greater, ">") 62TOK_PUNCTUATION(l_brace, "{") 63TOK_PUNCTUATION(l_paren, "(") 64TOK_PUNCTUATION(l_square, "[") 65TOK_PUNCTUATION(less, "<") 66TOK_PUNCTUATION(minus, "-") 67TOK_PUNCTUATION(plus, "+") 68TOK_PUNCTUATION(question, "?") 69TOK_PUNCTUATION(r_brace, "}") 70TOK_PUNCTUATION(r_paren, ")") 71TOK_PUNCTUATION(r_square, "]") 72TOK_PUNCTUATION(star, "*") 73 74// Keywords. These turn "foo" into Token::kw_foo enums. 75 76// NOTE: Please key these alphabetized to make it easier to find something in 77// this list and to cater to OCD. 78TOK_KEYWORD(affine_map) 79TOK_KEYWORD(affine_set) 80TOK_KEYWORD(attributes) 81TOK_KEYWORD(bf16) 82TOK_KEYWORD(ceildiv) 83TOK_KEYWORD(complex) 84TOK_KEYWORD(dense) 85TOK_KEYWORD(f16) 86TOK_KEYWORD(f32) 87TOK_KEYWORD(f64) 88TOK_KEYWORD(false) 89TOK_KEYWORD(floordiv) 90TOK_KEYWORD(for) 91TOK_KEYWORD(func) 92TOK_KEYWORD(index) 93TOK_KEYWORD(loc) 94TOK_KEYWORD(max) 95TOK_KEYWORD(memref) 96TOK_KEYWORD(min) 97TOK_KEYWORD(mod) 98TOK_KEYWORD(none) 99TOK_KEYWORD(offset) 100TOK_KEYWORD(opaque) 101TOK_KEYWORD(size) 102TOK_KEYWORD(sparse) 103TOK_KEYWORD(step) 104TOK_KEYWORD(strides) 105TOK_KEYWORD(symbol) 106TOK_KEYWORD(tensor) 107TOK_KEYWORD(to) 108TOK_KEYWORD(true) 109TOK_KEYWORD(tuple) 110TOK_KEYWORD(type) 111TOK_KEYWORD(unit) 112TOK_KEYWORD(vector) 113 114#undef TOK_MARKER 115#undef TOK_IDENTIFIER 116#undef TOK_LITERAL 117#undef TOK_PUNCTUATION 118#undef TOK_KEYWORD 119