The included test files can be executed.
They will always print the inline HTML,
indicating that PHP is doing the equivalent of inserting semicolons.
Fixes#246
Also, ignore temporary files created by vim
Before, tolerant-php-parser parsed the tokens after `<?=` and `<?php`
the same way.
Fixes#220 (This commit and subsequent commits in this PR)
This adds `TokenKind::ScriptSectionStartWithEchoTag` and handles the
subsequent tokens differently if that token kind is seen instead of
`ScriptSectionStartTag`.
This reuses `ExpressionStatement` with an `EchoExpression` for simplicity.
The resulting expression will have no `echoKeyword` because
`<?=` was part of the preceding `InlineHTML` Node.
- In all cases that I'm aware of,
the ExpressionStatement with the EchoExpression will be moved
into the outer statement list.
NOTE: echo is a statement, not an expression.
It must be followed by `?>` or `;`
- `echo exprList` can't be used as an expression.
- Contrast with `print expr`, (`PrintIntrinsicExpression`),
which is correctly treated as an expression.
Update documentation
Add a test that the Parser will warn about `<?= 'expr'<EOF>`.
- Fixing that bug got rid of an incorrect EmptyExpression in another test
(programStructure5.php.tree)
Add a new array `otherQualifiedNameList` alongside qualifiedName
to `CatchClause`. (Contains remaining `Token`s and `QualifiedName`s)
(This design breaks backwards compatibility as little as possible)
- A future backwards incompatible release should merge the two
properties into `qualifiedNameList`,
or something along those lines.
Add a new helper method to parse the catch list.
- The new helper is required because
`tests/cases/php-langspec/exception_handling/odds_and_ends.php`
should not fail because `catch (int $e)` is **syntactically** valid php
(in 7.x), i.e. `php --syntax-check` doesn't reject it.
Do this in a way that makes it less likely that applications already
using targetName will throw an exception or error.
This should be revisited in a future backwards incompatible release.
Add remainingTargetNames as a new property.
NOTE: traits16.php is invalid php 7 code,
so traits16.php.diag should be non-empty.
However, tolerant-php-parser emits a slightly different error
message than `php -l` would.
Update tests diagnostics and expected generated ASTs
For backwards compatibility, continue to make `yield from expr`
have an ArrayElement as a child node.
To maintain the invariant that all Nodes must have at least one child,
make $yieldExpression->arrayElement be null when parsing `yield;`
Aside: `yield &$a;` is (and should be)
parsed as the binary operator `(yield) & ($a)`.
This is surprising, but makes sense, being the only sane parse tree.
- Add a unit test that `yield & &$a;` is invalid.
There is no way to parse that.
Verified with the PHP module nikic/php-ast
```php
var_export(ast_dump(
ast\parse_code('<?php function test() { yield & $x; }', 50)
));
```
Previously, the fallback case when something beginning
with the token `$` wasn't a simple variable
would be to assume it would be a complex variable
such as `$$x`
Check that the first token would be valid before recursing.