Tbsp – treesitter-based source processing language
1–10 of 47 posts
Re: Tbsp – treesitter-based source processing language
#2I'm a big fan of semgrep letting me query ASTs, this feels like something in a similar space. Down with lines, up with everything being trees!
Re: Tbsp – treesitter-based source processing language
#3Re: Tbsp – treesitter-based source processing language
#4So an awk but that knows how to walk structures instead of just lines. Excellent! I'm a big fan of semgrep letting me query ASTs, this feels like something in a similar space. Down with lines, up with everything being trees!
Re: Tbsp – treesitter-based source processing language
#5Maybe update the link to https://git.peppe.rs/languages/tbsp/tree/readme.txt ?
Re: Tbsp – treesitter-based source processing language
#6So an awk but that knows how to walk structures instead of just lines. Excellent! I'm a big fan of semgrep letting me query ASTs, this feels like something in a similar space. Down with lines, up with everything being trees!
Have you checked ast-grep and gritql?
Re: Tbsp – treesitter-based source processing language
#7Re: Tbsp – treesitter-based source processing language
#8Question (caveat: first export to treesitter and tools like this): Is there a reason the example demonstrates the use of depth as a variable instead of it being built in?
Nesting level of a particular "type" is general enough that it might be included OOTB. What you want to do with this might be generalizable - for example instead of
```
enter section {
depth += 1;
}
leave section {
depth -= 1;
}
enter atx_heading {
print("");
}
leave atx_heading {
print("\n");
}
```It could simply be:
```
enter atx_heading {
print("");
}
leave atx_heading {
print("\n");
}
```So depth is always of the nested levels of the same node type, but available out of the box. For markdown, it's headings, sections and lists come to mind - but I might be wrong.
In any event, this looks really well thought-out and now to checkout the other tools mentioned in the comments.....
Re: Tbsp – treesitter-based source processing language
#9Earlier quoted context omitted.
Have you checked ast-grep and gritql?
Are these alternatives to semgrep?
Re: Tbsp – treesitter-based source processing language
#10Earlier quoted context omitted.
Are these alternatives to semgrep?
More or less, yes. CLI, offline, no need for a cloud account. Used ast-grep successfully to locate bad code blocks (dynamic typing, don't even get me started) and also to replace them with others. Highly recommended.
At work, we use it for enforcing a bunch of custom lint rules configured as a yaml file committed directly to our repo, entirely cloud-free.
(I may be overreading your comment as suggesting that these were reasons to use ast-grep over semgrep.)