next up previous
Next: Tokens in pointcuts Up: Lexical Structure of Pointcuts Previous: Lexical Structure of Pointcuts

Examples of differences from the Java lexical structure

The example program clearly demonstrates ways in which the lexical structure of pointcuts is very different from the lexical structure of Java.

For example, if one were to use the ordinary Java lexical rules, then the expression ``*1.Foo+.new(..)'' would be tokenized as:

[ op("*"), fp_literal(1.0), Id("Foo"), op("+"), op("."), keyword("new"), op("("), op("."), op(".") op(")")].

However, in pointcuts, the intended lexical structure is quite different and would be tokenized as:

[ IdPat("*1"), op("."), id("Foo"), op("+"), op("."), keyword("new"), op("("), op(".."), op(")")].

Note that ``*1" is an identifier pattern, which matches any identifier ending in 1. Also, the sequence ``+." is recognized as one token, not two. This simplifies the grammar and avoids shift-reduce conflicts. Finally, the sequence ``.." is recognized as one token, which also simplifies the grammar.

Another example of the need for a special lexical structure for pointcuts is given in the definition of the pointcut notKeywords. The ordinary Java lexical rules would tokenize the expression ``*if*..*while*" as:

[ op("*"), keyword("if"), op("*"), op("."), op("."), op("*"), keyword("while"), op("*")].

whereas this expression inside a pointcut has a completely different lexical structure, namely:

[ IdPat("*if*"), op(".."), IdPat("*while*") ] .


next up previous
Next: Tokens in pointcuts Up: Lexical Structure of Pointcuts Previous: Lexical Structure of Pointcuts
hendren 2004-09-02