Hi,

 

I’m having some difficulty using the Parsec library, perhaps you could help. I’ve reduced my problem as shown below. I would like the ‘only_prod’ parser to require the reserved string “only”, _optionally_ followed by an identifier. As part of ‘mytest’, this should then be followed by the reserved string “end”.

 

mytest = do { only_prod; end }

only_prod = do { reserved "only"; try identifier }

end = reserved "end"

 

i.e. I’d like both

> parseTest mytest "only end"

and

>parseTest mytest "only green end"

to parse successfully. As it stands, only the second is successful. The first fails with:

 

parse error at (line 1, column 9):

unexpected end of input

expecting letter or digit or "end"

 

Does anyone have an idea how I could repair the situation?

 

Thanks in advance,

Paul