[Haskell-cafe] [Parsec] No identEnd in ParsecToken?

Stephane Bortzmeyer bortzmeyer at nic.fr
Tue Sep 5 10:17:41 EDT 2006

I'm trying to use Parsec for a language which have identifiers where
the '-' character is allowed only inside identifiers, not at the start
or the end.

ParsecToken has identStart to tell that the '-' is not allowed at the
start but I find no equivalent identEnd?

I tried also to express the same rule with ordinary combinators,
without ParsecToken but this fails:

identifier = do
    start <- letter
    rest <- many (alphaNum <|> char '-') 
    end <- letter       
    return ([start] ++ rest ++ [end])
  <?> "characters authorized for identifiers"

because the parser created by "many" is greedy: it consumes
everything, including the final letter.

Any idea?

More information about the Haskell-Cafe mailing list