{- |
Module      :  ./CASL/SymbolParser.hs
Description :  Parser for symbols in translations and reductions
Copyright   :  (c) Christian Maeder, Uni Bremen 2002-2006
License     :  GPLv2 or higher, see LICENSE.txt

Maintainer  :  Christian.Maeder@dfki.de
Stability   :  provisional
Portability :  portable

Parsing symbols for translations and reductions
-}

module CASL.SymbolParser
  ( symbItems
  , symbItem
  , symbMapItems
  , opOrPredType
  , symbKind
  ) where

import CASL.AS_Basic_CASL
import CASL.Formula
import CASL.ToDoc ()

import Common.AnnoState
import Common.DocUtils
import Common.Id
import Common.Keywords
import Common.Lexer
import Common.Token
import qualified Control.Monad.Fail as Fail

import Text.ParserCombinators.Parsec

-- | parsing a possibly qualified identifier
symb :: [String] -> SYMB_KIND -> AParser st SYMB
symb :: [String] -> SYMB_KIND -> AParser st SYMB
symb ks :: [String]
ks k :: SYMB_KIND
k = [String] -> GenParser Char (AnnoState st) Id
forall st. [String] -> GenParser Char st Id
parseId [String]
ks GenParser Char (AnnoState st) Id
-> (Id -> AParser st SYMB) -> AParser st SYMB
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ i :: Id
i -> case SYMB_KIND
k of
    Sorts_kind -> SYMB -> AParser st SYMB
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB -> AParser st SYMB) -> SYMB -> AParser st SYMB
forall a b. (a -> b) -> a -> b
$ Id -> SYMB
Symb_id Id
i
    _ -> case SYMB_KIND
k of
        Ops_kind -> do
             Token
c <- GenParser Char (AnnoState st) Token
forall st. GenParser Char st Token
colonST
             OP_TYPE
o <- [String] -> AParser st OP_TYPE
forall st. [String] -> AParser st OP_TYPE
opType [String]
ks
             SYMB -> AParser st SYMB
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB -> AParser st SYMB) -> SYMB -> AParser st SYMB
forall a b. (a -> b) -> a -> b
$ Id -> TYPE -> Range -> SYMB
Qual_id Id
i (OP_TYPE -> TYPE
O_type OP_TYPE
o) (Range -> SYMB) -> Range -> SYMB
forall a b. (a -> b) -> a -> b
$ Token -> Range
tokPos Token
c
        Preds_kind -> do
             Token
c <- GenParser Char (AnnoState st) Token
forall st. AParser st Token
colonT
             PRED_TYPE
p <- [String] -> AParser st PRED_TYPE
forall st. [String] -> AParser st PRED_TYPE
predType [String]
ks
             SYMB -> AParser st SYMB
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB -> AParser st SYMB) -> SYMB -> AParser st SYMB
forall a b. (a -> b) -> a -> b
$ Id -> TYPE -> Range -> SYMB
Qual_id Id
i (PRED_TYPE -> TYPE
P_type PRED_TYPE
p) (Range -> SYMB) -> Range -> SYMB
forall a b. (a -> b) -> a -> b
$ Token -> Range
tokPos Token
c
        _ -> do
             Token
c <- GenParser Char (AnnoState st) Token
forall st. GenParser Char st Token
colonST
             TYPE
t <- [String] -> AParser st TYPE
forall st. [String] -> AParser st TYPE
opOrPredType [String]
ks
             SYMB -> AParser st SYMB
forall (m :: * -> *) a. Monad m => a -> m a
return (Id -> TYPE -> Range -> SYMB
Qual_id Id
i TYPE
t (Range -> SYMB) -> Range -> SYMB
forall a b. (a -> b) -> a -> b
$ Token -> Range
tokPos Token
c)
     AParser st SYMB -> AParser st SYMB -> AParser st SYMB
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> SYMB -> AParser st SYMB
forall (m :: * -> *) a. Monad m => a -> m a
return (Id -> SYMB
Symb_id Id
i)

-- | parsing a type for an operation or a predicate
opOrPredType :: [String] -> AParser st TYPE
opOrPredType :: [String] -> AParser st TYPE
opOrPredType ks :: [String]
ks =
    do (b :: Bool
b, s :: Id
s, p :: Range
p) <- [String] -> GenParser Char (AnnoState st) (Bool, Id, Range)
forall st. [String] -> GenParser Char st (Bool, Id, Range)
opSort [String]
ks
       if Bool
