← All projects
Project record1 mention
Originally shared on Hacker News

Text-specialized parser combinator library

This library provides parser combinators specialized for parsing text, written as an alternative to `nom` after it proved an imperfect fit. It includes a `Span` primitive that tracks where in a file a token came from for implementing error messages, the standard `Sequence` and `Choice` operations, and two custom operations: `Compose`, where each parser consumes the output of the previous parser (useful for handling escapable strings), and `Fuse`, which concatenates matched results into a single token for pattern matching.

Last shared
01 / The problem

What it addresses

The author needed a parser tailored to their needs after `nom` proved underpowered in some areas, overpowered in others, and `nom 8` broke their code in awkward-to-fix ways.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. Text-specialized parser combinator library

    This library provides parser combinators specialized for parsing text, written as an alternative to `nom` after it proved an imperfect fit. It includes a `Span` primitive that tracks where in a file a token came from for implementing error messages, the standard `Sequence` and `Choice` operations, and two custom operations: `Compose`, where each parser consumes the output of the previous parser (useful for handling escapable strings), and `Fuse`, which concatenates matched results into a single token for pattern matching.

    Problem: The author needed a parser tailored to their needs after `nom` proved underpowered in some areas, overpowered in others, and `nom 8` broke their code in awkward-to-fix ways.

    Posted by @maxbond · Original source ↗

    Source text · @maxbond · · Source ↗

    A parser combinator library. I'm writing a tool that will do static analysis of SQL (in a very limited fashion, it's a build tool and not a static analyzer, but I need to understand dependency relationships between statements).