DEV Community

Josh Holbrook
Josh Holbrook

Posted on

1

Matanuska ADR 003 - Recursive Descent Parser

This article is a repost of an ADR from Matanuska BASIC, my attempt to write a BASIC interpreter in TypeScript.

Context

My initial strategy for parsing was to use parser combinators. In Rust, this was the nom library. In Typescript, this was typescript-parsec.

This strategy is great for hacking up a simple parser. However, I found that it's a relatively inflexible approach, and requires tuning your interface to match the assumptions of the library.

Crafting Interpreters, meanwhile, details how to write recursive descent parsers. These are "hand-rolled", which on its face can require more work. However, the architecture is relatively straightforward to understand and implement, and it's much more flexible.

Decision

Matanuska BASIC will use recursive descent parsers for both its parser and compiler.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay