php-parser/lib/PHPParser
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
..
Builder Add function builder 2012-03-11 09:02:52 +01:00
Comment Collect normal comments too, not only doc comments 2012-05-06 17:49:04 +02:00
Lexer Add support for yield expressions (PHP 5.5) 2012-09-07 23:41:57 +02:00
Node Scalar_String::create() -> Scalar_String::parse() 2012-10-19 15:17:08 +02:00
NodeVisitor Fix NameResolver to properly copy attributes 2012-05-04 10:18:50 +02:00
PrettyPrinter Better prededence and associativity handling in pretty printer 2012-10-31 17:34:06 +01:00
Serializer Add line number information to comments 2012-06-06 14:33:38 +01:00
Unserializer Add line number information to comments 2012-06-06 14:33:38 +01:00
Autoloader.php Cover errors (and fix errors for namespace names) 2011-11-27 12:58:20 +01:00
Builder.php Add class builder 2012-03-10 17:56:56 +01:00
BuilderAbstract.php Add ability to specify arrays as default values 2012-03-11 08:53:04 +01:00
BuilderFactory.php Add function builder 2012-03-11 09:02:52 +01:00
Comment.php Fix some doc comments 2012-09-07 23:41:54 +02:00
Error.php Some more test improvements (+ fixes) 2011-11-27 21:50:19 +01:00
Lexer.php Add line number information to comments 2012-06-06 14:33:38 +01:00
Node.php Fix getAttribute signature in Node interface 2012-05-11 18:48:23 +02:00
NodeAbstract.php Fix $node->getDocComment() 2012-05-06 18:24:26 +02:00
NodeDumper.php Add PHPParser_Node interface 2011-09-21 21:43:19 +02:00
NodeTraverser.php Remove unused variable 2012-03-03 17:01:28 +01:00
NodeVisitor.php Don't use references in NodeTraverser 2011-09-24 23:39:05 +02:00
NodeVisitorAbstract.php Cover, fix and cleanup XML unserializer 2011-12-03 15:15:20 +01:00
Parser.php Scalar_String::create() -> Scalar_String::parse() 2012-10-19 15:17:08 +02:00
PrettyPrinterAbstract.php Better prededence and associativity handling in pretty printer 2012-10-31 17:34:06 +01:00
Serializer.php Add XML serialization and unserialization support 2011-11-06 17:07:38 +01:00
Template.php Use inject-once approach for lexer 2012-05-04 10:16:46 +02:00
TemplateLoader.php Add a filesystem template loader. 2012-04-03 23:52:00 +02:00
Unserializer.php Add XML serialization and unserialization support 2011-11-06 17:07:38 +01:00