diff --git a/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/AntlrTool.java b/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/AntlrTool.java index 911f60ec9..afbff4fb7 100644 --- a/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/AntlrTool.java +++ b/monticore-generator/src/main/java/de/monticore/codegen/parser/antlr/AntlrTool.java @@ -8,6 +8,7 @@ import de.monticore.grammar.grammar._symboltable.MCGrammarSymbol; import de.monticore.grammar.grammar._symboltable.ProdSymbol; import de.se_rwth.commons.SourcePosition; +import de.se_rwth.commons.SourcePositionBuilder; import de.se_rwth.commons.StringTransformations; import de.se_rwth.commons.logging.Log; import org.antlr.v4.Tool; @@ -59,7 +60,7 @@ protected void createMessage(ANTLRMessage message, boolean isError) { ST msgST = errMgr.getMessageTemplate(message); String origMessage = msgST.render(); - Log.debug(origMessage, "AnltrTool"); + Log.debug(origMessage, "AntlrTool"); // Change arguments corresponding to names in MC grammar Object[] args = message.getArgs(); @@ -84,7 +85,11 @@ protected void createMessage(ANTLRMessage message, boolean isError) { String output = "0xA1129 " + "Error from Antlr subsystem: " + messageST.render() + " (see e.g. www.antlr.org)"; if (position.equals(SourcePosition.getDefaultSourcePosition())) { - Log.error(output); + SourcePosition sourcePosition = new SourcePositionBuilder(). + setFileName(message.fileName). + setLine(message.line). + setColumn(message.charPosition).build(); + Log.error(output, sourcePosition); } else { Log.error(output, position); diff --git a/monticore-generator/src/main/resources/parser/Lexer.ftl b/monticore-generator/src/main/resources/parser/Lexer.ftl index bc4cbe96f..ae5fe198d 100644 --- a/monticore-generator/src/main/resources/parser/Lexer.ftl +++ b/monticore-generator/src/main/resources/parser/Lexer.ftl @@ -11,10 +11,12 @@ options { ${tc.includeArgs("parser.LexerMember", [antlrGenerator, parserHelper.getGrammarSymbol().getName()])} +// Implicit token <#list genHelper.getLexSymbolsWithInherited() as lexSymbol> ${genHelper.getLexSymbolName(lexSymbol)} : '${lexSymbol}'; - + +// Explicit token <#list genHelper.getLexerRulesToGenerate() as lexProd> <#list antlrGenerator.createAntlrCode(lexProd) as lexerRule> ${lexerRule}