Just like any other aspect-oriented language, AspectMatlab provides a variety of patterns that can be used to match basic language constructs. In addition to standard patterns such as those supported by AspectJ, a scientific programming language like MATLAB possesses other important cross-cutting concerns. In MATLAB, array constructs are heavily used and programs are written in the form of large functions or scripts containing many loops.
Grammar rules for patterns are presented in Figure 2. Patterns are contained inside blocks, and an aspect can contain any number of such blocks of patterns. A pattern is formed by its unique name and the pattern designators. AspectMatlab provides a number of primitive patterns targeting different constructs of MATLAB. These primitive patterns can be logically combined to form the compound pattern designators. We will discuss this concept in detail in Section 2.2.6.
While providing the basic function-related
patterns like and
, we also introduce
two new sets of patterns: (1)
/
patterns, enabling the facility to
capture array-related operations along with useful context exposure;
and (2) loop patterns, which will help programmers to handle the loop
iteration space and details of loop-intensive computation. AspectMatlab
also supports a special
pattern, which allows us
to restrict the scope of matching to certain constructs of the source code,
such as functions, scripts, classes or loops.
Towards the bottom of Figure 2, we introduce some grammar rules to enable a programmar to perform selective matching. MATLAB syntax allows us to make a function call, without even providing the exact number of parameters specified in the function signature. Arrays can be indexed in a similar fashion. So AspectMatlab provides a functionality to enhance the matching based on the actual parameters/indices involved. We explain the idea of selective matching in Section 2.2.3.
Moreover, matching can be performed based on the expressions containing wild card symbol "*", which results in a broader scope of matching.
A list of primitive patterns supported by AspectMatlab is presented in Table I. We discuss the different kinds of patterns in the following sections.