Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why pyparsing, not ply or regex?


Never used ply, but why not regex? Regex cannot easily match recursive structures, and can't be easily composed. Pyparsing gives you more structure and ready building blocks. It actually can use regex as one of the term objects.

Ply tries to implement lex/yacc only, so it's far from a nice interface really...

Or specifically: it's trivial to match `specific_func(any_expression, {capture, these, values})`, but it's practically impossible with regex and painful to post-process with ply.


Jamie Zawinski <jwz@netscape.com> wrote on Tue, 12 Aug 1997 13:16:22 -0700:

Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.


"I've noticed that when I get quoted in .sig files, it's never any of the actual clever things I say all the time. Usually it's something dumb." --Jamie Zawinski


regexps are error prone better use ASTs see Facebook's jscodeshift




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: