
I'm constructing a AST tree for expressions.
When i've got the following code
multiplyExpression.Production =
primaryExpression["exp1"] + (multiplyOperator["op"] + multiplyExpression["exp2"].OnErrorContinue()).Optional()
> AstConditional<ArithmeticOperatorExpression>(AstFrom("exp1"), AstFrom("exp2"))
.SetProperty(e => e.Operator, AstFrom("op"))
.SetProperty(e => e.LeftExpression, AstFrom("exp1"))
.SetProperty(e => e.RightExpression, AstFrom("exp2"));
The operater field is correctly set to '*'
But when I try to add the divide operator '/' with the following code
multiplyExpression.Production =
primaryExpression["exp1"] + ((@multiplyOperator | @divideOperator).SetLabel("op") + multiplyExpression["exp2"].OnErrorContinue()).Optional()
> AstConditional<ArithmeticOperatorExpression>(AstFrom("exp1"), AstFrom("exp2"))
.SetProperty(e => e.Operator, AstFrom("op"))
.SetProperty(e => e.LeftExpression, AstFrom("exp1"))
.SetProperty(e => e.RightExpression, AstFrom("exp2"));
The Operator property is not set anymore. My AST nodes are created correcty, but I need the value of the operator Terminal.
How can I Fix this?