Miam • JS
miam.js is a parser combinator framework written in TypeScript. It
is highly inspired by the
excellent nom project. A special focus
is brough on the type system to provide as much safety as possible,
and to avoid consuming too much memory. Thus, the goal of miam.js is
to provide a safe and relatively fast framework to build parsers.
miam.js is written in TypeScript, a language that compiles into JavaScript.
Features
- Zero-copy: The parsers do not copy the string being analysed despite the fact that they are all pure,
- Safe parsing: We commit to bring as much safety as possible regarding the current tooling and languages we have. All means (like type system) are used to provide a safe framework to develop new parsers,
- Speed: No benchmark yet, but we hope that our approach with zero-copy will help to be fast,
- Lightweight: All the type system disappears at compile-time (from TypeScript to JavaScript); the resulting files are small (≈5Kb).
List of parsers
| Parser name | Description | Example |
|---|---|---|
tag |
consumes a given constant value |
|
concat |
concatenates two or more parsers together |
|
alt |
tests all given parsers until one succeed |
|
opt |
tries a parser |
|
regex |
consumes a given regular-expression based value |
|
map |
transforms the consumed value from a parser into something else with a function |
|
label_do |
gives a name (“label”) to all parser values, and passes them into a function for a final transformation (“do”) |
|
precede |
consumes a prefix and a subject, returns the subject |
|
terminate |
consumes a subject and a suffix, returns the subject |
|
Example
See the examples/ directory for some examples.
The test/unit/ directory contains a nice overview of the API too.
Status
Still under development. Please don't use it right now :-). API is under stabilisation.