access state.customData when construct Expression

SyntaxEditor for WPF Forum

Posted 9 years ago by Aurore
Version: 13.2.0591
Avatar

Hello,

I'd like to set my OperatorExpression (inherits from Expression), with some values setted in (IParserState)State.CustomData?

Is it possible ?

Here the code where i'd like to add something like this ".SetProperty(e => e.MyProperty, state.customData.AnotherProperty)"

logicalExpr.Production = stringCompExpr["stringComp"] + ((@logicalAnd > Ast(LOGICAL_AND) |
		@logicalOr > Ast(LOGICAL_OR) | @logicalXor > Ast(LOGICAL_XOR)).SetLabel("operator")
	+ logicalExpr["logical"]).Optional() > AstLeftAssociativity<Expression, OperatorExpression>(
	AstConditional<OperatorExpression>(AstFrom("stringComp"), AstFrom("logical")).SetProperty(e => e.Operator, AstFrom("operator"))
	.SetProperty(e => e.LeftExpression, AstFrom("stringComp")).SetProperty(e => e.RightExpression, AstFrom("logical")),
	n => n.LeftExpression, n => n.RightExpression, (n1, n2) => OperatorKindCheck(n1, n2, LOGICAL_AND, LOGICAL_OR, LOGICAL_XOR));

 

thanks

Aurore

Comments (2)

Answer - Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Aurore,

I don't believe you can do it right in the code there, however if you add something like an OnSuccess handler at the end of a term in the production, then in that OnSuccess callback handler, you can examine the IParserState that is passed in and update an AST node from the state.AstNodeBuilder.Matches.  Note that depending on your scenario, you might need to run this OnSuccess code on callers of this particular production instead of in the production itself.


Actipro Software Support

Posted 9 years ago by Aurore
Avatar

Hello,

Thanks for your answer.

I solved my problem.

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.