Declarative and deterministic parsing of AspectJ

Date of Submission: 
March 18, 2009
Report Number: 
Report PDF: 
AspectJ, a language that provides aspect constructs in Java, has historically proven difficult to parse using traditional methods. The AspectJ Bench Compiler (abc) uses a traditional LALR(1) parser, but must use a custom-built, non-declarative scanner that switches modes based on whether the parse is in an aspect or not. This allows the parser to reserve different sets of keywords against the identifiers. More recently, Visser et al. have devised a declarative parser for AspectJ in their nondeterministic scannerless-GLR framework --- although they have to add a new feature, grammar mix-ins, to handle the problem of the different sets of keywords. We have adapted the LALR(1) grammar used in abc to extend the Java grammar in our ableJ framework. As it happens, with a context-aware scanner, the abc version of AspectJ can be parsed deterministically and declaratively, due to the fact that a context-aware scanner can tell whether it is scanning within an aspect or not.