problem.preparseformula
problem.preparseformula |
Purpose
Perform an initial scan of a formula written as a character string, identifying the operators but not attempting to identify the types of the individual tokens
Synopsis
(type, value, stringtable) = problem.preparseformula (formula)
Arguments
formula
|
Character string containing the formula, written in the same free-format style as formulae in Extended MPS format, with spaces separating tokens.
|
type
|
Array of token types providing the parsed formula.
|
value
|
Array of values corresponding to the types in
Type.
|
stringtable
|
Character buffer to receive the names of the unidentified tokens.
|
Example
The following example converts the formula "sin(x+y)" into internal parsed format without trying to identify the tokens apart from operands and numbers, and then writes it out as a sequence of tokens.
(type, value, stab) = p.preparseformula ("sin ( x + y )") i=0 while type[i] != xslp_op_eof: if type[n] == xslp_UNKNOWN: print ("? ", value[i]) else: str = p.itemname (type[i], value[i]) printf (str) i += 1
Further information
Only operands and numbers are identified by preparseformula. All other operands, including names of variables, functions are left as strings of type xslp_op_unknown. The Value of such a type is the index in stringtable of the start of the token name.
The parsed formula can be converted into a calculable formula by replacing the xslp_op_unknown tokens by the correct types and values.
Related topics