b then TYPE -> AParser st TYPE
forall (m :: * -> *) a. Monad m => a -> m a
return (OP_TYPE -> TYPE
O_type (OpKind -> [Id] -> Id -> Range -> OP_TYPE
Op_type OpKind
Partial [] Id
s Range
p))
         else do
           Token
c <- GenParser Char (AnnoState st) Token
forall st. GenParser Char st Token
crossT
           (ts :: [Id]
ts, ps :: [Token]
ps) <- [String] -> GenParser Char (AnnoState st) Id
forall st. [String] -> GenParser Char st Id
sortId [String]
ks GenParser Char (AnnoState st) Id
-> GenParser Char (AnnoState st) Token
-> GenParser Char (AnnoState st) ([Id], [Token])
forall tok st a b.
GenParser tok st a
-> GenParser tok st b -> GenParser tok st ([a], [b])
`separatedBy` GenParser Char (AnnoState st) Token
forall st. GenParser Char st Token
crossT
           (OP_TYPE -> TYPE)
-> ParsecT String (AnnoState st) Identity OP_TYPE
-> AParser st TYPE
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap OP_TYPE -> TYPE
O_type ([String]
-> [Id]
-> [Token]
-> ParsecT String (AnnoState st) Identity OP_TYPE
forall st. [String] -> [Id] -> [Token] -> GenParser Char st OP_TYPE
opFunSort [String]
ks (Id
s Id -> [Id] -> [Id]
forall a. a -> [a] -> [a]
: [Id]
ts) (Token
c Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps))
              AParser st TYPE -> AParser st TYPE -> AParser st TYPE
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> TYPE -> AParser st TYPE
forall (m :: * -> *) a. Monad m => a -> m a
return (PRED_TYPE -> TYPE
P_type (PRED_TYPE -> TYPE) -> PRED_TYPE -> TYPE
forall a b. (a -> b) -> a -> b
$ [Id] -> Range -> PRED_TYPE
Pred_type (Id
s Id -> [Id] -> [Id]
forall a. a -> [a] -> [a]
: [Id]
ts) (Range -> PRED_TYPE) -> Range -> PRED_TYPE
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange ([Token] -> Range) -> [Token] -> Range
forall a b. (a -> b) -> a -> b
$ Token
c Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps)
         AParser st TYPE -> AParser st TYPE -> AParser st TYPE
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (OP_TYPE -> TYPE)
-> ParsecT String (AnnoState st) Identity OP_TYPE
-> AParser st TYPE
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap OP_TYPE -> TYPE
O_type ([String]
-> [Id]
-> [Token]
-> ParsecT String (AnnoState st) Identity OP_TYPE
forall st. [String] -> [Id] -> [Token] -> GenParser Char st OP_TYPE
opFunSort [String]
ks [Id
s] [])
         AParser st TYPE -> AParser st TYPE -> AParser st TYPE
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> TYPE -> AParser st TYPE
forall (m :: * -> *) a. Monad m => a -> m a
return (Id -> TYPE
A_type Id
s)
    AParser st TYPE -> AParser st TYPE -> AParser st TYPE
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (PRED_TYPE -> TYPE)
-> ParsecT String (AnnoState st) Identity PRED_TYPE
-> AParser st TYPE
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PRED_TYPE -> TYPE
P_type ParsecT String (AnnoState st) Identity PRED_TYPE
forall st. GenParser Char st PRED_TYPE
predUnitType

-- | parsing one symbol or a mapping of one to second symbol
symbMap :: [String] -> SYMB_KIND -> AParser st SYMB_OR_MAP
symbMap :: [String] -> SYMB_KIND -> AParser st SYMB_OR_MAP
symbMap ks :: [String]
ks k :: SYMB_KIND
k =
    do SYMB
s <- [String] -> SYMB_KIND -> AParser st SYMB
forall st. [String] -> SYMB_KIND -> AParser st SYMB
symb [String]
ks SYMB_KIND
k
       do
         Token
f <- String -> AParser st Token
forall st. String -> AParser st Token
asKey String
mapsTo
         SYMB_KIND
k2 <- SYMB_KIND
-> ParsecT String (AnnoState st) Identity SYMB_KIND
-> ParsecT String (AnnoState st) Identity SYMB_KIND
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option SYMB_KIND
Implicit (ParsecT String (AnnoState st) Identity SYMB_KIND
 -> ParsecT String (AnnoState st) Identity SYMB_KIND)
