[Haskell-cafe] Parsec (Zero or One of)

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Tue Mar 25 16:29:55 EDT 2008


On Mar 25, 2008, at 16:26 , Paul Keir wrote:
> Thankyou. Yes, I'd also noticed that "only end" could result in the  
> "end" part being taken as an identifier. The language I'm parsing  
> actually doesn't have reserved words though; so "end" and "only"  
> are both possible valid identifiers. I should then probably replace  
> my use of say, reserved "only", with string "only"; whiteSpace; for  
> clarity. Still stuck though...
>


But now you have an ambiguity in your language, which is exactly why  
the parse is failing:  "only end" could be waiting for "end", or for  
end of file / whatever tokens might follow this clause.  In the worst  
case, the latter might lead to a situation where an unambiguous parse  
is impossible.

You might want to provide a better description of the full language  
--- and think about how it would need to be implemented to avoid  
ambiguity.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list