-
Notifications
You must be signed in to change notification settings - Fork 18
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
improve runtime expression error description - fix #236 #240
Conversation
I didn't review the code yet, but looking at the tests this change rocks! It should really make life easier when dealing with buggy expressions. Restarted Travis-CI as there was (again) a problem with Android... |
I'm going to merge this since I think it is very much needed from the dev point of view. Still, I'm a bit worried by the amount of code it adds (ex.: b-laporte@f20a6ea#diff-140f5dd94b099dbe1a0557ace1e0c3daR722). I would be very keen on experimenting with the runtime expression processing as I'm starting to suspect that it might be resulting in smaller code for applications (framework + compiled templates) and shouldn't degrade performance. In any case I've got nothing to back-up such claims so we will have to have solid infrastructure for measuring framework / code size and runtime performance before making any changes. |
@b-laporte so I've spent last couple of days looking more into the expression handling logic and I think that I've come up with an alternative implementation based on the Pratt's parser. I've pushed a POC here and I'm quite excited about the result since:
The best part is that decoupling expressions parsing from other parts of the code-base open doors to really exciting opportunities: ex.: we could install observers using the current algorithm in browsers that don't support O.o and switch to O.o in browsers that have it (Chrome for now). Not saying that this is 5-minutes job but at least the path is paved. I didn't look to closely to perf numbers but looking at the algorithm I can't think of an obvious perf bottlenecks. Lexing is O(n), parsing is O(n) and evaluation is O(n) as well. I'm really happy about those findings as I believe that we can have rock-solid expression parser with a smaller footprint so please, if you are planning any bigger changes in the areas touching expression parsing / observing, I would like that we sync up. |
Nice 👍 |
@PK1A great job on that one !! pretty impressive |
OK, since we are integrating different approach to expression parsing where we will have expression string ready, I think we can close this PR. But it was very valuable anyway since it triggered my quest for an alternative parsing technique. |
This PR improves runtime error descriptions involving expressions. This is done in 3 steps:
To be complete a 2nd change should be also done to the compiler to pass the file name to the compiled template function (and then include it in all error messages) - but this can be done in a separate PR as code is independent from the current changes.