-
-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Hi, and thanks a lot for the amazing work on this PHP parser!
I am writing a generic tree transformer for tree-sitter grammars in order to integrate them in a structural diff tool (https://github.com/GumTreeDiff/gumtree) and I was currently trying to integrate PHP thanks to your awesome grammar.
I noticed something weird for the case of strings. If I parse
<?php foo("test") ?>
I obtain (syntax is this: type: associated_text [start_pos,end_pos], I only retain the associated text on leafs)
program [0,21]
php_tag: <?php [0,5]
expression_statement [6,17]
function_call_expression [6,17]
name: foo [6,9]
arguments [9,17]
(: ( [9,10]
argument [10,16]
encapsed_string [10,16]
": " [10,11]
string: test [11,15]
": " [15,16]
): ) [16,17]
text_interpolation [18,20]
?>: ?> [18,20]
Which is perfect! (perhaps thinking again I am not sure to understand the text_interpolation node but this is not a problem for my usage)
However for the program
<?php foo('test') ?>
I get
php_tag: <?php [0,5]
expression_statement [6,17]
function_call_expression [6,17]
name: foo [6,9]
arguments [9,17]
(: ( [9,10]
argument [10,16]
string [10,16]
': ' [10,11]
': ' [15,16]
): ) [16,17]
text_interpolation [18,20]
?>: ?> [18,20]
Notice that in this case the value associated to the string production is not in any child of the string typed node, as it was the case for the encapsed_string and it prevents me to associate the string value to the string node since I retain only the text for leaf nodes.
Is it a normal behavior? Would it be too much hassle to make it work like encapsed_string work?
Cheers!