[antlr-interest] how to initialize Antlr local variables?

Ching zching01 at gmail.com
Tue Jan 4 15:57:48 PST 2011


Thank you! Another question is that I am doing type checking in my grammar
file, is there a way to display errors like the syntax error instead of
sending them to stderr? I read Terrence Parr's recently posting (
http://www.stringtemplate.org/wiki/display/ANTLR3/Pattern+for+returning+errors+from+ANTLR+in+data+structures,+not+STDERR)
, not sure I understand it. Hope you can help. Thanks.

-- Ching

On Thu, Dec 30, 2010 at 8:21 PM, Nick Vlassopoulos
<nvlassopoulos at gmail.com>wrote:

> Hi Ching,
>
> I am not sure if it is a legitimate statement, but what you probably want
> is the @members and @header keywords that add your code in the
> generated files.
>
> HTH,
>
> Nikos
>
> On Thu, Dec 30, 2010 at 10:53 PM, Ching <zching01 at gmail.com> wrote:
>
>> Hi,
>>
>> In a Antlr grammar file, I declared a number of variables. Is there a way
>> to
>> initialize these variables, for example, in the default constructor?
>>
>> Is below a legitimate grammar statement?
>>
>> *start:  initialization { var = new XXX();}  compilation_unit EOF*
>>
>> Thanks.
>>
>> 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