1.0.1 • Published 9 years ago
nearley-unparse v1.0.1
nearley-unparse
JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.
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.startwhich rule to start the unparser. (default:grammar.ParserStart)options.override_rulea map where the keys are the rule name and the value is a function that returns a string for that rule.options.filterRulea 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_sizeuseful to limit how deeply nested rules are. (default: 25)options.max_loopsuseful to keep it from running "forever". (default: 500)
License
MIT