problem.parseformula
problem.parseformula |
Purpose
Parse a formula written as an unparsed array of tokens into internal parsed (reverse Polish) format
Synopsis
ntoken = problem.parseformula (intype, invalue, type, value)
Arguments
intype
|
Array of token types providing the unparsed formula.
|
invalue
|
Array of values corresponding to the types in
inType.
|
ntoken
|
The number of tokens in the parsed formula (not counting the terminating
xslp_op_eof token).
|
type
|
Array of token types providing the parsed formula.
|
value
|
Array of values corresponding to the types in
type.
|
Example
Assuming that
x and
y are already defined as columns with index
iX and
iY respectively, the following example converts the formula "sin(x+y)" into internal parsed format, and then writes it out as a sequence of tokens.
intype = [] invalue = [] intype = [xslp_op_ifun, xslp_op_lb, xslp_op_col, xslp_op_op, xslp_op_col, xslp_op_rb, xslp_op_eof] invalue = [xslp_op_sin, 0, iX , xslp_op_plus, iY, 0, 0] type = [] value = [] ntoken = p.parseformula (intype, invalue, type, value) i=0 while type[n] != xslp_op_eof: str = p.itemname (type[i], value[i]) print (str) i += 1
Further information
For possible token types and values, see the chapter on "Formula Parsing" in the SLP reference manual.
Related topics