https://github.com/purag/pearley
:white_circle: Pearley is a *shiny* new implementation of the Earley parsing algorithm in Javascript.
https://github.com/purag/pearley
earley-parser grammar parser parser-generator
Last synced: about 1 year ago
JSON representation
:white_circle: Pearley is a *shiny* new implementation of the Earley parsing algorithm in Javascript.
- Host: GitHub
- URL: https://github.com/purag/pearley
- Owner: purag
- License: gpl-2.0
- Created: 2015-07-29T08:00:21.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-31T22:54:30.000Z (almost 11 years ago)
- Last Synced: 2025-03-31T00:05:36.390Z (about 1 year ago)
- Topics: earley-parser, grammar, parser, parser-generator
- Language: JavaScript
- Homepage:
- Size: 121 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pearley
Pearley is a *shiny* new implementation of the Earley parsing algorithm in Javascript.
Pearley can parse any context-free grammar, including left-recursive, right-recursive, and ambiguous grammars, and grammars containing epsilon rules (the null/empty rule).
# [math.js](https://jsfiddle.net/purmou/opg92y7h/17/embedded/result/)
This demo shows how Pearley can parse math expressions with the +, -, *, and / operators, parentheses, and numbers of arbitrary length.
To run it, you must include [tokenizer.js](https://purmou.github.io/ParserGen/tokenize.js) from my ParserGen repo to tokenize the strings.
You can also click the link to see the demo on jsFiddle. Check the console for output. First line of output is the tokenized string, second line of output is the list of tokens parsed by Pearley, and the last line of output is the table of state sets.
# [parens.js](http://jsfiddle.net/purmou/opg92y7h/19/)
This demo lets you parse a string containing balanced pairs of parentheses, meaning *n* open parentheses followed by *n* close parentheses.
i.e.
- `((()))`
- `()`
- `` (it works on empty strings)
- `((((((()))))))`