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

Variable in a Formula

This module defines a class var_c. The objects of this class correspond to variables in formulas.


Construction:

var_c:
var_c(str_t name_ptr, str_t name_end);
This method creates a new variable. There should be only one variable created for a given name in each formula, but there is no way this method could check it. So it should be called only via scope_c::find. The two pointers name_ptr and name_end together define the name of the variable: name_ptr points at the first character of the variable name in the buffer of the lexical analyzer, and name_end points at one character after the last character of the variable name. This constructor will copy the variable name, because the buffer of the lexical scanner will change. The copying is done with dynamic memory, so there is no real restriction on the length of variable names. However, empty variable names are forbidden.


Object Methods:

name:
str_t name(void);
This method returns the name of the variable (as a null-terminated string).
print:
void print(void);
This method prints the variable name.


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), March 18, 2001.    [HTML 3.2 Checked]