Hi,
I have developed an expression evaluating grammar, which is inspired by the c# original expression grammar.
I have own parser to produce AST, then I walk that AST and transform to System.Linq.Expressions.Expression object which represent my AST. Expression are evaluated against instance of simple object.
For example, the AST for
item.Hello() expression looks like:
INVOKE MEMBER_ACCESS ARGUMENTS IDENTIFIER IDENTIFIER null item Hello
|
The problem is, when I want to create MEMBER_ACCESS subtree using Expression.MakeMemberAccess,
MakeMemberAcces method accepts only property or field member, not methods. Also invoking using
Expression.Invoke requires lambda expression or delegate expression. Thus I cannot invoke any method,
because it is recognized by my grammar as MEMBER_ACCESS(exactly same as in original C# grammar).
One soluition I can imagine is to convert MEMBER_ACCESS subtree to a delegate, but don't know how due to
Expression.MakeMemberAccess issue.
The goal is to evaluate expressions like item.Property.Method().AnotherMethod() etc.