-
Notifications
You must be signed in to change notification settings - Fork 15
fix: new ast for some language constructs #263
Conversation
the logic there makes sense for |
So, if I understand correctly, should I make Or your idea is to parse |
all language constructs should be statements IMO, wdyt @ryangjchandler? as for print, i think we can create a seperate enum for it, something like: pub enum Print {
Expression {
print: Span,
expression: Expression,
ending: Ending, // <- not a semicolon, use `utils::skip_ending(state)?;`
},
Arguments {
print: Span,
arguments: ArgumentList,
ending: Ending,
}
} I think to make the code a bit more clean, we can add |
Couple of thoughts from me:
|
right..., maybe we can add a new |
I've created a POC here of a new node called It appears to be reasonable. What you guys think? This could be used for die, exit... |
@KennedyTedesco can you please push the change to this PR so we can review it? |
@azjezz Changes pushed, only for Ps: Tests are failing when trying to install some composer dependencies. Locally, all good. |
This is ready for review. Overall changes:
I think that's it. Latter, I'll open some issues about things we need to work on/fix on some parts of the parsing analyses. |
e7c38e2
to
7790602
Compare
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. 😅