[WIP] Sketching IR and parsing support for affine maps, affine expressions
Run test case:
$ mlir-opt test/IR/parser-affine-map.mlir
test/IR/parser-affine-map.mlir:3:30: error: expect '(' at start of map range
#hello_world2 (i, j) [s0] -> i+s0, j)
^
PiperOrigin-RevId: 202736856
diff --git a/lib/Parser/TokenKinds.def b/lib/Parser/TokenKinds.def
index 7eae470..72d769a 100644
--- a/lib/Parser/TokenKinds.def
+++ b/lib/Parser/TokenKinds.def
@@ -21,7 +21,7 @@
//===----------------------------------------------------------------------===//
#if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) && !defined(TOK_LITERAL)&&\
- !defined(TOK_PUNCTUATION) && !defined(TOK_KEYWORD)
+ !defined(TOK_PUNCTUATION) && !defined(TOK_OPERATOR) && !defined(TOK_KEYWORD)
# error Must define one of the TOK_ macros.
#endif
@@ -37,6 +37,9 @@
#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
@@ -66,10 +69,20 @@
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(bf16)
TOK_KEYWORD(br)
@@ -94,4 +107,5 @@
#undef TOK_IDENTIFIER
#undef TOK_LITERAL
#undef TOK_PUNCTUATION
+#undef TOK_OPERATOR
#undef TOK_KEYWORD