
On 5/20/06, Udo Stenzel
do power colon integer reserved "Supply centers," integer reserved "Units:" ((reserved "Builds" >> return id) <|> (reserved "Disbands" >> return negate)) `ap` integer reserved "units." <|> reserved "unit."
I always struggle with when I need to use 'try' with parsec. I tend to over use it because I've had unexpected results when I leave it out. In your other email you say that 'reserved "Movement"' expands to 'lexeme (string "Movement")'. So I would think that, reserved "units." <|> reserved "unit." would need to be wrapped in a 'try'. Something like, try (reserved "units.") <|> reserved "unit." My understanding is that if 'unit.' appears in the input the first parser will parse up to the '.' and then fail and consume the input up to that point, leaving the alternative with only the period as input so it will also fail. So I'm wondering if someone could explain to me what is wrong with my understanding of parsec or point me to a resource that explains this (probably common) misunderstanding. Specifically, I would like to develop a better understanding of when 'try' is needed, and when it is not needed. Thanks, Jason