diff --git a/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/Grammar2Antlr.java b/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/Grammar2Antlr.java index 67c8bc9238..8b73f69d24 100644 --- a/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/Grammar2Antlr.java +++ b/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/Grammar2Antlr.java @@ -371,7 +371,7 @@ public void handle(ASTConstantGroup ast) { } else if (grammarInfo.getKeywordRules().contains(x.getName())) { addToCodeSection(parserHelper.getKeyRuleName(x.getName())); } else { - addToCodeSection("'" + x.getName() + "'"); + addToCodeSection(parserHelper.getLexSymbolName(x.getName())); } if (embeddedJavaCode) { diff --git a/monticore-test/it/src/main/grammars/mc/feature/constantgroups/SpecialLexerTokensInConstantGroup.mc4 b/monticore-test/it/src/main/grammars/mc/feature/constantgroups/SpecialLexerTokensInConstantGroup.mc4 new file mode 100644 index 0000000000..a2eb7bc75e --- /dev/null +++ b/monticore-test/it/src/main/grammars/mc/feature/constantgroups/SpecialLexerTokensInConstantGroup.mc4 @@ -0,0 +1,7 @@ +/* (c) https://github.com/MontiCore/monticore */ +package mc.feature.constantgroups; + +grammar SpecialLexerTokensInConstantGroup { + Start = ALTQUESTION bar:["?" | "!"]; + token ALTQUESTION = '?'; +}