Re:Simple Helper to Extract Values from a String
by 6ren on Thursday October 04, 2012 @08:25AM
(#4611945)
> 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.
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.