2018-06-30 02:15:56 +08:00
|
|
|
//===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===//
|
|
|
|
//
|
2020-01-26 11:58:30 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
2019-12-24 01:35:36 +08:00
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-06-30 02:15:56 +08:00
|
|
|
//
|
2019-12-24 01:35:36 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-06-30 02:15:56 +08:00
|
|
|
//
|
|
|
|
// This file is intended to be #include'd multiple times to extract information
|
|
|
|
// about tokens for various clients in the lexer.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
Fix a bug in the .mlir lexer, where a \0 character in a file is treated as a colon (due to an accidental fall through) instead of whitespace.
Summary:
While here, simplify the lexer a bit by eliminating the unneeded 'operator'
classification of certain sigils, they can just be treated as 'punctuation'.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76647
2020-03-24 06:39:32 +08:00
|
|
|
#if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) && \
|
|
|
|
!defined(TOK_LITERAL) && !defined(TOK_PUNCTUATION) && \
|
|
|
|
!defined(TOK_KEYWORD)
|
|
|
|
#error Must define one of the TOK_ macros.
|
2018-06-30 02:15:56 +08:00
|
|
|
#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_KEYWORD
|
|
|
|
#define TOK_KEYWORD(SPELLING)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Markers
|
|
|
|
TOK_MARKER(eof)
|
|
|
|
TOK_MARKER(error)
|
|
|
|
|
|
|
|
// Identifiers.
|
2019-01-03 06:16:40 +08:00
|
|
|
TOK_IDENTIFIER(bare_identifier) // foo
|
|
|
|
TOK_IDENTIFIER(at_identifier) // @foo
|
|
|
|
TOK_IDENTIFIER(hash_identifier) // #foo
|
|
|
|
TOK_IDENTIFIER(percent_identifier) // %foo
|
|
|
|
TOK_IDENTIFIER(caret_identifier) // ^foo
|
|
|
|
TOK_IDENTIFIER(exclamation_identifier) // !foo
|
2018-06-30 02:15:56 +08:00
|
|
|
|
|
|
|
// Literals
|
Fix a bug in the .mlir lexer, where a \0 character in a file is treated as a colon (due to an accidental fall through) instead of whitespace.
Summary:
While here, simplify the lexer a bit by eliminating the unneeded 'operator'
classification of certain sigils, they can just be treated as 'punctuation'.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76647
2020-03-24 06:39:32 +08:00
|
|
|
TOK_LITERAL(floatliteral) // 2.0
|
|
|
|
TOK_LITERAL(integer) // 42
|
|
|
|
TOK_LITERAL(string) // "foo"
|
|
|
|
TOK_LITERAL(inttype) // i4, si8, ui16
|
2018-06-30 02:15:56 +08:00
|
|
|
|
|
|
|
// Punctuation.
|
Fix a bug in the .mlir lexer, where a \0 character in a file is treated as a colon (due to an accidental fall through) instead of whitespace.
Summary:
While here, simplify the lexer a bit by eliminating the unneeded 'operator'
classification of certain sigils, they can just be treated as 'punctuation'.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76647
2020-03-24 06:39:32 +08:00
|
|
|
TOK_PUNCTUATION(arrow, "->")
|
|
|
|
TOK_PUNCTUATION(at, "@")
|
|
|
|
TOK_PUNCTUATION(colon, ":")
|
|
|
|
TOK_PUNCTUATION(comma, ",")
|
|
|
|
TOK_PUNCTUATION(ellipsis, "...")
|
|
|
|
TOK_PUNCTUATION(equal, "=")
|
|
|
|
TOK_PUNCTUATION(greater, ">")
|
|
|
|
TOK_PUNCTUATION(l_brace, "{")
|
|
|
|
TOK_PUNCTUATION(l_paren, "(")
|
|
|
|
TOK_PUNCTUATION(l_square, "[")
|
|
|
|
TOK_PUNCTUATION(less, "<")
|
|
|
|
TOK_PUNCTUATION(minus, "-")
|
|
|
|
TOK_PUNCTUATION(plus, "+")
|
|
|
|
TOK_PUNCTUATION(question, "?")
|
|
|
|
TOK_PUNCTUATION(r_brace, "}")
|
|
|
|
TOK_PUNCTUATION(r_paren, ")")
|
|
|
|
TOK_PUNCTUATION(r_square, "]")
|
|
|
|
TOK_PUNCTUATION(star, "*")
|
2018-06-30 09:09:29 +08:00
|
|
|
|
2018-06-30 02:15:56 +08:00
|
|
|
// Keywords. These turn "foo" into Token::kw_foo enums.
|
2019-03-30 13:23:34 +08:00
|
|
|
|
|
|
|
// NOTE: Please key these alphabetized to make it easier to find something in
|
|
|
|
// this list and to cater to OCD.
|
2020-01-14 05:12:37 +08:00
|
|
|
TOK_KEYWORD(affine_map)
|
|
|
|
TOK_KEYWORD(affine_set)
|
2018-09-19 07:36:26 +08:00
|
|
|
TOK_KEYWORD(attributes)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(bf16)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(ceildiv)
|
2019-03-30 13:23:34 +08:00
|
|
|
TOK_KEYWORD(complex)
|
2018-10-19 04:54:44 +08:00
|
|
|
TOK_KEYWORD(dense)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(f16)
|
|
|
|
TOK_KEYWORD(f32)
|
|
|
|
TOK_KEYWORD(f64)
|
2021-01-15 23:29:37 +08:00
|
|
|
TOK_KEYWORD(f80)
|
|
|
|
TOK_KEYWORD(f128)
|
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)
|
2019-01-03 02:20:00 +08:00
|
|
|
TOK_KEYWORD(func)
|
2018-10-07 08:21:53 +08:00
|
|
|
TOK_KEYWORD(index)
|
2019-01-24 05:11:23 +08:00
|
|
|
TOK_KEYWORD(loc)
|
2018-08-25 14:38:14 +08:00
|
|
|
TOK_KEYWORD(max)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(memref)
|
2018-08-25 14:38:14 +08:00
|
|
|
TOK_KEYWORD(min)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(mod)
|
2019-04-28 09:35:04 +08:00
|
|
|
TOK_KEYWORD(none)
|
2019-10-04 03:33:47 +08:00
|
|
|
TOK_KEYWORD(offset)
|
2018-10-24 04:44:04 +08:00
|
|
|
TOK_KEYWORD(opaque)
|
2018-07-12 12:31:07 +08:00
|
|
|
TOK_KEYWORD(size)
|
2019-03-30 13:23:34 +08:00
|
|
|
TOK_KEYWORD(sparse)
|
2018-07-20 00:52:39 +08:00
|
|
|
TOK_KEYWORD(step)
|
2019-10-04 03:33:47 +08:00
|
|
|
TOK_KEYWORD(strides)
|
2019-06-24 22:31:52 +08:00
|
|
|
TOK_KEYWORD(symbol)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(tensor)
|
2018-07-20 00:52:39 +08:00
|
|
|
TOK_KEYWORD(to)
|
2018-07-05 11:45:39 +08:00
|
|
|
TOK_KEYWORD(true)
|
2019-03-20 01:59:02 +08:00
|
|
|
TOK_KEYWORD(tuple)
|
2019-01-08 10:42:04 +08:00
|
|
|
TOK_KEYWORD(type)
|
2019-04-26 00:56:09 +08:00
|
|
|
TOK_KEYWORD(unit)
|
2018-06-30 02:15:56 +08:00
|
|
|
TOK_KEYWORD(vector)
|
|
|
|
|
|
|
|
#undef TOK_MARKER
|
|
|
|
#undef TOK_IDENTIFIER
|
|
|
|
#undef TOK_LITERAL
|
|
|
|
#undef TOK_PUNCTUATION
|
|
|
|
#undef TOK_KEYWORD
|