{- This module was generated from data in the Kate syntax highlighting file doxygen.xml, version 1.29, by Dominik Haumann (dhdev@gmx.de) -} module Text.Highlighting.Kate.Syntax.Doxygen ( highlight, parseExpression, syntaxName, syntaxExtensions ) where import Text.Highlighting.Kate.Definitions import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert import Text.ParserCombinators.Parsec import Data.List (nub) import qualified Data.Set as Set import Data.Map (fromList) import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String syntaxName = "Doxygen" -- | Filename extensions for this language. syntaxExtensions :: String syntaxExtensions = "*.dox;*.doxygen" -- | Highlight source code using this syntax definition. highlight :: String -> Either String [SourceLine] highlight input = case runParser parseSource startingState "source" input of Left err -> Left $ show err Right result -> Right result -- | Parse an expression using appropriate local context. parseExpression :: GenParser Char SyntaxState LabeledSource parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Doxygen" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context updateState $ \st -> st { synStLanguage = oldLang } return result parseSource = do lineContents <- lookAhead wholeLine updateState $ \st -> st { synStCurrentLine = lineContents } result <- manyTill parseSourceLine eof return $ map normalizeHighlighting result startingState = SyntaxState {synStContexts = fromList [("Doxygen",["Normal"])], synStLanguage = "Doxygen", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} parseSourceLine = manyTill parseExpressionInternal pEndLine pEndLine = do newline <|> (eof >> return '\n') context <- currentContext case context of "Normal" -> return () "LineComment" -> (popContext >> return ()) "BlockComment" -> return () "ML_TagWord" -> (popContext >> return ()) "ML_TagParam" -> (popContext >> return ()) "ML_TagWordWord" -> (popContext >> return ()) "ML_Tag2ndWord" -> (popContext >> popContext >> return ()) "ML_TagString" -> (popContext >> return ()) "ML_TagWordString" -> (popContext >> return ()) "ML_htmltag" -> return () "ML_htmlcomment" -> return () "ML_identifiers" -> return () "ML_types1" -> return () "ML_types2" -> return () "SL_TagWord" -> (popContext >> return ()) "SL_TagParam" -> (popContext >> return ()) "SL_TagWordWord" -> (popContext >> return ()) "SL_Tag2ndWord" -> (popContext >> popContext >> return ()) "SL_TagString" -> (popContext >> return ()) "SL_TagWordString" -> (popContext >> return ()) "SL_htmltag" -> (popContext >> return ()) "SL_htmlcomment" -> (popContext >> return ()) "SL_identifiers" -> (popContext >> return ()) "SL_types1" -> (popContext >> return ()) "SL_types2" -> (popContext >> return ()) _ -> return () lineContents <- lookAhead wholeLine updateState $ \st -> st { synStCurrentLine = lineContents, synStCharsParsedInLine = 0, synStPrevChar = '\n' } withAttribute attr txt = do if null txt then fail "Parser matched no text" else return () let style = fromMaybe "" $ lookup attr styles st <- getState let oldCharsParsed = synStCharsParsedInLine st let prevchar = if null txt then '\n' else last txt updateState $ \st -> st { synStCharsParsedInLine = oldCharsParsed + length txt, synStPrevChar = prevchar } return (nub [style, attr], txt) styles = [("Normal Text","Normal"),("Tags","Keyword"),("Word","Keyword"),("HTML Tag","Keyword"),("Description","String"),("Comment","Comment"),("Region","RegionMarker"),("Identifier","Others"),("HTML Comment","Comment"),("Types","DataType")] parseExpressionInternal = do context <- currentContext parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes)) list1bf8a436d042754c1d2e32468d66c2c102faa0ff = Set.fromList $ words $ "\\arg \\attention \\author \\callgraph \\code \\dot \\else \\endcode \\endcond \\enddot \\endhtmlonly \\endif \\endlatexonly \\endlink \\endmanonly \\endverbatim \\endxmlonly \\f[ \\f] \\f$ \\hideinitializer \\htmlonly \\interface \\internal \\invariant \\~ \\@ \\$ \\\\ \\# \\latexonly \\li \\manonly \\n \\nosubgrouping \\note \\only \\post \\pre \\remarks \\return \\returns \\sa \\see \\showinitializer \\since \\test \\todo \\verbatim \\warning \\xmlonly @arg @attention @author @callgraph @code @dot @else @endcode @endcond @enddot @endhtmlonly @endif @endlatexonly @endlink @endmanonly @endverbatim @endxmlonly @f[ @f] @f$ @hideinitializer @htmlonly @interface @internal @invariant @~ @@ @$ @\\ @# @latexonly @li @manonly @n @nosubgrouping @note @only @post @pre @remarks @return @returns @sa @see @showinitializer @since @test @todo @verbatim @warning @xmlonly" list752a849518c6b2c6ed09a392eb9b963590b0d4d5 = Set.fromList $ words $ "\\addtogroup \\a \\anchor \\b \\c \\class \\cond \\copydoc \\def \\dontinclude \\dotfile \\e \\elseif \\em \\enum \\example \\exception \\exceptions \\file \\htmlinclude \\if \\ifnot \\include \\link \\namespace \\p \\package \\ref \\relatesalso \\relates \\retval \\throw \\throws \\verbinclude \\version \\xrefitem @addtogroup @a @anchor @b @c @class @cond @copydoc @def @dontinclude @dotfile @e @elseif @em @enum @example @exception @exceptions @file @htmlinclude @if @ifnot @include @link @namespace @p @package @ref @relatesalso @relates @retval @throw @throws @verbinclude @version @xrefitem" list1c42383a6ecf5a9415d88c214f17fb69abfc6ea2 = Set.fromList $ words $ "\\param @param" list85845d83d1f4b8698c82a64e77f472a5e148c84b = Set.fromList $ words $ "\\image @image" list720a3dc9226d5baa2fb6b4d4b4936d6b743e7619 = Set.fromList $ words $ "\\defgroup \\page \\paragraph \\section \\struct \\subsection \\subsubsection \\union \\weakgroup @defgroup @page @paragraph @section @struct @subsection @subsubsection @union @weakgroup" listee8ad6be0c1e54d9294b36bea5a4dc108a2ad612 = Set.fromList $ words $ "\\addindex \\brief \\bug \\date \\deprecated \\fn \\ingroup \\line \\mainpage \\name \\overload \\par \\short \\skip \\skipline \\typedef \\until \\var @addindex @brief @bug @date @deprecated @fn @ingroup @line @mainpage @name @overload @par @short @skip @skipline @typedef @until @var" defaultAttributes = [("Normal","Normal Text"),("LineComment","Comment"),("BlockComment","Comment"),("ML_TagWord","Comment"),("ML_TagParam","Comment"),("ML_TagWordWord","Comment"),("ML_Tag2ndWord","Comment"),("ML_TagString","Comment"),("ML_TagWordString","Comment"),("ML_htmltag","Identifier"),("ML_htmlcomment","HTML Comment"),("ML_identifiers","Identifier"),("ML_types1","Types"),("ML_types2","Types"),("SL_TagWord","Comment"),("SL_TagParam","Comment"),("SL_TagWordWord","Comment"),("SL_Tag2ndWord","Comment"),("SL_TagString","Comment"),("SL_TagWordString","Comment"),("SL_htmltag","Identifier"),("SL_htmlcomment","HTML Comment"),("SL_identifiers","Identifier"),("SL_types1","Types"),("SL_types2","Types")] parseRules "Normal" = do (attr, result) <- (((pRegExpr (compileRegex "//(!|(/(?=[^/]|$)))>= withAttribute "Comment") >>~ pushContext "LineComment") <|> ((pRegExpr (compileRegex "/\\*(\\*[^*/]|!|[*!]<|\\*$)") >>= withAttribute "Comment") >>~ pushContext "BlockComment") <|> ((pRegExpr (compileRegex "//\\s*@\\{\\s*$") >>= withAttribute "Region")) <|> ((pRegExpr (compileRegex "//\\s*@\\}\\s*$") >>= withAttribute "Region")) <|> ((pRegExpr (compileRegex "/\\*\\s*@\\{\\s*\\*/") >>= withAttribute "Region")) <|> ((pRegExpr (compileRegex "/\\*\\s*@\\}\\s*\\*/") >>= withAttribute "Region"))) return (attr, result) parseRules "LineComment" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute "") . snd))) <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list1bf8a436d042754c1d2e32468d66c2c102faa0ff >>= withAttribute "Tags")) <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list752a849518c6b2c6ed09a392eb9b963590b0d4d5 >>= withAttribute "Tags") >>~ pushContext "SL_TagWord") <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list1c42383a6ecf5a9415d88c214f17fb69abfc6ea2 >>= withAttribute "Tags") >>~ pushContext "SL_TagParam") <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list85845d83d1f4b8698c82a64e77f472a5e148c84b >>= withAttribute "Tags") >>~ pushContext "SL_TagWordWord") <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" listee8ad6be0c1e54d9294b36bea5a4dc108a2ad612 >>= withAttribute "Tags") >>~ pushContext "SL_TagString") <|> ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list720a3dc9226d5baa2fb6b4d4b4936d6b743e7619 >>= withAttribute "Tags") >>~ pushContext "SL_TagWordString") <|> ((pDetectIdentifier >>= withAttribute "Comment")) <|> ((pString False "" >>= withAttribute "HTML Comment") >>~ (popContext >> return ()))) return (attr, result) parseRules "ML_identifiers" = do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext >> return ())) <|> ((pRegExpr (compileRegex "\\s*#?[a-zA-Z0-9]*") >>= withAttribute "String") >>~ (popContext >> return ())) <|> ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "ML_types1") <|> ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "ML_types2")) return (attr, result) parseRules "ML_types1" = do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext >> return ())) <|> ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext >> return ()))) return (attr, result) parseRules "ML_types2" = do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext >> return ())) <|> ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext >> return ()))) return (attr, result) parseRules "SL_TagWord" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list752a849518c6b2c6ed09a392eb9b963590b0d4d5) >> return ([],"") ) >>~ (popContext >> return ())) <|> ((pRegExpr (compileRegex "\\S(?=([][,?;()]|\\.$|\\.?\\s))") >>= withAttribute "Word") >>~ (popContext >> return ())) <|> ((pRegExpr (compileRegex "\\S") >>= withAttribute "Word"))) return (attr, result) parseRules "SL_TagParam" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((pString False "[in]" >>= withAttribute "Tags") >>~ pushContext "SL_Tag2ndWord") <|> ((pString False "[out]" >>= withAttribute "Tags") >>~ pushContext "SL_Tag2ndWord") <|> ((pString False "[in,out]" >>= withAttribute "Tags") >>~ pushContext "SL_Tag2ndWord") <|> ((pRegExpr (compileRegex "\\S(?=([][,?;()]|\\.$|\\.?\\s))") >>= withAttribute "Word") >>~ (popContext >> return ())) <|> ((pRegExpr (compileRegex "\\S") >>= withAttribute "Word"))) return (attr, result) parseRules "SL_TagWordWord" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((pRegExpr (compileRegex "\\S(?=([][,?;()]|\\.$|\\.?\\s))") >>= withAttribute "Word") >>~ pushContext "SL_Tag2ndWord") <|> ((pRegExpr (compileRegex "\\S") >>= withAttribute "Word"))) return (attr, result) parseRules "SL_Tag2ndWord" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((pRegExpr (compileRegex "\\S(?=([][,?;()]|\\.$|\\.?\\s))") >>= withAttribute "Word") >>~ (popContext >> popContext >> return ())) <|> ((pRegExpr (compileRegex "\\S") >>= withAttribute "Word"))) return (attr, result) parseRules "SL_TagString" = do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment")) <|> ((pString False "" >>= withAttribute "HTML Comment") >>~ (popContext >> return ()))) return (attr, result) parseRules "SL_identifiers" = do (attr, result) <- (((pRegExpr (compileRegex "\\s*#?[a-zA-Z0-9]*") >>= withAttribute "String") >>~ (popContext >> return ())) <|> ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "SL_types1") <|> ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "SL_types2")) return (attr, result) parseRules "SL_types1" = do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext >> return ())) return (attr, result) parseRules "SL_types2" = do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext >> return ())) return (attr, result) parseRules x = fail $ "Unknown context" ++ x