Live data from Hacker News

Tbsp – treesitter-based source processing language

git.peppe.rs

41–47 of 47 posts

Re: Tbsp – treesitter-based source processing language

#41
post #10

Earlier quoted context omitted.

Semgrep also a CLI, that can run offline and without a cloud account. 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.)

ast-grep is based on treesitter. I found Semgrep great for simple things but impossible due to edge cases for complicated things. ast-grep is more difficult for simple cases but all the information you need is there for complex cases.

[dead]

Re: Tbsp – treesitter-based source processing language

#42

The md-to-html demo is a good one, but worth mentioning that the Markdown parser[1] being used may not be suitable for more complex documents. From the README: > "...it is not recommended to use this parser where correctness is important. The main goal for this parser is to provide syntactical information for syntax highlighting..." There's also a separate block-level and inline parser, not sure how `tbsp` handles ne…

Even worse, the README implies tree-sitter is just not going to work for markdown at all[1], this is not a matter of a little polish and bugfixing:

> These stem from restricting a complex format such as markdown to the quite restricting tree-sitter parsing rules.

[1]: Outside of something like tree-sitter v2 with a much more complex grammar support. And frankly I personally don't think making more complex grammars in Javascript+C is a good way forward.

Re: Tbsp – treesitter-based source processing language

#43
post #21

For those that want to explore the grammars listed at https://github.com/tree-sitter/tree-sitter/wiki/List-of-pars... in a more friendly railroad diagram format I made https://mingodad.github.io/plgh/json2ebnf.html that reads the "src/grammar.json" and try it's best to generate an EBNF understood by (IPV6) https://www.bottlecaps.de/rr/ui or (IPV4) https://rr.red-dove.com/ui where we get a nice navigable railroad diag…

Hi, in case you're not already aware of the name clash, there's already a `rr` in the programming world. It's "record and replay": https://rr-project.org/ . Very different, but a very fine tool tool too.

[dead]

Re: Tbsp – treesitter-based source processing language

#45
post #10
post #9

Earlier quoted context omitted.

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.

Semgrep also a CLI, that can run offline and without a cloud account. 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.)

As the other sibling commenter said, both `ast-grep` and `gritql` are based on Treesitter which means that you can in fact just look for certain function call and it will be found no matter how it's formatted, something that plain grep and sometimes semgrep I am not sure can do.

I have used `ast-grep` to devise my own linters with crushing success.

Re: Tbsp – treesitter-based source processing language

#47
post #10

Earlier quoted context omitted.

Semgrep also a CLI, that can run offline and without a cloud account. 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.)

ast-grep is based on treesitter. I found Semgrep great for simple things but impossible due to edge cases for complicated things. ast-grep is more difficult for simple cases but all the information you need is there for complex cases.

Semgrep is also based on tree sitter
Post reply on HN