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.

Billboard image

The fastest way to detect downtimes

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitoring.

Get started now

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay