Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!boulder!uswat!jbw From: jbw@zeb.uswest.com (Joe Wells) Newsgroups: comp.lang.perl Subject: Re: Recursive descent parsers in perl? Message-ID: Date: 6 Jul 90 01:33:17 GMT References: Sender: news@uswat.UUCP Distribution: comp Organization: U S West Advanced Technologies Lines: 19 In-reply-to: yukngo@obelix.gaul.csd.uwo.ca's message of 28 Jun 90 09:03:54 GMT In article yukngo@obelix.gaul.csd.uwo.ca (Cheung Yukngo) writes: When I was writing a perl program to parse rfc822 mail headers, I noticed that the grammar to describe the header is actually context-free. The comments in a header are delimited by "(" and ")" and can be nested. Using regular expressions to recognize them may or may not be painful; but I wonder how difficult it is to have a general recursive descent parser generator facility in perl. Am I asking too much? Look at the file lisp/rfc822.el in the GNU Emacs distribution. This is a "hairy" recursive descent parser for rfc822 addresses that uses regular expressions as much as it can. Of course, it will help if you know Lisp. You could probably translate this code into perl with only a few months work ... It's only 281 lines of code. -- Joe Wells