Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
guide:start [2023/04/19 14:29] – created rajit | guide:start [2023/04/21 17:43] (current) – [Referencing a particular language body] rajit | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== A Guide to Using ACT Data Structures ====== | ====== A Guide to Using ACT Data Structures ====== | ||
+ | |||
+ | ===== Getting Started ===== | ||
+ | |||
+ | ==== Initialization ==== | ||
+ | |||
+ | 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: | ||
+ | < | ||
+ | Act::Init (&argc, &argv); | ||
+ | </ | ||
+ | where '' | ||
+ | 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 *a; | ||
+ | a = new Act (argv[1]); | ||
+ | </ | ||
+ | where '' | ||
+ | ==== Referencing a process ==== | ||
+ | |||
+ | Once the '' | ||
+ | < | ||
+ | Process *p = a-> | ||
+ | if (!p-> | ||
+ | p = p-> | ||
+ | } | ||
+ | </ | ||
+ | In this example, the assumption is that '' | ||
+ | ==== Referencing the languages body ==== | ||
+ | |||
+ | The languages body can be accessed from the process pointer: | ||
+ | < | ||
+ | act_languages *lang; | ||
+ | lang = p-> | ||
+ | </ | ||
+ | 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 '' | ||
+ | ==== Referencing a particular language body ==== | ||
+ | |||
+ | A language body can be accessed from the languages pointer. For example, for the chp body: | ||
+ | <code c++> | ||
+ | act_chp *chp; | ||
+ | chp = lang-> | ||
+ | </ | ||
+ | Note that the '' | ||
+ | |||
+ | Finally, to get a pointer to the actual object that stores the CHP data structure: | ||
+ | < | ||
+ | act_chp_lang_t *chp_lang; | ||
+ | chp_lang = chp->c; | ||
+ | </ | ||
+ | |||
+ | ===== The CHP data structure ===== | ||
+ | The '' | ||
+ | |||
+ | ==== The statement list data structure ==== | ||
+ | The linked list '' | ||
+ | <code c++> | ||
+ | act_chp_lang_t *c; // contains the overall chp body | ||
+ | act_chp_lang_t *stmt; | ||
+ | list_t *stmt_list; | ||
+ | listitem_t *li; | ||
+ | |||
+ | // if c->type is ACT_CHP_SEMI or ACT_CHP_COMMA | ||
+ | stmt_list = c-> | ||
+ | |||
+ | for (li = list_first (stmt_list); | ||
+ | |||
+ | stmt = (act_chp_lang_t *)(list_value(li)); | ||
+ | // do something here | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||