GENESIS: Documentation

Related Documentation:

Details of Extending the Model Container

For the example of adding a PulseGen to the Model Container, with the exception of adding a symbol for the pulse object (see below), the following steps are automated by the function pulse_gen given in the documentation for Extending the Model Container.

The following subheadings are in order of execution.

Add the new tokenizer

First add a new tokenizer to the analyzer.l file:

   pulse { return(TOKEN_PULSE); }

Add the new token

The new token is added to the description.tokens file located in hierarchy/output/symbols/:

   %token TOKEN_PULSE

Add a parser rule

A series of grammar rules must now be added:

Add rules

The next step is to add a rule for each of the declarations just made so that the parser knows what to do with them.

Rule for PulseSymbol
   PulseSymbol  
      :  
         PulseSection  
         {  
#line  
            //- put symbol table element on stack  
            $$ = &$1->bio.ioh.iol.hsle;  
         }

The PulseSymbol uses a Bio Component symbol.

Rule for PulseDescription
   PulseDescription        /* <ppulse> */  
      :  
         {  
   #line  
            $$ = ParserContextGetActual((PARSERCONTEXT *)pacParserContext);  
         }  
      |  
         PulseDescription  
         ChildSectionOptionalInputOptionalParameters  
         {  
   #line  
            //- link children  
            if ($2)  
            {  
               SymbolAddChild(&$1->bio.ioh.iol.hsle, $2);  
            }  
 
            //- reset actual symbol  
            ParserContextSetActual  
               ((PARSERCONTEXT *)pacParserContext,  
               &$1->bio.ioh.iol.hsle);  
 
            //- put symbol description on stack  
            $$ = $1;  
         }  
      |  
         PulseDescription  
         Parameters  
            {  
   #line  
            //- link parameters  
            SymbolParameterLinkAtEnd(&$1->bio.ioh.iol.hsle, $2);  
 
            //- reset actual symbol  
            ParserContextSetActual  
               ((PARSERCONTEXT *)pacParserContext,  
               &$1->bio.ioh.iol.hsle);  
 
            //- put symbol on stack  
               $$ = $1;  
         }  
      ;

Rule for PulseSectionEnd
   PulseSectionEnd  
      :  
         EndPushedPidin  
         TOKEN_PULSE  
         {  
   #line  
         }  
      ;

Rule for PulseSectionFront
   PulseSectionFront       /* <ppulse> */  
      :  
         PulseSectionFront1  
         PulseSectionFront2  
         {  
   #line  
            //- prepare struct for symbol table  
            $$ = $1;  
 
            //- set actual symbol  
            ParserContextSetActual  
               ((PARSERCONTEXT *)pacParserContext,  
               &$$->bio.ioh.iol.hsle);  
 
            //- assign name to symbol  
            SymbolSetName(&$$->bio.ioh.iol.hsle, $2);  
         }  
      ;

Rule for PulseSectionFront1
   PulseSectionFront1      /* <ppulse> */  
      :  
         TOKEN_PULSE  
         {  
   #line  
            //- prepare struct for symbol table  
            $$ = PulseCalloc();  
 
            //- set actual symbol  
            ParserContextSetActual  
               ((PARSERCONTEXT *)pacParserContext,  
               &$$->bio.ioh.iol.hsle);  
         }  
      ;

Note: This is called by PulseCalloc, which must be defined for this to work.

Rule for PulseSectionFront2
   PulseSectionFront2      /* <ppulse> */  
      :  
         IdentifierOptionIndexPushedPidin  
         {  
   #line  
            //- put identifier on stack  
            $$ = $1;  
         }  
      ;

Rule for PulseSection
   PulseSection    /* <ppulse> */  
      :  
         PulseSectionFront  
            InputOutputRelations  
            OptionalItemInputRelations  
            PulseDescription  
         PulseSectionEnd  
         {  
   #line  
            //- link input/output relations  
            SymbolAssignBindableIO(&$4->bio.ioh.iol.hsle, $2);  
 
            //- bind I/O relations  
            SymbolAssignInputs(&$4->bio.ioh.iol.hsle, $3);  
 
            //- put finished section info on stack  
            $$ = $4;  
         }  
      ;