[antlr-interest] Reg Multi-line comments
Gokulakannan Somasundaram
gokul007 at gmail.com
Sat Jul 25 13:43:03 PDT 2009
Hi David-Sarah Hopwood,
Sorry i missed your post and failed to reply.
Yes this solution works well in Java. But the problem
is that i am trying to do in C++(C), and this is not possible there. So i am
introducing the state information with the Nevertheless, it is a very
thoughtful solution and thanks for helping me out.
Thanks,
Gokul.
On Fri, Jul 17, 2009 at 11:03 AM, David-Sarah Hopwood <
david-sarah at jacaranda.org> wrote:
> Gokulakannan Somasundaram wrote:
> > Actually there is a comment like this before the source code of the
> > function.
> >
> > /** A more general version of getRuleInvocationStack where you can
> > * pass in, for example, a RecognitionException to get it's rule
> > * stack trace. This routine is shared with all recognizers, hence,
> > * static.
> > *
> > * TODO: move to a utility class or something; weird having lexer
> call
> > * this */
> > public static List getRuleInvocationStack(Throwable e,
> > String recognizerClassName)
> >
> >
> > It more or less sounds to me that lexer should not call this.
>
> The recipe in section 10.2 of 'The Definitive ANTLR Reference' does so,
> therefore it's a supported API, not internal. Moving it would break all
> lexers using that recipe.
>
> Calling the static version of this method rather than the instance
> version (with no arguments) is correct: if you don't obtain the stack
> from the RecognitionException that is passed to getErrorMessage, then
> the relevent lexer rule will no longer be on the current stack in some
> cases.
>
> > When i observe
> > the source code, i see that your approach may not be possible, because
> the
> > token to be tried out never gets saved anywhere. But let me check this.
>
> It is possible because the implementation uses a stack trace to determine
> which lexer methods were on the call stack when the RecognitionException
> was thrown, and so no explicit state is needed. In any case, I tested this
> code before posting; it works.
>
> --
> David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090726/0bdeffc0/attachment.html
More information about the antlr-interest
mailing list