为什么antlr3 C#解析器方法私人? [英] Why are antlr3 c# parser methods private?
问题描述
我在建设一个ANTLR解析器编译为Java的工作目标。当我重新定位为C#2它产生的解析器中,所有的解析方法是私有的,但标记为[GrammarRule(RuleName中)]属性。
I'm building a parser in antlr which compiles to a working java target. When I retarget for c#2 it produces a parser in which all of the parse methods are private but marked with a [GrammarRule("rulename")] attribute.
什么是认可的手段,实际调用解析器?
What is the approved means to actually invoke the parser?
我使用ANTLR 3.3 2010年11月30日12点45分30秒
I am using ANTLR 3.3 Nov 30, 2010 12:45:30
谢谢,
刘德华
Thanks, Andy
推荐答案
请至少有一个解析器规则公开是这样的:
Make at least one parser rule "public" like this:
grammar T;
options {
language=CSharp2;
}
public parse
: privateRule+ EOF
;
privateRule
: Token+
;
// ...
您可以调用解析()
上生成的解析器。
You can then call parse()
on the generated parser.
保护
和私人
(如果没有指定缺省值)也支持。
protected
and private
(the default if nothing is specified) are also supported.
这篇关于为什么antlr3 C#解析器方法私人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!