Nikita Popov
1edf72c040
PHP 7: Support nullable types
...
Using a new NullableType node.
2016-07-06 18:36:18 +02:00
Nikita Popov
5ea2a76d80
PHP 7.1: Class constant visibility support
2016-07-05 23:01:06 +02:00
Nikita Popov
5044fce1ff
PHP 7.1: Add void+iterable support
...
In PHP 7 mode, these will now be represented as strings 'void'
and 'iterable'.
2016-07-05 22:35:27 +02:00
Nikita Popov
96cbd48df6
Improve error recovery quality
...
In particular, support recovering from a missing trailing semicolon,
while keeping the rest of the expression.
2016-04-20 16:47:50 +02:00
Nikita Popov
e45e31c218
Fix new.test and code test runner
...
Using only the basename leads to collisions...
2016-04-20 15:03:18 +02:00
algo13
371c783344
Escape all low control characters in strings
2016-04-19 17:45:39 +02:00
Nikita Popov
5a6e7dd452
Avoid superfluous newline when printing Nops
2016-04-19 15:10:51 +02:00
Nikita Popov
e7869b9f14
Forbid invalid octals in PHP 7 mode
2016-04-18 13:59:18 +02:00
Nikita Popov
4c7ad7e194
Allow nop statements before namespace declaration
2016-04-16 21:39:49 +02:00
Nikita Popov
588e6a4d4c
Add string kinds and doc string labels
...
Scalar\String_ and Scalar\Encapsed now have an additional "kind"
attribute, which may be one of:
* String_::KIND_SINGLE_QUOTED
* String_::KIND_DOUBLE_QUOTED
* String_::KIND_NOWDOC
* String_::KIND_HEREDOC
Additionally, if the string kind is one of the latter two, an
attribute "docLabel" is provided, which contains the doc string
label (STR in <<<STR) that was originally used.
The pretty printer will try to take the original kind of the string,
as well as the used doc string label into account.
2016-04-07 12:09:00 +09:00
Nikita Popov
14de71898e
Fix nop statement comment assignment
...
Keep around the start attributes on the lookahead token around in
a separate parser property.
2016-04-05 19:19:15 +09:00
Nikita Popov
5fa8493675
Make canonicalization less aggressive
2016-04-05 10:37:45 +09:00
Nikita Popov
b31a973fa7
Another fix for B"" handling
...
The lexer fix also need to account for uppercase B.
2016-04-04 22:07:50 +09:00
Nikita Popov
9ac3592190
Handle uppercase B"" prefix
2016-04-02 21:15:49 +09:00
Nikita Popov
aa199120c7
Add kind attribute for arrays
...
To distinguish array() and [] syntax. The pretty printer respects
this attribute. The shortArraySyntax pretty printer option acts as
a default in case the attribute is not specified.
2016-03-09 21:31:54 +01:00
Nikita Popov
ae30f97af6
Add "kind" attribute to LNumbers
...
Kind specifies whether the number was formatted as decimal, octal,
binary or hex. The pretty printer reproduces the number kind (but
not necessarily the exact formatting).
2016-03-09 21:10:55 +01:00
Nikita Popov
47c342a3e4
Add "kind" attribute to Stmt\Exit_
...
Attribute specifies whether this is a "die" or an "exit" and the
pretty printer behaves accordingly.
2016-03-09 20:20:36 +01:00
Nikita Popov
7eac2cfd8b
Introduce Nop statement to collect dangling comments
...
A Nop statement will be inserted into statement lists if there are
any trailing comments in the list (which would otherwise not be
associated with any node).
The pretty printer output currently still contains a superfluous
newline.
2016-03-09 19:48:36 +01:00
Nikita Popov
a0c216bf4b
Add dumpComments option to NodeDumper
...
Adding this as an option to avoid breaking people's tests.
Some of the test results show pretty clearly that we are incorrectly
assigning the same comment multiple times for nested nodes (mentioned
in #36 ).
2016-03-09 19:48:36 +01:00
Nikita Popov
a73aa7eec1
Pretty printer test coverage
...
Our output for yield / yield from is currently not very nice, but
also not easy to change.
2016-02-20 21:49:21 +01:00
Nikita Popov
1fe8f09caa
Fix __halt_compiler() pretty printing edge case
...
We can't strip the <?php at the end of a __halt_compiler() segment
in file mode.
Fixed by being a bit more explicit in prettyPrintFile() about what
we want to do...
2016-02-20 18:24:32 +01:00
Nikita Popov
d6361136e1
Update semi-reserved keyword list
...
Magic constant names have been added after the PHP 7 release.
We do not support and likely will not support __halt_compiler here
due to lexer limitations.
2016-02-09 13:30:39 +01:00
Nikita Popov
6dffb72ce0
Merge branch '1.x'
2016-01-15 22:02:35 +01:00
Nikita Popov
eb73441032
Support hashbang before namespace declaration
...
Fixes issue #243 .
2016-01-15 22:01:51 +01:00
Nikita Popov
719ca71d4a
Distinguish declare(); and declare(){}
...
It makes semantic difference and the latter form is actually
forbidden for strict_types.
This sets Declare->stmts to null for the body-less case.
2015-12-07 12:12:00 +01:00
Nikita Popov
a9074c7444
Introduce Scalar\EncapsedStringPart
2015-12-03 22:55:07 +01:00
Nikita Popov
98d28d7aa0
Drop test failing on HHVM
...
Can readd if Travis ever updates the HHVM version again, I
remember this being fixed ages ago.
2015-10-03 12:17:41 +02:00
Nikita Popov
e4b837e0c4
Split up pretty printer test in stmt/expr
...
The list was getting unweildly.
Also improve error message when parsing fails in pretty printer
test and extend some tests.
2015-10-02 11:16:12 +02:00
Aydin
2b9c5a62cb
Multiple init test for for loop
2015-10-02 11:03:33 +02:00
Aydin
99e89743bd
More PrettyPrinter tests
2015-10-02 11:03:32 +02:00
Nikita Popov
39a039fa42
Add option for short array syntax in pretty printer
2015-09-21 15:12:59 +08:00
Nikita Popov
eecaf1e93b
Merge branch '1.x'
...
Conflicts:
grammar/rebuildParsers.php
lib/PhpParser/Parser.php
2015-09-19 22:07:29 +08:00
Nikita Popov
950ada4cba
Fix issue #227
...
Use \z instead of $.
2015-09-19 22:05:23 +08:00
Nikita Popov
f57d217e91
Update group use support
...
To conform with current PHP 7 implementation
* Allow use \Foo\{Bar};
* Disallow use Foo\{\Bar};
* Disallow missing trailing semicolon (that was a bug)
2015-08-20 16:42:49 +02:00
Nikita Popov
dc85742034
Merge branch '1.x'
...
Conflicts:
CHANGELOG.md
composer.json
test/PhpParser/ParserTest.php
2015-07-14 19:43:49 +02:00
Nikita Popov
b9afcdfd92
Revert "Make tests compatible with PHP 7"
...
This reverts commit 91295a0790
.
This should no longer be necessary.
Conflicts:
test/PhpParser/ParserTest.php
2015-07-14 19:21:57 +02:00
Nikita Popov
8090531acd
Fix pretty printing of const derefs for 5.x
...
(FOO)[0] is only supported on 7.x
2015-07-09 12:38:30 +02:00
Nikita Popov
f872fa9b0b
Merge branch '1.x'
2015-07-04 14:40:53 +02:00
Nikita Popov
d5668f536d
Fix __HALT_COMPILER_OFFSET__ support on HHVM
2015-07-04 13:15:48 +02:00
Nikita Popov
ef9a154d09
Add support for unicode escape sequences
...
Only parsed if the PHP 7 parser is used.
2015-06-13 20:51:02 +02:00
Nikita Popov
0da72fad00
Support scalar type declarations
2015-06-13 20:16:09 +02:00
Nikita Popov
71fa7c6674
Support UVS in pretty printer
...
Try to generate interoperable code where possible (but not
everything can be expressed in PHP 5).
2015-06-13 20:01:01 +02:00
Nikita Popov
61e060694d
Implement generalized yield operator
...
And split tokens.y off, so I don't waste time debugging this again...
2015-06-13 18:11:40 +02:00
Nikita Popov
602b9807eb
Import some UVS tests
2015-06-13 15:42:09 +02:00
Nikita Popov
d18dcc0c7f
Implement UVS
2015-06-13 14:59:24 +02:00
Nikita Popov
dca46febc9
Implement semi-reserved identifiers
2015-06-13 12:47:13 +02:00
Nikita Popov
1a1bd1448d
Support mixed group use declarations
2015-06-13 11:27:38 +02:00
Nikita Popov
9620f79cdc
Add partial group use support
...
Supported via Stmt\GroupUse which has Name $prefix in addition to
the usual.
Still missing: Mixed group uses.
2015-06-12 23:05:28 +02:00
Nikita Popov
8b64195cf2
Try .17G print if .16G is not enough
...
This should be enough for all cases, because: A double has 53 bits
of mantissa (including the implicit 1 bit), which is 53*ln(2)/ln(10)
= 15.95 decimal digits. However the leading decimal digit may encode
less than the usual 3.32 bits, which will push this over the edge to
requiring 17 decimal digits.
2015-05-02 11:48:55 +02:00
Nikita Popov
648800f07f
Increase float pretty printing precision
...
This removes the reliance on the "precision" ini setting.
Furthermore the default of precision=14 is not sufficient.
2015-05-01 19:15:33 +02:00