2 Mar 2003 08:35
How to make Parser explicitly "fail"?
L BB <utlbb <at> yahoo.com>
2003-03-02 07:35:03 GMT
2003-03-02 07:35:03 GMT
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/
(Continue reading)
RSS Feed