ANTLR tokenVocab 中的相对路径
Relative path in ANTLR tokenVocab
我是ANTLR的新手,正在进步,遇到了这个问题。
我有这样的结构:
-- MAIN
---|__ SUB
|__ ABCLexer.g4
|__ ABCParser.g4
BaseLexer.g4
我想在 ABCParser 中使用 BaseLexer。所以,我尝试了很多事情,例如:
options {tokenVocab=BaseLexer;}
options {tokenVocab='../BaseLexer';}
options {tokenVocab='fullpath to BaseLexer';}
我也尝试过使用 import 来查看是否可以正常工作。都无济于事。在我将所有内容拉回到同一个目录之前,有没有简单的方法可以做到这一点?
不要在导入语句中使用路径,而是在工具调用中指定语法搜索路径,如 tool-options 文档中所述:
$ antlr4 -lib /tmp A.g4
在 vscode 的 ANTLR4 扩展中,您可以在扩展设置中以 described in the documentation 的形式提供此信息(参见 importDir
设置)。
我是ANTLR的新手,正在进步,遇到了这个问题。
我有这样的结构:
-- MAIN
---|__ SUB
|__ ABCLexer.g4
|__ ABCParser.g4
BaseLexer.g4
我想在 ABCParser 中使用 BaseLexer。所以,我尝试了很多事情,例如:
options {tokenVocab=BaseLexer;}
options {tokenVocab='../BaseLexer';}
options {tokenVocab='fullpath to BaseLexer';}
我也尝试过使用 import 来查看是否可以正常工作。都无济于事。在我将所有内容拉回到同一个目录之前,有没有简单的方法可以做到这一点?
不要在导入语句中使用路径,而是在工具调用中指定语法搜索路径,如 tool-options 文档中所述:
$ antlr4 -lib /tmp A.g4
在 vscode 的 ANTLR4 扩展中,您可以在扩展设置中以 described in the documentation 的形式提供此信息(参见 importDir
设置)。