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.
|
2018-07-08 06:48:26 +08:00
|
|
|
TOK_IDENTIFIER(bare_identifier) // foo
|
|
|
|
TOK_IDENTIFIER(at_identifier) // @foo
|
|
|
|
TOK_IDENTIFIER(hash_identifier) // #foo
|
|
|
|
TOK_IDENTIFIER(percent_identifier) // %foo
|
2018-06-30 02:15:56 +08:00
|
|
|
// 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, "+")
|
2018-07-04 11:16:08 +08:00
|
|
|
TOK_OPERATOR(minus, "-")
|
2018-06-30 09:09:29 +08:00
|
|
|
TOK_OPERATOR(star, "*")
|
|
|
|
// 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)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(ceildiv)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(cfgfunc)
|
2018-07-04 08:51:28 +08:00
|
|
|
TOK_KEYWORD(else)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(extfunc)
|
|
|
|
TOK_KEYWORD(f16)
|
|
|
|
TOK_KEYWORD(f32)
|
|
|
|
TOK_KEYWORD(f64)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(false)
|
|
|
|
TOK_KEYWORD(floordiv)
|
2018-07-04 08:51:28 +08:00
|
|
|
TOK_KEYWORD(for)
|
|
|
|
TOK_KEYWORD(if)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(memref)
|
|
|
|
TOK_KEYWORD(mlfunc)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(mod)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(return)
|
|
|
|
TOK_KEYWORD(tensor)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(true)
|
2018-06-30 02:15:56 +08:00
|
|
|
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
|