5 ms·
This is a great post. I’d previously started to write a tree-sitter grammar for djot but bounced off when I realised I’d have to use an external scanner. Nice t
by robjwells 3y ago
This is a great post. I’d previously started to write a tree-sitter grammar for djot but bounced off when I realised I’d have to use an external scanner. Nice to have an article that sets out how to do so.
Link in the post is currently broken, but here’s the author’s grammar on GitHub: https://github.com/treeman/tree-sitter-djot https://github.com/treeman/tree-sitter-djot
- lawn 3y agoOh shoot, fixed the link. Thanks!
- heresie-dabord 3y agoIn the interest of making the page the best version of itself, the following phrase makes a mistake often made by native US English speakers: > But, you might wonder how does a Tree-sitter grammar look like, How does $thing look? or What does $thing look like? Similarly, one often hears "Where are we at?" It is common enough to be seen as a regionalism. -- Your friendly tree-sitting grammarian
- lawn 3y agoHuh, I'm not a native English speaker, but I changed it to "what does a Tree-sitter grammar look like". It does sound better.
- Joker_vD 3y agoInterestingly enough, in German and Polish the analogous expression is in fact "how does X look like?" So maybe it's an interference from those two languages? Or maybe it's even a relict of the older English expression, displaced in England by "what does X look like" after the Am/Br language split had happened.
- VyseofArcadia 3y agoAnecdotally, I hear the how/what confusion from nearly every non-native English speaker I've ever met, regardless of native language. I wonder if it's one of those little things that's surprisingly rare, like the th sound.
- ngai_aku 3y ago> Similarly, one often hears "Where are we at?" It is common enough to be seen as a regionalism. I’m a native English speaker who says “Where are we at”. I think it’s informal, but I never considered it to be wrong or awkward like the first example. Perhaps I’m in the region where it’s common.
- samatman 3y ago> "Where are we at?" Often elided to "Where we at?". It's dialect, I wouldn't use either in formal/technical writing, but I would unselfconsciously say the latter, as in "ok, moving down the agenda, where we at with item 3?".
- airstrike 3y agoI don't think that's necessarily better... The two alternatives I think parse best are: 1. But you might wonder: what does a Tree-sitter grammar look like, and how do you create one for a language? 2. But you might wonder what a Tree-sitter looks like and how to create one for a language. In either case, I agree the right word is "what" not "how". The comma after "but" bugs me tremendously. The colon can be replaced by an em dash (—) if the writer prefers it—but I would not use a question mark for the second clause without separating it from the first "but you might wonder" in some way. The comma left in alternative #1 is to needed (recommended?) because the "and" is joining two clauses with different subjects. I think it's not strictly needed in alternative #2 because it's really "(but you might wonder (what a tree sitter looks like and how to create one for a language))" where the inner term is a list of things the reader might wonder, and lists with only two items do not take a comma before "and" I would also prefer "Where are we?" over "Where are we at?" Not an English speaker, so just my $0.02.
- dunham 3y agoAs an exercise, I did one two years ago for pi-forall. That had a small scanner for the off-sides stuff. I lost steam after I got it working (and needed to add a bunch of rules). I think I was mainly trying to see if I could get tree-sitter to do off-sides (haskell-like indentation). One issue that I remember was the web application to test the grammar needed an exact version of the emscripten stuff. And I had to sort out what that version was myself.