Support for affine integer sets
- introduce affine integer sets into the IR
- parse and print affine integer sets (both inline or outlined) similar to
affine maps
- use integer set for IfStmt's conditional, and implement parsing of IfStmt's
conditional
- fixed an affine expr paren omission bug while one this.
TODO: parse/represent/print MLValue operands to affine integer set references.
PiperOrigin-RevId: 207779408
diff --git a/lib/Parser/Lexer.cpp b/lib/Parser/Lexer.cpp
index 02db4db..91fa8ad 100644
--- a/lib/Parser/Lexer.cpp
+++ b/lib/Parser/Lexer.cpp
@@ -111,7 +111,13 @@
return lexComment();
return emitError(tokStart, "unexpected character");
- case '@': return lexAtIdentifier(tokStart);
+ case '@':
+ if (*curPtr == '@') {
+ ++curPtr;
+ return lexDoubleAtIdentifier(tokStart);
+ }
+ return lexAtIdentifier(tokStart);
+
case '#':
LLVM_FALLTHROUGH;
case '%':
@@ -199,6 +205,20 @@
return formToken(Token::at_identifier, tokStart);
}
+/// Lex an '@@foo' identifier.
+///
+/// function-id ::= `@@` bare-id
+///
+Token Lexer::lexDoubleAtIdentifier(const char *tokStart) {
+ // These always start with a letter.
+ if (!isalpha(*curPtr++))
+ return emitError(curPtr - 1, "expected letter in @@ identifier");
+
+ while (isalpha(*curPtr) || isdigit(*curPtr) || *curPtr == '_')
+ ++curPtr;
+ return formToken(Token::double_at_identifier, tokStart);
+}
+
/// Lex an identifier that starts with a prefix followed by suffix-id.
///
/// affine-map-id ::= `#` suffix-id