Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are antlr3 c# parser methods private?

Tags:

c#

antlr

antlr3

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

like image 587
Andy Bisson Avatar asked Jun 20 '11 12:06

Andy Bisson


People also ask

What is the use of antlr3 runtime?

runtime dll, or antlr3. runtime dll if you're using ANTLR version 3. Your C# program can now parse text files using the grammar that you compiled in step 1.

What is antlr3?

ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.


1 Answers

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.

like image 182
Bart Kiers Avatar answered Sep 27 '22 21:09

Bart Kiers