Hassan Tariq
6f1f206862
Fix minor typo
2021-11-13 22:39:16 +01:00
Nikita Popov
d2c645f163
Adjust token count in octal emulator
2021-09-03 16:35:10 +02:00
Nikita Popov
def24f2224
Add support for explicit octal literals
2021-09-03 16:29:30 +02:00
Máté Kocsis
55c4269232
Add support for new PHP 8.1 modifiers ( #796 )
...
Implement support for readonly properties (https://wiki.php.net/rfc/readonly_properties_v2 ) and
final class contstants (https://wiki.php.net/rfc/final_class_const ).
2021-07-21 12:43:29 +02:00
Nikita Popov
a8223f228a
Add emulation for enum keyword
2021-03-20 17:49:44 +01:00
Nikita Popov
b5351f883a
Make keyword emulation check case-insensitive
2020-09-23 20:19:40 +02:00
Nikita Popov
8505acd151
Correctly handle ?-> in encapsed strings
...
Followup upstream change.
2020-09-19 15:47:14 +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
75abbbd2d4
Handle flexible heredoc via TokenEmulator
...
Extend the interface to support preprocessing.
2020-09-06 17:05:23 +02:00
Nikita Popov
39b046007d
Refactor token emulator registration
...
Only determine needed emulators based on PHP version once, and
add an adaptor that allows treating forward and reverse emulation
the same.
Previously the isEmulationNeeded() check was too conservative,
as it also considered emulators that are not relevant for the
version. Though possibly that check should just be dropped
altogether.
2020-09-06 15:50:52 +02:00
Nikita Popov
23d9c17770
Add support for nullsafe operator
2020-08-09 12:08:05 +02:00
Nikita Popov
303342630d
Fix a token reference
2020-08-01 22:36:49 +02:00
Nikita Popov
1a1300aa2a
Add reverse emulation support
2020-08-01 22:34:36 +02:00
Nikita Popov
3698f4b727
Add common KeywordEmulator
...
The logic for keyword emulation is always going to be the same.
2020-08-01 22:02:52 +02:00
Nikita Popov
7b2ec6703f
Accept a phpVersion option in emulative lexer
...
Testing this will require reverse emulation support.
2020-08-01 21:56:06 +02:00
Nikita Popov
61328f89da
Separate out emulator version info
2020-08-01 21:49:53 +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
Nikita Popov
a2443aaefa
Make check in numeric literal separator emulator more precise
...
a) Don't check for !== false, preg_match() return 0 if there is
no match. This effectively means that the check was always true.
b) Check for hex characters only if there's an 0x prefix. 1_1 is
very likely a numeric separator, but a_b might well be part of
an identifier.
Fixes #639 .
2020-02-09 22:50:19 +01:00
Nikita Popov
5644a916bc
Sync flexible heredoc emulation with label fix
...
This was recently fixed in PHP via
310708845f
so we should fix it here as well.
I'm not adding a dedicated test as it will fail until new PHP versions
are released. This is indirectly tested through the php-src tester.
2019-08-30 20:21:28 +02:00
Tomáš Votruba
3f718ee2c3
[PHP 7.4] Add support for numeric literal separators ( #615 )
...
Implements RFC https://wiki.php.net/rfc/numeric_literal_separator .
Closes #614 .
2019-06-30 12:13:28 +02:00
Nikita Popov
aad0e2896f
Remove token registration from TokenEmulator interface
2019-06-23 14:50:14 +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
a5c726bfbf
Make sure heredoc end label not followed by label char
2018-09-21 11:44:39 +02:00
Nikita Popov
83766c8c0e
Partial support for flexible heredoc/nowdoc
...
This only implements the token emulation part, it does not yet
handle the indentation stripping.
Emulating this feature on old PHP versions is really tough and is
not going to work perfectly, but hopefully this implementation is
"good enough".
2018-09-21 11:16:00 +02:00
Gabriel Caruso
68d07c4662
[CS] New line in the end of file
2018-01-13 16:08:26 +01:00
Gabriel Caruso
a8968caa5b
[CS] Remove extra lines
2018-01-13 16:03:53 +01:00
TomasVotruba
e2e99f269b
Add strict_types to lib code
2017-08-18 23:00:13 +02:00
TomasVotruba
58bf92e4f7
[cs] remove unused imports
2017-08-13 21:14:28 +02:00
Nikita Popov
60f1504978
Drop emulative lexer implementation
...
Nothing to emulate anymore... Revert this commit when something
turns up.
2017-04-24 22:15:50 +02:00
Matthew Brown
9857a545e2
Remove unused variables ( #357 )
2017-02-11 11:05:36 +01:00
Nikita Popov
bfea338d36
Update doc comments after previous comment
...
Make some of the type annotations more accurate, and complete the
generated doc-comments to be complete (with description and
parameter annotations.)
2017-01-26 00:16:54 +01:00
Matthew Brown
e3b87f40aa
Add non-void return types
2017-01-25 23:32:50 +01:00
Nikita Popov
3b4dd387b8
Comment out code for handling new keywords
2017-01-19 20:58:45 +01:00
Nikita Popov
61574a1818
Drop support for PHP 5.5
2017-01-19 20:55:08 +01:00
Nikita Popov
f99a96e0a2
Introduce ErrorHandler
...
Add ErrorHandler interface, as well as ErrorHandler\Throwing
and ErrorHandler\Collecting. The error handler is passed to
Parser::parse(). This supersedes the throwOnError option.
NameResolver now accepts an ErrorHandler in the ctor.
2016-10-16 22:12:46 +02:00
Nikita Popov
e926efd62e
Fix regex
2016-09-30 19:17:10 +02:00
Nikita Popov
17d1e738fa
Don't use ~__EMU sequences in emulative lexer
...
These were necessary back in the day when we had to emulate some
complex functionality such as nowdoc strings. Now we can simply
directly translate certain token sequences.
The motivation for this change is to avoid preprocessing of the source
code, which would complicate offset-aware error handling inside the
lexer as offsets would no longer be correct.
2016-09-30 19:10:16 +02:00
Nikita Popov
038e11da4b
Remove support for PHP 5.4
2016-07-05 22:29:41 +02:00
Nikita Popov
bc21514ecf
Move token constants into separate class
...
As these are shared between Php5 and Php7 parsers they should be
in some common place, otherwise we'd have to always reference either
one or the other.
2015-06-13 18:39:55 +02:00
Nikita Popov
e6619f5514
Drop 5.4 support from emulative lexer
2015-05-02 22:13:55 +02:00
Nikita Popov
ab80054e97
Add support for "yield from"
2015-04-26 11:56:02 +02:00
Nikita Popov
251e689283
Add support for spaceship operator (<=>) [PHP 7]
...
Added as Expr\BinaryOp\Spaceship.
2015-03-12 23:13:31 +01:00
Nikita Popov
01f4be6b4d
Add support for null coalesce operator (??) [PHP 7]
...
Added as Expr\BinaryOp\Coalesce.
2015-03-12 22:45:56 +01:00
nikic
7c98ad6f9b
Support file offsets in emulative lexer as well
...
Also run normal lexer tests against emulative lexer and fix a bug
in __halt_compiler() handling found as a result.
2014-11-27 20:57:38 +01:00
nikic
616be1d0fc
Use emulative lexer for < 5.6RC1
...
Earlier releases come with incorrect tokenizer data for T_POW and
T_POW_EQUAL.
2014-08-31 16:33:41 +02:00
nikic
b3332184cf
Minor cleanups to emulative lexer
...
Be consistent about version numbers. We'll only emulate until
beta1 of a release, as that's the feature freeze release.
2014-03-27 00:01:39 +01:00
nikic
1cb6e1407c
Fix ** emulation wrt comments
2014-03-26 23:41:06 +01:00
nikic
cda6f575f0
Add support for pow operator (PHP 5.6)
2014-03-26 19:18:16 +01:00
nikic
96f1151ab2
Add support for variadic parameters (PHP 5.6)
2014-03-26 18:23:30 +01:00