Pasukon generates parsers using an easy to learn grammar. It's based on parser combinators, and also implements a lexing step.
It is highly extensible (you can make your own lexer and combinators), has no external dependencies, and works in both Node.js and Browser.
lex match NUMBER /[0-9]+(?:\.[0-9]+)?/ match PLUS '+' match MINUS '-' match TIMES '*' match DIV '/' match POPEN '(' match PCLOSE ')' ignore WHITESPACE /^\s+/ /lex addition | (subtraction as :lhs) then :PLUS then (subtraction as :rhs) |> 'return $.lhs + $.rhs' | subtraction ; subtraction | (multiplication as :lhs) then :MINUS then (multiplication as :rhs) |> 'return $.lhs - $.rhs' | multiplication ; multiplication | (division as :lhs) then :TIMES then (division as :rhs) |> 'return $.lhs * $.rhs' | division ; division | (expression as :lhs) then :DIV then (expression as :rhs) |> 'return $.lhs / $.rhs' | expression ; expression | :POPEN then (addition as :expr) then :PCLOSE |> 'return $.expr' | number ; number | :NUMBER 'return +$1' ; start | addition ;
Parsers derive meaning from arbitrary text. They have many different applications, from programming language creation, to decoding JSON, to translating between different formats.
Pasukon allows you to create a parser by using it's friendly domain-specific language to define a grammar.
Because using a DSL is much easier and faster than writing a parser by hand, it's great for prototyping, as well as learning.
You can find the full documentation at the GitHub repo.