3 ms·
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
by DannoHung 14y ago
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.
1) http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Fo...
2) http://simpleparse.sourceforge.net/ http://simpleparse.sourceforge.net/
- coob 14y agoWas there really any need to wrap your (useful) criticism in vile dickishness?
- helper-method 14y agoYour 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.
- oinksoft 14y agoI 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).
- 6ren 14y ago> 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.
- aslakhellesoy 14y agoOr 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]. [1] http://tools.ietf.org/html/rfc6570 http://tools.ietf.org/html/rfc6570 [2] http://tools.ietf.org/html/rfc6570#section-1.4 http://tools.ietf.org/html/rfc6570#section-1.4 - "In general, regular expression languages are better suited for variable matching." [3] https://github.com/sporkmonger/addressable https://github.com/sporkmonger/addressable