Commit Graph

296 Commits

Author SHA1 Message Date
Nikita Popov
a8223f228a Add emulation for enum keyword 2021-03-20 17:49:44 +01:00
Nikita Popov
7284a4d019 Remove no longer necessary class parsing workaround
This was split to work around the attribute assignment bug fixed
in the previous commit, and as such is no longer necessary.
2020-12-20 10:53:45 +01:00
Nikita Popov
893a5bce3f Fix #741 incorrect varvar positions 2020-12-19 22:03:43 +01:00
Nikita Popov
8a97fa157f Recover from missing semicolon after property or class const
Fixes #712.
2020-09-19 23:11:36 +02:00
Tomas Votruba
4c22c62783
[PHP 8.0] Add attributes support (#661)
Adds support for PHP 8 attributes, represented using `AttrGroup` nodes
containing `Attribute` nodes. The `attrGroup` subnode is added to all
nodes that can have attributes.

This is still missing FPPP support.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-09-13 21:01:17 +02:00
Nikita Popov
f66a32e2df Emulate PHP 8 attribute syntax
Perform emulation by replacing #[ with %[, then patching % back
to # and coalescing #[ into T_ATTRIBUTE if it is a freestanding
token.
2020-09-06 17:42:38 +02:00
Nikita Popov
78e08fc178 Allow keywords in namespace declaration 2020-08-09 21:19:59 +02:00
Nikita Popov
a98350581c Add support for throw expression 2020-08-09 20:52:55 +02:00
Nikita Popov
7f398769a0 Add support for static return type 2020-08-09 18:52:32 +02:00
Nikita Popov
98f7f39d1c Add named argument support
Not adding any explicit FPPP support, as I don't think add/remove
of names can be handled any better than full reformatting.
2020-08-09 17:37:44 +02:00
Nikita Popov
23d9c17770 Add support for nullsafe operator 2020-08-09 12:08:05 +02:00
Nikita Popov
31be7b4ed9 Update php-yacc, remove unused tokens 2020-08-08 19:22:28 +02:00
Nikita Popov
a63b495fe6 Migrate grammar to use PHP 8 T_NAME_* tokens
This will break everything on PHP < 8.
2020-07-23 12:01:50 +02:00
Nikita Popov
2d1998938c [PHP 8.0] Support trailing comma in closure use list
RFC: https://wiki.php.net/rfc/trailing_comma_in_closure_use_list
2020-07-22 18:43:55 +02:00
Mikaël Mayer
d8b19d7963
Fixed rebuildParsers.php (#686)
phpyacc is a sh file and should not be run via the php interpreter, but directly.
2020-07-16 21:51:43 +02:00
Tomas Votruba
69c5d48afd
[PHP 8.0] Add match expressions (#672)
RFC:  https://wiki.php.net/rfc/match_expression_v2
Upstream implementation: php/php-src#5371

Closes #671.
2020-07-15 21:40:05 +02:00
TomasVotruba
b58b19ed1d Add constructor promotion support 2020-06-27 17:57:47 +02:00
TomasVotruba
244db65dd1 [PHP 8.0] Add trailing comma in parameter list 2020-06-12 20:24:25 +02:00
TomasVotruba
b5f5313d73 [PHP 8.0] Add exception witout variable 2020-06-03 09:18:13 +02:00
Nikita Popov
d86ca0f745 Support arbitrary expressions in new/instanceof 2020-02-22 21:09:03 +01:00
Nikita Popov
c8d1216531 Treat magic constants like normal constants 2020-02-22 21:06:03 +01:00
Nikita Popov
8999a13cb2 Make class constants fully dereferencable 2020-02-22 21:03:53 +01:00
Nikita Popov
c1eaa0d5cd Unify array and object dereferencability 2020-02-22 20:57:39 +01:00
Nikita Popov
ca5f7c9761 Split productions, unify {} dereferencing 2020-02-22 20:54:55 +01:00
Nikita Popov
ad696ee75d Make encapsed strings fully dereferencable 2020-02-22 20:49:11 +01:00
Nikita Popov
568236a305 Allow expressions in list()
Similar to the previous commit: list() syntactically accepts any
expression and non-variables are compile-time errors. The special
case of ($a) ends up being legal by accident.
2020-02-19 21:29:17 +01:00
Nikita Popov
9dda080a9d Allow expressions in isset()
Partial fix for #653. PHP 7 allows expressions inside isset(), but
rejects non-variables in the compiler. A side-effect of this is that
isset(($x)) is allowed, though this is not intentional.
2020-02-19 21:14:33 +01:00
Nikita Popov
46cbd9393a Place Nop nodes more precisely
If the Nop is created to collect comments, place it directly after
the comment, instead of at the next non-whitespace character.
2020-02-09 17:10:33 +01:00
Nikita Popov
664c10121e Add support for union types
We definitely need to introduce a general "Type" abstraction in
the next major version.
2019-11-08 14:45:32 +01:00
Nikita Popov
eacc5dbe19 Default to using php-yacc to generate the parsers 2019-10-19 15:24:38 +02:00
Nikita Popov
3226eb4086 Accept KMYACC env var in rebuildParsers.php 2019-10-19 12:28:45 +02:00
Nikita Popov
54c37f6b3b Remove -l flag from kmyacc invocation
For PHP this doesn't do anything anyway.
2019-10-19 11:14:42 +02:00
Nikita Popov
94d93f27a5 Revert "Recover from error inside alternative array deref syntax"
This reverts commit 9d44edf85d.
2019-05-24 22:58:13 +02:00
Nikita Popov
9d44edf85d Recover from error inside alternative array deref syntax
This is to improve error recovery for cases like #545.
2019-05-12 11:38:15 +02:00
Nikita Popov
60d025a914 Fix attributes for zero-length nop nodes
Previously zero-length nop nodes used the lookahead start attributes
and current end attributes. This choice ends up being somewhat weird,
because the end attributes will be the at the last non-whitespace,
non-comment token, which might be quite far back. More problematically,
we may not have encountered any non-discarded token if we're at the
start of the file, in which case we will have no end attributes to
assign.

Change things to use a canonical "zero-length" node representation,
where the end position (token & file) will be exactly one before the
start position.

Fixes #589.
2019-05-11 20:01:25 +02:00
Tomas Votruba
8012faea54 [PHP 7.4] Add array spread 2019-05-09 19:15:35 +02:00
Tomáš Votruba
f3b19c19ef [PHP 7.4] Add support for arrow functions (#602)
Per RFC https://wiki.php.net/rfc/arrow_functions_v2.
2019-05-09 14:17:28 +02:00
Tomas Votruba
9de96821f7 Add support for ??= operator
Introduced in PHP 5.4, represented using an AssignOp\Coalesce node.
2019-02-09 11:16:26 +01:00
Nikita Popov
6b9dd7afe7 Avoid redundant argument 2019-01-12 17:31:37 +01:00
Tomas Votruba
af8c729603 Add PHP 7.4 typed properties support 2019-01-05 21:34:25 +01:00
Tomas Votruba
0ef61b49bb add float/double/real KIND support to Cast\Double node 2019-01-05 19:23:00 +01:00
Nikita Popov
f42bbc2403 Avoid default action for error production
error is not necessarily going to have a semantic value, make sure
that the default action $$=$1 is not used.

Fixes #551.
2018-11-30 11:00:48 +01:00
Nikita Popov
3d0f7843d4 Support error recovery for missing return type
The return type is set to "null" in this case.

Fixes #544.
2018-10-25 16:56:50 +02:00
Nikita Popov
5f73c4de80 Flexible doc: Validate end label indentation
Move doc string parsing logic from rebuildParsers.php and
String_::parseDocString() into ParserAbstract. This stuff is
going to get complicated now.

For now only implement the validation of the indentation on the
end label.
2018-09-21 16:31:17 +02:00
Nikita Popov
8b1c9c0409 Store comment at end of class in Nop statement
Fixed #509.
2018-07-07 12:49:49 +02:00
Nikita Popov
f967b867d5 Improve error recovery in arrays
Similarly to missing semicolons, the error is not indicated in the
AST.

Fixes #512.
2018-07-07 12:24:06 +02:00
Nikita Popov
7b201b63d2 Error recovery for functions without body 2018-05-13 16:28:08 +02:00
Nikita Popov
01e85a26c6 Support recovery for param without variable
We store an Expr\Error for the variable in this case.
2018-05-12 19:49:39 +02:00
Nikita Popov
fa99c3fbfb Recover from foreach without as 2018-04-28 22:31:45 +02:00
Nikita Popov
7208b1c7ac Improve error recovery in classes (#492) 2018-03-30 16:03:03 +02:00