Tiny declarative parser combinator toolkit written in Typescript, for the browser or server.
I recently open sourced Teg: a tiny, typed, parser combinator toolkit in Typescript. It allows you to build powerful parsers in a really composable, semantic, and typed way.
GitHub - tanishqkancharla/teg: A tiny parser combinator toolkit
A tiny parser combinator toolkit. Contribute to tanishqkancharla/teg development by creating an account on GitHub.
I’m still locking down the API, but this is currently used for my website to parse my custom blog post format.— Tanishq Kancharla (tk) 🌊 (@moonriseTK) June 11, 2022
Here are some examples of what you can do with it (with full automatic type inference!):
Split up parsing very semantically: (block = one of …) pic.twitter.com/GKIJkRvv90
Teg aims to be a semantic and approachable library for parsing. Teg's semantics are mostly based off PEGS: Parsing Expression Grammers
Teg is, for the most part, a porting of the ideas described here to Typescript.
This is currently used by my website for the blog post format.
Previously, I was using Ohm. But it ended up being painful to maintain. I found having everything in Typescript is much nicer than a DSL; its straightforward for me to read and write, and it gives me all the power of a general purpose language.
I plan on also adopting it for Gem. Essentially making my own blogging platform and text editor, so I can take notes quickly, and export it out as a blog post in my exact format.
As a part of that, I'm figuring out how to make an incremental version of Teg. I found some promising ideas in this paper.
But I still need to get around to implementing the ideas in Typescript, and there are some modifications I'm thinking about. I'm gonna make a separate post about that, once I finish going through the whole paper.
After that, I plan on making a desktop version of Gem that lets you save, add themes...loads of cool stuff. But that's in the far distance for now. Teg is a nights and weekends project, so it'll take a while before I get there.