446N/ADescription : parsing SparQ CompositionTables
446N/ACopyright : (c) Christian Maeder and Uni Bremen 2002-2005
446N/ALicense : GPLv2 or higher
446N/AMaintainer : fmossa@informatik.uni-bremen.de
446N/AParses CompositionTables in SparQ(Lisp)-Format using Parsec
446N/AparseSparQTableFromFile :: String -> IO (Either ParseError Table)
446N/AparseSparQTableFromFile = parseFromFile parseSparQTable
446N/AparseSparQTable :: Parser Table
446N/A calculusName <- parseCalculusName
4744N/A identityRelation <- parseCalculusProperties
4744N/A (Table_Attrs calculusName (Baserel identityRelation) br)
4744N/A compt ct (Reflectiontable []) (Models [])
4744N/AparseArBaPa :: Parser String
4744N/AparseArBaPa = try parseArity <|> try parseBasisEntity <|> try parseQualifier
4744N/AparseCalculusProperties :: Parser String
4744N/AparseCalculusProperties = do
4744N/A many (parseArBaPa <|> try parseParametric)
4744N/A ide <- parseIdentityRelation
4744N/AparseParametric :: Parser String
4744N/AparseBasisEntity :: Parser String
4744N/AparseIdentityRelation :: Parser String
4744N/A string ":identity-relation"
4744N/A return (baserelBaserel ide)
4744N/AparseQualifier :: Parser String
4744N/AparseQualifierBrace :: Parser String
4744N/A string "(" <|> string "#'("
4744N/A many (many1 (noneOf "()") <|> try parseQualifierBrace)
4744N/Askippable = many1 space <|> parseAnnotation
4744N/AparseAnnotation :: Parser String
4744N/A many (many1 (noneOf ";") <|>
4744N/A try (string ";" << notFollowedBy (char ';')))
4744N/AparseCalculusName :: Parser String
5073N/AparseQuotedStrings :: Parser String
4744N/Aword = many1 (letter <|> char '_' <|> char '.' <|> char '-' <|> digit)
4744N/AparseBaseRelations :: Parser [Baserel]
4744N/A baserels <- many1 parseRelationId
4744N/AparseCompTable :: Parser Compositiontable
4744N/A string ":composition-operation"
4744N/A cmptabentries <- parseComptabentryList
4744N/A return (Compositiontable cmptabentries)
4744N/AparseComptabentryList :: Parser [Cmptabentry]
4744N/AparseComptabentryList = many1 parseComptabentry
4744N/AparseComptabentry :: Parser Cmptabentry
4744N/A results <- parseComptabentryResults
4744N/A return (Cmptabentry (Cmptabentry_Attrs rel1 rel2) results)
4744N/AparseComptabentryResults :: Parser [Baserel]
4744N/AparseComptabentryResults = try (do
4744N/A results <- many1 parseRelationId
4744N/A <|> (tryString "NIL" >> return [])
4744N/AparseConversetable :: Parser Conversetable
4744N/AparseConversetable = try (do
4744N/A return (Conversetable_Ternary entry1 entry3 entry2))
4744N/A return (Conversetable entry)
4744N/AparseConverse :: Parser [Contabentry]
4744N/A string ":converse-operation"
4744N/A invrels <- many1 parseContabentry
4744N/AparseContabentry:: Parser Contabentry
4744N/A return (Contabentry id1 id2)
4744N/AparseContabentryList :: String -> Parser [Contabentry_Ternary]
4744N/A invrels <- many1 parseContabentryTernary
4744N/AparseContabentryTernary :: Parser Contabentry_Ternary
4744N/AparseContabentryTernary = do
4744N/A ids <- many1 parseRelationId <|> parseBracedRelationIds
4744N/A return (Contabentry_Ternary id1 ids)
4744N/AparseBracedRelationIds :: Parser [Baserel]
4744N/A ids <- many1 parseRelationId
4744N/AparseReflectionOperations :: Parser String
4744N/AparseReflectionOperations = do
4744N/A string ":reflection-operation"
4744N/AparseInverse :: Parser [Contabentry_Ternary]
4744N/AparseInverse = parseContabentryList ":inverse-operation"
4744N/AparseHoming :: Parser [Contabentry_Ternary]
4744N/AparseHoming = parseContabentryList ":homing-operation"
4744N/AparseShortcut :: Parser [Contabentry_Ternary]
4744N/AparseShortcut = parseContabentryList ":shortcut-operation"
4744N/AparseRelationId :: Parser Baserel
4744N/A chars <- many1 (noneOf "() \r\v\f\t\160\n")