From c9c1b2381daab5ed43a6cfc7cca952ad972c5de6 Mon Sep 17 00:00:00 2001 From: mac-op Date: Mon, 3 Nov 2025 00:31:50 +0700 Subject: [PATCH 1/2] Add support for ellipsis token in MLIR lexer --- .../org/komlir/intellijmlirplugin/MLIRLexer.kt | 12 ++++++++++++ .../org/komlir/intellijmlirplugin/MLIRTokenTypes.kt | 1 + 2 files changed, 13 insertions(+) diff --git a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt index ce531e6..539b765 100644 --- a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt +++ b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt @@ -140,6 +140,18 @@ class MLIRLexer : LexerBase() { currentOffset++ tokenType = MLIRTokenTypes.OPERATOR } + char == '.' -> { + currentOffset++ + tokenType = when { + currentOffset < endOffset - 1 && buffer[currentOffset] == char && buffer[currentOffset + 1] == char -> { + currentOffset += 2 + MLIRTokenTypes.ELLISPIS + } + else -> { + TokenType.BAD_CHARACTER + } + } + } else -> { currentOffset++ tokenType = TokenType.BAD_CHARACTER diff --git a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt index 33d2efd..6210434 100644 --- a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt +++ b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt @@ -22,6 +22,7 @@ object MLIRTokenTypes { @JvmField val RBRACKET = IElementType("MLIR_RBRACKET", MLIRLanguage) @JvmField val LT = IElementType("MLIR_LT", MLIRLanguage) @JvmField val GT = IElementType("MLIR_GT", MLIRLanguage) + @JvmField val ELLISPIS = IElementType("MLIR_ELLIPSIS", MLIRLanguage) object TokenSets { @JvmField val identifiers = TokenSet.create(IDENTIFIER, SSA_VALUE, SYMBOL_REF, OPERATION) From 777e75b3955ddfa2460355390bf548a42dfc036e Mon Sep 17 00:00:00 2001 From: mac-op Date: Mon, 3 Nov 2025 00:41:19 +0700 Subject: [PATCH 2/2] Fix typo in token name --- src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt | 2 +- src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt index 539b765..415d997 100644 --- a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt +++ b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRLexer.kt @@ -145,7 +145,7 @@ class MLIRLexer : LexerBase() { tokenType = when { currentOffset < endOffset - 1 && buffer[currentOffset] == char && buffer[currentOffset + 1] == char -> { currentOffset += 2 - MLIRTokenTypes.ELLISPIS + MLIRTokenTypes.ELLIPSIS } else -> { TokenType.BAD_CHARACTER diff --git a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt index 6210434..2d17b9b 100644 --- a/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt +++ b/src/main/kotlin/org/komlir/intellijmlirplugin/MLIRTokenTypes.kt @@ -22,7 +22,7 @@ object MLIRTokenTypes { @JvmField val RBRACKET = IElementType("MLIR_RBRACKET", MLIRLanguage) @JvmField val LT = IElementType("MLIR_LT", MLIRLanguage) @JvmField val GT = IElementType("MLIR_GT", MLIRLanguage) - @JvmField val ELLISPIS = IElementType("MLIR_ELLIPSIS", MLIRLanguage) + @JvmField val ELLIPSIS = IElementType("MLIR_ELLIPSIS", MLIRLanguage) object TokenSets { @JvmField val identifiers = TokenSet.create(IDENTIFIER, SSA_VALUE, SYMBOL_REF, OPERATION)