Related articles |
---|
Generate text, given a regex midhatali@gmail.com (Midhat) (2008-03-23) |
Re: Generate text, given a regex m.helvensteijn@gmail.com (2008-03-27) |
Re: Generate text, given a regex gene.ressler@gmail.com (Gene) (2008-03-26) |
Generate text, given a regex domenico.bianculli@lu.unisi.ch (Domenico Bianculli) (2008-03-27) |
Re: Generate text, given a regex gene.ressler@gmail.com (Gene) (2008-04-11) |
Re: Generate text, given a regex rsc@swtch.com (Russ Cox) (2008-04-11) |
From: | "Russ Cox" <rsc@swtch.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 11 Apr 2008 16:59:01 -0400 |
Organization: | Compilers Central |
References: | 08-04-042 |
Keywords: | parse, testing |
Posted-Date: | 11 Apr 2008 16:58:25 EDT |
> Nonetheless, it's an interesting exercise. Will probably use it in a
> data structures course some time in the future. If you want to
> implement the "obvious" recursive solution and still generate every
> possible string, you effectively need coroutines to do alternation.
Or lazy evaluation (same thing). Doug McIlroy's functional pearl
"Enumerating the strings of regular languages" in JFP (preprint at
http://www.cs.dartmouth.edu/~doug/nfa.ps.gz) gives elegant Haskell
code to generate texts both directly from the regular expression (the
grammar route) and from the equivalent automaton.
Russ
Return to the
comp.compilers page.
Search the
comp.compilers archives again.