module COL.Parse_AS where
import Common.AnnoState
import Common.Id
import Common.Lexer
import Common.Token
import COL.AS_COL
import Text.ParserCombinators.Parsec
colSigItems :: AParser st COL_SIG_ITEM
colSigItems :: AParser st COL_SIG_ITEM
colSigItems = [String]
-> String
-> ([String] -> AParser st Id)
-> ([Annoted Id] -> Range -> COL_SIG_ITEM)
-> AParser st COL_SIG_ITEM
forall st b a.
[String]
-> String
-> ([String] -> AParser st b)
-> ([Annoted b] -> Range -> a)
-> AParser st a
itemList [String]
col_reserved_words String
constructorS [String] -> AParser st Id
forall st. [String] -> GenParser Char st Id
parseId [Annoted Id] -> Range -> COL_SIG_ITEM
Constructor_items
AParser st COL_SIG_ITEM
-> AParser st COL_SIG_ITEM -> AParser st COL_SIG_ITEM
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [String]
-> String
-> ([String] -> AParser st (Id, Maybe Int))
-> ([Annoted (Id, Maybe Int)] -> Range -> COL_SIG_ITEM)
-> AParser st COL_SIG_ITEM
forall st b a.
[String]
-> String
-> ([String] -> AParser st b)
-> ([Annoted b] -> Range -> a)
-> AParser st a
itemList [String]
col_reserved_words String
observerS [String] -> AParser st (Id, Maybe Int)
forall st. [String] -> AParser st (Id, Maybe Int)
observerItem [Annoted (Id, Maybe Int)] -> Range -> COL_SIG_ITEM
Observer_items
instance AParsable COL_SIG_ITEM where
aparser :: AParser st COL_SIG_ITEM
aparser = AParser st COL_SIG_ITEM
forall st. AParser st COL_SIG_ITEM
colSigItems
observerItem :: [String] -> AParser st (Id, Maybe Int)
observerItem :: [String] -> AParser st (Id, Maybe Int)
observerItem ks :: [String]
ks =
do CharParser (AnnoState st) Token
forall st. CharParser st Token
oParenT
Id
i <- [String] -> GenParser Char (AnnoState st) Id
forall st. [String] -> GenParser Char st Id
parseId [String]
ks
CharParser (AnnoState st) Token
forall st. AParser st Token
anComma
String
n <- ParsecT String (AnnoState st) Identity Char
-> ParsecT String (AnnoState st) Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String (AnnoState st) Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
CharParser (AnnoState st) Token
forall st. CharParser st Token
cParenT
(Id, Maybe Int) -> AParser st (Id, Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Id
i, Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ String -> Int
forall a. Read a => String -> a
read String
n)