This repository was archived by the owner on Jul 24, 2024. It is now read-only.
fix: new ast for some language constructs #263
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This is a work in progress to address the issue discussed here: https://github.com/php-rust-tools/parser/issues/258
Some notes:
1) Currently,
die()
andexit()
are both expressions. I have kept them that way, but I am wondering whether it would be more concise to construct them as statements instead. This is tricky because they behave like functions, but they are not.I have coded the spans start and end using an
Option<Span>
fordie()
andexit()
, as parentheses are optional for them: 1a0fd30print()
handles this differently withvalue: Parenthesized {
:https://github.com/php-rust-tools/parser/blob/main/tests/fixtures/0269/ast.txt#L349-L355
2)
print
is treated as an expression, but it was coded differently: https://github.com/php-rust-tools/parser/blob/main/src/parser/expressions.rs#L1099(The
Precedence::Prefix
shouldn´t bePrecedence::Print
?)I am wondering whether
die()
andexit()
should follow the same ideas used inprint()
or if we need to changeprint()
to followdie()
andexit()
.3)
isset()
andunset()
are special because they cannot accept all kind of argument. For example,isset(null)
is not valid. Therefore, we need to create a new issue to describe the need for a new function to parse their parameters and throw parser errors when necessary. I think this could be work for another PR.Not trivial to decide those things. 😅