[antlr-interest] Lexer and Parser using CSharp3

Gian Maria g_giacomello at yahoo.it
Sun Dec 19 04:43:30 PST 2010


 

program: start+;

 

start :      (let | num);

 

let    :      LET;

num    :      NUM;

 

LET    :      ('a'..'z')+;

NUM    :      ('0'..'9')+;

 

WHITESPACE   :      ( '\t' | ' ' | '\r' | '\n' )+ { $channel = HIDDEN; };

 

 

1) Why inside Lexer and Parser all methods are declared Private (for example
the above "program" parser rule)? If I want to use one method of my Parser I
have to change it to public inside source code, is right to do this?

 

2) Is there a way to find if CommonTokenStream find some undefined chars in
the string?

 

In the above definition I want as input only lower case letters and number,
so if I write "123 aa 5 Bc" I want to detect the error at "B", How can I do
that?

 

The language I use is C# and the above code is a little example Just to test
the ANTLR functions to take me a Global understand of the potentiality.

Tank you for the support, I'm learning ANTLR but is not too easy at the
beginning.

 

Best regards Gian



More information about the antlr-interest mailing list