This page will explain how to go from a Relapse grammar to validating a parsed tree.
This is done in two steps.
Each of these steps have several alternatives.
- Construct the Grammar
This assumes you have already constructed a parser, if not see the page on parser usage.
Constructing a Relapse Grammar
First we need to parse our relapse string into a grammar.
This is perfect for when we are receiving a string from the user or a configuration file.
If you don’t understand the relapseString’s value it might be good idea to first take the Relapse Tour.
We could also have programmatically constructed our ast (abstract syntax tree).
This can become quite verbose, so we can rather use the combinator library, with which we can more concisely, but still programmatically, construct the grammar.
We can also use construct functions on the leaves.
Now that we have a initialized parser and a relapse grammar we can validate the parsed tree against the schema.
We create a memoized grammar for faster repeated execution.