parsec.js
A JavaScript parser combinator library inspired by Parsec of Haskell.
Install:
npm install parsec.js
Examples:
const whitespace = const lexeme = p << whitespaceconst lbrace = const rbrace = const lbrack = const rbrack = const negtive = const re_var_name = '[a-zA-Z_][a-zA-Z0-9_]*' const id = const attr = const value = id | const has = const oops = whitespace >> has const s = oopsconsole // [ '$x', 'y', '$z' ]
More advanced sample: JSON parser
You can run: NODE_PATH=./lib babel-node examples/json.js
to test this example.