Commit Graph

521 Commits

Author SHA1 Message Date
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
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
Nikita Popov
272ab6c8d8 Add some recovery tests 2015-04-30 19:02:51 +02:00
Nikita Popov
0731b47655 Don't distinguish test-fail / test
With error recovery this is fluid. Using .test for everything.
2015-04-30 17:45:36 +02:00
Nikita Popov
3b7d8e8b5d Enable basic error recovery
Adding only a single recovery rule for now.

The API is now:
 * throwOnError parser option must be disabled.
 * List of Errors is available through $parser->getErrors(). This
   method is available either way.
 * If no recovery is possible $parser->parse() will return null.
   (Obviously only if throwOnError is disabled).
2015-04-30 17:41:57 +02:00
Nikita Popov
a35c2a2067 Add column info to EOF errors
EOF errors are now located one past the end of the file.
2015-04-27 15:37:41 +02:00
Nikita Popov
55b2ead967 Make special class name checks case insensitive 2015-04-26 23:13:27 +02:00
Nikita Popov
e1a0ec3724 Add support for anonymous classes
Has not landed upstream yet, but syntax is unlikely to change.
2015-04-26 23:04:31 +02:00
Nikita Popov
66896dbde6 Poison attribute initializations in parser
Those should error if they end up being used.
2015-04-26 22:32:18 +02:00
Nikita Popov
338bc1f8e7 Fix "print" pretty-printing
Precedence was previously ignored.
2015-04-26 11:56:04 +02:00
Nikita Popov
ab80054e97 Add support for "yield from" 2015-04-26 11:56:02 +02:00
Nikita Popov
a6d2cd69f8 Clarify attribute assignment code
* Don't assign to attribute stack on reduce - why was that there
in the first place?
* Assign attributes to the position in the stack where the first
token of the production is, instead of one position earlier.
* Add a comment to clarify why we also assign attributes on read,
instead of just on shift.
2015-04-26 11:56:01 +02:00
Nikita Popov
6996db1e3a Build node attributes inside semantic action methods
Minor performance improvement for parsing, also allows to access
attributes with higher granulity in the parser, though this is not
currently done.

* #n can now be used to access the stack position of a token. $n
  is the same as $this->semStack[#n]. (Post-translate $n will
  actually be the stack position.)
* $attributeStack is now $this->startAttributeStack and
  $endAttributes is now $this->endAttributes.
* Attributes for a node are now computed inside the individual
  reduction methods, instead of being passed as a parameter.
  Accessible through the attributes() macro.
2015-04-26 11:55:59 +02:00
Nikita Popov
e30c3ac01b Merge pull request #195 from GrahamCampbell/patch-1
Bump version to 1.3
2015-04-19 20:52:51 +02:00
Graham Campbell
a5477a4eaf Version bump 2015-04-19 17:57:38 +01:00
Nikita Popov
7a40498cb4 Regenerate parser
Also drop the error() parser macro.
2015-04-19 18:12:56 +02:00
Nikita Popov
65f1adbe65 Merge primary error recovery code
The grammar does not yet actually implement error recovery.
2015-04-19 18:11:05 +02:00
Nikita Popov
c8454271e1 Make column info 1-based 2015-04-18 21:20:45 +02:00
Nikita Popov
62f83a0dc2 Add column info for non-syntax errors where relatively precise
Should it also be added if only rough information is available? E.g.
spanning an entire class?
2015-04-18 13:27:58 +02:00
Nikita Popov
611fa5c7f1 Test parser position information (syntax errors) 2015-04-18 13:27:57 +02:00
Nikita Popov
4defbc2174 Make Error column info attribute based 2015-04-18 12:51:26 +02:00
Gerrit Addiks
33a39fae06 added column-numbers to syntax errors 2015-04-18 10:14:49 +02:00
Nikita Popov
e4eab9ec0c Simplify code
The new class couldn't already exist at that point - if it did, the
old name would have been aliased already and the autoloader wouldn't
trigger.
2015-04-03 22:30:30 +02:00
Nikita Popov
6aaa87f143 Fix PHP 7 alias registration
This fixes the case where the old name is used before the new one
is ever used, e.g. when manually constructing nodes, as opposed to
parsing them.

