[SLP-Homepage]    [Source Modules]    [Manual]    [Run]    [Examples]
 

Set of All Variables in a Formula

This module defines a class scope_c which keeps track of all variables in a formula. It is currently implemented simply as a list of variables, but e.g. a hash table would also be possible. There are no instances of this class, all methods are declared as static.


Class Methods:

reset:
static void reset(void);
This method creates a new empty variable list.
find:
static var_c* find(str_t name_ptr, str_t name_end);
This method searches a variable. The variable name is defined by a pointer to the start of the name in the scanner buffer, and a pointer just behind the last character. If the search is successful, the existing variable is returned, otherwise a new variable is created and appended to the list.
first:
static var_t first(void);
Together with next below, this function offers the possibility to loop over all variables in the current list. This is e.g. needed when a rule for a query is constructed and the answer variables are not explicitly specified. The variables are returned in the sequence they were created by a call to find above. The function returns NIL if the current variable list is empty.
next:
static var_t next(void);
This function returns the next variable in the current variable list. One starts a scan over the variable list by calling first above. In this way one gets the first variable (or NIL if the list is empty). After that, one calls this function next to retrieve the variables one by one until it returns NIL.
print:
static void print(void);
This method prints the lists of variables (separated by commas and introduced with the string "SCOPE:"). It is defined only in the debugging version.


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), April 4, 2002.    [HTML 3.2 Checked]