Copyright | (c) Christian Maeder and Uni Bremen 2002-2006 |
---|---|
License | GPLv2 or higher, see LICENSE.txt |
Maintainer | Christian.Maeder@dfki.de |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Parsing of interspersed annotations
- a parser state to collect annotations
- parsing annoted keywords
- parsing an annoted item list
- type AParser st = GenParser Char (AnnoState st)
- class AParsable a where
- class TermParser a where
- termParser :: Bool -> AParser st a
- aToTermParser :: AParser st a -> Bool -> AParser st a
- data AnnoState st = AnnoState {
- toAnnos :: [Annotation]
- _userState :: st
- emptyAnnos :: st -> AnnoState st
- parseAnnos :: AnnoState a -> GenParser Char st (AnnoState a)
- parseLineAnnos :: AnnoState a -> GenParser Char st (AnnoState a)
- addAnnos :: AParser st ()
- addLineAnnos :: AParser st ()
- getAnnos :: AParser st [Annotation]
- mLineAnnos :: GenParser Char st [Annotation]
- annos :: AParser st [Annotation]
- lineAnnos :: AParser st [Annotation]
- tryItemEnd :: [String] -> AParser st ()
- startKeyword :: [String]
- annoParser :: AParser st a -> AParser st (Annoted a)
- allAnnoParser :: AParser st a -> AParser st (Annoted a)
- trailingAnnosParser :: AParser st a -> AParser st [Annoted a]
- annosParser :: AParser st a -> AParser st [Annoted a]
- itemList :: [String] -> String -> ([String] -> AParser st b) -> ([Annoted b] -> Range -> a) -> AParser st a
- auxItemList :: [String] -> [Token] -> AParser st b -> ([Annoted b] -> Range -> a) -> AParser st a
- itemAux :: [String] -> AParser st a -> AParser st ([a], [Token], [[Annotation]])
- wrapAnnos :: AParser st a -> AParser st a
- asKey :: String -> AParser st Token
- anComma :: AParser st Token
- anSemi :: AParser st Token
- semiOrComma :: CharParser st Token
- anSemiOrComma :: AParser st Token
- trySemi :: AParser st Token
- trySemiOrComma :: AParser st Token
- optSemi :: AParser st ([Token], [Annotation])
- equalT :: AParser st Token
- colonT :: AParser st Token
- equiT :: AParser st Token
- lessT :: AParser st Token
- dotT :: AParser st Token
- asT :: AParser st Token
- barT :: AParser st Token
- forallT :: AParser st Token
Documentation
type AParser st = GenParser Char (AnnoState st)
parsers that can collect annotations via side effects
class AParsable a where
aToTermParser :: AParser st a -> Bool -> AParser st a
data AnnoState st
just the list of currently collected annotations
AnnoState | |
|
OperatorState (AnnoState st) |
emptyAnnos :: st -> AnnoState st
no annotations
parseAnnos :: AnnoState a -> GenParser Char st (AnnoState a)
add further annotations to the input state
parseLineAnnos :: AnnoState a -> GenParser Char st (AnnoState a)
add only annotations on consecutive lines to the input state
addLineAnnos :: AParser st ()
add only annotations on consecutive lines to the internal state
getAnnos :: AParser st [Annotation]
extract all annotation from the internal state,
resets the internal state to emptyAnnos
mLineAnnos :: GenParser Char st [Annotation]
annotations on consecutive lines
annos :: AParser st [Annotation]
explicitly parse annotations, reset internal state
lineAnnos :: AParser st [Annotation]
explicitly parse annotations on consecutive lines. reset internal state
tryItemEnd :: [String] -> AParser st ()
succeeds if the previous item is finished
startKeyword :: [String]
keywords that indicate a new item for tryItemEnd
.
the quantifier exists does not start a new item.
annoParser :: AParser st a -> AParser st (Annoted a)
parse preceding annotations and the following item
allAnnoParser :: AParser st a -> AParser st (Annoted a)
trailingAnnosParser :: AParser st a -> AParser st [Annoted a]
parse preceding and consecutive trailing annotations of an item in
between. Unlike annosParser
do not treat all trailing annotations as
preceding annotations of the next item.
annosParser :: AParser st a -> AParser st [Annoted a]
parse an item list preceded and followed by annotations
itemList :: [String] -> String -> ([String] -> AParser st b) -> ([Annoted b] -> Range -> a) -> AParser st a
parse an item list preceded by a singular or plural keyword, interspersed with semicolons and an optional semicolon at the end
auxItemList :: [String] -> [Token] -> AParser st b -> ([Annoted b] -> Range -> a) -> AParser st a
generalized version of itemList
for an other keyword list for tryItemEnd
and without pluralKeyword
itemAux :: [String] -> AParser st a -> AParser st ([a], [Token], [[Annotation]])
parse an item list without a starting keyword
annoted keywords
semiOrComma :: CharParser st Token
anSemiOrComma :: AParser st Token
trySemiOrComma :: AParser st Token
check for a semicolon or comma beyond annotations and trailing line annos
optSemi :: AParser st ([Token], [Annotation])
optional semicolon followed by annotations on consecutive lines