Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
research:dsal:aspectg [2009/02/19 14:38] – jfabry | research:dsal:aspectg [2009/02/19 14:38] (current) – jfabry | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== AspectG ===== | ||
+ | |||
+ | (Internal classification: | ||
+ | |||
+ | Reference paper: **" | ||
+ | |||
+ | The reference discusses both AspectG and [[AspectLISA]] | ||
+ | |||
+ | ===== Domain of the language ===== | ||
+ | |||
+ | The definition of programming languages (grammars) and compiler construction. An important problem in this area is the modularity, reusability and extensibility of a language specification. AOSD is used here to modularize semantic concerns that crosscut many language components described in the grammar. | ||
+ | |||
+ | From the reference paper: " | ||
+ | |||
+ | AspectG is a DSAL for ANTLR grammars. (ANTLR stands for ANother Tool for Language Recognition) ANTLR is a parser generator that facilitates the building of language tools, it uses EBNF notation for grammar specification. Tokens are defined using regular expressions and semantic actions are written in a General Purpose Language (GPL). | ||
+ | |||
+ | ===== Intent of the language ===== | ||
+ | |||
+ | | ||
+ | |||
+ | Note that the authors claim that AspectG could be language-independent, | ||
+ | |||
+ | Comparing [[AspectLISA]] and AspectG in one line: [[AspectLISA]] allows for extension of the base language, AspectG allows for the definition of new tools on an existing grammar. | ||
+ | |||
+ | ===== Join Point Model and Advice Model ===== | ||
+ | |||
+ | * JPM: Domain-Specific : Matches are on both the syntax of the grammar **and** the semantic actions. | ||
+ | * AM: General-Purpose : Semantic actions are written in Java (could be any GPL) | ||
+ | |||
+ | ===== Anatomy of the language ===== | ||
+ | |||
+ | The structure of AspectG pointcuts is similar to AspectJ pointcuts, except that they use either the '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | "The advice are semantic rules written as native Java statements that can be applied at join points specified by pointcuts" | ||
+ | |||
+ | ===== Typical Example ===== | ||
+ | |||
+ | As the base language: ANTLR is a DSL, we first include an example of code in ANTLR. This is an excerpt of the same robot example as in [[AspectLISA]]. | ||
+ | |||
+ | root :( | ||
+ | BEGIN | ||
+ | {fileio.print(" | ||
+ | commands | ||
+ | END EOF!); | ||
+ | commands:( command commands | ); | ||
+ | command :( | ||
+ | LEFT {fileio.print(" | ||
+ | |RIGHT | ||
+ | |UP {fileio.print(" | ||
+ | |DOWN {fileio.print(" | ||
+ | |||
+ | The first pointcut below matches all command productions within the above example, the second is an illustration of a boolean expression of predicates, matching all command productions that increase the time counter (which again matches all productions). | ||
+ | |||
+ | pointcut productions(): | ||
+ | pointcut count_gpllinenumber(): | ||
+ | within(command.*) && match(fileio.print(" | ||
+ | |||
+ | The following advice is used as part of a debugging tool for the robot language | ||
+ | |||
+ | before(): productions() {dsllinenumber++; | ||
+ | after(): | ||
+ | gplendline=fileio.getLinenumber(); | ||
+ | filemap.print(" | ||
+ | + dsllinenumber + ", | ||
+ | + gplbeginline + "," | ||
+ | |||
+ | ===== Enforced Restrictions ===== | ||
+ | |||
+ | AspectG can only add extra semantic actions to rules in the underlying grammar. The code for these rules, in a GPL, is however simply merged into the grammar (the weaver is a preprocessor). There is no verification of these actions whatsoever, which is why the authors claim AspectG could be language-independent. | ||
+ | |||
+ | ===== Implementation description ===== | ||
+ | |||
+ | Aspects are woven into the ANTLR grammar itself, in a preprocessor approach. The preprocessor uses an ANTLR-built ANTLR parser together with low-level matching and transformation operations on the AST of the ANTLR source. Aspects are treated as a set of rewrite rules, the weaver applies these rules until no more matching rules can be found. | ||
+ | |||