%top { #include #include #include using namespace std; set functions; } %language cpp %% // this is a comment /* so is this */ enter function_definition { char * name = tbget_node_text($$->"declarator"->"declarator"); functions.insert(name); free(name); } %% /* @BAKE tbsp -o $*.tb.cpp $@ g++ -o $*.out $*.tb.cpp $(pkg-config --cflags --libs tree-sitter tree-sitter-cpp) -ggdb ./$*.out $@ @STOP */ #include "file2str.h" signed main(int argc, char * * argv) { if (argc < 2) { return 1; } FILE2STR(fstr, argv[1]); tbtraverse(fstr); for (const auto &i : functions) { puts(i.c_str()); } return 0; }