https://github.com/smallhelm/nearley-unparse
JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.
https://github.com/smallhelm/nearley-unparse
grammar nearley nearley-grammar nearley-unparse unparse
Last synced: 5 months ago
JSON representation
JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.
- Host: GitHub
- URL: https://github.com/smallhelm/nearley-unparse
- Owner: smallhelm
- License: mit
- Created: 2016-07-19T01:42:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-19T18:15:14.000Z (almost 9 years ago)
- Last Synced: 2024-11-29T15:46:09.711Z (6 months ago)
- Topics: grammar, nearley, nearley-grammar, nearley-unparse, unparse
- Language: JavaScript
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nearley-unparse
[](https://travis-ci.org/smallhelm/nearley-unparse)
JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.
```js
var unparse = require("nearley-unparse");//somehow import your compiled grammar
var grammar = require("./grammar");var src = unparse(grammar);
//BAM! Now you have generated some src that will parse.
```## API
### src = unparse(grammar[, options])
* `options.start` which rule to start the unparser. (default: `grammar.ParserStart`)
* `options.override_rule` a map where the keys are the rule name and the value is a function that returns a string for that rule.
* `options.filterRule` a function that will take in a rule and return true if it should be selected. This is handy when you want to exclude rules like paren wrapping so it doesn't just output something like this: `(((((1)))))`
* `options.max_stack_size` useful to limit how deeply nested rules are. (default: 25)
* `options.max_loops` useful to keep it from running "forever". (default: 500)## License
MIT