Skip to content

JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.

License

Notifications You must be signed in to change notification settings

smallhelm/nearley-unparse

Repository files navigation

nearley-unparse

build status

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.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

About

JavaScript API to "unparse" any nearley grammar. Also allows overrides for given grammar rules.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published