Usage Philosophy

To create an Alma2 Front-End, the expert (called like that because this user must have expertise in attribute grammars and traditional compiler techniques) need to go through the following steps:

  1. Domain Analysis. This task should be the first of all. Here, the expert is encouraged to create a conceptual map or ontology, where is described the problem domain by means of concepts and relations between them.
  2. Language Analysis. As the DSL to which the FE is being constructed, is already defined, the analysis of its main program domain concepts should be made without any troubles. In this case, a list of such concepts with a small description addressing their semantics, would ease the next steps.
  3. Interconnection of Domains. With the ontology of the problem domain and the list of the program domain concepts, a relation between concepts of levels should be made. This task is made manually, but regarding the recent advances done in the area of concept localization, it can be automatized.
  4. Search for Imagery. This task requires deep knowledge on the problem domain, because the images should depict the concepts and their actions in such a domain.
  5. Creation of the Attribute Grammar. Resorting to LISA (or similar compiler generators), an AG should be defined. In the grammar, the main attribute of the root symbol, should synthesize a DapAST structure, so the generated compiler for the FE can create a DapAST when processing the input program.
The creation of the DapAST is not so obvious. The following information shows important aspects that are mainly used to construct the DapAST.
  • Injecting Sub-Trees - In a DSL it is not used to have ways of defining the state of a program, because it is intrinsic to the language. However, for questions of animation and visualization of the problem and program domains, it may be interesting to define it. So, the tree representing the program semantics, must be injected of variables defining the state of the programs. Using user-defined functions and the semantic patterns of Alma.
    EXAMPLE:
       CAlmaNode nX = new CAssignNode (tX, 0); 
       CAlmaNode nY = new CAssignNode (tY, 0);
    
  • Using Animation Patterns - The creation of the DapAST, is simply done by chaining the trees resulting from the synthesis of the attribute of any nonterminal in the grammar, and assigning it to other attribute of other nonterminal. This is the basic method to build the DapAST. The difficulty lies on the correct application of the semantic and animation patterns.
    EXAMPLE:
       CDeclNode n = new AnimDeclNode(token, "integer", null, node,
                                      new AnimationPattern[]{
    	                                    new APIdentity(actor, new int[]{0})
                                      }
    
  • Tranlation - The translation of a DSL into a DapAST is not easy. Depends on the language, on their semantics, and how the expert wants the problem domain to be visualized. Imagine a language to control a robot with an instruction for moving it, based on the cardinal points: (N)orth, (S)outh, (E)ast and (W)est. We can think about the following semantics for these instructions, knowing the state posX = posY = 0:
    	N → y = y+1 
    	S → y = y−1 
    	E → x = x+1 
    	W → x = x−1
    
    With this we are able to build the semantical part of the DapAST with ease. In order to animate the robot we need to use the correct animation patterns. In this example we are interested in moving the robot to a new position, so we could use the following construction:
    	1 ruleInstruction_N{
    	2    MOVE :: = #N compute { 
    	3       MOVE.tree = new AnimAssignNode (
    	4                         tY, 
    	5                         new COperNode ( 
    	6                              new CVarNode ( tY ) , 
    	7                              new CConstNode ( 1 ) , 
    	8                              "+" 
    	9                          ), 
    	10                       new AnimationPattern[]{
    	11                           new APMove ( robot, new int[]{0}, "posX" , "posY")
    	12                       } 
    	13               ) ; 
    	14      } ; 
    	15 } 
    
    


PREVIOUS DETAIL