-
Notifications
You must be signed in to change notification settings - Fork 99
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
Implementing a syntaxicTree for version 2.0 of ExpressionEvaluator #58
Comments
I've been making a little investigation and found that this library make something "like" the version 2 of this library should make. |
This is the context
those the usings
and this is the main test
In my machine, I get 3 miliseconds for the 100,000 iterations. |
@TheoVC Thanks for your your investigation and your tests. Yes I think syntaxic tree or compilation are a big speed enhencement for multiple execution. Speed is a big drawdown of EE. |
I investigated a bit in the wonderful world of
|
For investigation purposes... I have done a recursive descent parser based on the Richard Weeks series.
of maybe
the type could be null if you don't want a context... and just use the variables feature another feature that would be wonderfull is that the library not just evaluates an expression, but also produce an string explaining to the user what’s happening inside the expression. Something like this: For expression:
produce an explanation like this:
if you remove the coments you can have something like this;
So this string can be displayed by the application and easily the IT guy or even the user himself can deduce what it’s going wrong? or simply to know why ??? you get that result. We already achieve this using codingseb but has a lot of manual parsing and it’s slow… |
Hello, if that's of any help, what do you think about this library ? https://github.com/davideicardi/DynamicExpresso |
Yes it's a really good lib. I created a new repo where I test some partial rewriting of EE with a ExpressionTree compilation. I made a lot of copy paste modify operations from EE so it's not really a Lexer/ASTNode but I made a parser part that build a tokens tree from which I can get an expression tree and then compile to |
I am just a bit stuck on how to adapt the variables and on the fly events (that were for me the big cool stuff of EE with syntax customization) without doing just the same as these already existing libraries. |
Also very interesting stuff here thank for sharing this serie. I am watching it. And I am asking myself about the perfs of Lexer/ASTNodes char by char parsing versus my big regex way of parsing. |
@codingseb one of the cleanest architectures of hand written parser is here - https://github.com/scriban/scriban Anyway for v2 our main goal should be performance as I think we can live without cool customization when such implementaion can't be then used in real world applications. Hence a good solution would imho be able to generate bytecode for either native c# or custom vm which would then interpret this simpler language on runtime. Lua vm has only ~50 bytecode opcodes. Of almost the same importance is imho ability to properly sandbox the script evaluation as untrusted code will be interpreted in many use cases. This should include recursion depth limit, total instructions to interpret limit, no access to clr classes unless explicitly provided. Last thing I would love to see is native async / await support. This is becoming more and more important with each new version of c#. |
I create here an issue to follow and document (first for myself but for who is interested) the evolution of the work to version 2.0
The goal is to deeply refactor ExpressionEvaluator to internally build a syntaxic tree with different kinds of tokens.
The evaluation will be executed in 2 phases.
This will allow a lot of stuffs that are not possible with the current "on the fly" way of evaluating things.
It should allow to :
Risks and drawdowns
I will also decide how to split things between version 1 and 2.
The text was updated successfully, but these errors were encountered: