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
guide:start [2023/04/20 22:32]
rajit [Referencing a process]
guide:start [2023/04/21 13:43] (current)
rajit [Referencing a particular language body]
Line 5: Line 5:
 ==== Initialization ==== ==== Initialization ====
  
-Act files are read in automatically when the library is initialized as:+Act configuration files are read in and any ACT command-line options are parsed and removed from the argument list automatically when the library is initialized as:
 <code> <code>
 Act::Init (&argc, &argv); Act::Init (&argc, &argv);
 </code> </code>
 where ''argc'' and ''argv'' are the usual command-line options to ''main()''. This should be the first function call before any other ACT functions are used.  where ''argc'' and ''argv'' are the usual command-line options to ''main()''. This should be the first function call before any other ACT functions are used. 
-When this call is executed, the file provided in the command-line is read in and processed to create the internal act data structures.+When this call is executed, any configuration files provided on the command-line and the default configuration files are read in and processed to create internal act data structures.
 Typically, the next step is to create an ''Act'' pointer to the data structure: Typically, the next step is to create an ''Act'' pointer to the data structure:
 <code> <code>
Line 16: Line 16:
 a = new Act (argv[1]); a = new Act (argv[1]);
 </code> </code>
 +where ''argv[1]'' is the top-level ACT file name. This parses the ACT input file, and creates data structures for all the instances, namespaces, processes, etc. specified in the ACT file.
 ==== Referencing a process ==== ==== Referencing a process ====
  
-Once the act pointer has been created, a process (provided in the command-line arguments) within the file can be accessed and expanded:+Once the ''Act'' pointer has been created, a process (provided in the command-line arguments) within the file can be accessed and expanded (if necessary):
 <code> <code>
 Process *p = a->findProcess (argv[2]); Process *p = a->findProcess (argv[2]);
Line 26: Line 26:
 } }
 </code> </code>
 +In this example, the assumption is that ''argv[2]'' holds a string that corresponds to the process name.
 ==== Referencing the languages body ==== ==== Referencing the languages body ====
  
Line 34: Line 34:
 lang = p->getlang(); lang = p->getlang();
 </code> </code>
 +This provides access to all the sub-languages specified within the process.((The refinement body is processed by the expansion phase, and hence the expanded process will contains the appropriate sub-language bodies after taking the specified number of refinement steps into account. This is why ''-ref=k'' is an ACT command-line option.))
 ==== Referencing a particular language body ==== ==== Referencing a particular language body ====
  
 A language body can be accessed from the languages pointer. For example, for the chp body: A language body can be accessed from the languages pointer. For example, for the chp body:
-<code>+<code c++>
 act_chp *chp; act_chp *chp;
 chp = lang->getchp(); chp = lang->getchp();
 </code> </code>
 +Note that the ''chp'' pointer will be NULL if there is no CHP sub-language specified within the process definition.
  
-Finally, to get a pointer to the actual object that stores the chp data structure:+Finally, to get a pointer to the actual object that stores the CHP data structure:
 <code> <code>
 act_chp_lang_t *chp_lang; act_chp_lang_t *chp_lang;
Line 53: Line 54:
  
 ==== The statement list data structure ==== ==== The statement list data structure ====
-The linked list ''list_t'' contains elements of type ''listitem_t''. See ''list.h'' or ''list.c'' for details and available methods. This is used to store lists of statements. To get the actual statement stored in the list of statements, call ''list_value'' on the required ''listitem_t'' of the list: +The linked list ''list_t'' contains elements of type ''listitem_t''. See ''list.h'' or ''list.c'' for details and available methods. In a CHP data structure, this is used to store lists of statements. To get the actual statement stored in the list of statements, call ''list_value'' on the required ''listitem_t'' of the list: 
-<code>+<code c++>
 act_chp_lang_t *c; // contains the overall chp body act_chp_lang_t *c; // contains the overall chp body
 act_chp_lang_t *stmt; act_chp_lang_t *stmt;
Line 60: Line 61:
 listitem_t *li; listitem_t *li;
  
 +// if c->type is ACT_CHP_SEMI or ACT_CHP_COMMA 
 stmt_list = c->u.semi_comma.cmd; // returns the linked list stmt_list = c->u.semi_comma.cmd; // returns the linked list