[英]Creating command line alias for Java class in ANTLR 4 generated parser
Below is a line of code I found in Chapter 1 of the "The Definitive ANTLR 4 Reference" book. 下面是我在“权威ANTLR 4参考”一书的第1章中找到的代码行。 This command is not working in Windows command prompt.
该命令在Windows命令提示符下不起作用。 How can I correct this error so it stores an alias for the Tool?
如何更正此错误,以便它存储工具的别名? I imagine the author forgot to include the alias in this line of code, but I don't know where it should go.
我想象作者忘了在此代码行中包含别名,但是我不知道该去哪里。
C:\source\antlr4\Hello>java -cp C:\libraries\antlr-4.4-complete.jar;%CLASSPATH% org.antlr.v4.Tool %*
Error: 错误:
error(7): cannot find or open file: %*
In the book, the jar file is not on version 4.4, but rather 4.0. 在本书中,jar文件不是版本4.4,而是版本4.0。 That's the only difference.
那是唯一的区别。 Instead of typing the line below, I should just be able to type "antlr4" from the command line to initiate the generated parser to accept input.
不用键入下面的行,我应该只能从命令行键入“ antlr4”来启动生成的解析器以接受输入。
C:\source\antlr4\Hello>java org.antlr.v4.runtime.misc.TestRig Hello r -tree
I am following the Hello World grammar. 我正在遵循Hello World语法。
In UNIX, it looks like the equivalent is: 在UNIX中,等效项是:
alias antlr4='java -jar /usr/local/lib/antlr-4.4-complete.jar'
Turns out that you should exclude the quotes when defining an alias in Windows. 事实证明,在Windows中定义别名时应排除引号。 There is also a
$*
to accept parameters. 还有一个
$*
可以接受参数。
C:\source\antlr4\Hello>doskey antlr4=java -jar C:\libraries\antlr-4.4-complete.jar $*
C:\source\antlr4\Hello>doskey grun=java org.antlr.v4.runtime.misc.TestRig $*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.