Re: Generate text, given a regex



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

.



Relevant Pages

  • Re: Data Structures help
    ... MIke Beam wrote: ... so I can traverse it to find my solutions. ... Use a recursive solution. ... At any position i in the string, ...
    (comp.lang.java.programmer)
  • Re: Code Optimization - AnsiStringReplace
    ... Why all these static/dynamic arrays? ... Is there not a recursive solution ... string would then know exactly how many bytes to allocate for the output ... Chunks of source string or replace string could then be moved in ...
    (borland.public.delphi.language.basm)