[abc-users] Trouble extending the lexer

From: Eric Bodden <eric@bodden.de>
Date: Fri Dec 10 2004 - 14:48:14 GMT

 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

This week I started to implement the LTL language extension, I
mentioned earlier (syntax here:
http://www.bodden.de/download.php?OOPSLA_04_Syntax_Semantic)

Extending the grammar was really done quite straightforward. However
I am having some small trouble extending the lexer.
I know I was recommended to introduce a new lexer state for my LTL
pointcuts. However, as a quick test if things work I want to just add
the appropriate keywords to the appropriate states. I tried the
following:

- ---
    public void initLexerKeywords(AbcLexer lexer) {
                // Add the base keywords
                super.initLexerKeywords(lexer);

        lexer.addGlobalKeyword("@LTL", new LexerAction_c(new
Integer(abc.ltl.parse.sym.LTL_DECL_PREFIX),
                        new Integer(lexer.pointcut_state())));

        lexer.addPointcutKeyword("F", new LexerAction_c(new
Integer(abc.ltl.parse.sym.LTL_FINALLY)));

        lexer.addPointcutKeyword("G", new LexerAction_c(new
Integer(abc.ltl.parse.sym.LTL_GLOBALLY)));

        lexer.addPointcutKeyword("U", new LexerAction_c(new
Integer(abc.ltl.parse.sym.LTL_UNTIL)));
    }
- ---

However, when I try to parse the following test file...

- ---
package testcases;
public class SyntaxCheck {
        @LTL(F(call(public void SyntaxCheck.foo())))
        public void foo() {
                //do nothing
        }
}
- ---

... I get the following parsing lexing error reported:

- ---
ltl-harness/testcases/SyntaxCheck.java:10: Illegal character "@"
        @LTL(F(call(public void SyntaxCheck.foo())))
        ^

ltl-harness/testcases/SyntaxCheck.java:10: Syntax error.
        @LTL(F(call(public void SyntaxCheck.foo())))
              ^

2 errors.
Compiler failed.
- ---

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/SyntaxCheck.java:10: Syntax error.
        LTL(F(call(public void SyntaxCheck.foo())))
        ^-^

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?

Cheers,
Eric

- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQbm3LcwiFCm7RlWCEQKQUwCfYiK/X4SC8wprIXaVT/syq8h5Oy0AoL+W
JsJ/XTDHEb5X0P564vIi2QYW
=aVFG
-----END PGP SIGNATURE-----
Received on Fri Dec 10 14:49:03 2004

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