[antlr-interest] Custom lexer and parser constructors

Cameron Ross cross at kojeware.com
Tue May 18 09:42:28 PDT 2010


My initial problem with using the @member blocks is that you cannot redefine
default ctor generation from within the @member blocks (I was thinking of
adding a default stderr log handler to the default ctors).  This would
ensure that the error logger was always set to something.  I've come up with
an alternative approach where I initialize the error logger on the member
definition and then overwrite it from a custom ctor defined within the
@member blocks.  Everything is now working as I'd like.

Thanks for the help guys.
Cameron.

On Tue, May 18, 2010 at 12:18 PM, Bart Kiers <bkiers at gmail.com> wrote:

> On Tue, May 18, 2010 at 6:04 PM, Cameron Ross <cross at kojeware.com> wrote:
>
>> Hi,
>>
>> Is there a way to define custom constructors for ANTLR lexers and parsers?
>>
>
> Sure, you can create custom methods, c-tors and attributes in:
>
> @parser::members {
>   // here
> }
>
> or
>
> @lexer::members {
>   // here
> }
>
> Regards,
>
> Bart Kiers.
>



-- 
Kojeware Corporation


More information about the antlr-interest mailing list