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.
Comments and doc comments are now saved in the 'comments' attribute, as an array. The are instances of PHPParser_Comment[_Doc].
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.
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);