parse.js is a library for creating combinatorial parsers in Javascript. It is based on Nate Young's Parsatron which in turn is based on Parsec.
Combinatorial parsers allow complex parsers to be created from a set of simple building blocks. Compared to other parsing techniques, combinatorial parsers can be written more quickly and integrate better with the host language.
- parse-ecma - Combinatory parsers for lexing and parsing ECMAScript 5.
git clone https://github.com/mattbierner/parse.js parse
cd parse
git submodule update --init --recursive
parse.js depends on Nu internally and also uses Nu objects in the API.
Include any AMD style module loader and load parse:
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="application/javascript" src="require.js"></script>
<script type="application/javascript">
requirejs.config({
paths: {
'parse': './lib',
'nu': './dependencies/nu/lib'
}
});
require(['parse/parse'], function(parse) {
...
});
</script>
</body>
All files live in the top level 'parse' module.
Core functionality. Defines core parsers and data structures for creating and running parsers.
Parsers for working specifically with strings.
Redefines iterative core parsers to return regular Javascript arrays instead of streams.
parse.js is written in Javascript / Khepri. Khepri is a ECMAScript subset that, among other things, adds a shorted lambda function syntax. It is also implemented using parse.js. Besides lambda functions, Khepri files (*.kep) are pretty much plain old Javascript.
For now, both the .js and .kep versions of source code will be kept in 'lib/', but only Khepri sources will be developed and Javascript files will be generated from it.