tree-sitter-python icon indicating copy to clipboard operation
tree-sitter-python copied to clipboard

custumize sexp (s-expression) output

Open dnns92 opened this issue 4 years ago • 0 comments
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?

dnns92 avatar Jan 28 '21 14:01 dnns92