Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkout some https://github.com/dadhi/FastExpressionCompiler and DryIoC #65

Open
dzmitry-lahoda opened this issue Oct 30, 2020 · 5 comments

Comments

@dzmitry-lahoda
Copy link

it has some tree to String stuff and complex trees

@zspitz
Copy link
Owner

zspitz commented Oct 31, 2020

Thank you for the link. The magic happens in the ToCSharpPrinter class and in the ToExpressionPrinter class. It may be interesting to extract these into a separate project and see how they perform in unit tests against this library.

@dzmitry-lahoda
Copy link
Author

@dadhi

@dadhi
Copy link

dadhi commented Nov 1, 2020

Wow, wow :) this lib does much more than mine.. great job. For now, mine are more of the diagnostics helpers to the compiler (though I have plans to use C# output for the code gen later).

@zspitz Btw, do you handle the expressions with the block on the right side of the assignment, or inside the ternarary - I mean the cases where in C# you must have an expression but the Expression trees allow the blocks?

@zspitz
Copy link
Owner

zspitz commented Nov 1, 2020

@dadhi Thanks for the kind words.

Btw, do you handle the expressions with the block on the right side of the assignment, or inside the ternarary - I mean the cases where in C# you must have an expression but the Expression trees allow the blocks?

I try. I was under the (apparently mistaken) impression that C# supports the , operator, which (in other C-style languages) has the same semantics as a BlockExpression -- multiple statements, and the last expression becomes the value of the entire expression. I will have to rethink this.

But my goal is a little different -- I'm not aiming for code that is completely syntactically correct, but rather a string that uses C# constructs as much as possible to represent an expression tree. So, for example, VB.NET doesn't have a standalone block structure; the grouped statements are always in the context of some other syntax -- For Each, or a method, or an If...Then. So if I have a BlockExpression without any other context, I represent it as a Block ... End Block syntax, which (I think) gets the point across, even if it isn't syntactically valid.

There will always be expressions that can't be represented in a given language; C# is the best in this regard, but aside from BlockExpressions there's also unsupported dynamic operations -- DeleteIndexBinder and DeleteMemberBinder -- which other languages support.

And so, it might be better to render BlockExpression in an expression context, as standard curly-braced blocks.

@dadhi
Copy link

dadhi commented Nov 1, 2020

Interesting, thanks for the doc link. My goal is to provide a compilable C# as much as possible, as I plan the code-gen and also extract the result output to the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants