Erik Rose
Erik Rose
One nice thing about spitting out a new class for each Grammar is that we could use super() to implement parent-rule delegation. But OTOH, I don't want to get married...
We'll use the `rule_name^` syntax to delegate to a supergrammar's rule: ``` super = Grammar(""" hi_mom = greeting " mom" greeting = "yo" / "hi" / "sup" """) sub =...
@halst, I wouldn't mind your feedback on the above.
Consider that OMeta's delegation syntax is just "super"; that is, it doesn't allow delegation to supergrammar rules other than the one you're currently overriding. Is it useful to be able...
In that case, you might also like the critique of `__add__` that I didn't post: > Syntactically, we'll override `__add__`. This is mostly because `a = b + c` is...
You raise a good point about composition. Sometimes it's nice to overlay the namespaces and override rules; other times, it's nice to compose and let the grammar we're delegating to...
You're not going to believe this. It just so happens that, because of the way custom rules are built, we get composition for free. For example, let's compose 2 wiki...
Also, we should rename `custom` to `extra` to take into account this new use case.
Here's something fun. I don't necessarily think it's a good idea. ``` python Grammar( any_wiki = "mediawiki / freakywiki", a_custom_rule = lambda text, pos: ..., an_import = another_grammar, something_else =...
Even if grammars implemented the Expression interface, how would we make their entrypoints available in another grammar without a `custom=` or `extra=`?