forked from OSchip/llvm-project
108 lines
3.1 KiB
C++
108 lines
3.1 KiB
C++
//===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===//
|
|
//
|
|
// Copyright 2019 The MLIR Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
// =============================================================================
|
|
//
|
|
// This file is intended to be #include'd multiple times to extract information
|
|
// about tokens for various clients in the lexer.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) && !defined(TOK_LITERAL)&&\
|
|
!defined(TOK_PUNCTUATION) && !defined(TOK_OPERATOR) && !defined(TOK_KEYWORD)
|
|
# error Must define one of the TOK_ macros.
|
|
#endif
|
|
|
|
#ifndef TOK_MARKER
|
|
#define TOK_MARKER(X)
|
|
#endif
|
|
#ifndef TOK_IDENTIFIER
|
|
#define TOK_IDENTIFIER(NAME)
|
|
#endif
|
|
#ifndef TOK_LITERAL
|
|
#define TOK_LITERAL(NAME)
|
|
#endif
|
|
#ifndef TOK_PUNCTUATION
|
|
#define TOK_PUNCTUATION(NAME, SPELLING)
|
|
#endif
|
|
#ifndef TOK_OPERATOR
|
|
#define TOK_OPERATOR(NAME, SPELLING)
|
|
#endif
|
|
#ifndef TOK_KEYWORD
|
|
#define TOK_KEYWORD(SPELLING)
|
|
#endif
|
|
|
|
|
|
// Markers
|
|
TOK_MARKER(eof)
|
|
TOK_MARKER(error)
|
|
|
|
// Identifiers.
|
|
TOK_IDENTIFIER(bare_identifier) // foo
|
|
TOK_IDENTIFIER(at_identifier) // @foo
|
|
TOK_IDENTIFIER(affine_map_identifier) // #foo
|
|
// TODO: @@foo, etc.
|
|
|
|
// Literals
|
|
TOK_LITERAL(integer) // 42
|
|
TOK_LITERAL(string) // "foo"
|
|
TOK_LITERAL(inttype) // i421
|
|
|
|
// Punctuation.
|
|
TOK_PUNCTUATION(arrow, "->")
|
|
TOK_PUNCTUATION(colon, ":")
|
|
TOK_PUNCTUATION(comma, ",")
|
|
TOK_PUNCTUATION(question, "?")
|
|
TOK_PUNCTUATION(questionquestion, "??")
|
|
TOK_PUNCTUATION(l_paren, "(")
|
|
TOK_PUNCTUATION(r_paren, ")")
|
|
TOK_PUNCTUATION(l_brace, "{")
|
|
TOK_PUNCTUATION(r_brace, "}")
|
|
TOK_PUNCTUATION(l_bracket, "[")
|
|
TOK_PUNCTUATION(r_bracket, "]")
|
|
TOK_PUNCTUATION(less, "<")
|
|
TOK_PUNCTUATION(greater, ">")
|
|
TOK_PUNCTUATION(equal, "=")
|
|
// TODO: More punctuation.
|
|
|
|
// Operators.
|
|
TOK_OPERATOR(plus, "+")
|
|
TOK_OPERATOR(star, "*")
|
|
TOK_OPERATOR(ceildiv, "ceildiv")
|
|
TOK_OPERATOR(floordiv, "floordiv")
|
|
// TODO: More operator tokens
|
|
|
|
// Keywords. These turn "foo" into Token::kw_foo enums.
|
|
TOK_KEYWORD(affineint)
|
|
TOK_KEYWORD(bf16)
|
|
TOK_KEYWORD(br)
|
|
TOK_KEYWORD(cfgfunc)
|
|
TOK_KEYWORD(extfunc)
|
|
TOK_KEYWORD(f16)
|
|
TOK_KEYWORD(f32)
|
|
TOK_KEYWORD(f64)
|
|
TOK_KEYWORD(memref)
|
|
TOK_KEYWORD(mlfunc)
|
|
TOK_KEYWORD(return)
|
|
TOK_KEYWORD(tensor)
|
|
TOK_KEYWORD(vector)
|
|
|
|
#undef TOK_MARKER
|
|
#undef TOK_IDENTIFIER
|
|
#undef TOK_LITERAL
|
|
#undef TOK_PUNCTUATION
|
|
#undef TOK_OPERATOR
|
|
#undef TOK_KEYWORD
|