>>>>> "AR" == Adam Russell <[email protected]> writes:
AR> Uri Guttman wrote: >>>>>>> "AR" == Adam Russell <[email protected]> writes: >>>>>>> >> AR> The Gnaw talk got me thinking about how I solve many of my own AR> parsing problems. I have typically not gone the "deep" route of AR> using something like Parse::RecDescent because it seems like AR> overkill from what I typically do and the files I typically parse AR> are usually such an unpredictable mess that it almost seems easier AR> to not craft a grammar. Does this make sense? Is there an AR> acknowledged tipping point where it makes sense to implement a AR> formal grammar rather than gentle poking with regexes? What is AR> it? >> >> as you said it is hard to tell. sometimes it takes a sharp eye to see >> the regularities in an input stream so you can define a grammar. other >> times you need ad hoc regexes to parse it. i have been in both camps and >> it is just a problem you have to address with each case. >> AR> What I liked about Parse::Gnaw is that it seems to fill the middle AR> ground between stabbing AR> the input with regexes and writing a detailed grammar as per AR> parse::recdescent, javacc, and such like. from my take, it is very similar to regexes (greg pretty much said so). the api is different but the approach to matching text is very regex-like. you still need some form of grammar for the input. this is true for all parsers - simple or complex. and if you need a grammar for the parser you obviously need data that it can be parsed by it. kinda chicken/egg as is expected. but almost all data has a pattern to it, the problem is usually discerning it. many newbies when then learn regexes have more trouble finding and explaining the data pattern. uhm, i have lines which look like this and sometimes that but this part changes and i need to grab it. :) we have all seen that a proper explanation of a problem is usually most of the solution. you can parse with any parser but expressing the discerned patterns in that parser is the goal. gnaw gives you a different way to express the grammar and also it will work reasonably well on streams as it doesn't need to slurp the entire thing in first. but if it gets into backtracking, then all bets are off! uri -- Uri Guttman ------ [email protected] -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Free Perl Training --- http://perlhunter.com/college.html --------- --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

