Skip to content

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

Open

Description

@dzmitry-lahoda

it has some tree to String stuff and complex trees

Activity

  1. zspitz commented on Oct 31, 2020

    @zspitz
    Owner

    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.

  2. dzmitry-lahoda commented on Nov 1, 2020

    @dzmitry-lahoda
    Author
  3. dadhi commented on Nov 1, 2020

    @dadhi

    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?

  4. zspitz commented on Nov 1, 2020

    @zspitz
    Owner

    @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.

  5. dadhi commented on Nov 1, 2020

    @dadhi

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions