我是JavaCC的新手,无法弄清楚如何让它运行.我使用的是Mac OS X,我安装了javacc-6.0.zip并将其解压缩.我无法从我的路径访问javacc脚本,因为在javacc终端上键入时我收到以下消息:
-bash: javacc: command not found
Run Code Online (Sandbox Code Playgroud)
如何从我的路径访问javacc脚本?
我的解压缩文件夹javacc-6.0位于以下目录中:/Users/Rishabh/Desktop/javacc
所以我在终端上做了以下事情:
PATH=$PATH\:/Users/Rishabh/Desktop/javacc/javacc-6.0/
Run Code Online (Sandbox Code Playgroud)
javacc接下来打字给我同样的信息.
我试图在gcc上编译一个文件,我的'make'命令似乎抛出一个错误.
Rishabhs-MacBook-Pro:binutils-2.20.1 Rishabh$ make
make[3]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
Making info in doc
make chew
make[4]: `chew' is up to date.
./chew -f ./doc.str <./../opncls.c >opncls.tmp
/bin/sh ./../../move-if-change opncls.tmp opncls.texi
Making info in po
...
...
make[4]: Nothing to be done for `all'.
gcc -DHAVE_CONFIG_H -I. -I. -I. -I../bfd -I./../bfd -I./../include - DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -MT strings.o -MD -MP -MF .deps/strings.Tpo -c -o strings.o strings.c …Run Code Online (Sandbox Code Playgroud) 我正在编写一个编译器,将JavaCC转换为ANTLR4,其中一个规则涉及传递参数并从中获取返回值.
对于规则'term',我必须执行以下操作:
Term term(ReadOptions options, int priority):
{
int p = options.operatorSet.getNextLevel(priority);
Term t;
}
{
(
LOOKAHEAD({p==0})
t = simpleTerm(options)
|
LOOKAHEAD(<NAME_TOKEN>,{priority==1201 && is1201Separator(2)})
t = name()
|
t = operatorTerm(options, p)
)
{return t;}
}
Run Code Online (Sandbox Code Playgroud)
问题是我如何根据'p'的值匹配子规则.在以前版本的ANTLR中我可以使用=>而我的问题会解决,但我在ANTLR4中做什么?