Re: [abc-users] Trouble extending the lexer

From: Pavel Avgustinov <>
Date: Fri Dec 10 2004 - 15:22:08 GMT

Eric Bodden wrote:

> lexer.addGlobalKeyword("@LTL", new LexerAction_c(new
> new Integer(lexer.pointcut_state())));
Keywords can't contain non-identifier characters. The @ in the keyword
will be accepted, but the lexer won't ever match it -- the character @
itself will be matched first, hence the "illegal character" error you
observed. If you really want this, you'll have to add a rule to one of
the lexer states (possibly a new one y ou introduce) for @LTL -- or do
something in the parser when seeing @ + <identifier>.

>ltl-harness/testcases/ Illegal character "@"
> @LTL(F(call(public void
> ^
Yes, that's the error I expected. '@' is parsed separately, and the
grammar doesn't allow it to precede what is understood to be the
*identifier* LTL.

>So for some reason the @ seems to have priority over the "whole
>keyword" "@LTL" - I cannot really see why this is the case.
>And still, when I omit the "@" symbol in the lexetr and test input I
>receive the following:
>- ---
>ltl-harness/testcases/ Syntax error.
> LTL(F(call(public void
> ^-^
>1 error.
>Compiler failed.
>- ---
>Does "syntax error" mean here that lexing was ok but parsing failed
>or is that here a lexing error as well?
Syntax errors occur in parsing, so yes, lexing went fine. It could be
happening for one of two reasons -- either LTL was lexed as a keyword,
but your grammar doesn't allow it in that position, or it was lexed as
an identifier and the position is illegal for an identifier.

To trace this, you may want to call addGlobalKeyword(LTL..) with a
special class that prints something to stdout when it's lexed - there is
an example in the code for the standard abc lexer of how to execute
arbitrary code with keywords; check the default initLexerKeywords

Hope this helps, feel free to ask for more help.

Received on Fri Dec 10 15:22:19 2004

This archive was generated by hypermail 2.1.8 : Sat Dec 18 2004 - 22:20:03 GMT