Congratulations, you've implemented a kind of crappy psuedo-CFG parser.
See SimpleParse (1) for an example of a recursive descent parser implemented in Python accepting EBNF grammars (2).
I was talking with my friend at work today about the fact that most languages don't seem to have a simple library for parsing data so people end up relying on Regexes to get all their data extraction from strings done. He knows much, much more about parsers than I do though and told me to shut up and build one myself. That gave me pause.
Your comment is the reason why I detest the community on HN. If I would have put my personal time into this, and would read such a comment, I would find it extremely demotivating. The solution may not be perfect but it would be much more helpful if you constructive criticism instead of this.
I was noting this yesterday in the DollarDollarJS thread ... presumably in the quest for "karma," flaming open-source projects has really gotten popular over the past eight months or so on this website (I think that flaming of startup ideas has always been a feature, however).
> most languages don't seem to have a simple library for parsing data
This is what lex and yacc (etc) are for, but they aren't quite simple. Arguably, XML has largely replaced these for "parsing data", since DTDs and XML Schema are CFGs with some minor restrictions (e.g. 1-unambiguous). In many cases, you don't even need a CFG, just nested lists is enough, so JSON fills that role. For even simpler data, just lists of values, there's csv and unix-style line-based formats (use awk etc for parsing).
Interest in CFG's seems to have decreased dramatically since XML (and later JSON) met the simpler needs it served.
Or a simple RFC6570 parser (URI Template [1]) that supports variable extraction. Variable extraction isn't part of the spec [2], but at least one library implements it [3].
See SimpleParse (1) for an example of a recursive descent parser implemented in Python accepting EBNF grammars (2).
I was talking with my friend at work today about the fact that most languages don't seem to have a simple library for parsing data so people end up relying on Regexes to get all their data extraction from strings done. He knows much, much more about parsers than I do though and told me to shut up and build one myself. That gave me pause.
1) http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Fo... 2) http://simpleparse.sourceforge.net/