1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00
Commit Graph

348 Commits

Author SHA1 Message Date
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