tree-sitter-python
tree-sitter-python copied to clipboard
custumize sexp (s-expression) output
trafficstars
Hey forum,
how do I set the style of a s expression? E.g. I want to catch all the if statements, I use a query like this:(if_statement(condition_clause(_)) @condition_clause.inner) to get them. So lets say I matched on this line of code in c++
if (x==2) {doSomething} --> (condition clause value (binary_expression left: (identifier) right: (number_literal))) However, i'd rather like this style:
if (x==2) {doSomething} --> (condition clause value (binary_expression "=="( (identifier) (number_literal))) where we drop left/right and get more detail on the actual binary_expression, i.e. what kind of expression, etc. Can this be done without parsing the result again?