Verified Commit 87886d38 authored by Camil Staps's avatar Camil Staps 🙂

Clean.Types: add parsing for packed arrays

parent 02b66e2f
Pipeline #42165 passed with stage
in 2 minutes and 11 seconds
......@@ -30,6 +30,7 @@ from Text.Parsers.Simple.Core import :: Parser,
:: Token
= TIdent String // UpperCaseId or FunnyId
| TVar String // LowerCaseId
| TInt Int
| TArrow // ->
| TComma // ,
......@@ -55,6 +56,9 @@ where
(==) (TVar a) b = case b of
TVar b -> a == b
_ -> False
(==) (TInt a) b = case b of
TInt b -> a == b
_ -> False
(==) TArrow b = b=:TArrow
(==) TComma b = b=:TComma
(==) TStar b = b=:TStar
......@@ -106,6 +110,8 @@ where
with (id, cs`) = span isFunny cs
| isLower c = tkz [TVar $ toString [c:var]:tks] cs`
with (var, cs`) = span isIdentChar cs
| isDigit c = tkz [TInt (toInt (toString [c:int])):tks] cs`
with (int, cs`) = span isDigit cs
tkz _ _ = Nothing
isIdentChar :: !Char -> Bool
......@@ -132,15 +138,16 @@ where
<|> liftM Uniq (uniq argtype)
<|> liftM Uniq (uniq (liftM2 Cons cons $ some argtype))
<|> liftM Uniq (uniq (liftM2 Type ident $ some argtype))
<|> liftM (\t -> Type "_#Array" [t]) (braced (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!Array" [t]) (braced (pToken TStrict >>| type))
<|> liftM (\t -> Type "_Array" [t]) (braced type)
<|> liftM (\t -> Type "_#List!" [t]) (bracked (pToken TUnboxed >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_!List!" [t]) (bracked (pToken TStrict >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_#List" [t]) (bracked (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!List" [t]) (bracked (pToken TStrict >>| type))
<|> liftM (\t -> Type "_List!" [t]) (bracked (type |<< pToken TStrict))
<|> liftM (\t -> Type "_List" [t]) (bracked type)
<|> liftM (\t -> Type "_#Array" [t]) (braced (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_32#Array" [t]) (braced (pToken (TInt 32) >>| pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!Array" [t]) (braced (pToken TStrict >>| type))
<|> liftM (\t -> Type "_Array" [t]) (braced type)
<|> liftM (\t -> Type "_#List!" [t]) (bracked (pToken TUnboxed >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_!List!" [t]) (bracked (pToken TStrict >>| type |<< pToken TStrict))
<|> liftM (\t -> Type "_#List" [t]) (bracked (pToken TUnboxed >>| type))
<|> liftM (\t -> Type "_!List" [t]) (bracked (pToken TStrict >>| type))
<|> liftM (\t -> Type "_List!" [t]) (bracked (type |<< pToken TStrict))
<|> liftM (\t -> Type "_List" [t]) (bracked type)
<|> liftM (\ts -> Type ("_Tuple" +++ toString (length ts)) ts)
(parenthised (pSepBy1 type (pToken TComma)))
<|> (pToken TStrict >>| argtype) // ! ignored for now
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment