TestRig/grun 在解析示例文件时卡住了 [英] TestRig / grun gets stuck parsing the example file
问题描述
按照这个问题,我正在尝试学习如何使用 TestRig/grun 工具.考虑 这个 repo 中的语法文件.我运行了以下命令:
<前>export CLASSPATH=".:/usr/local/Cellar/antlr/<version>/antlr-<version>-complete.jar:$CLASSPATH"antlr <grammarName>.g4javac <grammarName>*.java但是当我跑步时
grun <输入文件>
它卡住了而不返回任何错误消息.我也用其他例子对此进行了测试,但无济于事.如果您能帮助我了解问题所在以及如何解决,我将不胜感激.
正常的 grun
别名以grammarName 和startRule 作为参数,并期待来自stdin 的输入:
grun <开始规则><<输入文件>
示例:
grun ElmerSolver 部分 -tree <例子/ex001.sif
如果您只想运行 Lexer,您可以使用伪启动规则";代币":
grun ElmerSolver 令牌 -tokens <例子/ex001.sif
有了你的样品,这给了我:
[@0,0:9='模拟',<'模拟'>,1:0][@1,11:13='End',<'End'>,2:0][@2,16:24='方程',<'方程'>,4:0][@3,25:25='1',<整数>,4:9][@4,27:29='End',<'End'>,5:0][@5,30:29='<EOF>',<EOF>,5:3]
(这是使用我在上一个答案中所做的语法更改,但应该展示结果)
Following this question, I'm trying to learn how to use the TestRig / grun tool. Consider the grammar file in this repo. I ran the below commands :
export CLASSPATH=".:/usr/local/Cellar/antlr/<version>/antlr-<version>-complete.jar:$CLASSPATH" antlr <grammarName>.g4 javac <grammarName>*.java
but when I run
grun <grammarName> <inputFile>
it gets stuck without returning any error messages. I have tested this with other examples as well to no avail. I would appreciate it if you could help me know what is the problem and how I can resolve it.
the normal grun
alias takes the grammarName and startRule as parameters and expects the input from stdin:
grun <grammarName> <startRule> < <inputFile>
example:
grun ElmerSolver sections -tree < examples/ex001.sif
If you want to run just the Lexer, you can use the "pseudo-startrule" "tokens":
grun ElmerSolver tokens -tokens < examples/ex001.sif
With your sample, this gives me:
[@0,0:9='Simulation',<'Simulation'>,1:0]
[@1,11:13='End',<'End'>,2:0]
[@2,16:24='Equation ',<'Equation '>,4:0]
[@3,25:25='1',<Integer>,4:9]
[@4,27:29='End',<'End'>,5:0]
[@5,30:29='<EOF>',<EOF>,5:3]
(That's using the grammar changes I made in the previous answer, but should demonstrate the results)
这篇关于TestRig/grun 在解析示例文件时卡住了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!