
The following terminal production is throwing an exception (the error is related to the section in bold):
additiveExpression.Production = multiplicativeExpression["leftexp"] + ( ( @addition >Ast( value: OperatorType.Addition.ToString() ) | @subtraction >Ast( OperatorType.Subtraction.ToString() ) ).SetLabel( "op" ) + additiveExpression["rightexp"] ).OnErrorContinue().Optional()
>AstConditional<BinaryOperatorExpression>( AstFrom( "leftexp" ), AstFrom( "rightexp" ) )
.SetProperty( expr => expr.OperatorType, AstFrom( "op" ) )
.SetProperty( expr => expr.LeftExpression, AstFrom( "leftexp" ) )
.SetProperty( expr => expr.RightExpression, AstFrom( "rightexp" ) );
The exception being thrown is:
{"The property '[...]LeftExpression' has a type '[...]IExpression' that can't be handled by this property construction node.\r\nParameter name: expression"}
I recently changed the LeftExpression property from a concrete class to an interface. When it was a concrete class, it worked fine. I would like to use the following:
.SetProperty( expr => expr.LeftExpression, AstFrom<ExpressionImplementation>( "leftexp" ) )
where ExpressionImplementation implements the interface that the LeftExpression property represents. But ExpressionImplementation does not derive from AstNodeBase, because I am trying to abstract away all Actipro classes from that level of the application. I'm pretty sure that I need to refactor my code in order to get this to work, but I figured I would post my question in case someone else sees a possible solution that I am missing.
[Modified 13 years ago]