I'm using OMeta and Python Parsley (http://parsley.readthedocs.org/) for parsing. Is there a way to access the string matched by a specific rule?
For example, consider this code:
In [1]: import parsley
In [2]: g = parsley.makeGrammar('addr = <digit+>:num ws <anything+>:street -> {"num": num, "street": street}', {})
In [3]: g('15032 La Cuarta St.').addr()
Out[3]: {'num': '15032', 'street': 'La Cuarta St.'}
I'm looking for a way to refer to entire match to return something like:
{'match': '15032 La Cuarta St.', 'num': '15032', 'street': 'La Cuarta St.'}
The following code works for this purpose:
g = parsley.makeGrammar('addr = <<digit+>:num ws <anything+>:street>:match -> {"num": num, "street": street, "match": match}', {})
However, I have hundreds of rules and I'd like to avoid wrapping each one.