我正在尝试在以下存储库中构建可用的Antlr V4语法:https://github.com/antlr/grammars-v4。我已经成功构建了Python3和Java语法,并且已经成功生成了目标* .java文件。但是,当我尝试构建C#语法时,例如CSharpLexer.g4,CSharpParser.g4和CsharpPreporcessorParser.g4我收到构建错误。它生成以下错误:
error(114): CSharpPreprocessorParser.g4:7:21: cannot find tokens file ./CSharpLexer.tokens
error(126): CSharpParser.g4:20:62: cannot create implicit token for string literal in non-combined grammar: '.'
error(126): CSharpParser.g4:25:14: cannot create implicit token for string literal in non-combined grammar: '?'
error(126): CSharpParser.g4:25:37: cannot create implicit token for string literal in non-combined grammar: '*'
error(126): CSharpParser.g4:31:8: cannot create implicit token for string literal in non-combined grammar: '*'
error(126): CSharpParser.g4:71:3: cannot create implicit token for string literal in non-combined grammar: '<'
error(126): CSharpParser.g4:71:14: cannot create implicit token for string literal in non-combined grammar: ','
error(126): CSharpParser.g4:71:25: cannot create implicit token for string literal in non-combined grammar: '>'
error(126): CSharpParser.g4:76:14: cannot create implicit token for string literal in non-combined grammar: ','
error(126): CSharpParser.g4:80:15: cannot create implicit token for string literal in non-combined grammar: ':'
error(126): CSharpParser.g4:99:3: cannot create implicit token for string literal in non-combined grammar: '='
error(126): CSharpParser.g4:99:9: cannot create implicit token for string literal in non-combined grammar: '+='
error(126): CSharpParser.g4:99:16: cannot create implicit token for string literal in non-combined grammar: '-='
error(126): CSharpParser.g4:99:23: cannot create implicit token for string literal in non-combined grammar: '*='
error(126): CSharpParser.g4:99:30: cannot create implicit token for string literal in non-combined grammar: '/='
我正在尝试使用Antlr V4 eclipse插件来构建它。我的目标是生成* .java文件以继续进行下一步。不确定如何构建所有csharp * .g4文件,因为Java和Python分别只有一个语法文件。
答案 0 :(得分:1)
首先构建CSharpLexer.g4。然后构建CSharpParser.g4和CsharpPreporcessorParser.g4。构建CSharpLexer.g4将生成CSharpLexer.tokens,供以后的CSharpParser.g4阶段使用。