为什么 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 Nov 30, 2010 12:45:30
I am using ANTLR 3.3 Nov 30, 2010 12:45:30
谢谢,安迪
推荐答案
让至少一个解析器规则公开"如下:
Make at least one parser rule "public" like this:
grammar T;
options {
language=CSharp2;
}
public parse
: privateRule+ EOF
;
privateRule
: Token+
;
// ...
然后您可以在生成的解析器上调用 parse()
.
You can then call parse()
on the generated parser.
protected
和 private
(如果未指定任何内容,则为默认值).
protected
and private
(the default if nothing is specified) are also supported.
这篇关于为什么 antlr3 c# 解析器方法是私有的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!