Date: Thu, 19 Sep 2002 16:53:22 -0400 To: Li Liao Subject: Re: homework question Thank you for your reply. It's really helpfull to see some examples,as I didn't take a compiler class and some thing are new to me. I also had some additional question in the secons email I sent you. And here is one more question for ex1: it's fairly easy to write a funcion for ex1 if we consider only simle strings like: Repeat(Char #"a"); Char #"a" The function will look like this fun canBeEmpty Empty = true | canBeEmpty (Repeat a) = true | canBeEmpty (Alt (a, b))= false | canBeEmpty (Conc (a, b))=false | canBeEmpty (Char a) = false; But we consider more complicated regular expressions like: Alt(Conc(Char #"a", Repeat(Char #"b")), Conc(Repeat(Char #"a"),Char #"b")) we'll have to parse the string and consider every case, if any Repeat or Empty is found, we'll return true. What is the best way to parse this string in ML and do comparisons?