2018-06-30 02:15:56 +08:00
|
|
|
//===- 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)&&\
|
2018-06-30 09:09:29 +08:00
|
|
|
!defined(TOK_PUNCTUATION) && !defined(TOK_OPERATOR) && !defined(TOK_KEYWORD)
|
2018-06-30 02:15:56 +08:00
|
|
|
# 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
|
2018-06-30 09:09:29 +08:00
|
|
|
#ifndef TOK_OPERATOR
|
|
|
|
#define TOK_OPERATOR(NAME, SPELLING)
|
|
|
|
#endif
|
2018-06-30 02:15:56 +08:00
|
|
|
#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"
|
2018-06-30 13:08:05 +08:00
|
|
|
TOK_LITERAL(inttype) // i421
|
2018-06-30 02:15:56 +08:00
|
|
|
|
|
|
|
// 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, "}")
|
2018-06-30 09:09:29 +08:00
|
|
|
TOK_PUNCTUATION(l_bracket, "[")
|
|
|
|
TOK_PUNCTUATION(r_bracket, "]")
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_PUNCTUATION(less, "<")
|
|
|
|
TOK_PUNCTUATION(greater, ">")
|
2018-06-30 09:09:29 +08:00
|
|
|
TOK_PUNCTUATION(equal, "=")
|
2018-06-30 02:15:56 +08:00
|
|
|
// TODO: More punctuation.
|
|
|
|
|
2018-06-30 09:09:29 +08:00
|
|
|
// Operators.
|
|
|
|
TOK_OPERATOR(plus, "+")
|
|
|
|
TOK_OPERATOR(star, "*")
|
|
|
|
TOK_OPERATOR(ceildiv, "ceildiv")
|
|
|
|
TOK_OPERATOR(floordiv, "floordiv")
|
|
|
|
// TODO: More operator tokens
|
|
|
|
|
2018-06-30 02:15:56 +08:00
|
|
|
// Keywords. These turn "foo" into Token::kw_foo enums.
|
2018-06-30 13:08:05 +08:00
|
|
|
TOK_KEYWORD(affineint)
|
2018-06-30 02:15:56 +08:00
|
|
|
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
|
2018-06-30 09:09:29 +08:00
|
|
|
#undef TOK_OPERATOR
|
2018-06-30 02:15:56 +08:00
|
|
|
#undef TOK_KEYWORD
|