add cons pattern to parser

This commit is contained in:
darkf 2013-10-19 02:05:16 -07:00
parent 3506e1282a
commit 16c882b501
1 changed files with 12 additions and 2 deletions

View File

@ -39,9 +39,19 @@ block = do
reserved "end"
return $ Block lst
intPattern = fmap IntP integer
varPattern = fmap VarP identifier
consPattern = do
x <- intPattern <|> varPattern
symbol "::"
y <- pattern
return $ ConsP x y
pattern = option UnitP $
fmap VarP identifier
<|> fmap IntP integer
try consPattern
<|> varPattern
<|> intPattern
patterns = sepBy pattern (symbol ",")