Nikita Popov
2be7838fc6
Correctly assign attrs for encaps vars
2016-10-08 23:58:39 +02:00
Nikita Popov
f6eb341b15
Fix GroupUse prefix attribute assignment
2016-10-08 23:55:46 +02:00
Nikita Popov
a7120116b0
Merge branch '2.x'
2016-08-30 22:38:34 +02:00
Nikita Popov
83f34e7fa4
Retain comments on blocks on first inner statement
2016-08-30 22:37:51 +02:00
Nikita Popov
d0cfb98133
Merge branch '2.x'
...
Conflicts:
lib/PhpParser/Parser/Php7.php
2016-08-30 22:14:09 +02:00
Nikita Popov
13f7321def
Forbid "=& new" in PHP 7 mode
2016-08-30 22:12:01 +02:00
Nat Zimmermann
46495abb49
Fix typo in grammar/README.md
2016-08-11 16:17:08 +02:00
Nikita Popov
977cbab8e7
Decrement errorState when recovering from -> error
...
It's likely that an error after -> will trigger another one due to
missing semicolon without shifting a single token. We prevent an
immediate failure in this case by manually setting errorState to 2,
which will suppress the duplicate error message, but allow error
recovery.
2016-07-25 17:37:54 +02:00
Nikita Popov
09086fbe0a
Support partial parsing of $foo->
...
Introduce Error node for this purpose.
2016-07-25 17:03:58 +02:00
Nikita Popov
5f97b12576
Introduce explicit Finally node
2016-07-25 14:25:04 +02:00
Nikita Popov
eefcfeed23
Remove analyze.php
...
Has outlived its usefulness...
2016-07-25 13:38:05 +02:00
Nikita Popov
867ae5148d
Bring Trait constructor in line with Class/interface
2016-07-22 17:01:51 +02:00
Nikita Popov
537b59d4d1
PHP 7.1: Support multi-catch
...
Catch::$type is now an array Catch::$types.
2016-07-22 15:40:00 +02:00
Nikita Popov
574665b45b
PHP 7.1: list() with keys
...
Expr\List will now contain ArrayItems instead of plain variables.
I'm reusing ArrayItem, because code handling list() must also handle
arrays, and this allows both to go through the same code path.
This also renames Expr\List->vars to ->items.
TODO: Should Expr\List be dropped in favor of Expr\Array with an
extra flag?
2016-07-09 21:55:55 +02:00
Nikita Popov
437890d386
PHP 7: Short destructuring syntax
...
Potentially the pretty printer should force use of [] in assignment
context, instead of relying on the existance of the right attribute.
2016-07-06 23:43:23 +02:00
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
90eb1165d1
Switch Exit kind attribute to flag
...
To be consistent with everything else.
2016-04-19 14:51:05 +02:00
Nikita Popov
e7869b9f14
Forbid invalid octals in PHP 7 mode
2016-04-18 13:59:18 +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
f493219c7d
Move "kind" attribute handling out of lexer
...
Doesn't belong there and will cause issue with multiple assignments.
2016-03-10 12:55:15 +01: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
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
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
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
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
2496cd38ad
Various docs fixes
2015-07-14 21:11:54 +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
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
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
74c57eef0e
Test PHP 5 and PHP 7 parsers
...
At this point they should return the same result.
2015-06-13 13:56:45 +02:00
Nikita Popov
fdbddc4b8c
Add Multiple parser
2015-06-13 13:38:24 +02:00
Nikita Popov
ca3b44bf60
Fork separate PHP 7 parser
...
Also add ParserInterface
2015-06-13 13:09:34 +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
a0e7d5e0aa
Set correct number of s/r conflicts
2015-05-02 22:51:38 +02:00
Nikita Popov
51ec2a25fe
Move parser to Parser\Php5
...
Old name still exists.
2015-05-02 22:50:11 +02:00
Nikita Popov
9d42e4a2e2
Drop short array simulation from .phpy syntax
...
Instead use real short array syntax.
2015-05-02 22:30:44 +02:00
Nikita Popov
23bf4f0c13
Add some error documentation
2015-04-30 21:58:45 +02:00
Nikita Popov
57ac7e39bf
Drop name magic from rebuildParser.php
...
Now using explicitly imported names, instead of magically
prepending Name\.
Also remove trailing whitespace from generated file.
2015-04-30 19:20:38 +02:00