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
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
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
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
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
Sebastian Bergmann
b9e3565587
Fugbix typo.
2012-04-04 15:54:45 +02:00
nikic
6657ac4b76
Clarify that parser is autogenerated
2012-03-02 00:43:34 +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
8bdb478785
Cover Parser.php as much as possible
2011-12-07 18:17:05 +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
fa5f9e0740
Formatting fix
2011-12-04 17:03:01 +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
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
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
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
126efbc056
Make more things optional
...
Make $stmts and $subNodes optional in most places
2011-10-28 19:14:06 +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
82c495657e
Remove zend_language_parser.y from distribution
2011-10-21 14:38:25 +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
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
9ed77427a2
Rename Expr_List to Expr_AssignList
2011-10-16 14:49:13 +02:00
nikic
6fc85143ca
Fix parsing of $$$a
2011-10-16 14:30:22 +02:00
nikic
2d57f52d24
Add more specialized constructors
2011-10-15 19:28:15 +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
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
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
847cdbc5c6
Swap argument order for ArrayItem
2011-09-02 19:49:46 +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
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
7bd3980a2e
Remove node analysis from analyze.php and fix some other things about it
2011-08-14 15:52:57 +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
690b505a7a
Make array_pair an extra grammar rule, for cleaner grammar and correct $line
2011-08-10 11:24:20 +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
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
7d43c02c06
Fix analyzer.php
2011-08-09 13:26: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
afd6c70b77
Merge preprocessor.php into rebuildParser.php. Don't distribute the temporary preprocessed grammar anymore
2011-08-04 12:46:48 +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
dd2404b57a
Rename "ns" to "name" in Stmt_UseUse
2011-08-04 12:01:03 +02:00
nikic
70306000e8
In rebuildParser.php output stderr too (so there actually is output)
2011-08-04 11:47:29 +02:00
nikic
afcf7777bf
Don't generate y.output file anymore as it really bloats diffs
2011-08-04 11:12:19 +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
dd13cd4fe9
Add README for grammar folder
2011-06-26 20:56:35 +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
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
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
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
74f05f5459
Fix wrong node signature in grammar
2011-06-02 22:57:00 +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
2fb0206deb
Add missing rules to parser to allow a::${b}
2011-05-31 17:28:22 +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
9aed651d51
Remove Stmt_Noop
2011-05-30 17:39:20 +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
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
15e268cd8b
Parse escape sequences in encapsed strings too
2011-05-29 20:06:53 +02:00
nikic
685171ddc5
Fix incorrect Node creation for dynamic static property access
2011-05-29 12:24:27 +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
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