3853N/ADescription : Parser for extended modal logic
3853N/AMaintainer : Christian.Maeder@dfki.de
3853N/Aext_modal_reserved_words :: [String]
3853N/Aext_modal_reserved_words = map show [Intersection, Union] ++
3853N/AboxParser :: AParser st (MODALITY, Bool, Range)
3853N/A return (modal, True, toRange open [] close)
3853N/AdiamondParser :: AParser st (MODALITY, Bool, Range)
3853N/A return (modal, False, toRange open [] close)
4141N/A return (SimpleMod $ Token emptyS p, False, p)
4141N/ArekPrimParser :: AParser st (FORMULA EM_FORMULA)
4141N/ArekPrimParser = genPrimFormula modalPrimFormulaParser ext_modal_reserved_words
4141N/AinfixTok :: AParser st (Token, Bool)
4141N/AinfixTok = pair (asKey untilS) (return True)
4518N/A <|> pair (asKey sinceS) (return False)
4141N/A-- | Modal infix formula parser
4141N/AmodalFormulaParser :: AParser st EM_FORMULA
3853N/A p1 <- modalPrimFormulaParser
4500N/A return $ UntilSince b (ExtFORMULA p1) f2 $ tokPos t
4500N/A (f1, (t, b)) <- try $ pair rekPrimParser infixTok
3853N/A return $ UntilSince b f1 f2 $ tokPos t
3853N/AprefixModifier :: AParser st (FORMULA EM_FORMULA -> EM_FORMULA)
3853N/AprefixModifier = let mkF f r = return $ flip f $ tokPos r in
3853N/A (asKey allPathsS >>= mkF (PathQuantification True))
3853N/A <|> (asKey somePathsS >>= mkF (PathQuantification False))
3853N/A <|> (asKey nextS >>= mkF (NextY True))
3853N/A <|> (asKey yesterdayS >>= mkF (NextY False))
3853N/A <|> (asKey generallyS >>= mkF (StateQuantification True True))
3853N/A <|> (asKey eventuallyS >>= mkF (StateQuantification True False))
3853N/A <|> (asKey hithertoS >>= mkF (StateQuantification False True))
3853N/A <|> (asKey previouslyS >>= mkF (StateQuantification False False))
3853N/A mnb <- (asKey muS >> return True)
3853N/A <|> (asKey nuS >> return False)
3853N/A z <- varId ext_modal_reserved_words
3853N/A ahb <- (asKey atS >> return True)
3853N/A <|> (asKey hereS >> return False)
4500N/AmodalPrimFormulaParser :: AParser st EM_FORMULA
3853N/AmodalPrimFormulaParser = fmap ModForm modDefnParser <|> do
3853N/A (modal, b, r) <- boxParser <|> diamondParser
3853N/A (lgb, val) <- option (False, 1) $ do
3853N/A lgb <- option False $ (asKey lessEq >> return True)
3853N/A <|> (asKey greaterEq >> return False)
3853N/A number <- getNumber << skipSmart
3853N/A return (lgb, value 10 number)
3853N/A em_formula <- rekPrimParser
3853N/A return $ BoxOrDiamond b modal lgb val em_formula r
3853N/A em_formula <- rekPrimParser
3853N/AparsePrimModality :: AParser st MODALITY
3853N/A f <- formula $ greaterS : ext_modal_reserved_words
3853N/A Mixfix_formula t -> return $ TermMod t
3853N/A _ -> asSeparator quMark >> return (Guard f)
3853N/A <|> fmap (SimpleMod . Token emptyS . Range . (: [])) getPos
3853N/AparseTransClosModality :: AParser st MODALITY
3853N/A mt <- many $ asKey tmTransClosS
3853N/A return $ if null mt then t else TransClos t
3853N/AparseCompModality :: AParser st MODALITY
3853N/AparseCompModality = parseBinModality Composition parseTransClosModality
3853N/AparseInterModality :: AParser st MODALITY
3853N/AparseInterModality = parseBinModality Intersection parseCompModality
3853N/AparseBinModality :: ModOp -> AParser st MODALITY -> AParser st MODALITY
3853N/AparseModality :: AParser st MODALITY
3853N/AparseModality = parseBinModality Union parseInterModality
4060N/Ainstance TermParser EM_FORMULA where
4060N/A termParser = aToTermParser modalFormulaParser
4060N/Arigor = (asKey rigidS >> return True)
4060N/A <|> (asKey flexibleS >> return False)
4060N/AsigItemParser :: AParser st EM_SIG_ITEM
4060N/A itemList ext_modal_reserved_words opS opItem (Rigid_op_items rig)
4060N/A <|> itemList ext_modal_reserved_words predS predItem (Rigid_pred_items rig)
4060N/Ainstance AParsable EM_SIG_ITEM where
4060N/AmKey = asKey modalityS <|> asKey modalitiesS
3853N/AnKey = asKey nominalS <|> asKey (nominalS ++ sS)
3853N/AmodDefnParser :: AParser st ModDefn
3853N/A mtime <- optionMaybe $ asKey timeS
3853N/A mterm <- optionMaybe $ asKey termS
3853N/A (annoParser $ sortId ext_modal_reserved_words) anSemiOrComma
3853N/A parseAxioms (ModDefn (isJust mtime) (isJust mterm) ids)
3853N/AbasicItemParser :: AParser st EM_BASIC_ITEM
3853N/AbasicItemParser = fmap ModItem modDefnParser <|> do
3853N/A (annoId, ks) <- separatedBy (annoParser simpleId) anSemiOrComma
4803N/A return $ Nominal_decl annoId $ catRange $ k : ks
4803N/AparseAxioms :: ([FrameForm] -> Range -> a) -> Range -> AParser st a
4803N/A someAxioms <- many parseFrames
4803N/A $ pos `appRange` toRange o [] c
4803N/AparseFrames :: AParser st FrameForm
4803N/A (vs, ps) <- varItems ext_modal_reserved_words
4803N/A return $ FrameForm vs [] $ catRange $ v : ps
4803N/A (vs, ps) <- varDecls ext_modal_reserved_words
4803N/A emDotFormulae a vs $ catRange $ f : ps
4803N/A <|> emDotFormulae [] [] nullRange
4803N/AaxiomsToFrames :: [Annotation] -> [VAR_DECL] -> Range
4803N/A -> BASIC_ITEMS () () EM_FORMULA -> FrameForm
4803N/AaxiomsToFrames a vs posl ais = case ais of
4803N/A Axiom_items (Annoted ft qs as rs : fs) ds ->
4803N/A let aft = Annoted ft qs (a ++ as) rs
4803N/A in FrameForm vs (aft : fs) (posl `appRange` ds)
4803N/A _ -> error "axiomsToFrames"
4803N/AemDotFormulae :: [Annotation] -> [VAR_DECL] -> Range -> AParser st FrameForm
4803N/AemDotFormulae a v p = fmap (axiomsToFrames a v p)
4803N/A $ dotFormulae ext_modal_reserved_words
4803N/Ainstance AParsable EM_BASIC_ITEM where