exptok splits a simple arithmetic expression into tokens.
Return Value
ssToks is a string of tokens. In case of an error ssToks is a number containing the position of the error in ssExpression.The tokens are separated by the character \2. A token consists of a type and the token string. The type and the token string are separated by the character \1.
The following token types exist:
| Type Value | Meaning |
|---|---|
| F$n | Value is a function call. n is the number of parameters. |
| V | Variable name |
| O | Operator +-*/^ |
| S | String |
| N | Number |
| C | Parenthesis ( or ) or Comma ,. |
Parameters
ssExpression is an arithmetic expression. The following elements are allowed in the expression: Operators: +,-,*,/,^ Parenthesis: ( und ) Function names, variable names, string contants enclosed in "-characters, also Strings and numbers of the form 1, 1.2, 1.2e3, -1.2e-3 Functions can have an empty parameter list as in print() or a list of parameters separated by a comma (,).
Example
toks = exptok("3 * sin(2.3) + abc / 1");
* toks
N3O*F$1sinC(N2.3C)O+VabcO/N1
* toks = strtok(toks, "\1\2");
* toks'
N
3
O
*
F$1
sin
C
(
N
2.3
C
)
O
+
V
abc
O
/
N
1
See also
id-285600