The previous approach would try to register the alias from OLD to
NEW. This would trigger autoloading on NEW and afterwards it would
register the alias from OLD to NEW. Afterwards the alias registration
which originally triggered the autoload would run, thus redeclaring
the class.

TL;DR aliases suck, closes #192.
2015-04-03 22:22:39 +02:00
Nikita Popov
08f97eb4ef Release PHP-Parser 1.2.2 2015-04-03 16:33:59 +02:00
Markus Malkusch
8d18848fb0 Don't set unserialize_callback_func in Autoloader::register() as it has side effects even when the library is not used 2015-04-03 16:25:33 +02:00
Nikita Popov
805078e0a9 Add missing type hints 2015-03-28 18:14:24 +01:00
Nikita Popov
52dafafd10 Resolve param type hints earlier
For convenience of concurrent visitors that want to perform
enterNode actions based on Stmt\Function_ etc.

Fixes #188.
2015-03-25 20:57:39 +01:00
Nikita Popov
dba7524b37 Release PHP-Parser 1.2.1 2015-03-24 20:10:28 +01:00
Nikita Popov
617bf0aa41 Fix registering of PHP 7 aliases
The previous approach was causing issues, because "instanceof"
does not invoke the autoloader.
2015-03-24 20:04:50 +01:00
Nikita Popov
dce19b074b Strict type compliance
Were this library to be fully annotated with scalar types and
return types where possible and were strict types to be enabled
for all files, the test suite would now pass.
2015-03-24 11:19:17 +01:00
Nikita Popov
edbf162e4c Release PHP-Parser 1.2.0 2015-03-22 17:17:25 +01:00
Nikita Popov
b23c53df5f Update CHANGELOG 2015-03-22 16:03:59 +01:00
Nikita Popov
cea0c4a9d6 Don't register aliases on PHP 7 2015-03-22 16:03:57 +01:00
Nikita Popov
879e8dcd6d Merge pull request #186 from mnapoli/clone-nodes
Added a flag to NodeTraverser to avoid cloning nodes
2015-03-22 15:19:10 +01:00
Matthieu Napoli
729c7bde0c #184 Add a flag to NodeTraverser to avoid cloning nodes 2015-03-22 11:19:04 +13:00
Nikita Popov
8982315b4e Rename Cast\Object as well
As it will very likely be soft-reserved in PHP 7.

Old alias is still available, as usual.
2015-03-21 18:57:55 +01:00
Nikita Popov
0f556c16f5 Fix a few more Scalar\String_ occurances
Totally forgot that the parser uses macros...
2015-03-21 18:54:52 +01:00
Nikita Popov
7ec277e1e1 Replace another Scalar\String occurance
Also canonicalize NameResover tests to avoid those pesky CRLF
issues.
2015-03-21 18:47:20 +01:00
Nikita Popov
1a627872f0 Rename nodes for compat with PHP 7
The old names will still be available on PHP 5.x.
2015-03-20 21:49:38 +01:00
Nikita Popov
592836c4dc Add support for T_HASHBANG (HHVM) 2015-03-14 19:53:08 +01:00
Nikita Popov
68defc2c6a Merge pull request #183 from alprs/fix-autoloader
Ensure compatibility with multiple composer autoloaders
2015-03-14 09:07:35 +01:00
Andreas Lutro
d225555830 Ensure compatibility with multiple autoloaders
Running a .phar or regular PHP executable that requires and includes its own
version of php-parser will cause a "cannot redeclare class" error if said
executable also includes the autoloader of the current working directory.
2015-03-13 23:54:32 +01: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
Nikita Popov
dc28449d81 Drop whitespace after ... varargs collection
Also drop an obsolete pretty printer test.
2015-03-12 22:19:34 +01:00
Nikita Popov
3ad0d4b310 Add support for return type declarations [PHP 7]
This adds an additional "returnType" subnode to Stmt\Function_,
Stmt\ClassMethod and Expr\Closure, as well as the corresponding
support in the name resolver and pretty printer.
2015-03-12 22:16:12 +01:00
Nikita Popov
4dbf067b4b Add a few more string interpolation tests
Originally wanted to simplify the pretty-printer output, but ...
edge cases everywhere :/
2015-03-11 20:01:26 +01:00
Nikita Popov
5567f0ab3b Add documentation TOC to readme 2015-03-10 21:32:21 +01:00