, 22 tweets, 22 min read Read on Twitter
@HarshilShah1910 I’ve heard great things about Lisp in Little Pieces, though I haven’t started it yet.
@HarshilShah1910 @garybernhardt’s screencast about making a compiler from scratch is a great, brisk into to lexing using regexes and building an AST using hand-rolled recursive descent (both great techniques to get started with)
@HarshilShah1910 @garybernhardt See also @munificentbob’s interpreters book
@HarshilShah1910 @garybernhardt @munificentbob Here was a gist of mine which implemented a simple regex-based lexer in js gist.github.com/pepasflo/4afa5…
@HarshilShah1910 @garybernhardt @munificentbob Same concept, but extracted the grammar out into its own file, and implemented in both python and js gist.github.com/pepasflo/8fcbd…
@HarshilShah1910 @garybernhardt @munificentbob Here's a lexer and parser I whipped up to find and replace a specific kind of element in an HTML document. Turns out this only works on XML though, not HTML (which can have unbalanced tags and other parsing headaches) gist.github.com/pepasflo/57f1e…
@HarshilShah1910 @garybernhardt @munificentbob If a basic compiler is something like: CODE -> lexer -> TOKENS -> parser -> AST -> code generation -> ASSEMBLY, then I've hacked around a lot with lexers and parsers but haven't really scratched the surface of code generation.
@HarshilShah1910 @garybernhardt @munificentbob (and judging by the quantity of tutorials available for each step, I'd say that's common)
@HarshilShah1910 @garybernhardt @munificentbob Prof. @mattmight also has lots of great material on lexers and parsers. one example to get you started: matt.might.net/articles/gramm…
@HarshilShah1910 @garybernhardt @munificentbob @mattmight After you get a parser implemented which can build an AST, a useful exercise would be to write a "compiler" which takes the AST and spits out graphviz notation, so that you can visualize the AST: gist.github.com/pepasflo/04f3c…
@HarshilShah1910 @garybernhardt @munificentbob @mattmight The railroad diagram generator is pretty great bottlecaps.de/rr/ui
@HarshilShah1910 @garybernhardt @munificentbob @mattmight While working out the regexes for your lexer, this is handy: regex101.com
@HarshilShah1910 @garybernhardt @munificentbob @mattmight I liked the idea suggested in this post belkadan.com/blog/2016/05/S… of approaching compilers by implementing a series of little projects ("that which I cannot create, I do no understand"). I brainstormed some project ideas here:
@HarshilShah1910 @garybernhardt @munificentbob @mattmight "An Incremental Approach to Compiler Construction" looks great, though I haven't gone through it yet.

Paper: github.com/namin/inc/blob…
The follow-up tutorial: github.com/namin/inc/blob…
Nada Amin's implementation: github.com/namin/inc
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Jason Pepas
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!