Skip to content

Commit 1668e58

Browse files
committed
fix: add an error message when a combined grammar has no implicit lexer grammar (fixes #687)
1 parent 85cc999 commit 1668e58

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/main/java/org/antlr/intellij/plugin/parsing/ParsingUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ public static Grammar[] loadGrammars(VirtualFile grammarFile, Project project) {
310310
case ANTLRParser.COMBINED :
311311
lg = g.getImplicitLexer();
312312
if ( lg==null ) {
313+
String msg = "No implicit lexer grammar found in combined grammar " + g.name
314+
+ ". Did you mean to declare a `parser grammar` instead?\n";
315+
console.print(msg, ConsoleViewContentType.ERROR_OUTPUT);
313316
lg = BAD_LEXER_GRAMMAR;
314317
}
315318
ANTLRv4PluginController.LOG.info("loadGrammars combined: "+lg.name+", "+g.name);

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ For really big files and slow grammars, there is an appreciable delay when displ
7474
<change-notes><![CDATA[
7575
<ul>
7676
<li>Fixed syntax highlighting in 2024.1 EAP (<a href="https://github.com/antlr/intellij-plugin-v4/issues/691">#691</a>)</li>
77+
<li>Explain when a grammar might lack the `parser` keyword (<a href="https://github.com/antlr/intellij-plugin-v4/issues/687">#687</a>)</li>
7778
</ul>
7879
See the complete list of <a href="https://github.com/antlr/intellij-plugin-v4/issues?q=milestone%3A1.23.1fix+is%3Aclosed">fixed issues</a>.
7980
]]>

0 commit comments

Comments
 (0)