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()
and exit()
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>
for die()
and exit()
, as parentheses are optional for them: https://github.com/php-rust-tools/parser/commit/1a0fd301818da1db7e05a3d2236bdb893de8f5b8
print()
handles this differently with value: 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 be Precedence::Print
?)
I am wondering whether die()
and exit()
should follow the same ideas used in print()
or if we need to change print()
to follow die()
and exit()
.
3) isset()
and unset()
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. :sweat_smile: