add cons pattern to parser
This commit is contained in:
parent
3506e1282a
commit
16c882b501
14
parser.hs
14
parser.hs
|
@ -39,9 +39,19 @@ block = do
|
||||||
reserved "end"
|
reserved "end"
|
||||||
return $ Block lst
|
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 $
|
pattern = option UnitP $
|
||||||
fmap VarP identifier
|
try consPattern
|
||||||
<|> fmap IntP integer
|
<|> varPattern
|
||||||
|
<|> intPattern
|
||||||
|
|
||||||
patterns = sepBy pattern (symbol ",")
|
patterns = sepBy pattern (symbol ",")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue