Hi Peter,
I haven't had a chance to really dig into this yet, but on initial inspection, I note that your grammar syntax looks a bit odd.. Is the text you quoted actually the Modgrammar (python) code you are trying to use (or is it just some variant of BNF, for example, and your actual code is different)?
If that is the Python code you're using (and you are using Modgrammar), then I'm not actually sure how it's working at all, to be honest. If it isn't, though, it would actually be very helpful if you could post the actual grammar-definition code you're working with as well..
Usually, if something's taking an inordinately long time, I find that usually means somebody's managed to get some left-recursion (
https://pythonhosted.org/modgrammar/tutorial.html#left-recursion) somewhere in their grammar definition, but I don't see off hand anywhere that you'd be likely to have that in your grammar, so that seems less likely in this case...
You might want to take a look at the debugging functionality (
http://pythonhosted.org/modgrammar/debugging.html), which can give you some deeper insight into each of the steps that the Modgrammar engine performs when parsing a particular bit of text (Note that it's just recently been pointed out to me there's a typo in that document: To turn debugging on, you should pass the "debug=..." (NOT "debugging") parameter when calling Grammar.parser() to create a parser object, so you would want to do something like "p = MyGrammar.parser(debug=sys.stderr)" )
--Alex