[Haskell-cafe] Regular Expression to Determinate Finite Automata translator

2010-07-22 Thread Aaron Gray
Hi, I am a Haskell newbie. I have coded a Regular Expression to Determinate Finite Automata translator. Algorithm from the Dragon Book. Would someone eyeball the code and give me suggestions please. I have not done anything on character classes yet though. And the parsing is a bit of a hack.

Re: [Haskell-cafe] Regular Expression to Determinate Finite Automata translator

2010-07-22 Thread Felipe Lessa
Some comments: - You can run your code thru HLint, here it gives me 27 suggestions. - Why don't you derive the Show instance for RE instead of writing it by yourself? - Note that do x do y ... is the same as do x y ... - You can parametrize RE as data RE s p =

Re: [Haskell-cafe] Regular Expression to Determinate Finite Automata translator

2010-07-22 Thread S. Doaitse Swierstra
The simplest way to make a recogniser out of a RE is to use one of the available parsing libraries: module RE where import Text.ParserCombinators.UU import Text.ParserCombinators.UU.Examples data RE = Epsilon | Leaf Char | Selection RE RE | Sequence RE RE | Kleene RE | Optional RE | End