regular expressions, stack and nesting
clp2 at rebertia.com
Sun Mar 22 18:18:20 CET 2009
2009/3/22 Aaron Brady <castironpi at gmail.com>:
> Every so often the group gets a request for parsing an expression. I
> think it would be significantly easier to do if regular expressions
> could modify a stack. However, since you might nearly as well write
> Python, maybe there is a compromise.
If you need to parse something of decent complexity, you ought to use
a actual proper parser generator, e.g. PLY, pyparsing, ANTLR, etc.
Abusing regular expressions like that to kludge jury-rigged parsers
together can only lead to pain when special cases and additional
grammar complexity emerge and start breaking the parser in difficult
ways. I'm not seeing the use case for your suggestion.
I have a blog:
More information about the Python-list