This is an online CGI demonstration page of the STX Expression Parser framework. The input string given below is parsed and evaluated by the library. Upon successful processing the evaluation result's type and value are displayed together with the expression's parse tree.
ParseTree Result as String |
Evaluation Result |
XML Node Tree <!DOCTYPE parsetree SYSTEM "parsetree.dtd"> <!-- (5 + 3) * 5.25 --> <parsetree version="1.0"> <parsenode rule="mul_expr"> <value>*</value> <parsenode rule="add_expr"> <value>+</value> <parsenode rule="integer_const"> <value>5</value> </parsenode> <parsenode rule="integer_const"> <value>3</value> </parsenode> </parsenode> <parsenode rule="double_const"> <value>5.25</value> </parsenode> </parsenode> </parsetree> |
You can also process the following examples:
6 + 3 * 12(5 + 3) * 5.25(int)(30 * 1.4)(5 + 1 + 1 + 1) * (4.25 + 0.4 * 2.5 / (3.1 - 0.525 * 4))COS(2 * PI)SQRT( COS(PI/4) * COS(PI/4) + SIN(PI/4) * SIN(PI/4) )a == 6 * 9a * 20000 <= ce == EXP(1)golden == (1 + SQRT(5)) / 2(a - 28) * (int)(e + 0.4 * 2.5 / (PI() - EXP(-0.644) * 4))a >= 5 OR (42 <= field2 AND field2 <= 48) || NOT(got == "yes")The following variables are defined by the demo and can be used in the expression:
a | 42 |
c | 299792458 |
e | 2.718281828459045 |
pi | 3.141592653589793 |
golden | 1.618033988749895 |
field1 | 12345678 |
field2 | 87654321 |
got | "no" |