next up previous contents
Next: Pattern match predicates Up: Predicates in rules Previous: Target code predicates

Target code lines

If a target predicate consists of one line of C, there is a special syntactic alternative for it. Target code lines consist of arbitrary C text, terminated by a newline character. If necessary, the newline also simulates a ','-token to the parser, so no intermediate commas are necessary with target code lines.


\begin{verbsyntax}\onerule{TargetCodeLine}{'*' any Newline}
\end{verbsyntax}

Target predicates may be used for test and set of node attributes or debugging generated code. E.g. the following rule tests whether a node is marked as deleted and removes it from some graphs:

  
GRS DeleteFromStatementLists(Proc:ProcGlobal)
{
   RULES
      Body(Proc,PBody),
      {* /* This target code is printed after the code for  */
         /* the preceeding predicate Body                   */ *},
      LinearBlocks(PBody,Block),
      * /* and this here is a single line of target code */
      Stmts(Block,Ass),
      Ass ~ Assign,
      {* /* target predicate to test, whether a node was really deleted */
         /* is copied to the rule test after the pattern match on Assign */
         if (!SimpleSTMT_Assign_get_deleted(Ass))
            continue;
      *}
   ==>
      DELETE Ass FREE;,       // really deallocate Ass
      * printf("deleting copy statement %s",STMT_provide_label(Ass)); 
      NOT Stmts(Block,Ass), 
      NOT list_of_definitions(Proc,Ass)
      * /* This here is really the end of the rule */
   ;
}



Uwe Assmann
1998-12-22