Antlr4 maven plugin cannot find grammar files in different directories

前端 未结 2 1917
青春惊慌失措
青春惊慌失措 2021-01-19 04:47

I\'m using the antlr4 maven plug-in to build my maven project which uses antlr4:

     org.antlr
     antlr4-         


        
相关标签:
2条回答
  • 2021-01-19 05:16

    I had the same problem and solved with the following configuration:

    <libDirectory>${basedir}/src/main/antlr4/yourGrammarDirectory</libDirectory>
    

    Look here: How to import grammar in Antlr4 to build with maven

    0 讨论(0)
  • 2021-01-19 05:19

    For the ANTLR 4.0 release, no testing was performed on imports across multiple directories.

    Due to the limited benefits (IMO) provided by the current grammar import mechanism, this is currently a very low priority feature. Currently, sharing grammar files by using imports will not allow you to share code for the generated parsers or the parse trees they produce. I've been using ANTLR for years on dozens of products (including commercial releases), and not once have I found composite grammars to provide more benefits than trouble. (Note that I'm talking about the import statement here. Separating lexer and parser grammars into separate files in the same directory is frequently beneficial and my preferred way to work.)

    0 讨论(0)
提交回复
热议问题