I'm trying to either find or come up with a superset of syntax for a parser expression grammar that allows you to do dynamic grammars. Does such a thing exist? An example usage would be writing a high-level grammar that parses a string and the result can either return an expression tree or throw based on whether some way of providing valid operators, their respective operator precedence, and their implementations allows the initial string to parse or not.
The basic idea behind monadic parsers is that a parser has some kind of "return value" (in general, a parse tree). You use the return value of one parser to compute a new parser.
Let's denote a parser returning a value of type a as Parser a.
Then if you have a Parser a and a function that can turn an a into a Parser b (functions are denoted as a -> Parser b) then you can compose these into a larger Parser b.
I've been reading this cs.nott.ac.uk/~pszgmh/monparsing.pdf it's quite interesting but it's a tad difficult for me to follow. The only language I know a little of which is even remotely similar is F#