-> ParsecT String (AnnoState st) Identity SYMB_KIND
-> ParsecT String (AnnoState st) Identity SYMB_KIND
forall a b. (a -> b) -> a -> b
$ ((SYMB_KIND, Token) -> SYMB_KIND)
-> ParsecT String (AnnoState st) Identity (SYMB_KIND, Token)
-> ParsecT String (AnnoState st) Identity SYMB_KIND
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SYMB_KIND, Token) -> SYMB_KIND
forall a b. (a, b) -> a
fst ParsecT String (AnnoState st) Identity (SYMB_KIND, Token)
forall st. AParser st (SYMB_KIND, Token)
symbKind
         case SYMB_KIND -> SYMB_KIND -> Maybe SYMB_KIND
joinSymbKinds SYMB_KIND
k SYMB_KIND
k2 of
           Nothing -> String -> AParser st SYMB_OR_MAP
forall (m :: * -> *) a. MonadFail m => String -> m a
Fail.fail (String -> AParser st SYMB_OR_MAP)
-> String -> AParser st SYMB_OR_MAP
forall a b. (a -> b) -> a -> b
$ "contradicting symbol kinds '"
             String -> String -> String
forall a. [a] -> [a] -> [a]
++ SYMB_KIND -> String -> String
forall a. Pretty a => a -> String -> String
showDoc SYMB_KIND
k "' and '" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SYMB_KIND -> String -> String
forall a. Pretty a => a -> String -> String
showDoc SYMB_KIND
k2 "'"
           Just k3 :: SYMB_KIND
k3 -> do
             SYMB
t <- [String] -> SYMB_KIND -> AParser st SYMB
forall st. [String] -> SYMB_KIND -> AParser st SYMB
symb [String]
ks SYMB_KIND
k3
             SYMB_OR_MAP -> AParser st SYMB_OR_MAP
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB -> SYMB -> Range -> SYMB_OR_MAP
Symb_map SYMB
s SYMB
t (Range -> SYMB_OR_MAP) -> Range -> SYMB_OR_MAP
forall a b. (a -> b) -> a -> b
$ Token -> Range
tokPos Token
f)
        AParser st SYMB_OR_MAP
-> AParser st SYMB_OR_MAP -> AParser st SYMB_OR_MAP
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> SYMB_OR_MAP -> AParser st SYMB_OR_MAP
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB -> SYMB_OR_MAP
Symb SYMB
s)

joinSymbKinds :: SYMB_KIND -> SYMB_KIND -> Maybe SYMB_KIND
joinSymbKinds :: SYMB_KIND -> SYMB_KIND -> Maybe SYMB_KIND
joinSymbKinds k1 :: SYMB_KIND
k1 k2 :: SYMB_KIND
k2 = case SYMB_KIND
k1 of
  Implicit -> SYMB_KIND -> Maybe SYMB_KIND
forall a. a -> Maybe a
Just SYMB_KIND
k2
  _ -> if SYMB_KIND
k2 SYMB_KIND -> SYMB_KIND -> Bool
forall a. Eq a => a -> a -> Bool
== SYMB_KIND
Implicit Bool -> Bool -> Bool
|| SYMB_KIND
k1 SYMB_KIND -> SYMB_KIND -> Bool
forall a. Eq a => a -> a -> Bool
== SYMB_KIND
k2 then SYMB_KIND -> Maybe SYMB_KIND
forall a. a -> Maybe a
Just SYMB_KIND
k1 else Maybe SYMB_KIND
forall a. Maybe a
Nothing

-- | parse a kind keyword
symbKind :: AParser st (SYMB_KIND, Token)
symbKind :: AParser st (SYMB_KIND, Token)
symbKind =
  [AParser st (SYMB_KIND, Token)] -> AParser st (SYMB_KIND, Token)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice (((SYMB_KIND, String) -> AParser st (SYMB_KIND, Token))
-> [(SYMB_KIND, String)] -> [AParser st (SYMB_KIND, Token)]
forall a b. (a -> b) -> [a] -> [b]
map (\ (v :: SYMB_KIND
v, s :: String
s) -> do
    Token
q <- String -> CharParser (AnnoState st) Token
forall st. String -> CharParser st Token
pluralKeyword String
s
    (SYMB_KIND, Token) -> AParser st (SYMB_KIND, Token)
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_KIND
v, Token
q))
  [(SYMB_KIND
Sorts_kind, String
sortS), (SYMB_KIND
Ops_kind, String
opS), (SYMB_KIND
Preds_kind, String
predS)])
  AParser st (SYMB_KIND, Token)
