问题
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?
I am using ANTLR 3.3 Nov 30, 2010 12:45:30
Thanks, Andy
回答1:
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.
来源:https://stackoverflow.com/questions/6411520/why-are-antlr3-c-sharp-parser-methods-private