How to make Parser explicitly "fail"?

L BB utlbb@yahoo.com
Sat, 1 Mar 2003 23:35:03 -0800 (PST)


Hi, there. I am glad to join Haskell community. :)

Here I have a question about Parser: how to make a
parser explicitly "fail"?

My question arises from the syntax below:

<statement>::=<keyword><seperator><variable>
<keyword>::="define"
<seperator>::=':'
<variable>::=identifier other than <keyword>
<identifier>::=(<letter>)+
<letter>::=a..z|A..Z

Now I am thinking of writing a Parser for variable. My
thought is:

variable::Parser String
variable = do s<-identifier
              if not (s=="define") then return s else
--let parser fail

I will be very happy if there is some mechanism to
implement the "else" branch, for I have thought of it
for long. :)

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/