2

I'm trying to use ANTLR to create a parser for simple language using C# code generation.

I have successfully product MyLangLexer.cs and MyLangParser.cs with very very simple rule called 'rule'.

The problem is that the generated method rule() is private.

All I want is to use ANTLR to parse a string into AST.

Thank you, Ido.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ido Ran
  • 10,584
  • 17
  • 80
  • 143

1 Answers1

5

The C# v3 target produces private methods by default, in contrary to Java's target. Add the keyword public in front of those rules you want to be public:

grammar MyLang;

...

public rule // rule is now public
  :  other
  ;

other // other is private
  :  ...
  ;

...
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288