Haskell Parsec Parser for Encountering [...]

Viewed 434

I'm attempting to write a parser in Haskell using Parsec. Currently I have a program that can parse

test x [1,2,3] end

The code that does this is given as follows

testParser = do { 
  reserved "test"; 
  v <- identifier; 
  symbol "["; 
  l <- sepBy natural commaSep;
  symbol "]";
  p <- pParser;
  return $ Test v (List l) p
 } <?> "end"

where commaSep is defined as

commaSep        = skipMany1 (space <|> char ',')

Now is there some way for me to parse a similar statement, specifically:

test x [1...3] end

Being new to Haskell, and Parsec for that matter, I'm sure there's some nice concise way of doing this that I'm just not aware of. Any help would be appreciated.

Thanks again.

1 Answers
Related