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
feb82eed33
Disable cloning in traverser by default
2015-07-14 17:39:56 +02:00
Nikita Popov
0ef15c111a
Merge branch '1.x'
2015-07-14 17:08:28 +02:00
Nikita Popov
d341d94976
Add ClassLike::getMethod($name)
...
To allow getting individual method with a given name.
2015-07-14 17:07:45 +02:00
Nikita Popov
0265c28e6e
Switch NameResolver resolve methods to be immutable
...
To make it theoretically possible to expose this as API.
Add slice() method to Name to allow this. Deprecate existing mutable
Name APIs.
2015-07-12 23:56:57 +02:00
Nikita Popov
5bd8cb84de
Add dummy ParserFactory test
...
:/
2015-07-12 22:53:17 +02:00
Nikita Popov
ebeeae19a6
Merge branch '1.x'
2015-07-12 22:12:28 +02:00
Nikita Popov
5ede167835
Fix infinite recursion in Use builder __call
2015-07-12 22:11:43 +02:00
Nikita Popov
49324ea412
Drop default values from Scalar ctor params
2015-07-12 22:02:18 +02:00
Nikita Popov
21e51c8cf6
Add some tests for Multiple parser
2015-07-12 22:00:02 +02:00
Nikita Popov
e7a2abb03b
Merge branch '1.x'
2015-07-11 22:33:19 +02:00
Nikita Popov
b862de1f5b
Support properties in trait builder
2015-07-11 22:31:45 +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
1d62e9d8cc
Fix implicit visibility for properties as well
...
Also switch to using PPP mask.
2015-07-05 20:17:52 +02:00
Lisachenko Alexander
e3195c246f
Fix public modifier check for ClassMethod node
2015-07-05 20:17:50 +02:00
Nikita Popov
90ab32f046
Merge branch '1.x'
2015-07-05 20:16:41 +02:00
Nikita Popov
7434a682e5
Fix implicit visibility for properties as well
...
Also switch to using PPP mask.
2015-07-05 20:16:21 +02:00
Lisachenko Alexander
0fbb5f90a1
Fix public modifier check for ClassMethod node
2015-07-05 20:10:48 +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
a5db176903
Merge branch '1.x'
2015-07-02 18:09:38 +02:00
Nikita Popov
42e368e964
Fix returnType typehints
...
Fixes issues #207
2015-07-02 18:06:41 +02:00
Nikita Popov
9c9a8cddce
Merge branch '1.x'
2015-06-20 12:34:36 +02:00
Nikita Popov
fd7ee2e083
Add missing regex anchor
2015-06-20 12:34:10 +02:00
Nikita Popov
179d32cfaf
Simplify handleHaltCompiler() implementation
...
Nowadays we're already tracking the filePos, no need to
recompute it.
2015-06-20 12:33:33 +02:00
Nikita Popov
f2b7a31509
Rename ParserInterface to Parser
...
And drop the alias of Parser to Parser\Php5.
2015-06-20 11:47:25 +02:00
Nikita Popov
813c9f1545
Add basic ParserFactory
2015-06-20 11:28:58 +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
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
583b560f71
Drop {@inheritDoc}
...
Those are unnecessary and actually against the spec.
2015-06-12 20:37:43 +02:00
Nikita Popov
db3dafd64d
Merge branch '1.x'
2015-06-05 18:57:04 +02:00
Suralc
bb2c5303ae
Add a FunctionLike interface to Methods, Functions and Closures.
...
The elements listed above share common elements like parameters, possible return types and bodies.
2015-06-05 18:56:25 +02:00
Nikita Popov
51ec2a25fe
Move parser to Parser\Php5
...
Old name still exists.
2015-05-02 22:50:11 +02:00
Nikita Popov
5d1e3be7d4
Anonymize some callbacks
2015-05-02 22:35:15 +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
cc75dd3612
Drop support for PHP 7 aliases
2015-05-02 22:21:12 +02:00
Nikita Popov
5f621c5adc
Drop support for legacy aliases from v0.9
2015-05-02 22:19:25 +02:00
Nikita Popov
29b9015f51
Drop support for old Node format
2015-05-02 22:17:34 +02:00
Nikita Popov
e6619f5514
Drop 5.4 support from emulative lexer
2015-05-02 22:13:55 +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
9caa51b3a5
Add some more tests
2015-05-01 20:18:04 +02:00
Nikita Popov
5513073a53
Drop Lexer::getPosition()
...
This was a leftover from the original column info implementation.
2015-05-01 20:18:01 +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
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
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
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
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
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
cea0c4a9d6
Don't register aliases on PHP 7
2015-03-22 16:03:57 +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
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
0c34706799
Add "use" builder
2015-03-10 16:05:55 +01:00
Nikita Popov
f9fc2fc9ee
Add support for global namespace in NS builder
...
NULL argument can now be used to create a global namespace {} block.
2015-03-10 15:28:19 +01:00
Nikita Popov
a2d7e8977a
Use real properties for storing subnodes
...
Instead of storing subnodes in a subNodes dictionary, they are
now stored as simple properties. This requires declarating the
properties, assigning them in the constructor, overriding
the getSubNodeNames() method and passing NULL to the first argument
of the NodeAbstract constructor.
[Deprecated: It's still possible to use the old mode of operation
for custom nodes by passing an array of subnodes to the constructor.]
The only behavior difference this should cause is that getSubNodeNames()
will always return the original subnode names and skip any additional
properties that were dynamically added. E.g. this means that the
"namespacedName" node added by the NameResolver visitor is not treated
as a subnode, but as a dynamic property instead.
This change improves performance and memory usage.
2015-03-09 08:54:20 +01:00
Thomas Ruiz
73cace360d
Implicit public should not generate as explicit public
2015-03-08 20:21:01 +01:00
Markus Staab
ce5c76d79b
prevent a unnecessary concat
...
analog to b7ffdbbb92
2015-02-13 16:02:54 +01:00
Nikita Popov
b7ffdbbb92
Optimize node dumper
...
For very deeply nested node trees this extra concatenation makes a
huge difference...
2015-02-13 15:20:25 +01:00
Tom Rochette
1366e833a1
Move getMethods() to new ClassLike node
...
Class_, Interface_ and Trait_ extend the ClassLike node, which
provides the getMethods() method.
2015-01-31 22:59:38 +01:00
Nikita Popov
a710f32a6a
Make Node\Expr\BinOp an abstract class
...
Only the children should be used ...
2015-01-18 00:10:02 +01:00
Nikita Popov
4071c4645d
Add NodeTraverser::DONT_TRAVERSE_CHILDREN support
2015-01-11 22:13:58 +01:00
Nikita Popov
4cd2b95a23
Fix 5.3 build and some small cleanups
2014-12-19 18:54:56 +01:00
Nikita Popov
7ab88416ac
Enforce Name|string for names in builders
...
While array (with name components) could technically be allowed (as
they are supported by the Name node itself), more likely than not
an array would due to incorrect usage of the API (e.g. array instead
of variadics).
2014-12-19 18:50:16 +01:00
Nikita Popov
ba625063e7
Support fully-qualified and ns-relative names in builders
2014-12-19 18:48:21 +01:00
Stepan Anchugov
01643e06d3
Add namespace builder
2014-12-19 18:19:33 +01:00
Nikita Popov
4387454fe0
Add trait builder (for completeness...)
2014-12-19 17:59:23 +01:00
Nikita Popov
55fdbc6dbc
Extract common builder methods to abstract classes
...
Declaration for fns/classes in general and FunctionLike for
functions/methods in particular.
2014-12-19 17:47:51 +01:00
Nikita Popov
a7797918b8
Update lexer docs for attribute options
2014-12-19 00:37:37 +01:00
Nikita Popov
46975107a7
Support token position attributes in lexer
...
Also change endFilePos semantics to refer to the last character that
is *included* in the token, rather than one past the last character.
This ensures that all end* attributes have the same semantics.
2014-12-19 00:37:36 +01:00
Nikita Popov
2438848487
Add support for doc comments in builders
2014-12-13 13:44:40 +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
Máximo Cuadros Ortiz
d774dbc1b7
Add optional startFilePos and endFilePos attributes
...
The lexer can now optionally add startFilePos and endFilePos
attributes, which are offsets in to the lexed code string.
The end offset currently points one past the last character of
the token - this is pending further discussion.
The attributes are not added by default and have to be enabled
using the new 'usedAttributes' lexer option:
$lexer = new Lexer([
'usedAttributes' => [
'comments', 'startLine', 'endLine',
'startFilePos', 'endFilePos'
]
]);
2014-11-27 20:38:29 +01:00
nikic
e26e63e9b0
Error on final or abstract properties
2014-11-13 20:25:52 +01:00
nikic
0f69f12b94
Use "public" visibility when not explicitly given
...
Fixes issue #143
2014-11-13 20:21:21 +01:00
nikic
7fbdb79a08
Fix whitespace when printing trait alias modifiers
2014-11-03 16:16:15 +01:00
Arne Blankerts
6fad8ff32a
Make NameResolver resolve trait alias and precedence names
2014-11-03 16:06:43 +01:00
nikic
99df8b86ae
Support HHVM T_ONUMBER token
2014-09-30 20:55:58 +02:00
nikic
3d40e2217d
Annotate some APIs as @internal
2014-09-30 20:26:06 +02:00
nikic
3e1665bbbd
Disallow new without a class name
...
Fixes #137 .
2014-09-28 12:41:35 +02:00
nikic
fd064dac6c
Very that node type is valid in XML unserializer
2014-09-12 00:39:59 +02:00
nikic
d9bd550414
Fix XML unserializer
2014-09-12 00:37:21 +02:00
nikic
94eca2ce44
Remove deprecated Template and TemplateLoader
2014-09-12 00:25:30 +02: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
452e1c0180
Add constant dereferencing, a list-minute 5.6 change
2014-08-31 16:14:36 +02:00
nikic
6d0589d14f
Ensure that special class names are unqualified
...
Replicates the PHP error message
2014-08-11 22:04:52 +02:00
nikic
ef121e690c
Preserve case of "static" class name
2014-08-11 21:44:50 +02:00
Elliot Levin
c0340053d1
Fix case sensitivity for special class names
2014-08-11 21:41:54 +02:00
Yuriy Vilks
39f323b5ad
Fix classname of Class_ in docblock of BuilderFactory
2014-08-11 20:53:18 +02:00
nikic
1f143393e5
Rewrite namespace handling code
...
Add a check for disallowed statements between braced namespaces
while at it.
2014-04-21 15:16:00 +02:00
nikic
6d1f77132c
Move Stmt\Namespace_::postprocess() to parser
2014-04-21 12:30:55 +02:00
nikic
2e195d7cb2
Make sure that pretty printer preserves whitespace after <?php
2014-04-21 11:15:33 +02:00
nikic
947a897238
Make names in the parser more descriptive
...
And improve the code a tad bit in general.
I left YY2TBLSTATES and YYNLSTATES around, because I don't fully
understand their role in the action double indexing.
2014-04-20 23:05:51 +02:00
nikic
1edbc89749
Use normal properties instead of static ones
2014-04-20 00:34:31 +02:00
nikic
0faa844a75
Separate parser code from generated data
2014-04-20 00:19:35 +02:00
nikic
4743e9b0b8
Update constant scalar expression support
2014-04-19 22:53:13 +02:00
nikic
e4e56511b9
Merge branch '0.9'
2014-04-19 22:26:35 +02:00
nikic
5960ecfc10
Disable xdebug.scream while lexing
2014-04-19 22:26:05 +02:00
Nikita Popov
c341ab2ecf
Make autoloader for new names PSR-0 compliant
2014-04-02 09:44:45 +02:00
nikic
c62ffedfca
Require file only if file exists
...
Allows usage of class_exists() on undefined classes.
2014-03-27 15:40:08 +01:00
nikic
4c06b0919a
Merge branch '0.9'
...
Conflicts:
lib/PhpParser/Template.php
lib/PhpParser/TemplateLoader.php
2014-03-27 12:53:24 +01:00
nikic
8429157ab5
Deprecate templating functionality
...
Other projects cover this a lot better.
2014-03-27 12:51:13 +01:00
Martin Hasoň
2605b8319e
Added support for autoload $prepend
2014-03-27 12:39:30 +01:00
nikic
91f6880734
Improve pretty printing of empty statement lists
...
The pStmts() method now also includes the leading \n, however only
if the statement list is non-empty.
2014-03-27 12:31:21 +01: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
a5e0bbcb62
Support use function/const in name resolver
2014-03-26 23:28:32 +01:00
nikic
3b7829b011
Add support for function and constant import (PHP 5.6)
2014-03-26 22:33:45 +01:00
nikic
bea89a0bf2
Add support for constant scalar expressions (PHP 5.6)
2014-03-26 21:48:12 +01:00
nikic
cda6f575f0
Add support for pow operator (PHP 5.6)
2014-03-26 19:18:16 +01:00
nikic
b5bcfa1168
Add support for argument unpacking (PHP 5.6)
2014-03-26 18:42:46 +01:00
nikic
96f1151ab2
Add support for variadic parameters (PHP 5.6)
2014-03-26 18:23:30 +01:00
nikic
f5be0d30f7
Guarantee that subnodes are always in the right order
2014-03-22 14:49:56 +01:00
Tomáš Polomský
c8c233f900
Correctly pretty print negative floats
2014-03-22 14:24:35 +01:00
nikic
8c59f41d02
Remove inline Name[] creations
...
This ensures that the attributes on the Name nodes are correct.
2014-03-22 14:24:33 +01:00
nikic
70077039b4
Add Scalar\MagicConst->getName()
...
Return magic constant name, e.g. __CLASS__.
Resolves #95 .
2014-02-21 18:16:18 +01:00
nikic
1c8481bff6
Merge branch '0.9'
...
Conflicts:
lib/PhpParser/Lexer.php
lib/PhpParser/Node/Stmt/Class.php
lib/PhpParser/Node/Stmt/ClassMethod.php
lib/PhpParser/Node/Stmt/Interface.php
lib/PhpParser/Node/Stmt/Namespace.php
lib/PhpParser/Node/Stmt/UseUse.php
lib/PhpParser/Parser.php
2014-02-12 20:23:12 +01:00
Martin Hasoň
118f28344d
Synchronized error messages with native php error messages
2014-02-12 20:19:48 +01:00
nikic
523e024ba0
Fix a number of other typos
2014-02-12 17:47:34 +01:00
nikic
f82862ec9c
Port library to use namespaces, with BC for old names
2014-02-06 20:29:35 +01:00
nikic
10e1c1895c
Remove 5.2 compatibilty code in some places
2014-02-05 22:37:07 +01:00
Arne Blankerts
6f36a88993
Ensure no registered error handler will see the 'reset' error
2014-01-24 20:27:42 +01:00
Brikou Carré
72310dd5a3
s/Elseif/ElseIf/
2013-11-27 15:05:37 +01:00
Jean-François Simon
7f4ab26732
Fix name resolver (class names are case insensitive)
2013-11-15 20:27:56 +01:00
Charles Sprayberry
700847e295
Add NodeTraverser::removeVisitor()
2013-09-28 13:21:30 +02:00
nikic
01123ae6af
Fix notices when generating expected tokens list (continued)
...
Forgot to add regenerated parser
2013-07-27 18:50:08 +02:00
nikic
77c08a75c9
Fix pretty printing of include
expressions
2013-07-27 16:23:27 +02:00
nikic
f9c3aa2a22
Improve PrettyPrinter construction perf by not using uniqid
...
The uniqid function is *very* slow on unix systems. The code has no
particular unique-ness requirements, so the much faster mt_rand()
function is used instead.
Closes PR #65 .
2013-07-13 01:03:57 +02:00
nikic
5ccf6196d6
Update changelog
2013-05-23 15:17:59 +02:00
Florent
12faad529e
Add interface builder
2013-05-23 15:14:58 +02:00
nikic
c0da1b88b2
Merge pull request #59 from Trismegiste/refactor-adding-an-interface-for-LSP
...
Adding an interface to the Node Traverser for LSP concern
2013-05-22 14:45:21 -07:00
Florent
900a3f3b7c
Implementing the interface for PHPParser_NodeTraverser
2013-05-16 15:44:12 +02:00
Florent
92df3e5add
Adding the interface
2013-05-16 15:43:24 +02:00
Jamie Burns
ba91348142
Typo fix
2013-05-15 16:48:42 +02:00
nikic
08f0cde6f9
Add prettyPrintFile() method
2013-04-15 20:53:23 +02:00
nikic
75ec7a3e78
Looks like I forgot to git add some files...
2013-02-14 21:49:08 +01:00
nikic
81d20bf10e
Pretty print namespaces in semicolon-style if possible
2013-01-15 18:21:42 +01:00
nikic
db18906dfc
Rename PrettyPrinter_Zend to PrettyPrinter_Default
2013-01-15 17:43:36 +01:00
nikic
fbaa1e5fc3
Add information on expected tokens to syntax errors
...
This now mimics the error messages provided by PHP itself (pre 5.4).
2013-01-15 17:30:14 +01:00
nikic
222c9612ab
Use RegexIterator in docs (by @lstrojny)
...
Also fix formatting in changelog and be more specific in a doc comment.
2012-12-21 13:28:35 +01:00
nikic
cdbad02fb2
Fix endAttributes assignment
...
The end attributes previously were always assigned from the last read token,
which does not necessarily correspond to the last token in the reduced rule.
In particular this occurs if the parser read a new token and based on that
lookahead decided to reduce a rule. The behavior was only correct if the
newly read token was first shifted and then the rule was reduced.
This is fixed by buffering the endAttributes of the new token in a temporary
variable and only assigning them once the token is shifted.
2012-11-20 16:12:19 +01:00
Nicolò Martini
bdb58ada7c
Update lib/PHPParser/BuilderAbstract.php
...
Updated BuilderAbstract::normalizeValue phpdoc description.
2012-11-06 18:28:15 +01:00
nikic
fc56da59ce
Rename pSafe to pNoIndent
...
Matches the function more closely
2012-10-31 17:50:54 +01:00
nikic
df17d62b40
Fix switch formatting
...
The switch cases were not indented and fall-through cases had an
unnecessary additional newline.
Patch by @pscheit (PR #39 ).
2012-10-31 17:46:48 +01:00
nikic
ac6f221c50
Better prededence and associativity handling in pretty printer
...
Previously the pretty printer added unnecessary and odd-looking parentheses
when several operators with the same precedence were chained:
'a' . 'b' . 'c' . 'd' . 'e'
// was printed as
'a' . ('b' . ('c' . ('d' . 'e')))
Another issue reported as part of #39 was that assignments inside closures
were wrapped in parentheses:
function() {
$a = $b;
}
// was printed as
function() {
($a = $b);
}
This was caused by the automatic precedence handling, which just regarded
the closure as an ordinal nested expression.
With the new system the $predenceMap of PrettyPrinterAbstract contains both
precedence and associativity and there is a new method pPrec() which prints
a node taking precedence and associativity into account.
For simpler usage there are additional function pInfixOp(), pPrefixOp() and
pPostfixOp().
Prints not going through pPrec() do not have any precedence handling (fixing
the closure issue).
2012-10-31 17:34:06 +01:00
nikic
9e43acee2c
Scalar_String::create() -> Scalar_String::parse()
...
Directly creating the node isn't necessary anymore, the token only needs
to be parsed. This makes it consistent with the other scalar parsing
methods and removes the need to pass $arguments around.
2012-10-19 15:17:08 +02:00
nikic
9d8e13b4a9
Fix Switch subnode order
...
Not that it makes much of a difference, but could have caused issues with
"out of order" visiting of nodes.
2012-10-19 14:54:56 +02:00
nikic
af5d288fb3
Add support for expressions in empty (PHP 5.5)
...
Apart from the grammar modifications this also renames the Empty subnode
from var to expr. This breaks BC.
2012-09-07 23:42:01 +02:00
nikic
f6c1ab6657
Adjust list and yield parsing, update prettyprinter
...
* nested list()s will now create nested List nodes (instead of just
nested arrays)
* yield $k => $v was parsed with key and value swapped. This is now fixed
* the pretty printer now works with the newly added language constructs
2012-09-07 23:41:59 +02:00
nikic
4259b44a84
Add support for constant dereferencing (PHP 5.5)
...
Examples: "foo"[2], [1, 2, 3][2]
2012-09-07 23:41:58 +02:00
nikic
417a8bb07e
Add support for yield expressions (PHP 5.5)
...
This adds a new Yield expression type, with subnodes key and value.
2012-09-07 23:41:57 +02:00
nikic
ae3774f0f2
Add support for finally clauses (PHP 5.5)
...
This adds a new finallyStmts subnode to the TryCatch node. If there is
no finally clause it will be null.
2012-09-07 23:41:56 +02:00
nikic
f8f1e17e41
Add support for list() in foreach (PHP 5.5)
...
Example: foreach ($coords as list($x, $y)) { ... }
This change slightly breaks backwards compatability, as it changes the
node structure for the previously existing `list(...) = $foo` assignments.
Those no longer have a dedicated `AssignList` node; instead they are
parsed as a normal `Assign` node with a `List` as `var`. Similarly the
use in `foreach` will generate a `List` for `valueVar`.
2012-09-07 23:41:55 +02:00
nikic
8d218110db
Fix some doc comments
2012-09-07 23:41:54 +02:00
nikic
5a947e9843
Fix parsing of $foo =& new Bar;
...
By-reference assignments of new expressions are now parsed as AssignRef
(instead of just Assign).
Closes issue #31 .
2012-07-23 11:36:47 +02:00
nikic
eb5991227d
Add Class->getMethods() function
2012-07-07 16:24:07 +02:00
nikic
4137d7a7a8
Add modifier accessors for ClassMethod etc
2012-07-07 16:08:37 +02:00
nikic
35ec185558
Make $line argument for Comment optional
...
Also add setLine() method.
2012-06-08 17:55:35 +02:00
Jon Cave
0911b2e1ce
Add line number information to comments
...
Line numbers are stored in the $line property of the PHPParser_Comment
and PHPParser_Comment_Doc classes and can be retrieved with getLine().
2012-06-06 14:33:38 +01:00
nikic
e16513a0eb
Fix parsing of new expressions in parenthesis
...
The new dereferencing syntaxes (new Foo)->bar and (new Foo)['bar'] were
causing a shift/reduce conflict with the '(' expr ')' rule. When
(new Foo) was encountered (without dereference operators following) the
parser thus threw a parse error.
The fix simply adds a special '(' new_expr ')' rule to expr. This does not
remove the shift/reduce conflict itself, but makes it irrelevant.
This fixes issue #20 .
2012-05-12 14:11:10 +02:00
nikic
10fc22f518
Replace \N with .
...
Older PCRE versions (coming with PHP 5.2) don't support \N yet.
2012-05-11 20:38:05 +02:00
nikic
93392c82e0
Fix getAttribute signature in Node interface
...
This fixes a build failure on PHP 5.2.
2012-05-11 18:48:23 +02:00
nikic
dab2fd4b7a
Fix comment reformatting on Linux
...
Remove the use of \R (with BSR_ANYCRLF) at two places, as it was causing
problems there.
2012-05-11 18:45:55 +02:00
nikic
81e53ce0ff
Insert comments when pretty printing
...
This changset also adds unit tests for Comments and adds a way to test the
pretty printer.
2012-05-11 16:18:14 +02:00
nikic
a824a2aba7
Fix $node->getDocComment()
...
getDocComment() now returns the last comment (given that it is a doc
comment). setDocComment() no longer exists, as it doesn't make sense
with the comment objects anymore. getAttribute() now returns by reference,
so it also works in reference contexts.
2012-05-06 18:24:26 +02:00
nikic
9d96dd1796
Adjust XML unserializer for new comments attribute
2012-05-06 18:12:02 +02:00
nikic
e587e3f4c6
Collect normal comments too, not only doc comments
...
Comments and doc comments are now saved in the 'comments' attribute, as an
array. The are instances of PHPParser_Comment[_Doc].
2012-05-06 17:49:04 +02:00
nikic
dd711f2a04
Generalize the attribute generation for nodes
...
Now two arrays are fetched from the lexer: $startAttributes and
$endAttributes. When constructing the attributes for a node, the
$startAttributes from the first token of the node and the $endAttributes
of the last token of the node are merged.
Now the end line is saved in the endLine attribute.
2012-05-05 17:34:27 +02:00
nikic
101a6ddcfc
Fix NameResolver to properly copy attributes
2012-05-04 10:18:50 +02:00
nikic
2f5ebf7c4d
Store line and doc comment as attributes
2012-05-04 10:16:59 +02:00
nikic
f66a672dd0
Start refactoring parser skeleton
...
The yacc parser skeleton with all those odd $yy short names is quite
non-obvious. This commits starts to refactor it a bit, to use more
obvious names and logic.
2012-05-04 10:16:49 +02:00
nikic
3701e02d32
Use inject-once approach for lexer
...
Now the lexer is injected only once when creating the parser. Instead of
$parser = new PHPParser_Parser;
$parser->parse(new PHPParser_Lexer($code));
$parser->parse(new PHPParser_Lexer($code2));
you write:
$parser = new PHPParser_Parser(new PHPParser_Lexer);
$parser->parse($code);
$parser->parse($code2);
2012-05-04 10:16:46 +02:00
Johannes M. Schmitt
c2c7fdd13d
fixes a bug were line number were lost
2012-05-03 23:58:47 -05:00
Johannes M. Schmitt
0dae07af6b
fixes a bug where catch type was not resolved
2012-05-03 23:52:39 -05:00
nikic
b42c9209c7
Fix PHP 5.2 build failure
...
lcfirst() isn't defined on PHP 5.2, so I added a fallback function, which
is defined in the bootstrap.php. Not sure whether that's the right place
to put it.
2012-04-23 22:17:06 +02:00
nikic
9329c91591
Merge branch 'codeGeneration'
...
* codeGeneration:
Add docs for templates
Add a filesystem template loader.
Add simple templating support.
Add usage example for builders to docs
Add function builder
Add ability to specify arrays as default values
Add property builder
Add parameter builder
Add method builder
Add class builder
2012-04-23 13:32:16 +02:00
nikic
5b27fb40ce
Fix line numbers for some list structures
...
When defining a list in the grammar the list elements have to get a separate
rule, otherwise they'll all be assigned the same line number.
2012-04-19 00:52:44 +02:00
nikic
e2a9745bf1
Make Serializer_XML::_serialize protected
2012-04-19 00:25:13 +02:00
nikic
a45360ccaf
Add tests for node attributes
...
Also fix the @inheritDoc declarations and do some whitespace normalization
2012-04-19 00:22:31 +02:00
Sebastian Bergmann
b9e3565587
Fugbix typo.
2012-04-04 15:54:45 +02:00
nikic
337da5648c
Fix XML unserializer
...
The subNodes array was not initialized, so for empty nodes it would just
be null. Due to the addition of attributes for nodes those have to be
initialized too.
2012-04-04 14:06:08 +02:00
nikic
a048112e2c
Add a filesystem template loader.
...
The template loaders loads templates from a base directory (and can
optionally use a suffix). For example
$templateLoader = new PHPParser_TemplateLoader(
$parser, './templates', '.php'
);
// loads ./templates/TestTemplate.php
$templateLoader->load('TestTemplate');
Again the implementation is not optimal. The loader probably shouldn't
intantiate the Template itself, but instead should accept a
TemplateFactory. This seemed like overkill to me, so I left it out.
2012-04-03 23:52:00 +02:00
nikic
19c1f80589
Add simple templating support.
...
Templates use __name__ placeholders. A variant of the placeholder with a
capitalized first latter can be accessed using __Name__ (this is useful
for camel case identifiers, e.g. get__Name__).
Currently the implemention is not particularly clean, because the Template
instantiates a Lexer itself. Fixing this requires a major refactoring of
the lexer/parser interface.
2012-04-03 22:47:41 +02:00
Johannes
2ccae143d0
added implementations for the new interface methods
2012-04-03 13:07:10 -05:00
Johannes
e932711fa4
added some methods for storing metadata to the interface
2012-04-03 13:04:24 -05:00
nikic
b8b68a969c
Add function builder
2012-03-11 09:02:52 +01:00
nikic
9e5c95b6aa
Add ability to specify arrays as default values
2012-03-11 08:53:04 +01:00
nikic
3ce3542032
Add property builder
2012-03-11 08:42:13 +01:00
nikic
4c8351fa86
Add parameter builder
2012-03-11 00:06:02 +01:00
nikic
48f0322aef
Add method builder
2012-03-10 23:25:26 +01:00
nikic
88e1f2eeab
Add class builder
2012-03-10 17:56:56 +01:00
nikic
d7407af87d
Remove unused variable
2012-03-03 17:01:28 +01:00
nikic
2ed6cac7c1
Don't traverse nodes merged by another visitor
...
If a NodeVisitor returns an array of nodes to merge these will no longer be traversed by all other visitors. That "feature" turned out to be a real pain in the ass on some occasions ;)
2012-03-03 16:50:45 +01:00
nikic
6657ac4b76
Clarify that parser is autogenerated
2012-03-02 00:43:34 +01:00
nikic
168982a912
Don't replace \ followed by { with NS_SEPARATOR
2012-02-21 19:28:40 +01:00
nikic
d98a65086b
Minor refactor and comments for emlative lexer
...
The emulative lexer is a single dirty hack so it needs a few more comments :)
2012-02-21 17:56:07 +01:00
nikic
608cfbba4e
Factor out error handling out of Lexer construcor
...
Makes the constructor more concise and puts the strange error handling stuff in separate methods
2012-02-21 17:00:49 +01:00
nikic
cf3117d82d
Fix parsing of integers that overflow into floats
...
Integers in hex/oct/bin notation that overflowed into floats were parsed incorrectly.
2012-01-15 16:54:48 +01:00
nikic
faf0351bab
Fix emulation of binary floats
...
All binary literals were lexed as integers, even if they were floats
2012-01-15 16:37:18 +01:00
nikic
bf252b2813
Fix NOWDOC emulation
...
Strings where the NOWDOC label appeared at the beginning of a line, but not followed by a newline were not correctly recognized.
2012-01-15 14:37:53 +01:00
nikic
c5c7aa5125
Add initial version of an emulative lexer
...
The emulative lexer allows lexing of PHP 5.4 on PHP 5.3 and PHP 5.2.
2011-12-18 17:03:11 +01:00
nikic
94d4c30a72
Fully Cover and fix NameResolver
...
Previously type hints were not resolved due to a typo. Also trait uses were not resolved.
2011-12-10 12:11:53 +01:00
nikic
df691065a6
Fix __halt_compiler() usage in namespace
...
This fixes the only left bug that was reported by parsing the PHP testsuite :)
2011-12-07 18:36:38 +01:00
nikic
80065965d3
[5.4] Add new \e escape sequence (0x1B/27)
2011-12-04 17:35:30 +01:00
nikic
1449cc2092
Disallow array deref using alternative syntax
...
f(){0} and a::b(){0} aren't allowed anymore (in compliance with PHP).
$a->b(){0} support stays for now (for technical reason).
2011-12-04 17:07:17 +01:00
nikic
db3181aff1
More test coverage and doc string parsing fixes
...
The parser didn't account for the additional newline after the content of doc strings, which is left there by the tokenizer for some reason. Additoinally esacape sequences were parsed in nowdoc strings.
Additionally this contains some minor changes to the grammar: Some _list nonterminals were refactored to have the possible single elements in a reparate rule and only assemble those single elements. (This reduces duplication and gives better assignment of line number context.)
2011-12-04 16:52:43 +01:00
nikic
c3df371998
Cover, fix and cleanup XML unserializer
2011-12-03 15:15:20 +01:00
nikic
b49c55c9e5
Cover NodeTraverser and bugs it found
...
a) ->traverseNode() now operates on a clone of the node, otherwise the original node will be modified too
b) before nodes were passed to the following visitor unchanged, even though they were already changed in the tree
2011-12-02 17:52:03 +01:00
nikic
8c2bf0373c
Some more test improvements (+ fixes)
2011-11-27 21:50:19 +01:00
nikic
3a4cc1a0f0
Do not distribute debug parser anymore
...
The debug parser (and the debug y.output) can be still built using rebuildParser.php?debug.
2011-11-27 21:48:34 +01:00
nikic
6ef6e1dab3
Cover errors (and fix errors for namespace names)
2011-11-27 12:58:20 +01:00
nikic
80d090ea14
Fix __halt_compiler with newline after closing tag
...
The newline after the closing tag is now not returned as part of the remaining text (PHP eats one newline after ?>).
2011-11-27 11:21:06 +01:00
nikic
933bebb9b8
Fix parsing of special int syntaxes
...
Also add the means to test code parsing.
2011-11-26 16:09:39 +01:00
nikic
adfa67cdcf
[5.4] Add direct dereferencing of new expression
...
(new A)->b(), (new A)->b, (new A)[0]. The feature is not implemented fully compliant (implemented as a `variable`, not `expr_without_variable`: Awaiting input on that on internals@.
2011-11-21 18:43:35 +01:00
nikic
3b02facf0c
Add an example
2011-11-12 18:29:50 +01:00
nikic
2ec6ae4b03
Make NameResolver add namespacedName subnodes
2011-11-12 13:24:59 +01:00
nikic
c44f6375ef
Start adding more extensive documentation
2011-11-12 13:07:12 +01:00
nikic
c94a4767df
Add tests for XML serialization
...
Also fix the invalid namespace URIs I used.
2011-11-06 18:09:32 +01:00
nikic
d9452e611a
Fix NameResolver for parameters without typehints
2011-11-06 17:16:40 +01:00
nikic
b84553e011
Add XML serialization and unserialization support
...
The unserializiation implementation currently is very hacky => needs some refactoring.
2011-11-06 17:07:38 +01:00
nikic
4e656fc58d
[5.4] Add full array dereferencing support
2011-11-04 07:40:48 +01:00
nikic
6ecae86981
[5.4] Add support for traits
2011-10-30 12:03:29 +01:00
nikic
613aa84f80
[5.4] Add support for static closures
...
This adds another property to Expr_Closure named "static". It's true for static closures and false otherwise.
2011-10-29 00:16:29 +02:00
nikic
c88d227597
Move some uses of the toArray() macro
...
Previously it was applied both to the result of inner_statement_list and statement, whereas only the latter required it.
2011-10-28 23:59:00 +02:00
nikic
c7c94f38f1
Stop using ArrayObject for nodes
...
Instead manually implement IteratorAggregate and define the required magic methods. The reasoning behind this is:
a) Extending ArrayObject is always risky, because a lot of magic which is known to be buggy is involved
b) This allows to lateron change the implementation for the nodes altogether, for example it could be changed to using real public fields instead of a $subNodes array.
2011-10-28 23:12:32 +02:00
nikic
126efbc056
Make more things optional
...
Make $stmts and $subNodes optional in most places
2011-10-28 19:14:06 +02:00
nikic
a3c24cf86c
[API] Rename Stmt_Func to Stmt_Function
2011-10-28 19:08:01 +02:00
nikic
f202aa9814
[API] Make all constructors specialized
...
For nodes that accept many optional arguments I chose to keep the $subNodes argument, but provide default values instead.
2011-10-28 19:06:24 +02:00
nikic
25f37ccc28
[API] Rename LambdaFunc to Closure
...
The term "closure" is more commonly used in PHP, even if the function doesn't use() any variables.
2011-10-26 18:34:12 +02:00
nikic
734dbecbc9
Add some more constructors
2011-10-21 16:51:37 +02:00
nikic
7806bf025e
[5.4] Add support for ClassName::{expr}
2011-10-21 14:09:41 +02:00
nikic
73cc546140
Slightly clean up scalar/static_sclar/common_sclar
...
name rule is now in common_scalar as it is shared. T_STRING_VARNAME is in encaps_var now.
2011-10-21 12:22:41 +02:00
nikic
ef9d0283e9
Add class_name_or_var nonterminal (to simplify)
...
class_name_or_var nonterminal is class_name | reference_variable
2011-10-21 11:50:03 +02:00
nikic
08ea0e3d56
[5.4] Add callable typehint
...
Need to refactor how typehints are saved. Saving array and callable typehints as strings isn't clean
2011-10-21 11:30:27 +02:00
nikic
ab982567d7
[5.4] Add support for short array syntax
2011-10-21 11:27:29 +02:00
nikic
1eb1118ee1
[5.4] Add object method array dereferencing
...
Other array dereferencing support will follow. Added this in advance as it simplified the code.
2011-10-21 11:12:51 +02:00
nikic
eae1abb6d7
[5.4] Add new tokens
...
This is to not throw noticed when parsing not yet supported code on 5.4
2011-10-21 11:12:34 +02:00
nikic
920f12f958
Allow __halt_compiler(); after braced namespaces
2011-10-20 23:06:38 +02:00
nikic
3233fdd24d
Add support for ClassName::$$a()
2011-10-20 22:29:34 +02:00
nikic
aea2f67c52
Fix AST for ClassName::$methodName()
2011-10-20 22:16:25 +02:00
nikic
9fba1df4e0
Circumvent token_get_all bug with b"$var"
2011-10-19 18:09:13 +02:00
nikic
69b298c4b5
Recognize halt_compiler() ?> (without ;)
2011-10-18 18:03:28 +02:00
nikic
7078252444
Fix pretty printing of whole-numbered floats
...
This time properly. Only remaining problem is that floats like 1e1000 are printed as INF. This may or may not be acceptable. The value will be the same, but the tests will signal a diff failure.
2011-10-16 15:39:23 +02:00
nikic
b77d66e5bd
Fix pretty print of ${$a}[0]
2011-10-16 15:25:40 +02:00
nikic
4ce618643f
Fix escaping in pretty print of ShellExec
2011-10-16 15:19:50 +02:00
nikic
9ed77427a2
Rename Expr_List to Expr_AssignList
2011-10-16 14:49:13 +02:00
nikic
43f9c37c7f
Add operator precedence for list() assignments
2011-10-16 14:44:39 +02:00
nikic
7f82d20cca
Fix pretty printing of whole-numbered floats
2011-10-16 14:36:45 +02:00
nikic
6fc85143ca
Fix parsing of $$$a
2011-10-16 14:30:22 +02:00
nikic
f30320b9b2
Fix Stmt_List pretty printing for nested list()s
2011-10-16 14:11:23 +02:00
nikic
527265cdf7
Fix Stmt_DeclareDeclare pretty printing
2011-10-16 13:38:23 +02:00
nikic
df657b703e
Rename caseList to cases in Node_Stmt_Switch
2011-10-15 19:30:48 +02:00
nikic
2d57f52d24
Add more specialized constructors
2011-10-15 19:28:15 +02:00
nikic
a7a7dfce18
Remove useless condition from Throw printer
2011-09-30 19:30:33 +02:00
nikic
535cf21b73
Swap argument order for Node_Case
...
$cond is now the first parameter and is not optional.
2011-09-30 19:19:17 +02:00
nikic
b7a034cd9f
Remove redundant check in NameResolver
2011-09-29 18:51:12 +02:00
nikic
53d33345e1
Simplify resolveOtherName logic
2011-09-28 20:29:19 +02:00
nikic
ab72f98570
Add NameResolver
...
The NameResolver visitor tries to resolve all names to fully qualified names. It will resolve all non-dynamic names, apart from unqualified function and constant names. The latter can not be resolved properly without running the code.
2011-09-28 20:14:27 +02:00
nikic
62183807ee
Add test coverage for Node_Name
...
And fix bugs found while doing so.
2011-09-28 18:11:28 +02:00
nikic
92f793001b
Fix some readme + doccomment typos
2011-09-28 16:26:51 +02:00
nikic
d53173c2f3
Don't use references in NodeTraverser
...
Stop using reference magic in the NodeTraverser. Instead use normal return values. Additionally enfore that an array is passed to ->traverse().
2011-09-24 23:39:05 +02:00
nikic
d5f148b43f
Merge Node_Name and Node_Name_Normal
2011-09-24 23:31:18 +02:00
nikic
df7cb44eed
Use seperate Name node classes instead of type subnode
2011-09-24 16:53:40 +02:00
nikic
858545732c
Add shared Node_Const
...
Node_Const is shared between Node_Stmt_ClassConst and Node_Stmt_Const. Maybe one could generalize it to a Node_NameToValue to share it with Node_Stmt_Declare too.
2011-09-23 21:00:59 +02:00
nikic
8bd8e815c9
Add missing doc and pretty print for Stmt_Declare
2011-09-23 18:53:11 +02:00
nikic
ea65ea7a32
Make some doc comments more precise
...
Additionally add two further constructors
2011-09-23 18:45:29 +02:00
nikic
ee4e55dc75
Move Node_Expr_FuncCallArg to Node_Arg (just like Node_Param)
2011-09-22 20:34:35 +02:00
nikic
06b7d63406
Add specialized constructors for statement nodes with only one subnode
2011-09-22 20:27:12 +02:00
nikic
a551bbc5a4
Add PHPParser_Node interface
2011-09-21 21:43:19 +02:00
nikic
3583c1955f
Improve NodeDumper performance and make testAgainstDirectory more friendly
2011-09-06 17:10:58 +02:00
nikic
847cdbc5c6
Swap argument order for ArrayItem
2011-09-02 19:49:46 +02:00
nikic
393221ce63
Some minor improvements (performance and exception wise) for the node traverser
2011-08-31 21:19:31 +02:00
nikic
63525d36e7
Fix / improve some method doc docomments / signatures
2011-08-22 17:38:05 +02:00
nikic
9cc2cf322b
Iterate replacement nodes using all visitors apart from the one having made the replacement
2011-08-20 16:16:59 +02:00
nikic
17a81b5c8f
Properly parse escape sequences:
...
* Add support for oct and hex escape sequences
* Take used quote type into account when parsing encapsed strings
2011-08-20 10:40:27 +02:00
nikic
05c514f9c5
Instantiate a Node_Name for 'static', too. Fix some doc comments.
2011-08-19 17:44:42 +02:00
nikic
299893066d
Fix NodeTraverser by putting to-be-deleted and to-be-merged nodes into the same queue. Additionally do not further iterate queued nodes.
2011-08-19 17:19:27 +02:00
nikic
ca51472c2f
Move Variable to Expr_Variable, move Stmt_FuncParam to Param (as it is used both in stmts and expr and both in funcs and methods)
2011-08-14 18:51:42 +02:00
nikic
bd602afc3a
Add specialized constructor for lambdas, too
2011-08-14 18:26:06 +02:00
nikic
96350be172
Implement the debug parser by extending the normal parser. That way there is no need to repeat all action codes and lookup tables twice.
2011-08-14 15:36:15 +02:00
nikic
297c9ac290
Use moriyoshi's fork of kmyacc, which fixes most of the issues of kmyacc with PHP
2011-08-14 14:52:24 +02:00
nikic
e0fe21287d
Add specialized constructors for all expression nodes apart from lambda
2011-08-11 10:25:51 +02:00
nikic
f412b3915f
Rename cast nodes and give them a common Expr_Cast parent (with specialized constructor)
2011-08-11 09:20:25 +02:00
nikic
284f32f475
Add specialized constructor for binary operators
2011-08-11 08:57:13 +02:00
nikic
22b507e9f4
Rename Bin[ary] to Bitwise (which is the correct name)
2011-08-11 08:42:28 +02:00
nikic
344913d44b
Add specialized constructors for assignment operations
2011-08-11 08:35:10 +02:00
nikic
d9a23f2dc7
Add specialized constructors for Expr_Array*, make Variable an Expr
2011-08-11 08:13:01 +02:00
nikic
c06cbb53dc
Make for-loop formatting nicer
2011-08-11 07:53:55 +02:00
nikic
690b505a7a
Make array_pair an extra grammar rule, for cleaner grammar and correct $line
2011-08-10 11:24:20 +02:00
nikic
818eb3940b
Allow to pass a string to the constructor of Node_Name
2011-08-09 15:23:18 +02:00
nikic
f67ff50550
Give all Scalar nodes and the special nodes Name and Variable specialized constructors for easier use
2011-08-09 15:07:05 +02:00
nikic
800bb9d94a
Remove unused files
2011-08-09 14:24:26 +02:00
nikic
ae46aeda7f
Don't save whether a string is binary anymore. The binary flag isn't going to be used in the next couple of years, so it doesn't make sense to unnecessarily complicate things.
2011-08-09 14:19:44 +02:00
nikic
197b8e6967
Don't save quote type for strings anymore (as it is irrelevant for script execution)
2011-08-09 14:12:15 +02:00
nikic
567f7c3536
Add possibility to delete and merge nodes in traverser
2011-08-09 12:32:18 +02:00
nikic
f00701fd8a
Use classes for visitors
2011-08-09 09:28:58 +02:00
nikic
ffecbf8ca5
Let the pretty printing methods for statements decide for themselves whether or not they add a semicolon. Only automatically add semicolons for expressions.
2011-08-04 18:44:21 +02:00
nikic
684a638f46
Add possibility to pretty print expressions to PrettyPrinter
2011-08-04 18:19:45 +02:00
nikic
29bac2a120
Further Name node methods
2011-08-04 16:30:04 +02:00
nikic
664be2871a
Make the resolve type of a name a normal subnode (type)
2011-08-04 13:59:56 +02:00
nikic
9c53838b1f
Properly handle fully qualified and relative names
2011-08-04 13:53:23 +02:00
nikic
2703f42933
If the short alias syntax is used compute the alias instead of setting it to null
2011-08-04 12:58:12 +02:00
nikic
12e61cb3ea
Allow use of normal dollar variables in .pre.phpy (by transforming them to #hash variables for kmyacc)
2011-08-04 12:16:31 +02:00
nikic
eaa9e62900
Add checks against use of self / parent class names and static constructors
2011-08-04 12:03:34 +02:00
nikic
217280c9ba
Add getLast and toString (and __toString) methods to Node_Name
2011-08-04 12:02:14 +02:00
nikic
dd2404b57a
Rename "ns" to "name" in Stmt_UseUse
2011-08-04 12:01:03 +02:00
nikic
962c4dc0f0
Add some more unit tests
2011-07-13 23:07:05 +02:00
nikic
cc80385aae
Fix incorrect line number extraction
2011-07-13 13:27:14 +02:00
nikic
a6f97681f6
Start adding Unit test (PHPUnit)
2011-07-13 13:03:37 +02:00
nikic
43b537f9f9
add NodeTraverser
2011-07-12 18:07:59 +02:00
nikic
a4e6d79116
Make the parser run without errors on 5.4
2011-07-04 21:09:20 +02:00
nikic
78f15cd50b
Associate last encountered doccomment with next node
2011-07-03 16:35:45 +02:00
nikic
033f5c81a0
Add missing #line hint for strings
2011-06-28 14:16:10 +02:00
nikic
f756d82cd4
Fetch start line instead of end line
2011-06-28 14:11:12 +02:00
nikic
b153bfa3a8
Remove reentrant error handling code (we don't need that currently)
2011-06-27 19:14:37 +02:00
nikic
d94cd1998b
fix typos
2011-06-26 18:45:19 +02:00
nikic
fb45e8a30c
Put statements belonging to a namespace statement into its stmt property, add some further checks against invalid namespace usage and fix the pretty printer to print global namespaces
2011-06-26 18:41:01 +02:00
nikic
1478ae9c54
Use ArrayObject for Nodes to abstract away array access implementation details
2011-06-25 17:51:17 +02:00
nikic
dfa59332ed
Move halt_compiler handling from parser to grammar
2011-06-12 17:19:12 +02:00
nikic
f11f228074
Associate some line information with nodes (currently the line the node ends in, as the starting line is harder to fetch)
2011-06-12 17:12:47 +02:00
nikic
363a0771da
fix incorrect usages of old ParseErrorException
2011-06-06 18:59:14 +02:00
nikic
b24d0e2dc4
Rename PHPParser_ParseErrorException to PHPParser_Error
2011-06-05 18:52:41 +02:00
nikic
83a2077f0e
Add Autoloader
2011-06-05 18:47:52 +02:00
nikic
620525a5da
Prefix all classes with PHPParser_
2011-06-05 18:40:04 +02:00
nikic
4006e55951
Fix typo Expr_ErrorSupress -> Expr_ErrorSuppress
2011-06-04 15:37:13 +02:00
nikic
8294ceb754
Fix pretty printing issues caused by Expr_InstanceOf vs Expr_Instanceof
2011-06-04 15:25:54 +02:00
nikic
bf00dff2cf
Make halt_compiler() work
2011-06-03 22:04:05 +02:00
nikic
d1f09c311e
Fix ambiguity when pretty printing dynamic property fetches with arrays
2011-06-03 18:24:21 +02:00
nikic
d82bbb3bea
Throw ParseErrorException on error instead of error callback
...
As long as the parser isn't reentrant having an error callback doesn't really make sense and only complicates everything.
2011-06-03 17:44:23 +02:00
nikic
0146a41132
Add missing precedence information for UnaryPlus and Minus
2011-06-02 23:15:56 +02:00
nikic
c94b09dec0
Make sure dnumbers are printed as dnumbers even if they could be printed as ints
2011-06-02 23:13:05 +02:00
nikic
eaffc0073c
Fix indentation fix for InlineHTML printing
2011-06-02 23:05:14 +02:00
nikic
74f05f5459
Fix wrong node signature in grammar
2011-06-02 22:57:00 +02:00
nikic
b80f326b6a
Fix problem with indented strings by introducing PrettyPrinter->pSafe
2011-06-02 22:52:24 +02:00
nikic
352cfde568
Slightly simplify grammar
2011-06-02 17:01:22 +02:00
nikic
1c4d47613c
Fix parsing of static methods with dynamic method name
2011-06-02 16:29:28 +02:00
nikic
fabe44ecb1
fix doccomment
2011-06-02 11:39:33 +02:00
nikic
25a5301b21
Optimize the NodeDumper (30% drop)
2011-06-01 22:20:04 +02:00
nikic
f40f10d6b4
Fix InlineHTML printing
2011-05-31 18:27:39 +02:00
nikic
2fb0206deb
Add missing rules to parser to allow a::${b}
2011-05-31 17:28:22 +02:00
nikic
4e50877e27
Don't check for method existance in pretty printer anymore
2011-05-31 16:56:03 +02:00
nikic
d1f1fb9877
Add goto support to pretty printer
2011-05-31 16:43:46 +02:00
nikic
4f3260f670
Add doccomments and slightly change some APIs
2011-05-31 16:33:11 +02:00
nikic
68a25ce7c1
Fix typo in grammar
2011-05-30 22:15:17 +02:00
nikic
e6b356af45
Fix some pretty printing issues
2011-05-30 22:11:11 +02:00
nikic
8a3074db38
Decouple NodeDumper from NodeAbstract
2011-05-30 19:21:25 +02:00
nikic
22ea3d6a70
Make Node_Scalar instanceof Node_Expr
2011-05-30 18:01:38 +02:00
nikic
9aed651d51
Remove Stmt_Noop
2011-05-30 17:39:20 +02:00
nikic
196d892090
Furthre work on PrettyPrinter
2011-05-30 17:29:10 +02:00
nikic
9c8651120f
Fix wrong Node signature for String_Scalar created by T_STRING_VARNAME
2011-05-29 21:09:37 +02:00
nikic
43b41e382f
Further work on PrettyPrinter
2011-05-29 21:06:43 +02:00
nikic
df82e3db45
Replace yydebug flag with separate debug parser "ParserDebug"
...
Debugging shouldn't be necessairy normally, but carries a 25% performance overhead.
2011-05-29 20:51:15 +02:00
nikic
489f8c8b56
Fix some prettyprinting issues
2011-05-29 20:38:36 +02:00
nikic
15e268cd8b
Parse escape sequences in encapsed strings too
2011-05-29 20:06:53 +02:00
nikic
3c13dce680
Further work on PrettyPrinter. Add possibility to test PrettyPrinter correctness
2011-05-29 17:33:03 +02:00
nikic
685171ddc5
Fix incorrect Node creation for dynamic static property access
2011-05-29 12:24:27 +02:00
nikic
02a1c63aed
Further work on pretty printer
2011-05-29 12:20:47 +02:00
nikic
355ddd8d75
Parse strings more correctly, keep information on whether it was a single or double quoted string
2011-05-28 00:21:12 +02:00
nikic
acab6f2826
Add initial implementation of pretty printer
2011-05-27 22:57:55 +02:00
nikic
d4f3cdd695
Simplify grammar thus reducing shift/reduce conflicts
2011-05-27 21:51:27 +02:00
nikic
ae3603d126
Fix parsing issue with array accesses on object accesses ($x->y[z])
2011-05-27 21:15:38 +02:00
nikic
eeb63065be
a) changes node structure (Stmt_, Expr_, ...) b) fixes parsing of x::$y[z]
...
Sorry for that one large commit. Won't happen again.
2011-05-27 18:42:36 +02:00
nikic
e00b460125
Slightly optimize the parser and improve the API
2011-04-29 21:06:11 +02:00
nikic
aea5e43349
Initial commit
2011-04-18 19:02:30 +02:00