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
  • 704,970
  • 168
  • 1,303
  • 1,425
Ido Ran
  • 9,676
  • 13
  • 75
  • 134

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
  • 161,100
  • 35
  • 287
  • 281