-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Parse, don’t validate #610
Comments
I understand what you mean now. But it's a bit hard for me to imagine how it will look. Do you mean, get rid of the intermediate AST layer, and construct the semantic types (e.g. Or do you mean, make the parser more specific, so we don't use e.g. |
I consider 4 main aspects:
Observations:
I would combine more specific rules (e.g. no array nor string where we expect a number) with maybe the immediate computation of whatever we can: masks, indexes. We want to have the error in context (file + position), not lost in postprocessing. This would also maybe help with 4 by allocating less, with as much as possible results directly usable by the semantic types. |
For fun, I did a quick test for one expr type, action/action list: It should be possible but I can see the appeal of how it's currently done. Possibly with a custom recursive descent parser it would be more natural. Arguably this small change is already an improvement. I'll play with this more if I have some time. |
@bluetech My point is that we use a bunch of
Expr
that require further check on their type after the yacc parsing. SoExpr
is too general and we may end up with error with no reference to erroneous file/line. Consider the silly:You would just get the following warning, without any reference to the erroneous line:
Imagine now having this in an included key type file: really not ideal for debugging. But at this stage we do not have parser context anymore!
On the other hand, the following file will fail with a better (but still incomplete1) error2:
That said, I guess that fully parsing a section is slower than the current approach so any include would get slower with the parse, don’t validate approach applied strictly.
Originally posted by @wismill in #598 (comment)
Footnotes
(unknown file)
instead of the path of the relevant file. ↩Guess what line is erroneous? The
<🦆>
one, not the<};>
one… ↩The text was updated successfully, but these errors were encountered: