[antlr-interest] Lexer and Parser using CSharp3

Massimiliano Donini maxgbr at hotmail.it
Sun Dec 19 10:20:03 PST 2010


  Hi Gian Maria
For generate public method with C# 3 runtime declare in your grammar the 
rule as public /protected
like this:

public start : (left | num);

Greetings Max

Il 19/12/2010 13:43, Gian Maria ha scritto:
>
>
> 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
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>



More information about the antlr-interest mailing list