AS_Annotation.der.hs revision 657542830709ac61a4079e93de6ef8bd4109d612
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder{- |
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiModule : $Header$
eb483f2216949400bfef8f6deb5320f071445626Christian MaederCopyright : (c) Klaus L�ttich, Christian Maeder, and Uni Bremen 2002-2003
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : hets@tzi.de
eb483f2216949400bfef8f6deb5320f071445626Christian MaederStability : provisional
eb483f2216949400bfef8f6deb5320f071445626Christian MaederPortability : portable
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski These datastructures describe the Annotations of (Het)CASL.
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder There is also a paramterized data type for an 'Annoted' 'item'.
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder See also chapter II.5 of the CASL Reference Manual.
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-}
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maedermodule Common.AS_Annotation where
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederimport Common.Id
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- DrIFT command
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder{-! global: UpPos !-}
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | start of an annote with its WORD or a comment
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata Annote_word = Annote_word String | Comment_start deriving (Show, Eq)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | line or group for 'Unparsed_anno'
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata Annote_text = Line_anno String | Group_anno [String] deriving (Show, Eq)
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | formats to be displayed (may be extended in the future).
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- Drop 3 from the show result to get the string for parsing and printing
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata Display_format = DF_HTML | DF_LATEX | DF_RTF
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder deriving (Show, Eq, Ord)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | swap a pair
e83ed59502a681713982f25c559aae77a4145734Christian Maederswap :: (a, b) -> (b, a)
e83ed59502a681713982f25c559aae77a4145734Christian Maederswap (a, b) = (b, a)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- | swap the entries of a lookup table
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederswapTable :: [(a, b)] -> [(b, a)]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederswapTable = map swap
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- | drop the first 3 characters from the show result
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedertoTable :: (Show a) => [a] -> [(a, String)]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedertoTable = map $ \a -> (a, drop 3 $ show a)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- | a lookup table for the textual representation of display formats
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdisplay_format_table :: [(Display_format, String)]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdisplay_format_table = toTable [ DF_HTML, DF_LATEX, DF_RTF ]
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | lookup the textual representation of a display format
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- in 'display_format_table'
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederlookupDisplayFormat :: Display_format -> String
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederlookupDisplayFormat df =
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder maybe (error "lookupDisplayFormat: unknown display format")
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder id $ lookup df display_format_table
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | precedence 'Lower' means less and 'BothDirections' means less and greater.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- 'Higher' means greater but this is syntactically not allowed in 'Prec_anno'.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- 'NoDirection' can also not be specified explicitly,
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- but covers those ids that are not mentionend in precedences.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata PrecRel = Higher | Lower | BothDirections | NoDirection
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder deriving (Show, Eq)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | either left or right associative
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata AssocEither = ALeft | ARight deriving (Show,Eq)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | semantic (line) annotations without further information.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- Use the same drop-3-trick as for the 'Display_format'.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederdata Semantic_anno = SA_cons | SA_def | SA_implies | SA_mono | SA_implied
2eb84fc82d3ffa9116bc471fda3742bd9e5a24bbChristian Maeder deriving (Show, Eq)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maeder-- | a lookup table for the textual representation of semantic annos
2eb84fc82d3ffa9116bc471fda3742bd9e5a24bbChristian Maedersemantic_anno_table :: [(Semantic_anno, String)]
2eb84fc82d3ffa9116bc471fda3742bd9e5a24bbChristian Maedersemantic_anno_table = toTable [SA_cons, SA_def,
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maeder SA_implies, SA_mono, SA_implied]
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maeder
35db0960aa2e2a13652381c756fae5fb2b27213bChristian Maeder-- | lookup the textual representation of a semantic anno
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski-- in 'semantic_anno_table'
eb483f2216949400bfef8f6deb5320f071445626Christian MaederlookupSemanticAnno :: Semantic_anno -> String
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederlookupSemanticAnno sa =
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder maybe (error "lookupSemanticAnno: no semantic anno")
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder id $ lookup sa semantic_anno_table
07b1bf56f3a486f26d69514d05b73100abb25a0eChristian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- | all possible annotations (without comment-outs)
eb483f2216949400bfef8f6deb5320f071445626Christian Maederdata Annotation = -- | constructor for comments or unparsed annotes
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder Unparsed_anno Annote_word Annote_text [Pos]
e83ed59502a681713982f25c559aae77a4145734Christian Maeder -- | known annotes
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder | Display_anno Id [(Display_format, String)] [Pos]
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder -- postion of anno start, keywords and anno end
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder | List_anno Id Id Id [Pos]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder -- postion of anno start, commas and anno end
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder | Number_anno Id [Pos]
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski -- postion of anno start, commas and anno end
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski | Float_anno Id Id [Pos]
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski -- postion of anno start, commas and anno end
e33e3b425e953236b4617870f995d263ac35b883Christian Maeder | String_anno Id Id [Pos]
58564afba8f0bb6b57783c4b440d0b666edf5f67Christian Maeder -- postion of anno start, commas and anno end
e83ed59502a681713982f25c559aae77a4145734Christian Maeder | Prec_anno PrecRel [Id] [Id] [Pos]
e33e3b425e953236b4617870f995d263ac35b883Christian Maeder -- ^ positions: "{",commas,"}", RecRel, "{",commas,"}"
3a3bbc51abf804d91bc9d8e0f2ce745cfae4c9c7Christian Maeder -- | Lower = "< " BothDirections = "<>"
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski | Assoc_anno AssocEither [Id] [Pos] -- position of commas
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski | Label [String] [Pos]
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski -- postion of anno start and anno end
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder -- All annotations below are only as annote line allowed
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder | Semantic_anno Semantic_anno [Pos]
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder -- position information for annotations is provided
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder -- by every annotation
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder deriving (Show)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maederinstance Eq Annotation where
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Unparsed_anno aw1 at1 _ == Unparsed_anno aw2 at2 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (aw1,at1)==(aw2,at2)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Display_anno i1 x1 _ == Display_anno i2 x2 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (i1,x1)==(i2,x2)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder List_anno i1 i2 i3 _ == List_anno i4 i5 i6 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (i1,i2,i3)==(i4,i5,i6)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Number_anno i1 _ == Number_anno i2 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = i1==i2
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Float_anno i1 i2 _ == Float_anno i3 i4 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (i1,i2)==(i3,i4)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder String_anno i1 i2 _ == String_anno i3 i4 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (i1,i2)==(i3,i4)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Prec_anno pr1 i1 i2 _ == Prec_anno pr2 i3 i4 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (pr1,i1,i2)==(pr2,i3,i4)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Assoc_anno ae1 i1 _ == Assoc_anno ae2 i2 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = (ae1,i1) == (ae2,i2)
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder Label str1 _ == Label str2 _
f30760456a3b6f7d4d54c65323dbc73cceca68fbChristian Maeder = str1 == str2
083679daeba30fce9d60f7170a2cfd9f9c80bfb2Till Mossakowski Semantic_anno sa1 _ == Semantic_anno sa2 _
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder = sa1 == sa2
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder _ == _ = False
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
7e4157a70efe2acab30dbe5079bba6db90923785Christian Maeder-- |
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- 'isLabel' tests if the given 'Annotation' is a label
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- (a 'Label' typically follows a formula)
eb483f2216949400bfef8f6deb5320f071445626Christian MaederisLabel :: Annotation -> Bool
1865083b72c1307e9040d78c2743abd5a54ee260Christian MaederisLabel a = case a of
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder Label _ _ -> True
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder _ -> False
eb483f2216949400bfef8f6deb5320f071445626Christian MaederisImplies :: Annotation -> Bool
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederisImplies a =
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder case a of
c58a5efdb3c9fbc80deb1c69716f09c67292a41dChristian Maeder Semantic_anno SA_implies _ -> True
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder _ -> False
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
585094c4284ed39eb8024cc1178c823c403200faChristian MaederisImplied :: Annotation -> Bool
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederisImplied a =
e83ed59502a681713982f25c559aae77a4145734Christian Maeder case a of
e83ed59502a681713982f25c559aae77a4145734Christian Maeder Semantic_anno SA_implied _ -> True
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder -- Semantic_anno _ _ -> False
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder _ -> False
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- |
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- 'isSemanticAnno' tests if the given 'Annotation' is a semantic one
eb483f2216949400bfef8f6deb5320f071445626Christian MaederisSemanticAnno :: Annotation -> Bool
dc427a9450cd7b463717a2255c804afa47a54365Christian MaederisSemanticAnno a = case a of
dc427a9450cd7b463717a2255c804afa47a54365Christian Maeder Semantic_anno _ _ -> True
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder _ -> False
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
dc427a9450cd7b463717a2255c804afa47a54365Christian Maeder-- |
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- 'isComment' tests if the given 'Annotation' is a comment line or a
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder-- comment group
585094c4284ed39eb8024cc1178c823c403200faChristian MaederisComment :: Annotation -> Bool
eb483f2216949400bfef8f6deb5320f071445626Christian MaederisComment c = case c of
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder Unparsed_anno Comment_start _ _ -> True
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder _ -> False
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- |
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- 'isAnnote' is the negation of 'isComment'
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian MaederisAnnote :: Annotation -> Bool
e64aab3e57d843884cd489cc3aa130120a400b05Christian MaederisAnnote = not . isComment
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- | an item wrapped in preceeding (left 'l_annos')
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- and following (right 'r_annos') annotations.
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder-- 'opt_pos' should carry the position of an optional semicolon
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder-- following a formula (but is currently unused).
eb483f2216949400bfef8f6deb5320f071445626Christian Maederdata Annoted a = Annoted { item :: a
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder , opt_pos :: [Pos]
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder , l_annos :: [Annotation]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder , r_annos :: [Annotation]}
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder deriving (Show, Eq)
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder-- | naming or labelling sentences
eb483f2216949400bfef8f6deb5320f071445626Christian Maederdata Named s = NamedSen { senName :: String,
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder sentence :: s }
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder deriving (Eq, Show)
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder-- | equip a sentence with an empty name
eb483f2216949400bfef8f6deb5320f071445626Christian MaederemptyName :: s -> Named s
e83ed59502a681713982f25c559aae77a4145734Christian MaederemptyName x = NamedSen { senName = "", sentence = x}
e83ed59502a681713982f25c559aae77a4145734Christian Maeder
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder-- | extending sentence maps to maps on labelled sentences
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedermapNamed :: (s->t) -> Named s -> Named t
585094c4284ed39eb8024cc1178c823c403200faChristian MaedermapNamed f (NamedSen n x) = NamedSen n $ f x
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- | extending sentence maybe-maps to maps on labelled sentences
7e4157a70efe2acab30dbe5079bba6db90923785Christian MaedermapNamedM :: Monad m => (s-> m t) -> Named s -> m (Named t)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedermapNamedM f (NamedSen n x) = do
25a0b76bc87e80c0f697951d9817862755a71d33Christian Maeder y <- f x
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder return $ NamedSen n y
e64aab3e57d843884cd489cc3aa130120a400b05Christian Maeder
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederinstance Ord s => Ord (Named s) where
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder compare (NamedSen n1 s1) (NamedSen n2 s2) = compare (n1,s1) (n2,s2)
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- | process all items and wrap matching annotations around the results
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedermapAnM :: (Monad m) => (a -> m b) -> [Annoted a] -> m [Annoted b]
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedermapAnM f al =
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder do il <- mapM (f . item) al
585094c4284ed39eb8024cc1178c823c403200faChristian Maeder return $ zipWith (flip replaceAnnoted) al il
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder
e83ed59502a681713982f25c559aae77a4145734Christian Maeder-- | replace the 'item'
e64aab3e57d843884cd489cc3aa130120a400b05Christian MaederreplaceAnnoted :: b -> Annoted a -> Annoted b
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian MaederreplaceAnnoted x (Annoted _ o l r) = Annoted x o l r
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder
eb483f2216949400bfef8f6deb5320f071445626Christian Maeder-- | add further following annotations
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaederappendAnno :: Annoted a -> [Annotation] -> Annoted a
eb483f2216949400bfef8f6deb5320f071445626Christian MaederappendAnno (Annoted x p l r) y = Annoted x p l (r++y)
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski
7e4157a70efe2acab30dbe5079bba6db90923785Christian Maeder-- | put together preceding annotations and an item
7e4157a70efe2acab30dbe5079bba6db90923785Christian MaederaddLeftAnno :: [Annotation] -> a -> Annoted a
7e4157a70efe2acab30dbe5079bba6db90923785Christian MaederaddLeftAnno l i = Annoted i [] l []
7e4157a70efe2acab30dbe5079bba6db90923785Christian Maeder
7e4157a70efe2acab30dbe5079bba6db90923785Christian Maeder-- | get the label following (or to the right of) an 'item'
9929f81562adecc8aafaefb14a0159afcf4a3351Christian MaedergetRLabel :: Annoted a -> String
25a0b76bc87e80c0f697951d9817862755a71d33Christian MaedergetRLabel a = let ls = filter isLabel (r_annos a) in
25a0b76bc87e80c0f697951d9817862755a71d33Christian Maeder if null ls then "" else
e83ed59502a681713982f25c559aae77a4145734Christian Maeder let Label l _ = head ls
c58a5efdb3c9fbc80deb1c69716f09c67292a41dChristian Maeder in if null l then "" else head l
25a0b76bc87e80c0f697951d9817862755a71d33Christian Maeder -- might be a multiline label
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder -- maybe remove white spaces
7e4157a70efe2acab30dbe5079bba6db90923785Christian Maeder