User Tools

Site Tools


lara:tutorial:languagespecification

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lara:tutorial:languagespecification [2015/04/06 22:42]
tdrc [Attributes Model]
lara:tutorial:languagespecification [2019/09/22 15:47] (current)
Line 1: Line 1:
-====== ​Tutorial - Target Language Specification ====== +====== ​Writing a Target Language Specification ====== 
 +;#; 
 +[[lara:​tutorial:​advanced| ← Advanced LARA ]] | [[lara:​tutorial:​languagespecification| Language Specification ]] | [[lara:​tutorial:​larai|Basic larai → ]] 
 +;#;
 The most critical element of an aspect-oriented language mechanism is the join point The most critical element of an aspect-oriented language mechanism is the join point
 model, the model that represents the programming language’s points of interest, like method model, the model that represents the programming language’s points of interest, like method
Line 9: Line 11:
 supported points of interest. ​ supported points of interest. ​
  
-One of the aspects of the LARA language is that it is partially agnostic to the target language. How LARA knows the join point model, the available attributes, and action that can be applied, is by using an external representation of the target language. This is accomplished by defining three files that represents the join point model and the attributes of a certain programming language, and the actions available in the weaver that will execute the LARA aspects. This approach proves an important feature of the meta-language ​that+One of the aspects of the LARA language is that it is partially agnostic to the target language. How LARA knows the join point model, the available attributes, and action that can be applied, is by using an external representation of the target language. This is accomplished by defining three files that represents the join point model and the attributes of a certain programming language, and the actions available in the weaver that will execute the LARA aspects. This approach proves an important feature of LARA that
 represents its flexibility and expandability. The three files are defined in an XML format, each with specific tags and attributes. represents its flexibility and expandability. The three files are defined in an XML format, each with specific tags and attributes.
  
Line 19: Line 21:
  
   - The gray arrow between **assignExpr** → **expr** means that **assignExpr** inherits everything that **expr** contains, including selectable join points, attributes and actions;   - The gray arrow between **assignExpr** → **expr** means that **assignExpr** inherits everything that **expr** contains, including selectable join points, attributes and actions;
-  - The arrows between **body** ↔ **loop** defines that **body** is able to select the loops inside itself and, in turn, *loop* is able to select its own body;+  - The arrows between **body** ↔ **loop** defines that **body** is able to select the loops inside itself and, in turn, **loop** is able to select its own body;
   - The two arrows connecting **body** → **stmt** means that in the first connection (without label) we are able to select all statements inside the body and in the second connection (with label **first_stmt**) we are going to select one type of statement (the first statement of the body). This is an example of having different selects for the same type of join point.   - The two arrows connecting **body** → **stmt** means that in the first connection (without label) we are able to select all statements inside the body and in the second connection (with label **first_stmt**) we are going to select one type of statement (the first statement of the body). This is an example of having different selects for the same type of join point.
 <​imgcaption jmpGraph|A simple example of a join point model hierarchy.>​ <​imgcaption jmpGraph|A simple example of a join point model hierarchy.>​
Line 321: Line 323:
 </​code>​ </​code>​
 ===== Action Model ===== ===== Action Model =====
-Actions that can be applied over the application.+ 
 +The Actions ​Model defines the actions ​that can be applied over the application. By default, LARA has already the **insert** and **def** actions predefined. All other actions the weaver is able to perform is defined in this action model. The following table considers some actions that current existing weavers can perform. 
 + 
 +^  Action ​    ​^ ​  ​Parameters ​                ​^^^ ​ Target Join Point  ^  Description ​  ^ 
 +| :::         ^ Name      ^Type    ^ Default ​  | :::                  | :::           | 
 +| report ​     | -         | -      | -         | any                  | create a report of a join point by using its attributes | 
 +| dna         | -         | -      | -         | function, loop       | extract a program DNA representation from the join point | 
 +| map         | to        | string | -         | function ​            | map computations to the given (embedded) target system | 
 +| :::         | id        | string | "​0" ​      | :::                  | ::: | 
 +| :::         | mode      | string | "​default"​ | :::                  | ::: | 
 +| unroll ​     | factor ​   | int    | 0         | loop                 | unroll a loop with a given factor | 
 +| interchange | loop2     | loop   | -         | loop                 | interchange the current loop with another, nested, loop | 
 + 
 +The action model is defined in its own xml formatted file. The list of actions is defined inside an **<​actions>​** element, with no attributes specified for this element. 
 + 
 +<code xml> 
 +<​actions>​ 
 +  ... 
 +</​actions>​ 
 +</​code>​ 
 + 
 +Each action is then defined in an **<​action>​** element with two attributes: the **name** of the action (mandatory) and the target **class** (optional). The target class specifies the join point classes that can perform that action. Many classes may be used in the **class** attribute, separated with a ','​ (comma). When the **class** attribute is not defined (or defined as "​*"​),​ then it is considered that the action can be performed in any join point class. 
 + 
 +<code xml> 
 +<​actions>​ 
 +  <action name="​report"/>​ 
 +  <action name="​dna"​ class="​function,​loop"/>​ 
 +  <action name="​map"​ class="​function"/>​ 
 +  <action name="​unroll"​ class="​loop"/>​ 
 +  <action name="​interchange"​ class="​loop"/> ​  
 +</​actions>​ 
 +</​code>​ 
 + 
 +The **report** and **dna** actions are ready to be used, since they do not require parameters. For the rest of the actions, a list of parameters is required. The parameters are defined each in a **<​parameter>​** element, inside the **<​action>​** element, with three attributes: the name and type (both mandatory), and the default value (optional) to be used if the parameter is not assigned in an action call, in a LARA aspect. The following code shows the complete action model for the actions defined in the table above.
  
 <code xml actionModel.xml>​ <code xml actionModel.xml>​
 <​actions>​ <​actions>​
-    <!-- Actions available within the REFLECT flow --> +  ​<action name="report"/
- <action name="unroll">​ +  <action ​name="dna" ​class="function,​loop"/>​ 
- <parameter ​name="k" ​type="int" default="​0"/>​ +  <action name="​map" class="​function">​ 
- </​action>​ +    <​parameter name="​to"​ type="​string"/>​ 
- <action name="​map">​ +    <​parameter name="​id"​ type="​string"​ default="​0"/>​ 
- <​parameter name="​to"​ type="​string"/>​ +    <​parameter name="​mode"​ type="​string"​ default="​default"/>​ 
- <​parameter name="​id"​ type="​string"​ default="​0"/>​ +  </​action>​ 
- <​parameter name="​mode"​ type="​string"​ default="​default"/>​ +  <action name="​unroll">​ 
- </​action>​+    <​parameter name="​factor"​ type="​int"​ default="​0"/>​ 
 +  </​action>​ 
 +  <action name="​interchange"​ class="​loop">​ 
 +    <​parameter name="​loop2"​ type="​loop"/>​ 
 +  ​</​action> ​
 </​actions>​ </​actions>​
 </​code>​ </​code>​
 +
 +;#;
 +[[lara:​tutorial:​advanced| ← Advanced LARA ]] | [[lara:​tutorial:​languagespecification| Language Specification ]] | [[lara:​tutorial:​larai|Basic larai → ]]
 +;#;
lara/tutorial/languagespecification.1428352973.txt.gz · Last modified: 2019/09/22 15:46 (external edit)