top | item 46583170

(no title)

egonschiele | 1 month ago

Maybe the most incredible part – did Claude write a recursive descent parser from scratch for this? https://github.com/enspirit/elo/blob/9f07fefcdf65c169089f123...

Not that it's super complex, but I'm surprised it didn't pick up an npm package. I wrote tarsec[1] and have been eyeing ohmjs[2]. And of course nearley is a classic.

[1] https://github.com/egonSchiele/tarsec [2] https://ohmjs.org [3] https://nearley.js.org

discuss

order

torginus|1 month ago

Recursive descent parsers are basically mechanical structures, if you get the grammar right (which encapsulates all the logic).

When I was a CS student, they seemed like magic to me as well, but later I got to revisit them for a project at work, and finally managed to understand the logic.

Imo, the biggest complexity in using them comes from how they handle operator precedence, with recursive nested expressions in the grammar, which I still don't find intuitive at all.

If you decide to hand-roll your own parser/syntax today, I recommend you look at Pratt-parsers, they are much nicer to write by hand. Modern languages (Rust, Go) , ironically are much simpler to parse, since they defined the syntax in such a way that they can be parsed unambigously by looking 1-2 tokens ahead.

And since all of them follow the same logic, AI has a ton of sources to learn from.

I'm also working on my programming language, and AI assistants have been able to generate these parsers for well over a year.

gatapia2|1 month ago

That git commit is very impressive (for Claude)

Edit: Oh, I think the main dev is just using Claude to do the commits (I guess to summarise changes, etc). It does not mean that Claude wrote all that code.

geoffschmidt|1 month ago

FWIW, at the bottom of the landing page they credit Claude for “every line of code, tests, and docs”

blambeau|1 month ago

Claude did, I swear

The parser was built gradually though, with logs of increments under automated tests.