Commit Graph

17 Commits

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