-> String -> AParser st (SYMB_KIND, Token)
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> "kind"

{- | Parse a possible kinded list of comma separated CASL symbols.
     The argument is a list of keywords to avoid as identifiers. -}
symbItems :: [String] -> AParser st SYMB_ITEMS
symbItems :: [String] -> AParser st SYMB_ITEMS
symbItems ks :: [String]
ks =
    do (is :: [SYMB]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
forall st. [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
symbs [String]
ks SYMB_KIND
Implicit
       SYMB_ITEMS -> AParser st SYMB_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_KIND -> [SYMB] -> Range -> SYMB_ITEMS
Symb_items SYMB_KIND
Implicit [SYMB]
is (Range -> SYMB_ITEMS) -> Range -> SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange [Token]
ps)
    AParser st SYMB_ITEMS
-> AParser st SYMB_ITEMS -> AParser st SYMB_ITEMS
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    do (k :: SYMB_KIND
k, p :: Token
p) <- AParser st (SYMB_KIND, Token)
forall st. AParser st (SYMB_KIND, Token)
symbKind
       (is :: [SYMB]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
forall st. [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
symbs [String]
ks SYMB_KIND
k
       SYMB_ITEMS -> AParser st SYMB_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_KIND -> [SYMB] -> Range -> SYMB_ITEMS
Symb_items SYMB_KIND
k [SYMB]
is (Range -> SYMB_ITEMS) -> Range -> SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange ([Token] -> Range) -> [Token] -> Range
forall a b. (a -> b) -> a -> b
$ Token
p Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps)

-- | Parse a possible kinded CASL symbol.
symbItem :: [String] -> AParser st SYMB_ITEMS
symbItem :: [String] -> AParser st SYMB_ITEMS
symbItem ks :: [String]
ks = do
    SYMB
i <- [String] -> SYMB_KIND -> AParser st SYMB
forall st. [String] -> SYMB_KIND -> AParser st SYMB
symb [String]
ks SYMB_KIND
Implicit
    SYMB_ITEMS -> AParser st SYMB_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_ITEMS -> AParser st SYMB_ITEMS)
-> SYMB_ITEMS -> AParser st SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ SYMB_KIND -> [SYMB] -> Range -> SYMB_ITEMS
Symb_items SYMB_KIND
Implicit [SYMB
i] (Range -> SYMB_ITEMS) -> Range -> SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ SYMB -> Range
forall a. GetRange a => a -> Range
getRange SYMB
i
  AParser st SYMB_ITEMS
-> AParser st SYMB_ITEMS -> AParser st SYMB_ITEMS
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    (k :: SYMB_KIND
k, p :: Token
p) <- AParser st (SYMB_KIND, Token)
forall st. AParser st (SYMB_KIND, Token)
symbKind
    SYMB
i <- [String] -> SYMB_KIND -> AParser st SYMB
forall st. [String] -> SYMB_KIND -> AParser st SYMB
symb [String]
ks SYMB_KIND
k
    SYMB_ITEMS -> AParser st SYMB_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_ITEMS -> AParser st SYMB_ITEMS)
-> SYMB_ITEMS -> AParser st SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ SYMB_KIND -> [SYMB] -> Range -> SYMB_ITEMS
Symb_items SYMB_KIND
k [SYMB
i] (Range -> SYMB_ITEMS) -> Range -> SYMB_ITEMS
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange [Token
p]

-- | parse a comma separated list of symbols
symbs :: [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
symbs :: [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
symbs ks :: [String]
ks k :: SYMB_KIND
k =
    do SYMB
s <- [String] -> SYMB_KIND -> AParser st SYMB
forall st. [String] -> SYMB_KIND -> AParser st SYMB
symb [String]
ks SYMB_KIND
k
       do
         Token
c <- CharParser (AnnoState st) Token
forall st. GenParser Char st Token
commaT CharParser (AnnoState st) Token
-> GenParser Char (AnnoState st) Id
-> CharParser (AnnoState st) Token
forall tok st a b.
GenParser tok st a -> GenParser tok st b -> GenParser tok st a
`followedWith` [String] -> GenParser Char (AnnoState st) Id
forall st. [String] -> GenParser Char st Id
parseId [String]
ks
         (is :: [SYMB]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
forall st. [String] -> SYMB_KIND -> AParser st ([SYMB], [Token])
symbs [String]
ks SYMB_KIND
k
         ([SYMB], [Token]) -> AParser st ([SYMB], [Token])
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB
s SYMB -> [SYMB] -> [SYMB]
forall a. a -> [a] -> [a]
: [SYMB]
is, Token
c Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps)
        AParser st ([SYMB], [Token])
-> AParser st ([SYMB], [Token]) -> AParser st ([SYMB], [Token])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ([SYMB], [Token]) -> AParser st ([SYMB], [Token])
forall (m :: * -> *) a. Monad m => a -> m a
return ([SYMB
s], [])

-- | parse a possible kinded list of CASL symbol mappings
symbMapItems :: [String] -> AParser st SYMB_MAP_ITEMS
symbMapItems :: [String] -> AParser st SYMB_MAP_ITEMS
symbMapItems ks :: [String]
ks =
    do (is :: [SYMB_OR_MAP]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
forall st.
[String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
symbMaps [String]
ks SYMB_KIND
Implicit
       SYMB_MAP_ITEMS -> AParser st SYMB_MAP_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_KIND -> [SYMB_OR_MAP] -> Range -> SYMB_MAP_ITEMS
Symb_map_items SYMB_KIND
Implicit [SYMB_OR_MAP]
is (Range -> SYMB_MAP_ITEMS) -> Range -> SYMB_MAP_ITEMS
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange [Token]
ps)
    AParser st SYMB_MAP_ITEMS
-> AParser st SYMB_MAP_ITEMS -> AParser st SYMB_MAP_ITEMS
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    do (k :: SYMB_KIND
k, p :: Token
p) <- AParser st (SYMB_KIND, Token)
forall st. AParser st (SYMB_KIND, Token)
symbKind
       (is :: [SYMB_OR_MAP]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
forall st.
[String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
symbMaps [String]
ks SYMB_KIND
k
       SYMB_MAP_ITEMS -> AParser st SYMB_MAP_ITEMS
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_KIND -> [SYMB_OR_MAP] -> Range -> SYMB_MAP_ITEMS
Symb_map_items SYMB_KIND
k [SYMB_OR_MAP]
is (Range -> SYMB_MAP_ITEMS) -> Range -> SYMB_MAP_ITEMS
forall a b. (a -> b) -> a -> b
$ [Token] -> Range
catRange ([Token] -> Range) -> [Token] -> Range
forall a b. (a -> b) -> a -> b
$ Token
p Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps)

-- | parse a comma separated list of symbol mappings
symbMaps :: [String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
symbMaps :: [String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
symbMaps ks :: [String]
ks k :: SYMB_KIND
k =
    do SYMB_OR_MAP
s <- [String] -> SYMB_KIND -> AParser st SYMB_OR_MAP
forall st. [String] -> SYMB_KIND -> AParser st SYMB_OR_MAP
symbMap [String]
ks SYMB_KIND
k
       do
         Token
c <- CharParser (AnnoState st) Token
forall st. GenParser Char st Token
commaT CharParser (AnnoState st) Token
-> GenParser Char (AnnoState st) Id
-> CharParser (AnnoState st) Token
forall tok st a b.
GenParser tok st a -> GenParser tok st b -> GenParser tok st a
`followedWith` [String] -> GenParser Char (AnnoState st) Id
forall st. [String] -> GenParser Char st Id
parseId [String]
ks
         (is :: [SYMB_OR_MAP]
is, ps :: [Token]
ps) <- [String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
forall st.
[String] -> SYMB_KIND -> AParser st ([SYMB_OR_MAP], [Token])
symbMaps [String]
ks SYMB_KIND
k
         ([SYMB_OR_MAP], [Token]) -> AParser st ([SYMB_OR_MAP], [Token])
forall (m :: * -> *) a. Monad m => a -> m a
return (SYMB_OR_MAP
s SYMB_OR_MAP -> [SYMB_OR_MAP] -> [SYMB_OR_MAP]
forall a. a -> [a] -> [a]
: [SYMB_OR_MAP]
is, Token
c Token -> [Token] -> [Token]
forall a. a -> [a] -> [a]
: [Token]
ps)
        AParser st ([SYMB_OR_MAP], [Token])
-> AParser st ([SYMB_OR_MAP], [Token])
-> AParser st ([SYMB_OR_MAP], [Token])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ([SYMB_OR_MAP], [Token]) -> AParser st ([SYMB_OR_MAP], [Token])
forall (m :: * -> *) a. Monad m => a -> m a
return ([SYMB_OR_MAP
s], [])