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.
- 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).
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 |
|
fold_many_m_n |
consumes a parser between m and n times, and fold each of them |
|
fold_many_0 |
alias for fold_many_m_n(0, Infinity, …, …) |
|
fold_many_1 |
alias for fold_many_m_n(1, Infinity, …, …) |
|
many_0 |
alias for fold_many_0([], …) where the result is an array of all items |
|
many_1 |
alias for fold_many_1([], …) where the result is an array of all items |
|
See the examples/
directory for some examples.
The test/unit/
directory contains a nice overview of the API too.
Still under development. Please don't use it right now :-). API is under stabilisation.