Tuesday, July 11, 2017

Introducing the Myna Parsing Library

Myna is an open-source recursive descent parsing library written in a combination of JavaScript / TypeScript.

Why another parsing library

I wrote Myna because I believed that:

Recursive Descent Parsers and Parsing Expression Grammars

A recursive descent parser is a parser that recognizes phrases in a grammar by trying to match the input to different grammar productions alternatives recursively until it succeeds, backtracking if a grammar production fails.

A Parsing Expression Grammar (PEG) is a formal way of expressing the grammar of a language that is based on string matching rather than string generation. Compared with other grammar forms like EBNF It allows grammars to have zero-length rules (assertions) and the order is strictly specified forcing it to be unambiguous.

As a result every PEG grammar can be easily apped to a recursive-descent parser.


This is my third open-source recursive-descent parsing library. My first was written in C++ and was called YARD. It was based on the idea of using templates to combine parsing rules defined as low-level types. It was inspired by the Boost.Spirit parser by Joel de Guzman and in turn inspired the PegTL by Colin Hirsch and Daniel Frey.

My second recursive-descent parsing library was the Jigsaw library written in C#.