A port with boats at Old Port of Montreal, Montreal, Canada, shot just after sunset with the lit-up city in the background


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.


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.

What I'm using it for

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.

What I'm going to be using it for

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.