highlighting-kate 0.3.1 → 0.4
raw patch · 118 files changed
+17153/−21009 lines, 118 filesdep +blaze-htmldep +mtldep −xhtmlPVP ok
version bump matches the API change (PVP)
Dependencies added: blaze-html, mtl
Dependencies removed: xhtml
API changes (from Hackage documentation)
- Text.Highlighting.Kate: OptDetailed :: FormatOption
- Text.Highlighting.Kate: OptInline :: FormatOption
- Text.Highlighting.Kate: OptLineAnchors :: FormatOption
- Text.Highlighting.Kate: OptNumberFrom :: Int -> FormatOption
- Text.Highlighting.Kate: OptNumberLines :: FormatOption
- Text.Highlighting.Kate: OptTitleAttributes :: FormatOption
- Text.Highlighting.Kate: data FormatOption
- Text.Highlighting.Kate: defaultHighlightingCss :: String
- Text.Highlighting.Kate: formatAsXHtml :: [FormatOption] -> String -> [SourceLine] -> Html
- Text.Highlighting.Kate: type LabeledSource = ([String], String)
- Text.Highlighting.Kate: type SourceLine = [LabeledSource]
- Text.Highlighting.Kate.Definitions: SyntaxState :: ContextStack -> String -> String -> Int -> Char -> Bool -> Bool -> [String] -> SyntaxState
- Text.Highlighting.Kate.Definitions: data SyntaxState
- Text.Highlighting.Kate.Definitions: instance Read SyntaxState
- Text.Highlighting.Kate.Definitions: instance Show SyntaxState
- Text.Highlighting.Kate.Definitions: synStCaptures :: SyntaxState -> [String]
- Text.Highlighting.Kate.Definitions: synStCaseSensitive :: SyntaxState -> Bool
- Text.Highlighting.Kate.Definitions: synStCharsParsedInLine :: SyntaxState -> Int
- Text.Highlighting.Kate.Definitions: synStContexts :: SyntaxState -> ContextStack
- Text.Highlighting.Kate.Definitions: synStCurrentLine :: SyntaxState -> String
- Text.Highlighting.Kate.Definitions: synStKeywordCaseSensitive :: SyntaxState -> Bool
- Text.Highlighting.Kate.Definitions: synStLanguage :: SyntaxState -> String
- Text.Highlighting.Kate.Definitions: synStPrevChar :: SyntaxState -> Char
- Text.Highlighting.Kate.Definitions: type ContextStack = Map String [String]
- Text.Highlighting.Kate.Definitions: type LabeledSource = ([String], String)
- Text.Highlighting.Kate.Definitions: type SourceLine = [LabeledSource]
- Text.Highlighting.Kate.Format: OptDetailed :: FormatOption
- Text.Highlighting.Kate.Format: OptInline :: FormatOption
- Text.Highlighting.Kate.Format: OptLineAnchors :: FormatOption
- Text.Highlighting.Kate.Format: OptNumberFrom :: Int -> FormatOption
- Text.Highlighting.Kate.Format: OptNumberLines :: FormatOption
- Text.Highlighting.Kate.Format: OptTitleAttributes :: FormatOption
- Text.Highlighting.Kate.Format: data FormatOption
- Text.Highlighting.Kate.Format: defaultHighlightingCss :: String
- Text.Highlighting.Kate.Format: formatAsXHtml :: [FormatOption] -> String -> [SourceLine] -> Html
- Text.Highlighting.Kate.Format: instance Eq FormatOption
- Text.Highlighting.Kate.Format: instance Read FormatOption
- Text.Highlighting.Kate.Format: instance Show FormatOption
- Text.Highlighting.Kate.Syntax.Actionscript: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Actionscript: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Actionscript: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Actionscript: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Ada: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Ada: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Ada: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Ada: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Alert: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Alert: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Alert: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Alert: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Alert_indent: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Alert_indent: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Alert_indent: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Alert_indent: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Apache: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Apache: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Apache: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Apache: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Asn1: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Asn1: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Asn1: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Asn1: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Asp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Asp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Asp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Asp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Awk: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Awk: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Awk: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Awk: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Bash: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Bash: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Bash: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Bash: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Bibtex: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Bibtex: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Bibtex: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Bibtex: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Boo: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Boo: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Boo: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Boo: syntaxName :: String
- Text.Highlighting.Kate.Syntax.C: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.C: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.C: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.C: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Changelog: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Changelog: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Changelog: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Changelog: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Clojure: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Clojure: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Clojure: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Clojure: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Cmake: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Cmake: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Cmake: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Cmake: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Coffeescript: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Coffeescript: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Coffeescript: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Coffeescript: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Coldfusion: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Coldfusion: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Coldfusion: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Coldfusion: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Commonlisp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Commonlisp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Commonlisp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Commonlisp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Cpp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Cpp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Cpp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Cpp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Cs: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Cs: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Cs: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Cs: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Css: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Css: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Css: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Css: syntaxName :: String
- Text.Highlighting.Kate.Syntax.D: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.D: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.D: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.D: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Diff: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Diff: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Diff: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Diff: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Djangotemplate: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Djangotemplate: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Djangotemplate: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Djangotemplate: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Doxygen: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Doxygen: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Doxygen: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Doxygen: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Doxygenlua: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Doxygenlua: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Doxygenlua: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Doxygenlua: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Dtd: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Dtd: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Dtd: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Dtd: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Eiffel: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Eiffel: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Eiffel: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Eiffel: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Email: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Email: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Email: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Email: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Erlang: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Erlang: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Erlang: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Erlang: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Fortran: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Fortran: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Fortran: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Fortran: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Fsharp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Fsharp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Fsharp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Fsharp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Gnuassembler: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Gnuassembler: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Gnuassembler: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Gnuassembler: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Go: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Go: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Go: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Go: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Haskell: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Haskell: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Haskell: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Haskell: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Haxe: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Haxe: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Haxe: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Haxe: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Html: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Html: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Html: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Html: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Ilerpg: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Ilerpg: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Ilerpg: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Ilerpg: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Ini: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Ini: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Ini: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Ini: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Java: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Java: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Java: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Java: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Javadoc: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Javadoc: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Javadoc: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Javadoc: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Javascript: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Javascript: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Javascript: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Javascript: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Json: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Json: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Json: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Json: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Jsp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Jsp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Jsp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Jsp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Latex: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Latex: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Latex: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Latex: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Lex: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Lex: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Lex: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Lex: syntaxName :: String
- Text.Highlighting.Kate.Syntax.LiterateHaskell: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.LiterateHaskell: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.LiterateHaskell: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.LiterateHaskell: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Lua: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Lua: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Lua: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Lua: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Makefile: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Makefile: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Makefile: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Makefile: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Mandoc: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Mandoc: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Mandoc: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Mandoc: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Matlab: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Matlab: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Matlab: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Matlab: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Maxima: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Maxima: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Maxima: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Maxima: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Mediawiki: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Mediawiki: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Mediawiki: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Mediawiki: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Metafont: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Metafont: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Metafont: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Metafont: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Mips: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Mips: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Mips: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Mips: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Modula2: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Modula2: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Modula2: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Modula2: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Modula3: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Modula3: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Modula3: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Modula3: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Monobasic: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Monobasic: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Monobasic: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Monobasic: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Nasm: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Nasm: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Nasm: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Nasm: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Noweb: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Noweb: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Noweb: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Noweb: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Objectivec: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Objectivec: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Objectivec: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Objectivec: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Objectivecpp: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Objectivecpp: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Objectivecpp: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Objectivecpp: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Ocaml: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Ocaml: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Ocaml: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Ocaml: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Octave: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Octave: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Octave: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Octave: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Pascal: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Pascal: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Pascal: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Pascal: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Perl: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Perl: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Perl: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Perl: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Php: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Php: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Php: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Php: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Pike: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Pike: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Pike: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Pike: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Postscript: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Postscript: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Postscript: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Postscript: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Prolog: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Prolog: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Prolog: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Prolog: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Python: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Python: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Python: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Python: syntaxName :: String
- Text.Highlighting.Kate.Syntax.R: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.R: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.R: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.R: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Relaxngcompact: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Relaxngcompact: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Relaxngcompact: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Relaxngcompact: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Rhtml: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Rhtml: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Rhtml: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Rhtml: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Ruby: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Ruby: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Ruby: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Ruby: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Scala: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Scala: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Scala: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Scala: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Scheme: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Scheme: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Scheme: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Scheme: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Sci: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Sci: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Sci: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Sci: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Sed: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Sed: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Sed: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Sed: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Sgml: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Sgml: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Sgml: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Sgml: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Sql: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Sql: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Sql: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Sql: syntaxName :: String
- Text.Highlighting.Kate.Syntax.SqlMysql: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.SqlMysql: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.SqlMysql: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.SqlMysql: syntaxName :: String
- Text.Highlighting.Kate.Syntax.SqlPostgresql: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.SqlPostgresql: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.SqlPostgresql: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.SqlPostgresql: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Tcl: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Tcl: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Tcl: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Tcl: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Texinfo: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Texinfo: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Texinfo: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Texinfo: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Verilog: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Verilog: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Verilog: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Verilog: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Vhdl: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Vhdl: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Vhdl: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Vhdl: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Xharbour: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Xharbour: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Xharbour: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Xharbour: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Xml: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Xml: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Xml: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Xml: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Xorg: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Xorg: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Xorg: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Xorg: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Xslt: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Xslt: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Xslt: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Xslt: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Xul: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Xul: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Xul: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Xul: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Yacc: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Yacc: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Yacc: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Yacc: syntaxName :: String
- Text.Highlighting.Kate.Syntax.Yaml: highlight :: String -> Either String [SourceLine]
- Text.Highlighting.Kate.Syntax.Yaml: parseExpression :: GenParser Char SyntaxState LabeledSource
- Text.Highlighting.Kate.Syntax.Yaml: syntaxExtensions :: String
- Text.Highlighting.Kate.Syntax.Yaml: syntaxName :: String
+ Text.Highlighting.Kate.Format.HTML: formatHtmlBlock :: FormatOptions -> [SourceLine] -> Html
+ Text.Highlighting.Kate.Format.HTML: formatHtmlInline :: FormatOptions -> [SourceLine] -> Html
+ Text.Highlighting.Kate.Format.HTML: styleToHtml :: Style -> Html
+ Text.Highlighting.Kate.Format.LaTeX: formatLaTeXBlock :: FormatOptions -> [SourceLine] -> String
+ Text.Highlighting.Kate.Format.LaTeX: formatLaTeXInline :: FormatOptions -> [SourceLine] -> String
+ Text.Highlighting.Kate.Format.LaTeX: styleToLaTeX :: Style -> String
+ Text.Highlighting.Kate.Styles: espresso :: Style
+ Text.Highlighting.Kate.Styles: haddock :: Style
+ Text.Highlighting.Kate.Styles: kate :: Style
+ Text.Highlighting.Kate.Styles: monochrome :: Style
+ Text.Highlighting.Kate.Styles: pygments :: Style
+ Text.Highlighting.Kate.Styles: tango :: Style
+ Text.Highlighting.Kate.Types: AlertTok :: TokenType
+ Text.Highlighting.Kate.Types: BaseNTok :: TokenType
+ Text.Highlighting.Kate.Types: CharTok :: TokenType
+ Text.Highlighting.Kate.Types: CommentTok :: TokenType
+ Text.Highlighting.Kate.Types: DataTypeTok :: TokenType
+ Text.Highlighting.Kate.Types: DecValTok :: TokenType
+ Text.Highlighting.Kate.Types: ErrorTok :: TokenType
+ Text.Highlighting.Kate.Types: FloatTok :: TokenType
+ Text.Highlighting.Kate.Types: FormatOptions :: Bool -> Int -> Bool -> Bool -> [String] -> [String] -> FormatOptions
+ Text.Highlighting.Kate.Types: FunctionTok :: TokenType
+ Text.Highlighting.Kate.Types: KeywordTok :: TokenType
+ Text.Highlighting.Kate.Types: NormalTok :: TokenType
+ Text.Highlighting.Kate.Types: OtherTok :: TokenType
+ Text.Highlighting.Kate.Types: RGB :: Word8 -> Word8 -> Word8 -> Color
+ Text.Highlighting.Kate.Types: RegionMarkerTok :: TokenType
+ Text.Highlighting.Kate.Types: StringTok :: TokenType
+ Text.Highlighting.Kate.Types: Style :: [(TokenType, TokenStyle)] -> Maybe Color -> Maybe Color -> Maybe Color -> Maybe Color -> Style
+ Text.Highlighting.Kate.Types: SyntaxState :: ContextStack -> String -> Int -> Char -> Bool -> Bool -> Bool -> [String] -> SyntaxState
+ Text.Highlighting.Kate.Types: TokenStyle :: Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> TokenStyle
+ Text.Highlighting.Kate.Types: backgroundColor :: Style -> Maybe Color
+ Text.Highlighting.Kate.Types: class FromColor a
+ Text.Highlighting.Kate.Types: class ToColor a
+ Text.Highlighting.Kate.Types: codeClasses :: FormatOptions -> [String]
+ Text.Highlighting.Kate.Types: containerClasses :: FormatOptions -> [String]
+ Text.Highlighting.Kate.Types: data Color
+ Text.Highlighting.Kate.Types: data FormatOptions
+ Text.Highlighting.Kate.Types: data Style
+ Text.Highlighting.Kate.Types: data SyntaxState
+ Text.Highlighting.Kate.Types: data TokenStyle
+ Text.Highlighting.Kate.Types: data TokenType
+ Text.Highlighting.Kate.Types: defStyle :: TokenStyle
+ Text.Highlighting.Kate.Types: defaultColor :: Style -> Maybe Color
+ Text.Highlighting.Kate.Types: defaultFormatOpts :: FormatOptions
+ Text.Highlighting.Kate.Types: fromColor :: FromColor a => Color -> a
+ Text.Highlighting.Kate.Types: instance Enum TokenType
+ Text.Highlighting.Kate.Types: instance Eq FormatOptions
+ Text.Highlighting.Kate.Types: instance Eq TokenType
+ Text.Highlighting.Kate.Types: instance FromColor (Double, Double, Double)
+ Text.Highlighting.Kate.Types: instance FromColor (Word8, Word8, Word8)
+ Text.Highlighting.Kate.Types: instance FromColor String
+ Text.Highlighting.Kate.Types: instance Read Color
+ Text.Highlighting.Kate.Types: instance Read FormatOptions
+ Text.Highlighting.Kate.Types: instance Read Style
+ Text.Highlighting.Kate.Types: instance Read SyntaxState
+ Text.Highlighting.Kate.Types: instance Read TokenStyle
+ Text.Highlighting.Kate.Types: instance Read TokenType
+ Text.Highlighting.Kate.Types: instance Show Color
+ Text.Highlighting.Kate.Types: instance Show FormatOptions
+ Text.Highlighting.Kate.Types: instance Show Style
+ Text.Highlighting.Kate.Types: instance Show SyntaxState
+ Text.Highlighting.Kate.Types: instance Show TokenStyle
+ Text.Highlighting.Kate.Types: instance Show TokenType
+ Text.Highlighting.Kate.Types: instance ToColor (Double, Double, Double)
+ Text.Highlighting.Kate.Types: instance ToColor (Word8, Word8, Word8)
+ Text.Highlighting.Kate.Types: instance ToColor String
+ Text.Highlighting.Kate.Types: lineAnchors :: FormatOptions -> Bool
+ Text.Highlighting.Kate.Types: lineNumberBackgroundColor :: Style -> Maybe Color
+ Text.Highlighting.Kate.Types: lineNumberColor :: Style -> Maybe Color
+ Text.Highlighting.Kate.Types: numberLines :: FormatOptions -> Bool
+ Text.Highlighting.Kate.Types: startNumber :: FormatOptions -> Int
+ Text.Highlighting.Kate.Types: synStCaptures :: SyntaxState -> [String]
+ Text.Highlighting.Kate.Types: synStCaseSensitive :: SyntaxState -> Bool
+ Text.Highlighting.Kate.Types: synStContexts :: SyntaxState -> ContextStack
+ Text.Highlighting.Kate.Types: synStKeywordCaseSensitive :: SyntaxState -> Bool
+ Text.Highlighting.Kate.Types: synStLanguage :: SyntaxState -> String
+ Text.Highlighting.Kate.Types: synStLineNumber :: SyntaxState -> Int
+ Text.Highlighting.Kate.Types: synStPrevChar :: SyntaxState -> Char
+ Text.Highlighting.Kate.Types: synStPrevNonspace :: SyntaxState -> Bool
+ Text.Highlighting.Kate.Types: titleAttributes :: FormatOptions -> Bool
+ Text.Highlighting.Kate.Types: toColor :: ToColor a => a -> Maybe Color
+ Text.Highlighting.Kate.Types: tokenBackground :: TokenStyle -> Maybe Color
+ Text.Highlighting.Kate.Types: tokenBold :: TokenStyle -> Bool
+ Text.Highlighting.Kate.Types: tokenColor :: TokenStyle -> Maybe Color
+ Text.Highlighting.Kate.Types: tokenItalic :: TokenStyle -> Bool
+ Text.Highlighting.Kate.Types: tokenStyles :: Style -> [(TokenType, TokenStyle)]
+ Text.Highlighting.Kate.Types: tokenUnderline :: TokenStyle -> Bool
+ Text.Highlighting.Kate.Types: type ContextStack = Map String [String]
+ Text.Highlighting.Kate.Types: type KateParser = GenParser Char SyntaxState
+ Text.Highlighting.Kate.Types: type SourceLine = [Token]
+ Text.Highlighting.Kate.Types: type Token = (TokenType, String)
- Text.Highlighting.Kate: highlightAs :: String -> String -> Either String [SourceLine]
+ Text.Highlighting.Kate: highlightAs :: String -> String -> [SourceLine]
- Text.Highlighting.Kate.Syntax: highlightAs :: String -> String -> Either String [SourceLine]
+ Text.Highlighting.Kate.Syntax: highlightAs :: String -> String -> [SourceLine]
Files
- BUGS +0/−3
- Highlight.hs +79/−35
- ParseSyntaxFiles.hs +160/−137
- README +4/−9
- Text/Highlighting/Kate.hs +25/−17
- Text/Highlighting/Kate/Common.hs +129/−115
- Text/Highlighting/Kate/Definitions.hs +0/−37
- Text/Highlighting/Kate/Format.hs +0/−95
- Text/Highlighting/Kate/Format/HTML.hs +127/−0
- Text/Highlighting/Kate/Format/LaTeX.hs +125/−0
- Text/Highlighting/Kate/Styles.hs +140/−0
- Text/Highlighting/Kate/Syntax.hs +25/−16
- Text/Highlighting/Kate/Syntax.hs.in +23/−6
- Text/Highlighting/Kate/Syntax/Actionscript.hs +108/−124
- Text/Highlighting/Kate/Syntax/Ada.hs +76/−88
- Text/Highlighting/Kate/Syntax/Alert.hs +27/−38
- Text/Highlighting/Kate/Syntax/Alert_indent.hs +27/−38
- Text/Highlighting/Kate/Syntax/Apache.hs +73/−91
- Text/Highlighting/Kate/Syntax/Asn1.hs +33/−44
- Text/Highlighting/Kate/Syntax/Asp.hs +214/−237
- Text/Highlighting/Kate/Syntax/Awk.hs +55/−68
- Text/Highlighting/Kate/Syntax/Bash.hs +668/−727
- Text/Highlighting/Kate/Syntax/Bibtex.hs +96/−113
- Text/Highlighting/Kate/Syntax/Boo.hs +190/−216
- Text/Highlighting/Kate/Syntax/C.hs +161/−181
- Text/Highlighting/Kate/Syntax/Changelog.hs +35/−48
- Text/Highlighting/Kate/Syntax/Clojure.hs +88/−102
- Text/Highlighting/Kate/Syntax/Cmake.hs +78/−94
- Text/Highlighting/Kate/Syntax/Coffeescript.hs +127/−148
- Text/Highlighting/Kate/Syntax/Coldfusion.hs +232/−262
- Text/Highlighting/Kate/Syntax/Commonlisp.hs +81/−96
- Text/Highlighting/Kate/Syntax/Cpp.hs +175/−195
- Text/Highlighting/Kate/Syntax/Cs.hs +100/−114
- Text/Highlighting/Kate/Syntax/Css.hs +187/−216
- Text/Highlighting/Kate/Syntax/D.hs +449/−497
- Text/Highlighting/Kate/Syntax/Diff.hs +123/−143
- Text/Highlighting/Kate/Syntax/Djangotemplate.hs +338/−387
- Text/Highlighting/Kate/Syntax/Doxygen.hs +287/−329
- Text/Highlighting/Kate/Syntax/Doxygenlua.hs +0/−369
- Text/Highlighting/Kate/Syntax/Dtd.hs +94/−110
- Text/Highlighting/Kate/Syntax/Eiffel.hs +45/−57
- Text/Highlighting/Kate/Syntax/Email.hs +141/−152
- Text/Highlighting/Kate/Syntax/Erlang.hs +73/−88
- Text/Highlighting/Kate/Syntax/Fortran.hs +246/−276
- Text/Highlighting/Kate/Syntax/Fsharp.hs +156/−176
- Text/Highlighting/Kate/Syntax/Gnuassembler.hs +79/−94
- Text/Highlighting/Kate/Syntax/Go.hs +72/−86
- Text/Highlighting/Kate/Syntax/Haskell.hs +90/−102
- Text/Highlighting/Kate/Syntax/Haxe.hs +87/−102
- Text/Highlighting/Kate/Syntax/Html.hs +239/−276
- Text/Highlighting/Kate/Syntax/Ilerpg.hs +0/−565
- Text/Highlighting/Kate/Syntax/Ini.hs +50/−63
- Text/Highlighting/Kate/Syntax/Java.hs +125/−145
- Text/Highlighting/Kate/Syntax/Javadoc.hs +174/−192
- Text/Highlighting/Kate/Syntax/Javascript.hs +157/−179
- Text/Highlighting/Kate/Syntax/Json.hs +91/−107
- Text/Highlighting/Kate/Syntax/Jsp.hs +336/−368
- Text/Highlighting/Kate/Syntax/Latex.hs +736/−802
- Text/Highlighting/Kate/Syntax/Lex.hs +148/−178
- Text/Highlighting/Kate/Syntax/LiterateHaskell.hs +54/−70
- Text/Highlighting/Kate/Syntax/Lua.hs +119/−140
- Text/Highlighting/Kate/Syntax/Makefile.hs +100/−120
- Text/Highlighting/Kate/Syntax/Mandoc.hs +44/−57
- Text/Highlighting/Kate/Syntax/Matlab.hs +75/−87
- Text/Highlighting/Kate/Syntax/Maxima.hs +57/−70
- Text/Highlighting/Kate/Syntax/Mediawiki.hs +0/−221
- Text/Highlighting/Kate/Syntax/Metafont.hs +172/−191
- Text/Highlighting/Kate/Syntax/Mips.hs +63/−75
- Text/Highlighting/Kate/Syntax/Modula2.hs +55/−70
- Text/Highlighting/Kate/Syntax/Modula3.hs +68/−82
- Text/Highlighting/Kate/Syntax/Monobasic.hs +123/−135
- Text/Highlighting/Kate/Syntax/Nasm.hs +66/−78
- Text/Highlighting/Kate/Syntax/Noweb.hs +58/−72
- Text/Highlighting/Kate/Syntax/Objectivec.hs +96/−111
- Text/Highlighting/Kate/Syntax/Objectivecpp.hs +196/−217
- Text/Highlighting/Kate/Syntax/Ocaml.hs +151/−171
- Text/Highlighting/Kate/Syntax/Octave.hs +128/−140
- Text/Highlighting/Kate/Syntax/Pascal.hs +84/−104
- Text/Highlighting/Kate/Syntax/Perl.hs +844/−919
- Text/Highlighting/Kate/Syntax/Php.hs +216/−242
- Text/Highlighting/Kate/Syntax/Pike.hs +103/−120
- Text/Highlighting/Kate/Syntax/Postscript.hs +45/−57
- Text/Highlighting/Kate/Syntax/Prolog.hs +64/−78
- Text/Highlighting/Kate/Syntax/Python.hs +200/−227
- Text/Highlighting/Kate/Syntax/R.hs +120/−137
- Text/Highlighting/Kate/Syntax/Relaxngcompact.hs +46/−60
- Text/Highlighting/Kate/Syntax/Rhtml.hs +1234/−1342
- Text/Highlighting/Kate/Syntax/Ruby.hs +1009/−1096
- Text/Highlighting/Kate/Syntax/Scala.hs +112/−128
- Text/Highlighting/Kate/Syntax/Scheme.hs +124/−146
- Text/Highlighting/Kate/Syntax/Sci.hs +46/−57
- Text/Highlighting/Kate/Syntax/Sed.hs +332/−368
- Text/Highlighting/Kate/Syntax/Sgml.hs +49/−64
- Text/Highlighting/Kate/Syntax/Sql.hs +81/−95
- Text/Highlighting/Kate/Syntax/SqlMysql.hs +104/−119
- Text/Highlighting/Kate/Syntax/SqlPostgresql.hs +107/−124
- Text/Highlighting/Kate/Syntax/Tcl.hs +75/−88
- Text/Highlighting/Kate/Syntax/Texinfo.hs +52/−67
- Text/Highlighting/Kate/Syntax/Verilog.hs +111/−130
- Text/Highlighting/Kate/Syntax/Vhdl.hs +262/−297
- Text/Highlighting/Kate/Syntax/Xharbour.hs +0/−174
- Text/Highlighting/Kate/Syntax/Xml.hs +155/−184
- Text/Highlighting/Kate/Syntax/Xorg.hs +67/−82
- Text/Highlighting/Kate/Syntax/Xslt.hs +217/−249
- Text/Highlighting/Kate/Syntax/Xul.hs +264/−303
- Text/Highlighting/Kate/Syntax/Yacc.hs +148/−179
- Text/Highlighting/Kate/Syntax/Yaml.hs +215/−241
- Text/Highlighting/Kate/Types.hs +137/−0
- changelog +92/−0
- highlighting-kate.cabal +13/−19
- xml/doxygenlua.xml +0/−481
- xml/doxygenlua.xml.bkp +481/−0
- xml/haskell.xml +9/−3
- xml/ilerpg.xml +0/−725
- xml/lua.xml +2/−3
- xml/lua.xml.bkp +304/−0
- xml/mediawiki.xml +0/−98
- xml/xharbour.xml +0/−543
− BUGS
@@ -1,3 +0,0 @@-Known bugs:--
Highlight.hs view
@@ -1,65 +1,73 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP, OverloadedStrings #-} module Main where import Text.Highlighting.Kate import System.IO (hPutStrLn, stderr) import System.Environment-import Text.XHtml.Transitional import System.Console.GetOpt import System.Exit import System.FilePath (takeFileName) import Data.Maybe (listToMaybe) import Data.Char (toLower)+import Text.Blaze.Renderer.String+import Text.Blaze+import qualified Text.Blaze.Html5 as H+import qualified Text.Blaze.Html5.Attributes as A -data Flag = CssPath String+data Flag = Sty String+ | Format String | Help | Fragment | List | NumberLines | Syntax String- | Detailed | TitleAttributes | Version deriving (Eq, Show) options :: [OptDescr Flag] options =- [ Option ['c'] ["css"] (ReqArg CssPath "PATH") "link CSS file"+ [ Option ['S'] ["style"] (ReqArg Sty "STYLE") "specify style"+ , Option ['F'] ["format"] (ReqArg Format "FORMAT") "output format (html|latex)" , Option ['f'] ["fragment"] (NoArg Fragment) "fragment, without document header" , Option ['h'] ["help"] (NoArg Help) "show usage message" , Option ['l'] ["list"] (NoArg List) "list available language syntaxes" , Option ['n'] ["number-lines"] (NoArg NumberLines) "number lines" , Option ['s'] ["syntax"] (ReqArg Syntax "SYNTAX") "specify language syntax to use"- , Option ['d'] ["details"] (NoArg Detailed) "include detailed lexical information in classes" , Option ['t'] ["title-attributes"] (NoArg TitleAttributes) "include structure in title attributes" , Option ['v'] ["version"] (NoArg Version) "print version" ] -cssPathOf :: [Flag] -> Maybe String-cssPathOf [] = Nothing-cssPathOf (CssPath s : _) = Just s-cssPathOf (_:xs) = cssPathOf xs- syntaxOf :: [Flag] -> Maybe String syntaxOf [] = Nothing syntaxOf (Syntax s : _) = Just s syntaxOf (_:xs) = syntaxOf xs +styleOf :: [Flag] -> Maybe Style+styleOf [] = Nothing+styleOf (Sty s : _) = case map toLower s of+ "pygments" -> Just pygments+ "espresso" -> Just espresso+ "kate" -> Just kate+ "tango" -> Just tango+ "haddock" -> Just haddock+ "monochrome" -> Just monochrome+ _ -> error $ "Unknown style: " ++ s+styleOf (_ : xs) = styleOf xs++formatOf :: [Flag] -> String+formatOf [] = "html" -- default+formatOf (Format s : _) = case map toLower s of+ "html" -> "html"+ "latex" -> "latex"+ _ -> error $ "Unknown format: " ++ s+formatOf (_ : xs) = formatOf xs+ filterNewlines :: String -> String filterNewlines ('\r':'\n':xs) = '\n' : filterNewlines xs filterNewlines ('\r':xs) = '\n' : filterNewlines xs filterNewlines (x:xs) = x : filterNewlines xs filterNewlines [] = [] --- | Highlight source code in XHTML using specified syntax.-xhtmlHighlight :: [FormatOption] -- ^ Options- -> String -- ^ Name of syntax to use- -> String -- ^ Source code to highlight- -> Html-xhtmlHighlight opts lang code =- case highlightAs lang code of- Right result -> formatAsXHtml opts lang result- Left _ -> pre $ thecode << code- main = do (opts, fnames, errs) <- getArgs >>= return . getOpt Permute options prg <- getProgName@@ -95,17 +103,53 @@ if not (lang `elem` (map (map toLower) languages)) then hPutStrLn stderr ("Unknown syntax: " ++ lang) >> exitWith (ExitFailure 4) else return ()- let highlightOpts = [OptTitleAttributes | TitleAttributes `elem` opts] ++- [OptDetailed | Detailed `elem` opts] ++- [OptNumberLines | NumberLines `elem` opts] ++- [OptLineAnchors | NumberLines `elem` opts]- let css = case cssPathOf opts of- Nothing -> style ! [thetype "text/css"] $ primHtml defaultHighlightingCss - Just cssPath -> thelink ! [thetype "text/css", href cssPath, rel "stylesheet"] << noHtml- let hcode = xhtmlHighlight highlightOpts lang code- let pageTitle = if null fnames then noHtml else thetitle << (takeFileName $ head fnames)- let metadata = meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"] +++- meta ! [name "generator", content "highlight-kate"]- if Fragment `elem` opts- then putStrLn $ renderHtmlFragment hcode- else putStrLn $ renderHtml $ header << [pageTitle, metadata, css] +++ body << hcode+ let highlightOpts = defaultFormatOpts{ titleAttributes = TitleAttributes `elem` opts+ , numberLines = NumberLines `elem` opts+ , lineAnchors = NumberLines `elem` opts+ }+ let fragment = Fragment `elem` opts+ let fname = case fnames of+ [] -> ""+ (x:_) -> x+ case formatOf opts of+ "html" -> hlHtml fragment fname highlightOpts (maybe pygments id $ styleOf opts)+ lang code+ "latex" -> hlLaTeX fragment fname highlightOpts (maybe pygments id $ styleOf opts) lang code+ x -> error $ "Uknown format " ++ x++hlHtml :: Bool -- ^ Fragment+ -> FilePath -- ^ Filename+ -> FormatOptions+ -> Style+ -> String -- ^ language+ -> String -- ^ code+ -> IO ()+hlHtml frag fname opts sty lang code =+ if frag+ then putStrLn $ renderHtml fragment+ else putStrLn $ renderHtml $ H.head (pageTitle >> metadata >> css) >> H.body (toHtml fragment)+ where fragment = formatHtmlBlock opts $ highlightAs lang code+ css = styleToHtml sty+ pageTitle = H.title $ toHtml fname+ metadata = H.meta ! A.httpEquiv "Content-Type" ! A.content "text/html; charset=UTF-8" >>+ H.meta ! A.name "generator" ! A.content "highlight-kate"++hlLaTeX :: Bool -- ^ Fragment+ -> FilePath -- ^ Filename+ -> FormatOptions+ -> Style+ -> String -- ^ language+ -> String -- ^ code+ -> IO ()+hlLaTeX frag fname opts sty lang code =+ if frag+ then putStrLn fragment+ else putStrLn $ "\\documentclass{article}\n\\usepackage[margin=1in]{geometry}\n" +++ macros ++ pageTitle +++ "\n\\begin{document}\n\\maketitle\n" ++ fragment ++ "\n\\end{document}"+ where fragment = formatLaTeXBlock opts $ highlightAs lang code+ macros = styleToLaTeX sty+ pageTitle = "\\title{" ++ fname ++ "}\n"+++
ParseSyntaxFiles.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE Arrows #-} -{- +{- ParseSyntaxFiles.hs processes a directory containing Kate XML syntax highlighting definitions. For each xml file in the directory, it creates a syntax highlighting parser@@ -21,23 +21,20 @@ module Main where import Text.XML.HXT.Core-import Control.Arrow-import Control.Arrow.ArrowList-import Control.Monad (liftM)+import Control.Monad import Data.List-import Data.Maybe import Data.Char (toUpper, toLower, isAlphaNum) import qualified Data.Map as Map import System.Directory import System.Environment-import System.Exit import System.FilePath import Text.PrettyPrint import Text.Printf (printf) import Data.Char (ord)-import Text.Highlighting.Kate.Definitions+import Text.Highlighting.Kate.Types import qualified Data.ByteString as B import Data.ByteString.UTF8 (fromString, toString)+import Text.Regex.Posix ((=~)) data SyntaxDefinition = SyntaxDefinition { synLanguage :: String@@ -57,7 +54,7 @@ , keywordDelims :: [Char] } deriving (Read, Show) -data SyntaxContext = +data SyntaxContext = SyntaxContext { contName :: String , contAttribute :: String , contLineEndContext :: String@@ -65,7 +62,7 @@ , contFallthrough :: Bool , contFallthroughContext :: String , contDynamic :: Bool- , contParsers :: [SyntaxParser] + , contParsers :: [SyntaxParser] } deriving (Read, Show) data SyntaxParser =@@ -83,118 +80,152 @@ , parserChildren :: [SyntaxParser] } deriving (Read, Show) --- | Converts a list of files (ending in .xml) and directories containing .xml files--- into a list of .xml files.+-- | Converts a list of files (ending in .xml) and directories containing+-- .xml files into a list of .xml files. argFiles :: [String] -> IO [String]-argFiles [] = error "Specify paths of xml files and/or directories containing xml syntax files."+argFiles [] = error "Specify paths of xml files and/or directories." argFiles args = do let isXmlFile x = isSuffixOf ".xml" x let (files, dirs) = partition isXmlFile args- dirContents <- mapM (\dir -> getDirectoryContents dir >>= return . map (combine dir) . filter isXmlFile) dirs+ dirContents <- forM dirs $ \dir -> do+ dc <- getDirectoryContents dir+ return $ map (combine dir) $ filter isXmlFile dc return $ nub (files ++ concat dirContents) -+libraryPath :: FilePath libraryPath = joinPath ["Text", "Highlighting", "Kate"]++destDir :: FilePath destDir = joinPath [libraryPath, "Syntax"] main :: IO () main = do files <- getArgs >>= argFiles destDirExists <- doesDirectoryExist destDir- if destDirExists- then return ()- else createDirectory destDir + unless destDirExists $ createDirectory destDir mapM_ processOneFile files+ names <- (sort . map dropExtension . filter (isSuffixOf ".hs"))+ `fmap` (getDirectoryContents destDir)+ writeSyntaxFile names+ writeCabalFile names++writeSyntaxFile :: [String] -> IO ()+writeSyntaxFile names = do let syntaxFile = combine libraryPath (addExtension "Syntax" "hs") putStrLn $ "Writing " ++ syntaxFile -- Get all syntax files, not only the newly generated ones.- names <- getDirectoryContents destDir >>= return . sort . map dropExtension . filter (isSuffixOf ".hs")- let imports = unlines $ map (\name -> "import qualified Text.Highlighting.Kate.Syntax." ++ name ++ " as " ++ name) names - let cases = unlines $ map (\name -> show (map toLower name) ++ " -> " ++ name ++ ".highlight") names- let languageExtensions = '[' :- (intercalate ", " $ map (\name -> "(" ++ show name ++ ", " ++ name ++ ".syntaxExtensions)") names) ++ "]"+ let imports = unlines $ map (\name ->+ "import qualified Text.Highlighting.Kate.Syntax." ++ name +++ " as " ++ name) names+ let cases = unlines $ map (\name ->+ show (map toLower name) ++ " -> " ++ name ++ ".highlight")+ names+ let languageExtensions = "[" ++ (intercalate ", " $ map (\name ->+ "(" ++ show name ++ ", " ++ name ++ ".syntaxExtensions)") names) ++ "]" syntaxFileTemplate <- liftM toString $ B.readFile (syntaxFile <.> "in")- let filledTemplate = fillTemplate 0 [("imports",imports),- ("languages",show names),- ("languageExtensions",languageExtensions),- ("cases",cases)] syntaxFileTemplate+ let filledTemplate = fillTemplate 0+ [("imports",imports),+ ("languages",show names),+ ("supportedlanguages", intercalate ", " $ map (\x ->+ "@" ++ map toLower x ++ "@") names),+ ("languageExtensions",languageExtensions),+ ("cases",cases)] syntaxFileTemplate B.writeFile syntaxFile $ fromString filledTemplate +writeCabalFile :: [String] -> IO ()+writeCabalFile names = do+ copyFile "highlighting-kate.cabal" "highlighting-kate.cabal.orig"+ cabalLines <- lines `fmap` readFile "highlighting-kate.cabal.orig"+ let (front,rest) = break (=~ "Text\\.Highlighting\\.Kate\\.Syntax\\.")+ cabalLines+ let end = dropWhile (=~ "Text\\.Highlighting\\.Kate\\.Syntax\\.") rest+ let toMod n = replicate 21 ' ' ++ "Text.Highlighting.Kate.Syntax." ++ n+ let newCabalLines = front ++ (map toMod names) ++ end+ writeFile "highlighting-kate.cabal" $ unlines newCabalLines+ putStrLn "Modified highlighting-kate.cabal."+ putStrLn "Backed up original as highlighting-kate.cabal.orig."+ processOneFile :: FilePath -> IO () processOneFile src = do [syntax] <- runX $ application src let name = nameFromPath src let outFile = joinPath [libraryPath, "Syntax", addExtension name "hs"]+ let isIncludeRules p = parserType p == "IncludeRules" && "##" `isPrefixOf`+ parserContext p let includeLangs = nub $ filter (/= name) $ map (drop 2 . parserContext) $- filter (\p -> (parserType p) == "IncludeRules" && "##" `isPrefixOf` (parserContext p)) $ - concatMap contParsers $ synContexts syntax- let includeImports = map (("import qualified " ++) . langNameToModule) includeLangs+ filter isIncludeRules $ concatMap contParsers $ synContexts syntax+ let includeImports = map (("import qualified " ++) . langNameToModule)+ includeLangs putStrLn $ "Writing " ++ outFile B.writeFile outFile $ fromString $- "{- This module was generated from data in the Kate syntax highlighting file " ++ (takeFileName src) ++ ", version " ++ - synVersion syntax ++ ",\n" ++- " by " ++ synAuthor syntax ++ " -}\n\n" ++ - "module Text.Highlighting.Kate.Syntax." ++ name ++ " ( highlight, parseExpression, syntaxName, syntaxExtensions ) where\n\- \import Text.Highlighting.Kate.Definitions\n\+ "{- This module was generated from data in the Kate syntax\n\+ \ highlighting file " ++ (takeFileName src) ++ ", version " +++ synVersion syntax ++ ", by " ++ synAuthor syntax ++ " -}\n\n" +++ "module Text.Highlighting.Kate.Syntax." ++ name ++ "\n " +++ "(highlight, parseExpression, syntaxName, syntaxExtensions)" +++ "\nwhere\n\+ \import Text.Highlighting.Kate.Types\n\ \import Text.Highlighting.Kate.Common\n" ++- unlines includeImports ++ - "import Text.ParserCombinators.Parsec\n\- \import Control.Monad (when)\n\+ unlines includeImports +++ "import Text.ParserCombinators.Parsec hiding (State)\n\ \import Data.Map (fromList)\n\- \import Data.Maybe (fromMaybe, maybeToList)\n\n" +++ \import Control.Monad.State\n\+ \import Data.Char (isSpace)\n\+ \import Data.Maybe (fromMaybe)\n" ++ (if null (synLists syntax)- then ""- else "import qualified Data.Set as Set\n") +++ then "\n"+ else "import qualified Data.Set as Set\n\n") ++ render (mkParser syntax) ++ "\n" +labelFor :: SyntaxDefinition -> String -> TokenType+labelFor syntax attr' =+ case lookup attr' (synItemDatas syntax) of+ Just "dsKeyword" -> KeywordTok+ Just "dsDataType" -> DataTypeTok+ Just "dsDecVal" -> DecValTok+ Just "dsBaseN" -> BaseNTok+ Just "dsFloat" -> FloatTok+ Just "dsChar" -> CharTok+ Just "dsString" -> StringTok+ Just "dsComment" -> CommentTok+ Just "dsOthers" -> OtherTok+ Just "dsAlert" -> AlertTok+ Just "dsFunction" -> FunctionTok+ Just "dsRegionMarker" -> RegionMarkerTok+ Just "dsError" -> ErrorTok+ _ -> NormalTok+ mkParser :: SyntaxDefinition -> Doc-mkParser syntax = +mkParser syntax = let name = text "-- | Full name of language." $$ text "syntaxName :: String" $$ text ("syntaxName = " ++ show (synLanguage syntax)) exts = text "-- | Filename extensions for this language." $$ text "syntaxExtensions :: String" $$ text ("syntaxExtensions = " ++ show (synExtensions syntax))- shortFormOf "dsKeyword" = ["kw"]- shortFormOf "dsDataType" = ["dt"] - shortFormOf "dsDecVal" = ["dv"]- shortFormOf "dsBaseN" = ["bn"]- shortFormOf "dsFloat" = ["fl"]- shortFormOf "dsChar" = ["ch"]- shortFormOf "dsString" = ["st"]- shortFormOf "dsComment" = ["co"]- shortFormOf "dsOthers" = ["ot"]- shortFormOf "dsAlert" = ["al"]- shortFormOf "dsFunction" = ["fu"]- shortFormOf "dsRegionMarker" = ["re"]- shortFormOf "dsError" = ["er"]- shortFormOf _ = []- styles = text ("styles = " ++ (show [(typ, shortsty) | (typ, sty) <- synItemDatas syntax, shortsty <- shortFormOf sty])) withAttr = text "withAttribute attr txt = do" $$ (nest 2 $ text "when (null txt) $ fail \"Parser matched no text\"" $$- text "let labs = attr : maybeToList (lookup attr styles)" $$- text "st <- getState" $$- text "let oldCharsParsed = synStCharsParsedInLine st" $$- text "let prevchar = if null txt then '\\n' else last txt" $$- text "updateState $ \\st -> st { synStCharsParsedInLine = oldCharsParsed + length txt, synStPrevChar = prevchar } " $$- text "return (labs, txt)")- parseExpressionInternal = text "parseExpressionInternal = do" $$ (nest 2 $ + text "updateState $ \\st -> st { synStPrevChar = last txt" $$+ text " , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }" $$+ text "return (attr, txt)")+ parseExpressionInternal = text "parseExpressionInternal = do" $$ (nest 2 $ text "context <- currentContext" $$- text "parseRules context <|> (pDefault >>= withAttribute (fromMaybe \"\" $ lookup context defaultAttributes))")+ text "parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))") parseExpression = text "-- | Parse an expression using appropriate local context." $$- text "parseExpression :: GenParser Char SyntaxState LabeledSource" $$- text "parseExpression = do" $$ (nest 2 $ + text "parseExpression :: KateParser Token" $$+ text "parseExpression = do" $$ (nest 2 $ text "st <- getState" $$ text "let oldLang = synStLanguage st" $$ text ("setState $ st { synStLanguage = " ++ show (synLanguage syntax) ++ " }") $$ text ("context <- currentContext <|> (pushContext " ++ show (contName $ head $ synContexts syntax) ++ " >> currentContext)") $$ text "result <- parseRules context" $$+ text "optional $ eof >> pEndLine" $$ text "updateState $ \\st -> st { synStLanguage = oldLang }" $$ text "return result")- defaultAttributes = text $ "defaultAttributes = " ++ (show $ map (\cont -> (contName cont, contAttribute cont)) $ synContexts syntax)+ defaultAttributes = text $ "defaultAttributes = " ++ (show $ map (\cont -> (contName cont, labelFor syntax $ contAttribute cont)) $ synContexts syntax) -- Note: lineBeginContexts seems not to be used in any of the xml files- -- lineBeginContexts = + -- lineBeginContexts = -- text $ "lineBeginContexts = " ++ (show $ map (\cont -> (contName cont, contLineBeginContext cont)) $ synContexts syntax) startingContext = head (synContexts syntax) contextNull = text $ "parseRules \"\" = parseRules " ++ show (contName startingContext)@@ -203,37 +234,27 @@ initialContextStack = Map.fromList [(synLanguage syntax, [contName startingContext])] startingState = SyntaxState { synStContexts = initialContextStack , synStLanguage = synLanguage syntax- , synStCurrentLine = ""- , synStCharsParsedInLine = 0+ , synStLineNumber = 0+ , synStPrevNonspace = False , synStPrevChar = '\n' , synStCaseSensitive = synCaseSensitive syntax , synStKeywordCaseSensitive = keywordCaseSensitive (synKeywordAttr syntax) , synStCaptures = [] } initState = text $ "startingState = " ++ show startingState- sourceLineParser = text "parseSourceLine = manyTill parseExpressionInternal pEndLine"- mainParser = text "parseSource = do " $$ - (nest 2 $ text "lineContents <- lookAhead wholeLine" $$- text "updateState $ \\st -> st { synStCurrentLine = lineContents }" $$- -- text "context <- currentContext" $$- -- text "pushContext (fromMaybe \"#stay\" $ lookup context lineBeginContexts)" $$- text "result <- manyTill parseSourceLine eof" $$- text "return $ map normalizeHighlighting result") mainFunction = text $ "-- | Highlight source code using this syntax definition.\n\- \highlight :: String -> Either String [SourceLine]\n\- \highlight input =\n\- \ case runParser parseSource startingState \"source\" input of\n\- \ Left err -> Left $ show err\n\- \ Right result -> Right result"+ \highlight :: String -> [SourceLine]\n\+ \highlight input = evalState (mapM parseSourceLine $ lines input) startingState"+ lineParser = text $ "parseSourceLine :: String -> State SyntaxState SourceLine\n\+ \parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine" endLineParser = text "pEndLine = do" $$- (nest 2 $ text "lookAhead $ newline <|> (eof >> return '\\n')" $$- text "context <- currentContext" $$+ (nest 2 $ text "context <- currentContext" $$ text "case context of" $$- (nest 2 $ (vcat $ map (\cont -> text (show $ contName cont) <> text " -> " <> - switchContext (contLineEndContext cont) <>+ (nest 2 $ (vcat $ map (\cont -> text (show $ contName cont) <> text " -> " <>+ switchContext (contLineEndContext cont) (<> text " >> ") <> if "#pop" `isPrefixOf` (contLineEndContext cont)- then text " >> pEndLine"- else text " >> pHandleEndLine") $ synContexts syntax) $$- (text $ "_ -> pHandleEndLine")))+ then text "pEndLine"+ else text "return ()") $ synContexts syntax) $$+ (text $ "_ -> return ()"))) {- text "pushContext (fromMaybe \"#stay\" $ lookup context lineBeginContexts)" $$ -} -- we use 'words "blah blah2 blah3"' to keep ghc from inlining the list, which makes compiling take a long time listDef (n, list) = text $ listName n ++ " = Set.fromList $ words $ " ++@@ -244,12 +265,12 @@ regexDef re = text $ compiledRegexName re ++ " = compileRegex " ++ show re regexes = vcat $ map regexDef $ nub $ [parserString x | x <- concatMap contParsers (synContexts syntax), parserType x == "RegExpr", parserDynamic x == False]- in vcat $ intersperse (text "") $ [name, exts, mainFunction, parseExpression, mainParser, initState, sourceLineParser, - endLineParser, withAttr, styles, parseExpressionInternal, lists, regexes,+ in vcat $ intersperse (text "") $ [name, exts, mainFunction, lineParser, parseExpression, initState,+ endLineParser, withAttr, parseExpressionInternal, lists, regexes, defaultAttributes {- , lineBeginContexts -}] ++ contexts ++ [contextNull, contextCatchAll] mkAlternatives :: [Doc] -> Doc-mkAlternatives docs = +mkAlternatives docs = let contents = vcat $ intersperse (text "<|>") docs in if length docs > 1 then char '(' <> contents <> char ')'@@ -258,24 +279,25 @@ mkRules :: SyntaxDefinition -> SyntaxContext -> Doc mkRules syntax context = let fallthroughParser = if contFallthrough context- then [parens (switchContext (contFallthroughContext context) <> - text " >> return ([], \"\")")]+ then [parens (switchContext (contFallthroughContext context) (<> text " >> ") <>+ text "currentContext >>= parseRules")] else []- in text ("parseRules " ++ show (contName context) ++ " = ") $$ + in text ("parseRules " ++ show (contName context) ++ " =") $$ if null (contParsers context) && null fallthroughParser then nest 2 (text "pzero")- else nest 2 $ (text "do (attr, result) <- " <> - (mkAlternatives $ (map (mkSyntaxParser syntax context) $ contParsers context) ++ fallthroughParser)) $$- text (" return (attr, result)")+ else nest 2 $ mkAlternatives $ (map (mkSyntaxParser syntax context) $ contParsers context) ++ fallthroughParser mkSyntaxParser :: SyntaxDefinition -> SyntaxContext -> SyntaxParser -> Doc-mkSyntaxParser syntax context parser = - let mainParser = text $ case parserType parser of+mkSyntaxParser syntax context parser =+ let attr' = case parserAttribute parser of+ "" -> labelFor syntax $ contAttribute context+ x -> labelFor syntax x+ mainParser = text $ case parserType parser of "DetectChar" -> "pDetectChar " ++ show (parserDynamic parser) ++ " " ++ show (parserChar parser)- "Detect2Chars" -> "pDetect2Chars " ++ show (parserDynamic parser) ++ " " ++ + "Detect2Chars" -> "pDetect2Chars " ++ show (parserDynamic parser) ++ " " ++ show (parserChar parser) ++ " " ++ show (parserChar1 parser) "AnyChar" -> "pAnyChar " ++ show (parserString parser)- "StringDetect" -> "pString " ++ show (parserDynamic parser) ++ " " ++ show (parserString parser) + "StringDetect" -> "pString " ++ show (parserDynamic parser) ++ " " ++ show (parserString parser) "RegExpr" -> if parserDynamic parser then "pRegExprDynamic " ++ show (parserString parser) else "pRegExpr " ++ compiledRegexName (parserString parser)@@ -294,9 +316,9 @@ "LineContinue" -> "pLineContinue" "IncludeRules" -> case parserContext parser of ('#':'#':xs) -> langNameToModule xs ++ ".parseExpression" ++- if parserIncludeAttrib parser || null (parserAttribute parser)+ if parserIncludeAttrib parser || attr' == NormalTok then ""- else " >>= ((withAttribute " ++ show (parserAttribute parser) ++ ") . snd)" + else " >>= ((withAttribute " ++ show attr' ++ ") . snd)" xs -> "parseRules " ++ show xs "DetectSpaces" -> "pDetectSpaces" "DetectIdentifier" -> "pDetectIdentifier"@@ -311,15 +333,9 @@ if parserType parser == "IncludeRules" then mainParser <> char ')' else (if parserLookAhead parser- then text "lookAhead (" <> mainParser <> text ") >> return ([],\"\") " - else mainParser <> text " >>= withAttribute " <> - text (if null (parserAttribute parser)- then show (contAttribute context)- else show (parserAttribute parser))) <> - char ')' <>- (if parserContext parser `elem` ["", "#stay"]- then empty - else text " >>~ " <> switchContext (parserContext parser))+ then text "lookAhead (" <> mainParser <> text ") >> return (NormalTok,\"\") "+ else mainParser <> text " >>= withAttribute " <> text (show attr')) <>+ char ')' <> switchContext (parserContext parser) (text " >>~ " <>) childParsers = parserChildren parser in char '(' <> (if null childParsers@@ -327,13 +343,17 @@ else text "withChildren " <> parserDoc <> char ' ' <> (mkAlternatives $ map (mkSyntaxParser syntax context) childParsers)) <> char ')' -switchContext next =+switchContext :: String -> (Doc -> Doc) -> Doc+switchContext next finalizer = case next of- x | "#pop" `isPrefixOf` x -> char '(' <>- text (concat $ intersperse " >> " $ replicate (length (filter (=='#') x)) "popContext") <> char ')'- "#stay" -> text "return ()"- x -> text ("pushContext " ++ show x) + x | "#pop" `isPrefixOf` x -> finalizer $+ char '(' <> text (concat $ intersperse " >> "+ $ replicate (length (filter (=='#') x)) "popContext") <> char ')'+ "#stay" -> empty+ "" -> empty+ x -> finalizer $ text ("pushContext " ++ show x) +langNameToModule :: String -> String langNameToModule str = "Text.Highlighting.Kate.Syntax." ++ case str of "Alerts" -> "Alert"@@ -356,7 +376,7 @@ normalize :: String -> String normalize "" = ""-normalize (x:xs) | isAlphaNum x = x : normalize xs +normalize (x:xs) | isAlphaNum x = x : normalize xs normalize (' ':xs) = '_':normalize xs normalize (x:xs) = printf "'%2x" (ord x) ++ normalize xs @@ -365,8 +385,8 @@ capitalize [] = [] nameFromPath :: FilePath -> String-nameFromPath = concat . map capitalize . words . - (map (\c -> if c == '-' then ' ' else c)) . takeFileName . +nameFromPath = concat . map capitalize . words .+ (map (\c -> if c == '-' then ' ' else c)) . takeFileName . dropExtension application :: String -> IOSArrow b SyntaxDefinition@@ -389,14 +409,14 @@ lists <- getLists -< x contexts <- getContexts -< x keywordAttr <- getKeywordAttrs -< x- returnA -< SyntaxDefinition { synLanguage = lang + returnA -< SyntaxDefinition { synLanguage = lang , synAuthor = author , synVersion = version- , synLicense = license + , synLicense = license , synExtensions = sources , synCaseSensitive = vBool True caseSensitive , synLists = lists- , synContexts = contexts + , synContexts = contexts , synItemDatas = itemdatas , synKeywordAttr = if null keywordAttr then defaultKeywordAttr@@ -413,12 +433,12 @@ getLists :: IOSArrow XmlTree [(String, [String])] getLists = listA $ multi (hasName "list")- >>> + >>> getAttrValue "name" &&& getListContents getListContents :: IOSArrow XmlTree [String] getListContents = listA $ getChildren- >>> + >>> hasName "item" >>> getChildren@@ -439,7 +459,7 @@ fallthroughContext <- getAttrValue "fallthroughContext" -< x dynamic <- getAttrValue "dynamic" -< x parsers <- getParsers -< x- returnA -< SyntaxContext + returnA -< SyntaxContext { contName = name , contAttribute = attribute , contLineEndContext = if null lineEndContext then "#stay" else lineEndContext@@ -450,7 +470,7 @@ , contParsers = parsers } getParsers :: IOSArrow XmlTree [SyntaxParser]-getParsers = listA $ getChildren +getParsers = listA $ getChildren >>> proc x -> do name <- getName -< x@@ -466,7 +486,7 @@ dynamic <- getAttrValue "dynamic" -< x children <- getParsers -< x let tildeRegex = name == "RegExpr" && length str > 0 && head str == '^'- returnA -< SyntaxParser + returnA -< SyntaxParser { parserType = name , parserAttribute = attribute , parserContext = context@@ -475,8 +495,8 @@ , parserFirstNonSpace = vBool False firstNonSpace , parserColumn = if tildeRegex then Just 0- else if null column - then Nothing + else if null column+ then Nothing else Just (read column) , parserDynamic = vBool False dynamic , parserString = if tildeRegex then drop 1 str else str@@ -491,18 +511,21 @@ caseSensitive <- getAttrValue "casesensitive" -< x weakDelim <- getAttrValue "weakDeliminator" -< x additionalDelim <- getAttrValue "additionalDeliminator" -< x- returnA -< SyntaxKeywordAttr + returnA -< SyntaxKeywordAttr { keywordCaseSensitive = vBool True caseSensitive , keywordDelims = (standardDelims ++ additionalDelim) \\ weakDelim } -standardDelims = " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" +standardDelims :: [Char]+standardDelims = " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" +defaultKeywordAttr :: SyntaxKeywordAttr defaultKeywordAttr = SyntaxKeywordAttr { keywordCaseSensitive = True , keywordDelims = standardDelims } -stripWhitespaceLeft = dropWhile isWhitespace -isWhitespace x = elem x [' ', '\t', '\n']+stripWhitespace :: String -> String stripWhitespace = reverse . stripWhitespaceLeft . reverse . stripWhitespaceLeft+ where stripWhitespaceLeft = dropWhile isWhitespace+ isWhitespace x = x `elem` [' ', '\t', '\n'] vBool :: Bool -> String -> Bool vBool defaultVal value = case value of@@ -515,7 +538,7 @@ fillTemplate :: Int -> [(String,String)] -> String -> String fillTemplate _ _ [] = [] fillTemplate _ [] lst = lst-fillTemplate n subs ('\n':xs) = '\n' : fillTemplate 0 subs xs+fillTemplate _ subs ('\n':xs) = '\n' : fillTemplate 0 subs xs fillTemplate n subs ('@':xs) = let (pref, suff) = break (=='@') xs in if length pref > 0 && all isAlphaNum pref && length suff > 0
README view
@@ -14,6 +14,7 @@ - Boo - C - Changelog+- Clojure - Cmake - Coffeescript - Coldfusion@@ -86,7 +87,6 @@ - Texinfo - Verilog - Vhdl-- Xharbour - Xml - Xorg - Xslt@@ -149,10 +149,7 @@ runghc ParseSyntaxFiles.hs xml -Note that ParseSyntaxFiles.hs requires the HXT package (>= 9.0.0). If you-added or removed a syntax definition, you will also need to-update the Extra-Source-Files and Exposed-Modules sections of-highlighting-kate.cabal before recompiling using 'cabal install'.+Note that ParseSyntaxFiles.hs requires the HXT package (>= 9.0.0). To get the current Kate syntax highlighting files, clone the kate repository:@@ -174,8 +171,6 @@ - javascript.xml: Fixed regex \s* (which matches empty string) by changes to DetectSpaces - perl.xml: Fixed regexes - needed backslash-escapes before ] and ^-- bash.xml: Changed "\\" to "\" in two Detect2Char rules in FindString--NOTE: Known bugs are recorded in the file BUGS. Please send bug reports (or-better, patches) to the author (jgm at berkeley dot edu).+- base report bugs on the github issue tracker:+<https://github.com/jgm/highlighting-kate/issues>.
Text/Highlighting/Kate.hs view
@@ -1,23 +1,30 @@ {- | Module : Text.Highlighting.Kate- Copyright : Copyright (C) 2008 John MacFarlane- License : GNU GPL, version 2 or above + Copyright : Copyright (C) 2008-2011 John MacFarlane+ License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable This helper module exports the main highlighting and formatting functions.- -A typical application will combine a highlighter and a formatter: +A typical application will combine a highlighter and a formatter.+This one reads ruby code from stdin and writes HTML:++> import Text.Highlighting.Kate+> import Text.Blaze.Renderer.String (renderHtml)+> import Text.Blaze (toHtml)+> import Text.Blaze.Html5 as H+> > main = do > code <- getContents-> case highlightAs "ruby" code of-> Right result -> putStrLn $ renderHtmlFragment $ -> formatAsXHtml [OptNumberLines] "ruby" result-> Left err -> error $ "Could not parse input: " ++ err+> putStrLn $ renderHtml+> $ do H.head (styleToHtml tango)+> H.body $ toHtml+> $ formatBlock defaultFormatOpts+> $ highlightAs "ruby" code -} @@ -25,16 +32,17 @@ , languages , languagesByExtension , languagesByFilename- , formatAsXHtml- , FormatOption (..)- , defaultHighlightingCss- , SourceLine- , LabeledSource , highlightingKateVersion+ , module Text.Highlighting.Kate.Types+ , module Text.Highlighting.Kate.Styles+ , module Text.Highlighting.Kate.Format.HTML+ , module Text.Highlighting.Kate.Format.LaTeX ) where-import Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..), defaultHighlightingCss )-import Text.Highlighting.Kate.Syntax ( highlightAs, languages, languagesByExtension, languagesByFilename )-import Text.Highlighting.Kate.Definitions ( SourceLine, LabeledSource )+import Text.Highlighting.Kate.Syntax+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Styles+import Text.Highlighting.Kate.Format.HTML+import Text.Highlighting.Kate.Format.LaTeX import Data.Version (showVersion) import Paths_highlighting_kate (version)
Text/Highlighting/Kate/Common.hs view
@@ -2,10 +2,10 @@ {- | Module : Text.Highlighting.Kate.Common Copyright : Copyright (C) 2008 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable Parsers used in all the individual syntax parsers.@@ -18,10 +18,11 @@ import System.IO.Unsafe (unsafePerformIO) import Text.Regex.PCRE.String #endif-import Text.Highlighting.Kate.Definitions-import Text.ParserCombinators.Parsec-import Data.Char (isDigit, chr, toLower)+import Text.Highlighting.Kate.Types+import Text.ParserCombinators.Parsec hiding (State)+import Data.Char (isDigit, toLower, isSpace) import Data.List (tails)+import Control.Monad.State import qualified Data.Map as Map import qualified Data.Set as Set @@ -52,13 +53,16 @@ (>>~) :: (Monad m) => m a -> m b -> m a a >>~ b = a >>= \x -> b >> return x -normalizeHighlighting :: [LabeledSource] -> [LabeledSource]+normalizeHighlighting :: [Token] -> [Token] normalizeHighlighting [] = [] normalizeHighlighting ((_,""):xs) = normalizeHighlighting xs-normalizeHighlighting ((a,x):(b,y):xs) | a == b = normalizeHighlighting ((a, x++y):xs)+normalizeHighlighting ((NormalTok,x):xs)+ | all isSpace x = (NormalTok,x) : normalizeHighlighting xs+normalizeHighlighting ((a,x):(b,y):xs)+ | a == b = normalizeHighlighting ((a, x++y):xs) normalizeHighlighting (x:xs) = x : normalizeHighlighting xs -pushContext :: [Char] -> GenParser tok SyntaxState ()+pushContext :: [Char] -> KateParser () pushContext context = if context == "#stay" then return () else do st <- getState@@ -67,10 +71,10 @@ let addContext c x = case x of Nothing -> Just [c] Just cs -> Just (c:cs)- let newContexts = Map.alter (addContext context) lang contexts + let newContexts = Map.alter (addContext context) lang contexts updateState $ \st -> st { synStContexts = newContexts } -popContext :: GenParser tok SyntaxState ()+popContext :: KateParser () popContext = do st <- getState let contexts = synStContexts st let lang = synStLanguage st@@ -78,9 +82,9 @@ Just (_:_) -> updateState $ \st -> st{ synStContexts = Map.adjust tail lang contexts } Just [] -> fail $ "Stack empty for language " ++ lang- Nothing -> fail $ "No context stack for language " ++ lang + Nothing -> fail $ "No context stack for language " ++ lang -currentContext :: GenParser tok SyntaxState String+currentContext :: KateParser String currentContext = do st <- getState let contexts = synStContexts st let lang = synStLanguage st@@ -89,215 +93,225 @@ Just (c:_) -> return c Nothing -> fail $ "No context stack for language " ++ lang -withChildren :: GenParser tok SyntaxState LabeledSource- -> GenParser tok SyntaxState LabeledSource- -> GenParser tok SyntaxState LabeledSource+withChildren :: KateParser Token+ -> KateParser Token+ -> KateParser Token withChildren parent child = do (pAttr, pResult) <- parent- (_, cResult) <- option ([],"") child+ (_, cResult) <- option (NormalTok,"") child return (pAttr, pResult ++ cResult) -wholeLine :: GenParser Char st [Char]-wholeLine = manyTill anyChar (newline <|> (eof >> return '\n'))--pFirstNonSpace :: GenParser tok SyntaxState ()+pFirstNonSpace :: KateParser () pFirstNonSpace = do- curLine <- currentLine- charsParsedInLine <- getState >>= return . synStCharsParsedInLine- let (sps, nonSps) = span (`elem` " \t") curLine- if length sps == charsParsedInLine && length nonSps > 0 - then return ()- else fail "Not first nonspace"+ rest <- getInput+ prevNonspace <- fromState synStPrevNonspace+ guard $ not $ prevNonspace || null rest || isSpace (head rest) currentColumn :: GenParser tok st Column-currentColumn = getPosition >>= return . sourceColumn--currentLine :: GenParser tok SyntaxState String-currentLine = getState >>= return . synStCurrentLine+currentColumn = sourceColumn `fmap` getPosition pColumn :: Column -> GenParser tok st () pColumn col = do curCol <- currentColumn- if col == (curCol - 1) -- parsec's columns start with 1- then return ()- else fail $ "Not column " ++ show col+ guard $ col == (curCol - 1) -- parsec's columns start with 1 -pGetCapture :: Int -> GenParser tok SyntaxState String+pGetCapture :: Int -> KateParser String pGetCapture capNum = do captures <- getState >>= return . synStCaptures if length captures < capNum then fail "Not enough captures" else return $ captures !! (capNum - 1) -pDetectChar :: Bool -> Char -> GenParser Char SyntaxState String-pDetectChar dynamic ch = do +pDetectChar :: Bool -> Char -> KateParser String+pDetectChar dynamic ch = do if dynamic && isDigit ch then pGetCapture (read [ch]) >>= try . string else char ch >>= return . (:[]) -pDetect2Chars :: Bool -> Char -> Char -> GenParser Char SyntaxState [Char]+pDetect2Chars :: Bool -> Char -> Char -> KateParser [Char] pDetect2Chars dynamic ch1 ch2 = try $ do [c1] <- pDetectChar dynamic ch1 [c2] <- pDetectChar dynamic ch2 return [c1, c2] -pKeyword :: [Char] -> Set.Set [Char] -> GenParser Char SyntaxState [Char]+pKeyword :: [Char] -> Set.Set [Char] -> KateParser [Char] pKeyword delims kws = try $ do- st <- getState- let prevChar = synStPrevChar st- case prevChar of- x | not (x `elem` delims) -> fail "Not preceded by a delimiter"- _ -> return ()+ notFollowedBy (oneOf delims)+ prevChar <- fromState synStPrevChar+ caseSensitive <- fromState synStKeywordCaseSensitive+ guard $ prevChar `elem` delims word <- many1 (noneOf delims)- let word' = if synStKeywordCaseSensitive st+ let word' = if caseSensitive then word else map toLower word if word' `Set.member` kws then return word else fail "Keyword not in list" -pString :: Bool -> [Char] -> GenParser Char SyntaxState String+pString :: Bool -> [Char] -> KateParser String pString dynamic str = if dynamic then subDynamic str >>= try . string else try $ string str -pAnyChar :: [Char] -> GenParser Char st [Char]+pAnyChar :: [Char] -> KateParser [Char] pAnyChar chars = oneOf chars >>= return . (:[]) -pDefault :: GenParser Char st [Char]-pDefault = noneOf "\n" >>= return . (:[])---- The following alternative gives a 25% speed improvement, but it's possible--- that it won't work for all syntaxes:--- pDefault = (many1 alphaNum) <|> (noneOf "\n" >>= return . (:[]))+pDefault :: KateParser [Char]+pDefault = (:[]) `fmap` anyChar -subDynamic :: [Char] -> GenParser tok SyntaxState [Char]+subDynamic :: [Char] -> KateParser [Char] subDynamic ('%':x:xs) | isDigit x = do captures <- getState >>= return . synStCaptures let capNum = read [x]+ let escapeRegexChar c | c `elem` "^$\\[](){}*+.?" = ['\\',c]+ | otherwise = [c]+ let escapeRegex = concatMap escapeRegexChar let replacement = if length captures < capNum then ['%',x] else captures !! (capNum - 1)- subDynamic xs >>= return . (replacement ++)+ subDynamic xs >>= return . (escapeRegex replacement ++) subDynamic (x:xs) = subDynamic xs >>= return . (x:) subDynamic "" = return "" -compileRegex :: String -> Regex+convertOctal :: String -> String+convertOctal [] = ""+convertOctal ('\\':'0':x:y:z:rest) | isOctalDigit x && isOctalDigit y && isOctalDigit z =+ case reads ['\\','o',x,y,z] of+ ((x,rest):_) -> x : convertOctal rest+ _ -> '\\':'o':x:y:z: convertOctal rest+convertOctal ('\\':x:y:z:rest) | isOctalDigit x && isOctalDigit y && isOctalDigit z =+ case reads ['\\','o',x,y,z] of+ ((x,rest):_) -> x : convertOctal rest+ _ -> '\\':'o':x:y:z: convertOctal rest+convertOctal (x:xs) = x : convertOctal xs++isOctalDigit :: Char -> Bool+isOctalDigit c = c == '0' || c == '1' || c == '2' || c == '3'+ || c == '4' || c == '5' || c == '6' || c == '7'++compileRegex :: String -> KateParser Regex #ifdef _PCRE_LIGHT-compileRegex regexpStr = compile ('.' : escapeRegex regexpStr) [anchored]+compileRegex regexpStr = return $ compile ('.' : convertOctal regexpStr) [anchored] #else compileRegex regexpStr =- case unsafePerformIO $ compile (compAnchored) (execNotEmpty) ('.' : escapeRegex regexpStr) of- Left _ -> error $ "Error compiling regex: " ++ show regexpStr- Right r -> r+ case unsafePerformIO $ compile (compAnchored) (execNotEmpty)+ ('.' : convertOctal regexpStr) of+ Left _ -> fail $ "Error compiling regex: " ++ show regexpStr+ Right r -> return r #endif -matchRegex :: Regex -> String -> Maybe [String]+matchRegex :: Regex -> String -> KateParser (Maybe [String]) #ifdef _PCRE_LIGHT-matchRegex r s = match r s [exec_notempty] +matchRegex r s = match r s [exec_notempty] #else-matchRegex r s = case unsafePerformIO (regexec r s) of - Right (Just (_, mat, _ , capts)) -> Just (mat : capts)- Right Nothing -> Nothing- Left matchError -> error $ show matchError+matchRegex r s = case unsafePerformIO (regexec r s) of+ Right (Just (_, mat, _ , capts)) -> return $ Just (mat : capts)+ Right Nothing -> return Nothing+ Left matchError -> fail $ show matchError #endif -pRegExpr :: Regex -> GenParser Char SyntaxState String+pRegExpr :: KateParser Regex -> KateParser String pRegExpr compiledRegex = do- st <- getState- let curLine = synStCurrentLine st- let charsParsedInLine = synStCharsParsedInLine st+ rest <- getInput+ prevChar <- fromState synStPrevChar -- Note: we keep one preceding character, so initial \b can match or not...- let remaining = if charsParsedInLine == 0- then ' ':curLine- else drop (charsParsedInLine - 1) curLine - case matchRegex compiledRegex remaining of- Just (x:xs) -> do if null xs- then return ()- else updateState (\st -> st {synStCaptures = xs})- string (drop 1 x) + let target = if prevChar == '\n'+ then ' ':rest+ else prevChar:rest+ regex <- compiledRegex+ matches <- matchRegex regex target+ case matches of+ Just (x:xs) | null x -> fail "Regex matched null string!"+ | otherwise -> do+ unless (null xs) $+ updateState (\st -> st {synStCaptures = xs})+ count (length x - 1) anyChar _ -> pzero -pRegExprDynamic :: [Char] -> GenParser Char SyntaxState String+pRegExprDynamic :: [Char] -> KateParser String pRegExprDynamic regexpStr = do regexpStr' <- subDynamic regexpStr- let compiledRegex = compileRegex regexpStr'- pRegExpr compiledRegex --escapeRegex :: String -> String-escapeRegex [] = ""-escapeRegex ('\\':'0':x:y:z:rest) | isDigit x && isDigit y && isDigit z =- chr (read ['0','o',x,y,z]) : escapeRegex rest-escapeRegex ('\\':x:y:z:rest) | isDigit x && isDigit y && isDigit z =- chr (read ['0','o',x,y,z]) : escapeRegex rest-escapeRegex (x:xs) = x : escapeRegex xs + pRegExpr $ compileRegex regexpStr' -integerRegex :: Regex+integerRegex :: KateParser Regex integerRegex = compileRegex "\\b[-+]?(0[Xx][0-9A-Fa-f]+|0[Oo][0-7]+|[0-9]+)\\b" -pInt :: GenParser Char SyntaxState String-pInt = pRegExpr integerRegex +pInt :: KateParser String+pInt = pRegExpr integerRegex -floatRegex :: Regex+floatRegex :: KateParser Regex floatRegex = compileRegex "\\b[-+]?(([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)\\b" -pFloat :: GenParser Char SyntaxState String+pFloat :: KateParser String pFloat = pRegExpr floatRegex -octRegex :: Regex+octRegex :: KateParser Regex octRegex = compileRegex "\\b[-+]?0[Oo][0-7]+\\b" -pHlCOct :: GenParser Char SyntaxState String+pHlCOct :: KateParser String pHlCOct = pRegExpr octRegex -hexRegex :: Regex+hexRegex :: KateParser Regex hexRegex = compileRegex "\\b[-+]?0[Xx][0-9A-Fa-f]+\\b" -pHlCHex :: GenParser Char SyntaxState String+pHlCHex :: KateParser String pHlCHex = pRegExpr hexRegex -pHlCStringChar :: GenParser Char st [Char]-pHlCStringChar = try $ do +pHlCStringChar :: KateParser [Char]+pHlCStringChar = try $ do char '\\' (oneOf "abefnrtv\"'?\\" >>= return . (\x -> ['\\',x]))- <|> (do a <- oneOf "xX"+ <|> (do a <- satisfy (\c -> c == 'x' || c == 'X') b <- many1 hexDigit return ('\\':a:b)) <|> (do a <- char '0' b <- many1 octDigit return ('\\':a:b)) -pHlCChar :: GenParser Char st [Char]+pHlCChar :: KateParser [Char] pHlCChar = try $ do char '\'' c <- pHlCStringChar char '\'' return ('\'' : c ++ "'") -pRangeDetect :: Char -> Char -> GenParser Char st [Char]+pRangeDetect :: Char -> Char -> KateParser [Char] pRangeDetect startChar endChar = try $ do char startChar- body <- manyTill (noneOf ['\n', endChar]) (char endChar)+ body <- manyTill (satisfy (/= endChar)) (char endChar) return $ startChar : (body ++ [endChar]) -pLineContinue :: GenParser Char st String-pLineContinue = try $ string "\\\n"+pLineContinue :: KateParser String+pLineContinue = try $ char '\\' >> eof >> return "\\" -pDetectSpaces :: GenParser Char st [Char]-pDetectSpaces = many1 (oneOf "\t ")+pDetectSpaces :: KateParser [Char]+pDetectSpaces = many1 (satisfy $ \c -> c == ' ' || c == '\t') -pDetectIdentifier :: GenParser Char st [Char]+pDetectIdentifier :: KateParser [Char] pDetectIdentifier = do first <- letter rest <- many alphaNum return (first:rest) -pHandleEndLine :: GenParser Char SyntaxState ()-pHandleEndLine = do- newline <|> (eof >> return '\n')- lineContents <- lookAhead wholeLine- updateState $ \st -> st { synStCurrentLine = lineContents- , synStCharsParsedInLine = 0- , synStPrevChar = '\n' }+fromState :: (SyntaxState -> a) -> KateParser a+fromState f = f `fmap` getState +mkParseSourceLine :: KateParser Token -- ^ parseExpressionInternal+ -> KateParser () -- ^ pEndline+ -> String+ -> State SyntaxState SourceLine+mkParseSourceLine parseExpressionInternal pEndLine ln = do+ modify $ \st -> st{ synStLineNumber = synStLineNumber st + 1 }+ st <- get+ let lineName = "line " ++ show (synStLineNumber st)+ let pline = do ts <- many parseExpressionInternal+ updateState $ \st -> st{ synStPrevChar = '\n' }+ pEndLine+ s <- getState+ return (s, ts)+ let (newst, result) = case runParser pline st lineName ln of+ Left _ -> (st, [(ErrorTok,ln)])+ Right (s,r) -> (s,r)+ put $! newst+ return $! normalizeHighlighting result
− Text/Highlighting/Kate/Definitions.hs
@@ -1,37 +0,0 @@-{- |- Module : Text.Highlighting.Kate.Definitions- Copyright : Copyright (C) 2008 John MacFarlane- License : GNU GPL, version 2 or above -- Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha - Portability : portable--Definitions for data structures needed by highlighting-kate.--}--module Text.Highlighting.Kate.Definitions where-import qualified Data.Map as Map---- | A stack of context names for each language. (Language-specific context--- stacks must be maintained because of IncludeRules.)-type ContextStack = Map.Map String [String]---- | State for syntax parser.-data SyntaxState = SyntaxState- { synStContexts :: ContextStack -- ^ Stack of contexts- , synStLanguage :: String -- ^ Language being parsed - , synStCurrentLine :: String -- ^ Contents of current line- , synStCharsParsedInLine :: Int -- ^ Num characters parsed in line- , synStPrevChar :: Char -- ^ Last character parsed- , synStCaseSensitive :: Bool -- ^ Language is case-sensitive- , synStKeywordCaseSensitive :: Bool -- ^ Keywords are case-sensitive- , synStCaptures :: [String] -- ^ List of regex captures from- -- last capturing match- } deriving (Read, Show)---- | A pair consisting of a list of attributes and some text.-type LabeledSource = ([String], String)---- | A line of source, list of labeled source items.-type SourceLine = [LabeledSource]
− Text/Highlighting/Kate/Format.hs
@@ -1,95 +0,0 @@-{- |- Module : Text.Highlighting.Kate.Format- Copyright : Copyright (C) 2008 John MacFarlane- License : GNU GPL, version 2 or above -- Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha - Portability : portable--Formatters that convert a list of annotated source lines to various output formats.--}--module Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..), defaultHighlightingCss ) where-import Text.Highlighting.Kate.Definitions-import Text.XHtml.Transitional-import Data.List (intersperse)---- | Options for formatters.-data FormatOption = OptNumberLines -- ^ Number lines- | OptNumberFrom Int -- ^ Number of first line- | OptLineAnchors -- ^ Anchors on each line number - | OptTitleAttributes -- ^ Include title attributes- | OptDetailed -- ^ Include detailed lexical information in classes.- -- (By default, only the default style is included. This- -- option causes output to be more verbose.)- | OptInline -- ^ Format as span-level, not block-level element- deriving (Eq, Show, Read)---- | Format a list of highlighted @SourceLine@s as XHtml.-formatAsXHtml :: [FormatOption] -- ^ Options- -> String -- ^ Language- -> [SourceLine] -- ^ Source lines to format- -> Html-formatAsXHtml opts lang lines =- let startNum = getStartNum opts- numberOfLines = length lines- code = thecode ! [theclass $ unwords ["sourceCode", lang]] << intersperse br (map (sourceLineToHtml opts) lines)- in if OptInline `elem` opts- then code- else if OptNumberLines `elem` opts- then let lnTitle = title "Click to toggle line numbers"- lnOnClick = strAttr "onclick" "with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"- nums = td ! [theclass "lineNumbers", lnTitle, lnOnClick] $ pre <<- (intersperse br $ map lineNum [startNum..(startNum + numberOfLines - 1)])- lineNum n = if OptLineAnchors `elem` opts- then anchor ! [identifier $ show n] << show n- else stringToHtml $ show n- sourceCode = td ! [theclass "sourceCode"] $ pre ! [theclass "sourceCode"] << code- in table ! [theclass "sourceCode"] $ tr << [nums, sourceCode]- else pre ! [theclass "sourceCode"] << code--labeledSourceToHtml :: [FormatOption] -> LabeledSource -> Html-labeledSourceToHtml _ ([], txt) = toHtml txt-labeledSourceToHtml opts (labs, txt) =- if null attribs- then toHtml txt- else thespan ! attribs << txt- where classes = unwords $- if OptDetailed `elem` opts- then map removeSpaces labs- else drop 1 labs -- first is specific- attribs = [theclass classes | not (null classes)] ++- [title classes | OptTitleAttributes `elem` opts]--sourceLineToHtml :: [FormatOption] -> SourceLine -> Html-sourceLineToHtml opts contents =- concatHtml $ map (labeledSourceToHtml opts) contents--removeSpaces :: String -> String-removeSpaces = filter (/= ' ')--getStartNum :: [FormatOption] -> Int-getStartNum [] = 1-getStartNum (OptNumberFrom n : _) = n-getStartNum (_:xs) = getStartNum xs--defaultHighlightingCss :: String-defaultHighlightingCss = - "table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre \n\ - \ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }\n\ - \td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }\n\ - \td.sourceCode { padding-left: 5px; }\n\ - \code.sourceCode span.kw { color: #007020; font-weight: bold; } \n\ - \code.sourceCode span.dt { color: #902000; }\n\ - \code.sourceCode span.dv { color: #40a070; }\n\ - \code.sourceCode span.bn { color: #40a070; }\n\ - \code.sourceCode span.fl { color: #40a070; }\n\ - \code.sourceCode span.ch { color: #4070a0; }\n\ - \code.sourceCode span.st { color: #4070a0; }\n\ - \code.sourceCode span.co { color: #60a0b0; font-style: italic; }\n\ - \code.sourceCode span.ot { color: #007020; }\n\ - \code.sourceCode span.al { color: red; font-weight: bold; }\n\ - \code.sourceCode span.fu { color: #06287e; }\n\ - \code.sourceCode span.re { }\n\ - \code.sourceCode span.er { color: red; font-weight: bold; }"
+ Text/Highlighting/Kate/Format/HTML.hs view
@@ -0,0 +1,127 @@+{- |+ Module : Text.Highlighting.Kate.Format.HTML+ Copyright : Copyright (C) 2008-2011 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Formatters that convert a list of annotated source lines to HTML.+-}++module Text.Highlighting.Kate.Format.HTML (+ formatHtmlInline, formatHtmlBlock, styleToHtml+ ) where+import Text.Highlighting.Kate.Types+import Text.Blaze+import qualified Text.Blaze.Html5 as H+import qualified Text.Blaze.Html5.Attributes as A+import Data.Monoid+import Data.List (intersperse)++-- | Format tokens using HTML spans inside @code@ tags. For example,+-- A @KeywordTok@ is rendered as a span with class @kw@.+-- Short class names correspond to 'TokenType's as follows:+-- 'KeywordTok' = @kw@, 'DataTypeTok' = @dt@,+-- 'DecValTok' = @dv@, 'BaseNTok' = @bn@, 'FloatTok' = @fl@,+-- 'CharTok' = @ch@, 'StringTok' = @st@, 'CommontTok' = @co@,+-- 'OtherTok' = @ot@, 'AlertTok' = @al@, 'FunctionTok' = @fu@,+-- 'RegionMarkerTok' = @re@, 'ErrorTok' = @er@. A 'NormalTok'+-- is not marked up at all.+formatHtmlInline :: FormatOptions -> [SourceLine] -> Html+formatHtmlInline opts = (H.code ! A.class_ (toValue $ unwords+ $ "sourceCode" : codeClasses opts))+ . mconcat . intersperse (toHtml "\n")+ . map (sourceLineToHtml opts)++tokenToHtml :: FormatOptions -> Token -> Html+tokenToHtml _ (NormalTok, txt) = toHtml txt+tokenToHtml opts (toktype, txt) =+ if titleAttributes opts+ then sp ! A.title (toValue $ show toktype)+ else sp+ where sp = H.span ! A.class_ (toValue $ short toktype) $ toHtml txt++short :: TokenType -> String+short KeywordTok = "kw"+short DataTypeTok = "dt"+short DecValTok = "dv"+short BaseNTok = "bn"+short FloatTok = "fl"+short CharTok = "ch"+short StringTok = "st"+short CommentTok = "co"+short OtherTok = "ot"+short AlertTok = "al"+short FunctionTok = "fu"+short RegionMarkerTok = "re"+short ErrorTok = "er"+short NormalTok = ""++sourceLineToHtml :: FormatOptions -> SourceLine -> Html+sourceLineToHtml opts contents = mapM_ (tokenToHtml opts) contents++formatHtmlBlockPre :: FormatOptions -> [SourceLine] -> Html+formatHtmlBlockPre opts = H.pre . formatHtmlInline opts++-- | Format tokens as an HTML @pre@ block. If line numbering is+-- selected, this is put into a table row with line numbers in the+-- left cell.+formatHtmlBlock :: FormatOptions -> [SourceLine] -> Html+formatHtmlBlock opts ls = container ! A.class_ (toValue $ unwords classes)+ where container = if numberLines opts+ then H.table $ H.tr ! A.class_ sourceCode+ $ nums >> source+ else pre+ sourceCode = toValue "sourceCode"+ classes = "sourceCode" :+ [x | x <- containerClasses opts, x /= "sourceCode"]+ pre = formatHtmlBlockPre opts ls+ source = H.td ! A.class_ sourceCode $ pre+ startNum = startNumber opts+ nums = H.td ! A.class_ (toValue "lineNumbers")+ $ H.pre+ $ mapM_ lineNum [startNum..(startNum + length ls - 1)]+ lineNum n = if lineAnchors opts+ then (H.a ! A.id (toValue $ show n) $ toHtml $ show n)+ >> toHtml "\n"+ else toHtml $ show n ++ "\n"++-- | Returns an HTML @style@ block with definitions for+-- formatting highlighted code according to the given style.+styleToHtml :: Style -> Html+styleToHtml f = H.style ! A.type_ (toValue "text/css") $ toHtml+ $ unlines $ tablespec ++ colorspec ++ map toCss (tokenStyles f)+ where colorspec = case (defaultColor f, backgroundColor f) of+ (Nothing, Nothing) -> []+ (Just c, Nothing) -> ["pre, code { color: " ++ fromColor c ++ "; }"]+ (Nothing, Just c) -> ["pre, code { background-color: " ++ fromColor c ++ "; }"]+ (Just c1, Just c2) -> ["pre, code { color: " ++ fromColor c1 ++ "; background-color: " +++ fromColor c2 ++ "; }"]+ tablespec = [+ "table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {"+ ," margin: 0; padding: 0; vertical-align: baseline; border: none; }"+ ,"table.sourceCode { " +++ maybe "" (\c -> "background-color: " ++ fromColor c ++ "; ") (backgroundColor f) +++ maybe "" (\c -> "color: " ++ fromColor c ++ "; ") (defaultColor f) +++ "}"+ ,"td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; " +++ maybe "" (\c -> "background-color: " ++ fromColor c ++ "; ") (lineNumberBackgroundColor f) +++ maybe "" (\c -> "color: " ++ fromColor c ++ "; ") (lineNumberColor f) +++ maybe "" (\c -> "border-right: 1px solid " ++ fromColor c ++ "; ") (lineNumberColor f) +++ "}"+ ,"td.sourceCode { padding-left: 5px; }"+ ]++toCss :: (TokenType, TokenStyle) -> String+toCss (t,tf) = "code > span." ++ short t ++ " { "+ ++ colorspec ++ backgroundspec ++ weightspec ++ stylespec+ ++ decorationspec ++ "}"+ where colorspec = maybe "" (\col -> "color: " ++ fromColor col ++ "; ") $ tokenColor tf+ backgroundspec = maybe "" (\col -> "background-color: " ++ fromColor col ++ "; ") $ tokenBackground tf+ weightspec = if tokenBold tf then "font-weight: bold; " else ""+ stylespec = if tokenItalic tf then "font-style: italic; " else ""+ decorationspec = if tokenUnderline tf then "text-decoration: underline; " else ""++
+ Text/Highlighting/Kate/Format/LaTeX.hs view
@@ -0,0 +1,125 @@+{- |+ Module : Text.Highlighting.Kate.Format.LaTeX+ Copyright : Copyright (C) 2008-2011 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Formatters that convert a list of annotated source lines to LaTeX.+-}++module Text.Highlighting.Kate.Format.LaTeX (+ formatLaTeXInline, formatLaTeXBlock, styleToLaTeX+ ) where+import Text.Highlighting.Kate.Types+import Text.Printf+import Data.List (intercalate)+import Control.Monad (mplus)+import Data.Char (isSpace)++formatLaTeX :: FormatOptions -> [SourceLine] -> String+formatLaTeX _ = intercalate "\n" . map sourceLineToLaTeX++-- | Formats tokens as LaTeX using custom commands inside+-- a @\\Highlight@ command. A @KeywordTok@ is rendered+-- using @\\KeywordTok{..}@, and so on.+formatLaTeXInline :: FormatOptions -> [SourceLine] -> String+formatLaTeXInline opts ls = "\\Verb{" ++ formatLaTeX opts ls ++ "}"++sourceLineToLaTeX :: SourceLine -> String+sourceLineToLaTeX contents = concatMap tokenToLaTeX contents++tokenToLaTeX :: Token -> String+tokenToLaTeX (NormalTok, txt) | all isSpace txt = escapeLaTeX txt+tokenToLaTeX (toktype, txt) = '\\':(show toktype ++ "{" ++ escapeLaTeX txt ++ "}")++escapeLaTeX :: String -> String+escapeLaTeX = concatMap escapeLaTeXChar+ where escapeLaTeXChar '\\' = "\\textbackslash{}"+ escapeLaTeXChar '{' = "\\{"+ escapeLaTeXChar '}' = "\\}"+ escapeLaTeXChar '|' = "\\textbar{}" -- used in inline verbatim+ escapeLaTeXChar x = [x]++-- LaTeX++-- | Format tokens as a LaTeX @Highlighting@ environment inside a+-- @Shaded@ environment. @Highlighting@ and @Shaded@ are+-- defined by the macros produced by 'styleToLaTeX'. @Highlighting@+-- is a verbatim environment using @fancyvrb@; @\\@, @{@, and @}@+-- have their normal meanings inside this environment, so that+-- formatting commands work. @Shaded@ is either nothing+-- (if the style's background color is default) or a @snugshade@+-- environment from @framed@, providing a background color+-- for the whole code block, even if it spans multiple pages.+formatLaTeXBlock :: FormatOptions -> [SourceLine] -> String+formatLaTeXBlock opts ls = unlines+ ["\\begin{Shaded}"+ ,"\\begin{Highlighting}[" +++ (if numberLines opts+ then "numbers=left," +++ (if startNumber opts == 1+ then ""+ else ",firstnumber=" ++ show (startNumber opts)) ++ ","+ else "") ++ "]"+ ,formatLaTeX opts ls+ ,"\\end{Highlighting}"+ ,"\\end{Shaded}"]++-- | Converts a 'Style' to a set of LaTeX macro definitions,+-- which should be placed in the document's preamble.+-- Note: default LaTeX setup doesn't allow boldface typewriter font.+-- To make boldface work in styles, you need to use a different typewriter+-- font. This will work for computer modern:+--+-- > \DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}+--+-- Or, with xelatex:+--+-- > \usepackage{fontspec}+-- > \setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}+-- > \setsansfont{Latin Modern Sans}+-- > \setmonofont[SmallCapsFont={Latin Modern Mono Caps}]{Latin Modern Mono Light}+--+styleToLaTeX :: Style -> String+styleToLaTeX f = unlines $+ [ "\\usepackage{color}"+ , "\\usepackage{fancyvrb}"+ , "\\DefineShortVerb[commandchars=\\\\\\{\\}]{\\|}"+ , "\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\}}"+ , "% Add ',fontsize=\\small' for more characters per line"+ ] +++ (case backgroundColor f of+ Nothing -> ["\\newenvironment{Shaded}{}{}"]+ Just (RGB r g b) -> ["\\usepackage{framed}"+ ,printf "\\definecolor{shadecolor}{RGB}{%d,%d,%d}" r g b+ ,"\\newenvironment{Shaded}{\\begin{snugshade}}{\\end{snugshade}}"])+ ++ map (macrodef (defaultColor f) (tokenStyles f)) (enumFromTo KeywordTok NormalTok)++macrodef :: Maybe Color -> [(TokenType, TokenStyle)] -> TokenType -> String+macrodef defaultcol tokstyles tokt = "\\newcommand{\\" ++ show tokt +++ "}[1]{" ++ (co . ul . bf . it . bg $ "{#1}") ++ "}"+ where tokf = case lookup tokt tokstyles of+ Nothing -> defStyle+ Just x -> x+ ul x = if tokenUnderline tokf+ then "\\underline{" ++ x ++ "}"+ else x+ it x = if tokenItalic tokf+ then "\\textit{" ++ x ++ "}"+ else x+ bf x = if tokenBold tokf+ then "\\textbf{" ++ x ++ "}"+ else x+ bcol = fromColor `fmap` tokenBackground tokf :: Maybe (Double, Double, Double)+ bg x = case bcol of+ Nothing -> x+ Just (r, g, b) -> printf "\\colorbox[rgb]{%0.2f,%0.2f,%0.2f}{%s}" r g b x+ col = fromColor `fmap`+ (tokenColor tokf `mplus` defaultcol) :: Maybe (Double, Double, Double)+ co x = case col of+ Nothing -> x+ Just (r, g, b) -> printf "\\textcolor[rgb]{%0.2f,%0.2f,%0.2f}{%s}" r g b x+
+ Text/Highlighting/Kate/Styles.hs view
@@ -0,0 +1,140 @@+{- |+ Module : Text.Highlighting.Kate.Styles+ Copyright : Copyright (C) 2011 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Styles for rendering annotated source lines.+-}++module Text.Highlighting.Kate.Styles ( pygments, kate, espresso, tango,+ haddock, monochrome )+where+import Text.Highlighting.Kate.Types++-- | Style based on pygments's default colors.+pygments :: Style+pygments = Style{+ backgroundColor = Nothing+ , defaultColor = Nothing+ , lineNumberColor = toColor "#aaaaaa"+ , lineNumberBackgroundColor = Nothing+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenColor = toColor "#007020", tokenBold = True })+ , (DataTypeTok, defStyle{ tokenColor = toColor "#902000" })+ , (DecValTok, defStyle{ tokenColor = toColor "#40a070" })+ , (BaseNTok, defStyle{ tokenColor = toColor "#40a070" })+ , (FloatTok, defStyle{ tokenColor = toColor "#40a070" })+ , (CharTok, defStyle{ tokenColor = toColor "#4070a0" })+ , (StringTok, defStyle{ tokenColor = toColor "#4070a0" })+ , (CommentTok, defStyle{ tokenColor = toColor "#60a0b0", tokenItalic = True })+ , (OtherTok, defStyle{ tokenColor = toColor "#007020" })+ , (AlertTok, defStyle{ tokenColor = toColor "#ff0000", tokenBold = True })+ , (FunctionTok, defStyle{ tokenColor = toColor "#06287e" })+ , (ErrorTok, defStyle{ tokenColor = toColor "#ff0000", tokenBold = True })+ ]+ }++-- | Style based on kate's default colors.+kate :: Style+kate = Style{+ backgroundColor = Nothing+ , defaultColor = Nothing+ , lineNumberColor = Nothing+ , lineNumberBackgroundColor = toColor "#dddddd"+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenBold = True })+ , (DataTypeTok, defStyle{ tokenColor = toColor "#800000" })+ , (DecValTok, defStyle{ tokenColor = toColor "#0000FF" })+ , (BaseNTok, defStyle{ tokenColor = toColor "#0000FF" })+ , (FloatTok, defStyle{ tokenColor = toColor "#800080" })+ , (CharTok, defStyle{ tokenColor = toColor "#FF00FF" })+ , (StringTok, defStyle{ tokenColor = toColor "#DD0000" })+ , (CommentTok, defStyle{ tokenColor = toColor "#808080", tokenItalic = True })+ , (AlertTok, defStyle{ tokenColor = toColor "#00ff00", tokenBold = True })+ , (FunctionTok, defStyle{ tokenColor = toColor "#000080" })+ , (ErrorTok, defStyle{ tokenColor = toColor "#ff0000", tokenBold = True })+ ]+ }++-- | Style based on pygments's tango colors.+tango :: Style+tango = Style{+ backgroundColor = toColor "#f8f8f8"+ , defaultColor = Nothing+ , lineNumberColor = toColor "#aaaaaa"+ , lineNumberBackgroundColor = Nothing+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenColor = toColor "#204a87", tokenBold = True })+ , (DataTypeTok, defStyle{ tokenColor = toColor "#204a87" })+ , (DecValTok, defStyle{ tokenColor = toColor "#0000cf" })+ , (BaseNTok, defStyle{ tokenColor = toColor "#0000cf" })+ , (FloatTok, defStyle{ tokenColor = toColor "#0000cf" })+ , (CharTok, defStyle{ tokenColor = toColor "#4e9a06" })+ , (StringTok, defStyle{ tokenColor = toColor "#4e9a06" })+ , (CommentTok, defStyle{ tokenColor = toColor "#8f5902", tokenItalic = True })+ , (OtherTok, defStyle{ tokenColor = toColor "#8f5902" })+ , (AlertTok, defStyle{ tokenColor = toColor "#ef2929" })+ , (FunctionTok, defStyle{ tokenColor = toColor "#000000" })+ , (ErrorTok, defStyle{ tokenColor = toColor "a40000", tokenBold = True })+ ]+ }++-- | Style based on ultraviolet's espresso_libre.css (dark background).+espresso :: Style+espresso = Style{+ backgroundColor = toColor "#2A211C"+ , defaultColor = toColor "#BDAE9D"+ , lineNumberColor = toColor "#BDAE9D"+ , lineNumberBackgroundColor = toColor "#2A211C"+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenColor = toColor "#43A8ED", tokenBold = True })+ , (DataTypeTok, defStyle{ tokenUnderline = True })+ , (DecValTok, defStyle{ tokenColor = toColor "#44AA43" })+ , (BaseNTok, defStyle{ tokenColor = toColor "#44AA43" })+ , (FloatTok, defStyle{ tokenColor = toColor "#44AA43" })+ , (CharTok, defStyle{ tokenColor = toColor "#049B0A" })+ , (StringTok, defStyle{ tokenColor = toColor "#049B0A" })+ , (CommentTok, defStyle{ tokenColor = toColor "#0066FF", tokenItalic = True })+ , (AlertTok, defStyle{ tokenColor = toColor "#ffff00" })+ , (FunctionTok, defStyle{ tokenColor = toColor "#FF9358", tokenBold = True })+ , (ErrorTok, defStyle{ tokenColor = toColor "ffff00", tokenBold = True })+ ]+ }++-- | Style based on haddock's source highlighting.+haddock :: Style+haddock = Style{+ backgroundColor = Nothing+ , defaultColor = Nothing+ , lineNumberColor = toColor "#aaaaaa"+ , lineNumberBackgroundColor = Nothing+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenColor = toColor "#0000FF" })+ , (CharTok, defStyle{ tokenColor = toColor "#008080" })+ , (StringTok, defStyle{ tokenColor = toColor "#008080" })+ , (CommentTok, defStyle{ tokenColor = toColor "#008000" })+ , (OtherTok, defStyle{ tokenColor = toColor "#ff4000" })+ , (AlertTok, defStyle{ tokenColor = toColor "#ff0000" })+ , (ErrorTok, defStyle{ tokenColor = toColor "ff0000", tokenBold = True })+ ]+ }++-- | Style with no colors.+monochrome :: Style+monochrome = Style{+ backgroundColor = Nothing+ , defaultColor = Nothing+ , lineNumberColor = Nothing+ , lineNumberBackgroundColor = Nothing+ , tokenStyles =+ [ (KeywordTok, defStyle{ tokenBold = True })+ , (DataTypeTok, defStyle{ tokenUnderline = True })+ , (CommentTok, defStyle{ tokenItalic = True })+ , (AlertTok, defStyle{ tokenBold = True })+ , (ErrorTok, defStyle{ tokenBold = True })+ ]+ }
Text/Highlighting/Kate/Syntax.hs view
@@ -1,7 +1,19 @@+{- |+ Module : Text.Highlighting.Kate.Syntax+ Copyright : Copyright (C) 2008-2011 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Token lexer for various languages.+-}+ module Text.Highlighting.Kate.Syntax ( highlightAs, languages, languagesByExtension, languagesByFilename ) where import Data.Char (toLower)-import Text.Highlighting.Kate.Definitions+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common (matchGlobs) import qualified Text.Highlighting.Kate.Syntax.Actionscript as Actionscript import qualified Text.Highlighting.Kate.Syntax.Ada as Ada@@ -28,7 +40,6 @@ import qualified Text.Highlighting.Kate.Syntax.Diff as Diff import qualified Text.Highlighting.Kate.Syntax.Djangotemplate as Djangotemplate import qualified Text.Highlighting.Kate.Syntax.Doxygen as Doxygen-import qualified Text.Highlighting.Kate.Syntax.Doxygenlua as Doxygenlua import qualified Text.Highlighting.Kate.Syntax.Dtd as Dtd import qualified Text.Highlighting.Kate.Syntax.Eiffel as Eiffel import qualified Text.Highlighting.Kate.Syntax.Email as Email@@ -40,7 +51,6 @@ import qualified Text.Highlighting.Kate.Syntax.Haskell as Haskell import qualified Text.Highlighting.Kate.Syntax.Haxe as Haxe import qualified Text.Highlighting.Kate.Syntax.Html as Html-import qualified Text.Highlighting.Kate.Syntax.Ilerpg as Ilerpg import qualified Text.Highlighting.Kate.Syntax.Ini as Ini import qualified Text.Highlighting.Kate.Syntax.Java as Java import qualified Text.Highlighting.Kate.Syntax.Javadoc as Javadoc@@ -55,7 +65,6 @@ import qualified Text.Highlighting.Kate.Syntax.Mandoc as Mandoc import qualified Text.Highlighting.Kate.Syntax.Matlab as Matlab import qualified Text.Highlighting.Kate.Syntax.Maxima as Maxima-import qualified Text.Highlighting.Kate.Syntax.Mediawiki as Mediawiki import qualified Text.Highlighting.Kate.Syntax.Metafont as Metafont import qualified Text.Highlighting.Kate.Syntax.Mips as Mips import qualified Text.Highlighting.Kate.Syntax.Modula2 as Modula2@@ -90,7 +99,6 @@ import qualified Text.Highlighting.Kate.Syntax.Texinfo as Texinfo import qualified Text.Highlighting.Kate.Syntax.Verilog as Verilog import qualified Text.Highlighting.Kate.Syntax.Vhdl as Vhdl-import qualified Text.Highlighting.Kate.Syntax.Xharbour as Xharbour import qualified Text.Highlighting.Kate.Syntax.Xml as Xml import qualified Text.Highlighting.Kate.Syntax.Xorg as Xorg import qualified Text.Highlighting.Kate.Syntax.Xslt as Xslt@@ -100,11 +108,11 @@ -- | List of supported languages. languages :: [String]-languages = ["Actionscript","Ada","Alert","Alert_indent","Apache","Asn1","Asp","Awk","Bash","Bibtex","Boo","C","Changelog","Clojure","Cmake","Coffeescript","Coldfusion","Commonlisp","Cpp","Cs","Css","D","Diff","Djangotemplate","Doxygen","Doxygenlua","Dtd","Eiffel","Email","Erlang","Fortran","Fsharp","Gnuassembler","Go","Haskell","Haxe","Html","Ilerpg","Ini","Java","Javadoc","Javascript","Json","Jsp","Latex","Lex","LiterateHaskell","Lua","Makefile","Mandoc","Matlab","Maxima","Mediawiki","Metafont","Mips","Modula2","Modula3","Monobasic","Nasm","Noweb","Objectivec","Objectivecpp","Ocaml","Octave","Pascal","Perl","Php","Pike","Postscript","Prolog","Python","R","Relaxngcompact","Rhtml","Ruby","Scala","Scheme","Sci","Sed","Sgml","Sql","SqlMysql","SqlPostgresql","Tcl","Texinfo","Verilog","Vhdl","Xharbour","Xml","Xorg","Xslt","Xul","Yacc","Yaml"]+languages = ["Actionscript","Ada","Alert","Alert_indent","Apache","Asn1","Asp","Awk","Bash","Bibtex","Boo","C","Changelog","Clojure","Cmake","Coffeescript","Coldfusion","Commonlisp","Cpp","Cs","Css","D","Diff","Djangotemplate","Doxygen","Dtd","Eiffel","Email","Erlang","Fortran","Fsharp","Gnuassembler","Go","Haskell","Haxe","Html","Ini","Java","Javadoc","Javascript","Json","Jsp","Latex","Lex","LiterateHaskell","Lua","Makefile","Mandoc","Matlab","Maxima","Metafont","Mips","Modula2","Modula3","Monobasic","Nasm","Noweb","Objectivec","Objectivecpp","Ocaml","Octave","Pascal","Perl","Php","Pike","Postscript","Prolog","Python","R","Relaxngcompact","Rhtml","Ruby","Scala","Scheme","Sci","Sed","Sgml","Sql","SqlMysql","SqlPostgresql","Tcl","Texinfo","Verilog","Vhdl","Xml","Xorg","Xslt","Xul","Yacc","Yaml"] -- | List of language extensions. languageExtensions :: [(String, String)]-languageExtensions = [("Actionscript", Actionscript.syntaxExtensions), ("Ada", Ada.syntaxExtensions), ("Alert", Alert.syntaxExtensions), ("Alert_indent", Alert_indent.syntaxExtensions), ("Apache", Apache.syntaxExtensions), ("Asn1", Asn1.syntaxExtensions), ("Asp", Asp.syntaxExtensions), ("Awk", Awk.syntaxExtensions), ("Bash", Bash.syntaxExtensions), ("Bibtex", Bibtex.syntaxExtensions), ("Boo", Boo.syntaxExtensions), ("C", C.syntaxExtensions), ("Changelog", Changelog.syntaxExtensions), ("Clojure", Clojure.syntaxExtensions), ("Cmake", Cmake.syntaxExtensions), ("Coffeescript", Coffeescript.syntaxExtensions), ("Coldfusion", Coldfusion.syntaxExtensions), ("Commonlisp", Commonlisp.syntaxExtensions), ("Cpp", Cpp.syntaxExtensions), ("Cs", Cs.syntaxExtensions), ("Css", Css.syntaxExtensions), ("D", D.syntaxExtensions), ("Diff", Diff.syntaxExtensions), ("Djangotemplate", Djangotemplate.syntaxExtensions), ("Doxygen", Doxygen.syntaxExtensions), ("Doxygenlua", Doxygenlua.syntaxExtensions), ("Dtd", Dtd.syntaxExtensions), ("Eiffel", Eiffel.syntaxExtensions), ("Email", Email.syntaxExtensions), ("Erlang", Erlang.syntaxExtensions), ("Fortran", Fortran.syntaxExtensions), ("Fsharp", Fsharp.syntaxExtensions), ("Gnuassembler", Gnuassembler.syntaxExtensions), ("Go", Go.syntaxExtensions), ("Haskell", Haskell.syntaxExtensions), ("Haxe", Haxe.syntaxExtensions), ("Html", Html.syntaxExtensions), ("Ilerpg", Ilerpg.syntaxExtensions), ("Ini", Ini.syntaxExtensions), ("Java", Java.syntaxExtensions), ("Javadoc", Javadoc.syntaxExtensions), ("Javascript", Javascript.syntaxExtensions), ("Json", Json.syntaxExtensions), ("Jsp", Jsp.syntaxExtensions), ("Latex", Latex.syntaxExtensions), ("Lex", Lex.syntaxExtensions), ("LiterateHaskell", LiterateHaskell.syntaxExtensions), ("Lua", Lua.syntaxExtensions), ("Makefile", Makefile.syntaxExtensions), ("Mandoc", Mandoc.syntaxExtensions), ("Matlab", Matlab.syntaxExtensions), ("Maxima", Maxima.syntaxExtensions), ("Mediawiki", Mediawiki.syntaxExtensions), ("Metafont", Metafont.syntaxExtensions), ("Mips", Mips.syntaxExtensions), ("Modula2", Modula2.syntaxExtensions), ("Modula3", Modula3.syntaxExtensions), ("Monobasic", Monobasic.syntaxExtensions), ("Nasm", Nasm.syntaxExtensions), ("Noweb", Noweb.syntaxExtensions), ("Objectivec", Objectivec.syntaxExtensions), ("Objectivecpp", Objectivecpp.syntaxExtensions), ("Ocaml", Ocaml.syntaxExtensions), ("Octave", Octave.syntaxExtensions), ("Pascal", Pascal.syntaxExtensions), ("Perl", Perl.syntaxExtensions), ("Php", Php.syntaxExtensions), ("Pike", Pike.syntaxExtensions), ("Postscript", Postscript.syntaxExtensions), ("Prolog", Prolog.syntaxExtensions), ("Python", Python.syntaxExtensions), ("R", R.syntaxExtensions), ("Relaxngcompact", Relaxngcompact.syntaxExtensions), ("Rhtml", Rhtml.syntaxExtensions), ("Ruby", Ruby.syntaxExtensions), ("Scala", Scala.syntaxExtensions), ("Scheme", Scheme.syntaxExtensions), ("Sci", Sci.syntaxExtensions), ("Sed", Sed.syntaxExtensions), ("Sgml", Sgml.syntaxExtensions), ("Sql", Sql.syntaxExtensions), ("SqlMysql", SqlMysql.syntaxExtensions), ("SqlPostgresql", SqlPostgresql.syntaxExtensions), ("Tcl", Tcl.syntaxExtensions), ("Texinfo", Texinfo.syntaxExtensions), ("Verilog", Verilog.syntaxExtensions), ("Vhdl", Vhdl.syntaxExtensions), ("Xharbour", Xharbour.syntaxExtensions), ("Xml", Xml.syntaxExtensions), ("Xorg", Xorg.syntaxExtensions), ("Xslt", Xslt.syntaxExtensions), ("Xul", Xul.syntaxExtensions), ("Yacc", Yacc.syntaxExtensions), ("Yaml", Yaml.syntaxExtensions)]+languageExtensions = [("Actionscript", Actionscript.syntaxExtensions), ("Ada", Ada.syntaxExtensions), ("Alert", Alert.syntaxExtensions), ("Alert_indent", Alert_indent.syntaxExtensions), ("Apache", Apache.syntaxExtensions), ("Asn1", Asn1.syntaxExtensions), ("Asp", Asp.syntaxExtensions), ("Awk", Awk.syntaxExtensions), ("Bash", Bash.syntaxExtensions), ("Bibtex", Bibtex.syntaxExtensions), ("Boo", Boo.syntaxExtensions), ("C", C.syntaxExtensions), ("Changelog", Changelog.syntaxExtensions), ("Clojure", Clojure.syntaxExtensions), ("Cmake", Cmake.syntaxExtensions), ("Coffeescript", Coffeescript.syntaxExtensions), ("Coldfusion", Coldfusion.syntaxExtensions), ("Commonlisp", Commonlisp.syntaxExtensions), ("Cpp", Cpp.syntaxExtensions), ("Cs", Cs.syntaxExtensions), ("Css", Css.syntaxExtensions), ("D", D.syntaxExtensions), ("Diff", Diff.syntaxExtensions), ("Djangotemplate", Djangotemplate.syntaxExtensions), ("Doxygen", Doxygen.syntaxExtensions), ("Dtd", Dtd.syntaxExtensions), ("Eiffel", Eiffel.syntaxExtensions), ("Email", Email.syntaxExtensions), ("Erlang", Erlang.syntaxExtensions), ("Fortran", Fortran.syntaxExtensions), ("Fsharp", Fsharp.syntaxExtensions), ("Gnuassembler", Gnuassembler.syntaxExtensions), ("Go", Go.syntaxExtensions), ("Haskell", Haskell.syntaxExtensions), ("Haxe", Haxe.syntaxExtensions), ("Html", Html.syntaxExtensions), ("Ini", Ini.syntaxExtensions), ("Java", Java.syntaxExtensions), ("Javadoc", Javadoc.syntaxExtensions), ("Javascript", Javascript.syntaxExtensions), ("Json", Json.syntaxExtensions), ("Jsp", Jsp.syntaxExtensions), ("Latex", Latex.syntaxExtensions), ("Lex", Lex.syntaxExtensions), ("LiterateHaskell", LiterateHaskell.syntaxExtensions), ("Lua", Lua.syntaxExtensions), ("Makefile", Makefile.syntaxExtensions), ("Mandoc", Mandoc.syntaxExtensions), ("Matlab", Matlab.syntaxExtensions), ("Maxima", Maxima.syntaxExtensions), ("Metafont", Metafont.syntaxExtensions), ("Mips", Mips.syntaxExtensions), ("Modula2", Modula2.syntaxExtensions), ("Modula3", Modula3.syntaxExtensions), ("Monobasic", Monobasic.syntaxExtensions), ("Nasm", Nasm.syntaxExtensions), ("Noweb", Noweb.syntaxExtensions), ("Objectivec", Objectivec.syntaxExtensions), ("Objectivecpp", Objectivecpp.syntaxExtensions), ("Ocaml", Ocaml.syntaxExtensions), ("Octave", Octave.syntaxExtensions), ("Pascal", Pascal.syntaxExtensions), ("Perl", Perl.syntaxExtensions), ("Php", Php.syntaxExtensions), ("Pike", Pike.syntaxExtensions), ("Postscript", Postscript.syntaxExtensions), ("Prolog", Prolog.syntaxExtensions), ("Python", Python.syntaxExtensions), ("R", R.syntaxExtensions), ("Relaxngcompact", Relaxngcompact.syntaxExtensions), ("Rhtml", Rhtml.syntaxExtensions), ("Ruby", Ruby.syntaxExtensions), ("Scala", Scala.syntaxExtensions), ("Scheme", Scheme.syntaxExtensions), ("Sci", Sci.syntaxExtensions), ("Sed", Sed.syntaxExtensions), ("Sgml", Sgml.syntaxExtensions), ("Sql", Sql.syntaxExtensions), ("SqlMysql", SqlMysql.syntaxExtensions), ("SqlPostgresql", SqlPostgresql.syntaxExtensions), ("Tcl", Tcl.syntaxExtensions), ("Texinfo", Texinfo.syntaxExtensions), ("Verilog", Verilog.syntaxExtensions), ("Vhdl", Vhdl.syntaxExtensions), ("Xml", Xml.syntaxExtensions), ("Xorg", Xorg.syntaxExtensions), ("Xslt", Xslt.syntaxExtensions), ("Xul", Xul.syntaxExtensions), ("Yacc", Yacc.syntaxExtensions), ("Yaml", Yaml.syntaxExtensions)] -- | Returns a list of languages appropriate for the given file extension. languagesByExtension :: String -> [String]@@ -115,10 +123,15 @@ languagesByFilename :: FilePath -> [String] languagesByFilename fn = [lang | (lang, globs) <- languageExtensions, matchGlobs fn globs] --- | Highlight source code using a specified syntax definition.-highlightAs :: String -- ^ Language syntax- -> String -- ^ Source code to highlight- -> Either String [SourceLine] -- ^ Either error message or result+-- | Highlight source code. The source language may be specified+-- by its canonical name (case-insensitive) or by a canonical+-- extension (if unique).+-- The parsers read the input lazily and parse line by line;+-- results are returned immediately.+-- Supported languages: @actionscript@, @ada@, @alert@, @alert_indent@, @apache@, @asn1@, @asp@, @awk@, @bash@, @bibtex@, @boo@, @c@, @changelog@, @clojure@, @cmake@, @coffeescript@, @coldfusion@, @commonlisp@, @cpp@, @cs@, @css@, @d@, @diff@, @djangotemplate@, @doxygen@, @dtd@, @eiffel@, @email@, @erlang@, @fortran@, @fsharp@, @gnuassembler@, @go@, @haskell@, @haxe@, @html@, @ini@, @java@, @javadoc@, @javascript@, @json@, @jsp@, @latex@, @lex@, @literatehaskell@, @lua@, @makefile@, @mandoc@, @matlab@, @maxima@, @metafont@, @mips@, @modula2@, @modula3@, @monobasic@, @nasm@, @noweb@, @objectivec@, @objectivecpp@, @ocaml@, @octave@, @pascal@, @perl@, @php@, @pike@, @postscript@, @prolog@, @python@, @r@, @relaxngcompact@, @rhtml@, @ruby@, @scala@, @scheme@, @sci@, @sed@, @sgml@, @sql@, @sqlmysql@, @sqlpostgresql@, @tcl@, @texinfo@, @verilog@, @vhdl@, @xml@, @xorg@, @xslt@, @xul@, @yacc@, @yaml@.+highlightAs :: String -- ^ Language syntax (e.g. "haskell") or extension (e.g. "hs").+ -> String -- ^ Source code to highlight+ -> [SourceLine] -- ^ List of highlighted source lines highlightAs lang = let lang' = map toLower lang lang'' = if lang' `elem` map (map toLower) languages@@ -152,7 +165,6 @@ "diff" -> Diff.highlight "djangotemplate" -> Djangotemplate.highlight "doxygen" -> Doxygen.highlight- "doxygenlua" -> Doxygenlua.highlight "dtd" -> Dtd.highlight "eiffel" -> Eiffel.highlight "email" -> Email.highlight@@ -164,7 +176,6 @@ "haskell" -> Haskell.highlight "haxe" -> Haxe.highlight "html" -> Html.highlight- "ilerpg" -> Ilerpg.highlight "ini" -> Ini.highlight "java" -> Java.highlight "javadoc" -> Javadoc.highlight@@ -179,7 +190,6 @@ "mandoc" -> Mandoc.highlight "matlab" -> Matlab.highlight "maxima" -> Maxima.highlight- "mediawiki" -> Mediawiki.highlight "metafont" -> Metafont.highlight "mips" -> Mips.highlight "modula2" -> Modula2.highlight@@ -214,11 +224,10 @@ "texinfo" -> Texinfo.highlight "verilog" -> Verilog.highlight "vhdl" -> Vhdl.highlight- "xharbour" -> Xharbour.highlight "xml" -> Xml.highlight "xorg" -> Xorg.highlight "xslt" -> Xslt.highlight "xul" -> Xul.highlight "yacc" -> Yacc.highlight "yaml" -> Yaml.highlight- _ -> (\_ -> Left ("Unknown language: " ++ lang))+ _ -> map (\l -> [(NormalTok, l)]) . lines
Text/Highlighting/Kate/Syntax.hs.in view
@@ -1,7 +1,19 @@+{- |+ Module : Text.Highlighting.Kate.Syntax+ Copyright : Copyright (C) 2008-2011 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Token lexer for various languages.+-}+ module Text.Highlighting.Kate.Syntax ( highlightAs, languages, languagesByExtension, languagesByFilename ) where import Data.Char (toLower)-import Text.Highlighting.Kate.Definitions+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common (matchGlobs) @imports@ @@ -22,10 +34,15 @@ languagesByFilename :: FilePath -> [String] languagesByFilename fn = [lang | (lang, globs) <- languageExtensions, matchGlobs fn globs] --- | Highlight source code using a specified syntax definition.-highlightAs :: String -- ^ Language syntax- -> String -- ^ Source code to highlight- -> Either String [SourceLine] -- ^ Either error message or result+-- | Highlight source code. The source language may be specified+-- by its canonical name (case-insensitive) or by a canonical+-- extension (if unique).+-- The parsers read the input lazily and parse line by line;+-- results are returned immediately.+-- Supported languages: @supportedlanguages@.+highlightAs :: String -- ^ Language syntax (e.g. "haskell") or extension (e.g. "hs").+ -> String -- ^ Source code to highlight+ -> [SourceLine] -- ^ List of highlighted source lines highlightAs lang = let lang' = map toLower lang lang'' = if lang' `elem` map (map toLower) languages@@ -35,4 +52,4 @@ _ -> lang' in case lang'' of @cases@- _ -> (\_ -> Left ("Unknown language: " ++ lang))+ _ -> map (\l -> [(NormalTok, l)]) . lines
Text/Highlighting/Kate/Syntax/Actionscript.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file actionscript.xml, version 1.0,- by Aaron Miller (armantic101@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file actionscript.xml, version 1.0, by Aaron Miller (armantic101@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Actionscript ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Actionscript+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Javadoc-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "ActionScript 2.0"@@ -20,60 +23,47 @@ syntaxExtensions = "*.as" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "ActionScript 2.0" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("ActionScript 2.0",["Normal"])], synStLanguage = "ActionScript 2.0", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("ActionScript 2.0",["Normal"])], synStLanguage = "ActionScript 2.0", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Member" -> (popContext) >> pEndLine "StaticImports" -> (popContext) >> pEndLine "Imports" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar 2" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("StaticImports","kw"),("Imports","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_properties = Set.fromList $ words $ "_accProps _focusrect _global _highquality _level _parent _quality _root _soundbuftime maxscroll scroll this" list_global'5ffunctions = Set.fromList $ words $ "asfunction call chr clearInterval duplicateMovieClip escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop ifFrameLoaded int isFinite isNaN length loadMovie loadMovieNum loadVariables loadVariablesNum mbchr mblength mbord mbsubstring nextFrame nextScene on onClipEvent ord parseFloat parseInt play prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip setInterval setProperty showRedrawRegions startDrag stop stopAllSounds stopDrag substring targetPath tellTarget toggleHighQuality trace typeof unescape unloadMovie unloadMovieNum updateAfterEvent"@@ -92,102 +82,96 @@ regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 = compileRegex "\\b[_a-zA-Z]\\w*(?=[\\s]*)" regex_'5cs'2a'2e'2a'24 = compileRegex "\\s*.*$" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Member","Normal Text"),("StaticImports","Normal Text"),("Imports","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Member",NormalTok),("StaticImports",NormalTok),("Imports",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute "Properties"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_global'5ffunctions >>= withAttribute "Global Functions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_classes >>= withAttribute "Classes"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_const >>= withAttribute "Constants"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pRegExpr regex_'5c'2e'7b3'2c3'7d'5cs'2b >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28import'5cs'2bstatic'29'5cb >>= withAttribute "Keyword") >>~ pushContext "StaticImports")- <|>- ((pRegExpr regex_'5cb'28package'7cimport'29'5cb >>= withAttribute "Keyword") >>~ pushContext "Imports")- <|>- ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute "Symbol") >>~ pushContext "Member")- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_global'5ffunctions >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_classes >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_const >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2e'7b3'2c3'7d'5cs'2b >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28import'5cs'2bstatic'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "StaticImports")+ <|>+ ((pRegExpr regex_'5cb'28package'7cimport'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "Imports")+ <|>+ ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute NormalTok) >>~ pushContext "Member")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Member" = - do (attr, result) <- (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute "Function") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Member" =+ (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "StaticImports" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'2e'2a'24 >>= withAttribute "StaticImports") >>~ (popContext))- return (attr, result)+parseRules "StaticImports" =+ ((pRegExpr regex_'5cs'2a'2e'2a'24 >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Imports" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'2e'2a'24 >>= withAttribute "Imports") >>~ (popContext))- return (attr, result)+parseRules "Imports" =+ ((pRegExpr regex_'5cs'2a'2e'2a'24 >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Commentar 1" = +parseRules "Commentar 1" = pzero -parseRules "Commentar 2" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar 2" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Ada.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file ada.xml, version 1.07,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file ada.xml, version 1.07, by -} -module Text.Highlighting.Kate.Syntax.Ada ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Ada+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Ada"@@ -19,57 +22,44 @@ syntaxExtensions = "*.adb;*.ads;*.ada;*.a" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Ada" } context <- currentContext <|> (pushContext "Default" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Ada",["Default"])], synStLanguage = "Ada", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Ada",["Default"])], synStLanguage = "Ada", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Default" -> return () >> pHandleEndLine+ "Default" -> return () "Region Marker" -> (popContext) >> pEndLine "String" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Pragmas","kw"),("Data Type","dt"),("Decimal","dv"),("Base-N","bn"),("Float","fl"),("Char","ch"),("String","st"),("Comment","co"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "abort abs abstract accept access aliased all and array at begin body constant declare delay delta digits do else elsif end entry exception exit for function generic goto in interface is limited mod new not null of or others out overriding package pragma private procedure protected raise range rem record renames requeue return reverse separate subtype tagged task terminate then type until use when while with xor" list_pragmas = Set.fromList $ words $ "all_calls_remote assert assertion_policy asynchronous atomic atomic_components attach_handler controlled convention detect_blocking discard_names elaborate elaborate_all elaborate_body export import inline inspection_point interrupt_handler interrupt_priority linker_options list locking_policy no_return normalize_scalars optimize pack page partition_elaboration_policy preelaborable_initialization preelaborate priority priority_specific_dispatching profile pure queuing_policy relative_deadline remote_call_interface remote_types restrictions reviewable shared_passive storage_size suppress task_dispatching_policy unchecked_union unsuppress volatile volatile_components"@@ -89,64 +79,62 @@ regex_'5cbend'5cb = compileRegex "\\bend\\b" regex_'27'2e'27 = compileRegex "'.'" -defaultAttributes = [("Default","Normal Text"),("Region Marker","Region Marker"),("String","String"),("Comment","Comment")]+defaultAttributes = [("Default",NormalTok),("Region Marker",RegionMarkerTok),("String",StringTok),("Comment",CommentTok)] -parseRules "Default" = - do (attr, result) <- (((pRegExpr regex_'5cbrecord'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2brecord'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbcase'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2bcase'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbif'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2bif'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbloop'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2bloop'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbselect'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2bselect'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cb >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pString False "-- BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pFirstNonSpace >> pString False "-- END" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragmas >>= withAttribute "Pragmas"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'27'2e'27 >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pAnyChar ":!%&()+,-/.*<=>|" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Default" =+ (((pRegExpr regex_'5cbrecord'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2brecord'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbcase'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2bcase'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2bif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbloop'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2bloop'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbselect'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2bselect'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cb >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pString False "-- BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pFirstNonSpace >> pString False "-- END" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragmas >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'27'2e'27 >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>|" >>= withAttribute NormalTok))) -parseRules "Region Marker" = +parseRules "Region Marker" = pzero -parseRules "String" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Comment" = +parseRules "Comment" = pzero parseRules "" = parseRules "Default"
Text/Highlighting/Kate/Syntax/Alert.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file alert.xml, version 1.08,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file alert.xml, version 1.08, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Alert ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Alert+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Alerts"@@ -19,63 +22,49 @@ syntaxExtensions = "" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Alerts" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Alerts",["Normal Text"])], synStLanguage = "Alerts", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Alerts",["Normal Text"])], synStLanguage = "Alerts", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of "Normal Text" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Alert","al")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_alerts = Set.fromList $ words $ "### ALERT BUG DANGER DEPRECATED FIXME HACK NOTE NOTICE SECURITY TASK TEST TESTING TODO WARNING" -defaultAttributes = [("Normal Text","Normal Text")]+defaultAttributes = [("Normal Text",NormalTok)] -parseRules "Normal Text" = - do (attr, result) <- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_alerts >>= withAttribute "Alert"))- return (attr, result)+parseRules "Normal Text" =+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_alerts >>= withAttribute AlertTok)) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Alert_indent.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file alert_indent.xml, version 1.08,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file alert_indent.xml, version 1.08, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Alert_indent ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Alert_indent+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Alerts_indent"@@ -19,63 +22,49 @@ syntaxExtensions = "" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Alerts_indent" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Alerts_indent",["Normal Text"])], synStLanguage = "Alerts_indent", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Alerts_indent",["Normal Text"])], synStLanguage = "Alerts_indent", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of "Normal Text" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Alert","al")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_alerts = Set.fromList $ words $ "### ALERT BUG DANGER DEPRECATED FIXME HACK NOTE NOTICE SECURITY TASK TEST TESTING TODO WARNING" -defaultAttributes = [("Normal Text","Normal Text")]+defaultAttributes = [("Normal Text",NormalTok)] -parseRules "Normal Text" = - do (attr, result) <- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_alerts >>= withAttribute "Alert"))- return (attr, result)+parseRules "Normal Text" =+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_alerts >>= withAttribute AlertTok)) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Apache.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file apache.xml, version 1.11,- by Jan Janssen (medhefgo@googlemail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file apache.xml, version 1.11, by Jan Janssen (medhefgo@googlemail.com) -} -module Text.Highlighting.Kate.Syntax.Apache ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Apache+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Apache Configuration"@@ -20,38 +23,30 @@ syntaxExtensions = "httpd.conf;httpd2.conf;apache.conf;apache2.conf;.htaccess*;.htpasswd*" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Apache Configuration" } context <- currentContext <|> (pushContext "apache" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Apache Configuration",["apache"])], synStLanguage = "Apache Configuration", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Apache Configuration",["apache"])], synStLanguage = "Apache Configuration", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "apache" -> return () >> pHandleEndLine+ "apache" -> return () "String Directives" -> (popContext) >> pEndLine "Integer Directives" -> (popContext) >> pEndLine "Alternative Directives" -> (popContext) >> pEndLine@@ -60,22 +55,17 @@ "Container Close" -> (popContext) >> pEndLine "Comment Alert" -> (popContext) >> pEndLine "Alert" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Directives","ot"),("String","st"),("Float","fl"),("Int","fl"),("Alternates","kw"),("Alert","er"),("Container","fu"),("Attribute","ot"),("Other","ch")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_String_Directives = Set.fromList $ words $ "acceptfilter accessfilename action addalt addaltbyencoding addaltbytype addcharset adddefaultcharset adddescription addencoding addhandler addicon addiconbyencoding addiconbytype addinputfilter addlanguage addmoduleinfo addoutputfilter addoutputfilterbytype addtype alias aliasmatch allow anonymous authbasicprovider authdbmgroupfile authdbmuserfile authdigestdomain authdigestfile authdigestgroupfile authdigestnonceformat authdigestprovider authgroupfile authldapbinddn authldapbindpassword authldapcharsetconfig authldapgroupattribute authldapurl authname authuserfile browsermatch browsermatchnocase bs2000account cachedisable cacheenable cachefile cachegcclean cachegcunused cacheroot cgimapextension charsetdefault charsetoptions charsetsourceenc cookiedomain cookielog cookiename coredumpdirectory customlog dav davgenericlockdb davlockdb dbdparams dbdpreparesql dbdriver defaulticon defaultlanguage defaulttype deflatefilternote deny directoryindex documentroot errordocument errorlog example expiresbytype expiresdefault extfilterdefine extfilteroptions filterchain filterdeclare filterprotocol filterprovider filtertrace forcetype forensiclog group header headername imapbase include indexignore indexoptions indexstylesheet isapicachefile languagepriority ldapsharedcachefile ldaptrustedca ldaptrustedcatype ldaptrustedclientcert ldaptrustedglobalcert listen loadfile loadmodule lockfile logformat metadir metasuffix mimemagicfile mmapfile namevirtualhost noproxy nwssltrustedcerts nwsslupgradeable passenv pidfile proxyblock proxydomain proxypass proxypassreverse proxypassreversecookiedomain proxypassreversecookiepath proxyremote proxyremotematch readmename redirect redirectmatch redirectpermanent redirecttemp removecharset removeencoding removehandler removeinputfilter removelanguage removeoutputfilter removetype requestheader require rewritebase rewritecond rewritelock rewritelog rewritemap rewriterule scoreboardfile script scriptalias scriptaliasmatch scriptlog scriptsock securelisten serveradmin serveralias servername serverpath serverroot setenv setenvif setenvifnocase sethandler setinputfilter setoutputfilter ssiendtag ssierrormsg ssistarttag ssitimeformat ssiundefinedecho sslcacertificatefile sslcacertificatepath sslcadnrequestfile sslcadnrequestpath sslcarevocationfile sslcarevocationpath sslcertificatechainfile sslcertificatefile sslcertificatekeyfile sslciphersuite sslcryptodevice sslhonorciperorder sslpassphrasedialog sslproxycacertificatefile sslproxycacertificatepath sslproxycarevocationfile sslproxycarevocationpath sslproxyciphersuite sslproxymachinecertificatefile sslproxymachinecertificatepath sslproxyprotocol sslrandomseed sslrequire sslrequiressl sslusername suexecusergroup transferlog typesconfig unsetenv user userdir virtualdocumentroot virtualdocumentrootip virtualscriptalias virtualscriptaliasip win32disableacceptex" list_Integer_Directives = Set.fromList $ words $ "allowconnect assignuserid authdigestnoncelifetime authdigestshmemsize cachedefaultexpire cachedirlength cachedirlevels cacheforcecompletion cachegcdaily cachegcinterval cachegcmemusage cachelastmodifiedfactor cachemaxexpire cachemaxfilesize cacheminfilesize cachesize cachetimemargin childperuserid cookieexpires davmintimeout dbdexptime dbdkeep dbdmax dbdmin dbdpersist deflatebuffersize deflatecompressionlevel deflatememlevel deflatewindowsize identitychecktimeout isapireadaheadbuffer keepalivetimeout ldapcacheentries ldapcachettl ldapconnectiontimeout ldapopcacheentries ldapopcachettl ldapsharedcachesize limitinternalrecursion limitrequestbody limitrequestfields limitrequestfieldsize limitrequestline limitxmlrequestbody listenbacklog maxclients maxkeepaliverequests maxmemfree maxrequestsperchild maxrequestsperthread maxspareservers maxsparethreads maxthreads maxthreadsperchild mcachemaxobjectcount mcachemaxobjectsize mcachemaxstreamingbuffer mcacheminobjectsize mcachesize minspareservers minsparethreads numservers proxyiobuffersize proxymaxforwards proxyreceivebuffersize proxytimeout rewriteloglevel rlimitcpu rlimitmem rlimitnproc scriptlogbuffer scriptloglength sendbuffersize serverlimit sslproxyverifydepth sslsessioncachetimeout sslverifydepth startservers startthreads threadlimit threadsperchild threadstacksize timeout"@@ -87,71 +77,63 @@ regex_'5b'5e'23'5d'2a = compileRegex "[^#]*" regex_'5b'5e'23'3e'5d'2a = compileRegex "[^#>]*" -defaultAttributes = [("apache","Normal Text"),("String Directives","Directives"),("Integer Directives","Other"),("Alternative Directives","Other"),("Comment","Comment"),("Container Open","Container"),("Container Close","Container"),("Comment Alert","Normal Text"),("Alert","Alert")]+defaultAttributes = [("apache",NormalTok),("String Directives",OtherTok),("Integer Directives",CharTok),("Alternative Directives",CharTok),("Comment",CommentTok),("Container Open",FunctionTok),("Container Close",FunctionTok),("Comment Alert",NormalTok),("Alert",ErrorTok)] -parseRules "apache" = - do (attr, result) <- (((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_String_Directives >>= withAttribute "Normal Text") >>~ pushContext "String Directives")- <|>- ((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Integer_Directives >>= withAttribute "Directives") >>~ pushContext "Integer Directives")- <|>- ((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Alternative_Directives >>= withAttribute "Directives") >>~ pushContext "Alternative Directives")- <|>- ((pRegExpr regex_'3c'5cw'2b >>= withAttribute "Container") >>~ pushContext "Container Open")- <|>- ((pRegExpr regex_'3c'2f'5cw'2b >>= withAttribute "Container") >>~ pushContext "Container Close")- <|>- ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)+parseRules "apache" =+ (((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_String_Directives >>= withAttribute NormalTok) >>~ pushContext "String Directives")+ <|>+ ((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Integer_Directives >>= withAttribute OtherTok) >>~ pushContext "Integer Directives")+ <|>+ ((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Alternative_Directives >>= withAttribute OtherTok) >>~ pushContext "Alternative Directives")+ <|>+ ((pRegExpr regex_'3c'5cw'2b >>= withAttribute FunctionTok) >>~ pushContext "Container Open")+ <|>+ ((pRegExpr regex_'3c'2f'5cw'2b >>= withAttribute FunctionTok) >>~ pushContext "Container Close")+ <|>+ ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")) -parseRules "String Directives" = - do (attr, result) <- (((pRegExpr regex_'5b'5e'23'5d'2a >>= withAttribute "String"))- <|>- ((parseRules "Comment Alert")))- return (attr, result)+parseRules "String Directives" =+ (((pRegExpr regex_'5b'5e'23'5d'2a >>= withAttribute StringTok))+ <|>+ ((parseRules "Comment Alert"))) -parseRules "Integer Directives" = - do (attr, result) <- (((pFloat >>= withAttribute "Float") >>~ pushContext "Integer Directives")- <|>- ((pInt >>= withAttribute "Int") >>~ pushContext "Integer Directives")- <|>- ((parseRules "Comment Alert")))- return (attr, result)+parseRules "Integer Directives" =+ (((pFloat >>= withAttribute FloatTok) >>~ pushContext "Integer Directives")+ <|>+ ((pInt >>= withAttribute FloatTok) >>~ pushContext "Integer Directives")+ <|>+ ((parseRules "Comment Alert"))) -parseRules "Alternative Directives" = - do (attr, result) <- (((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Alternates >>= withAttribute "Alternates"))- <|>- ((pDetectChar False '-' >>= withAttribute "Alternates"))- <|>- ((pDetectChar False '+' >>= withAttribute "Alternates"))- <|>- ((parseRules "Comment Alert")))- return (attr, result)+parseRules "Alternative Directives" =+ (((pKeyword " \n\t.():!+-<=>%&*/;?[]^{|}~\\" list_Alternates >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '-' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '+' >>= withAttribute KeywordTok))+ <|>+ ((parseRules "Comment Alert"))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Container Open" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Container") >>~ pushContext "Alert")- <|>- ((pRegExpr regex_'5b'5e'23'3e'5d'2a >>= withAttribute "Attribute"))- <|>- ((parseRules "Comment Alert")))- return (attr, result)+parseRules "Container Open" =+ (((pDetectChar False '>' >>= withAttribute FunctionTok) >>~ pushContext "Alert")+ <|>+ ((pRegExpr regex_'5b'5e'23'3e'5d'2a >>= withAttribute OtherTok))+ <|>+ ((parseRules "Comment Alert"))) -parseRules "Container Close" = - do (attr, result) <- ((pDetectChar False '>' >>= withAttribute "Container") >>~ pushContext "Alert")- return (attr, result)+parseRules "Container Close" =+ ((pDetectChar False '>' >>= withAttribute FunctionTok) >>~ pushContext "Alert") -parseRules "Comment Alert" = - do (attr, result) <- ((pDetectChar False '#' >>= withAttribute "Alert") >>~ pushContext "Alert")- return (attr, result)+parseRules "Comment Alert" =+ ((pDetectChar False '#' >>= withAttribute ErrorTok) >>~ pushContext "Alert") -parseRules "Alert" = +parseRules "Alert" = pzero parseRules "" = parseRules "apache"
Text/Highlighting/Kate/Syntax/Asn1.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file asn1.xml, version 1.00,- by Philippe Rigault -}+{- This module was generated from data in the Kate syntax+ highlighting file asn1.xml, version 1.00, by Philippe Rigault -} -module Text.Highlighting.Kate.Syntax.Asn1 ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Asn1+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "ASN.1"@@ -19,71 +22,57 @@ syntaxExtensions = "*.asn*.asn1" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "ASN.1" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("ASN.1",["Normal Text"])], synStLanguage = "ASN.1", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("ASN.1",["Normal Text"])], synStLanguage = "ASN.1", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine+ "Normal Text" -> return () "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Comment","co"),("Data Type","dt")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "DEFINITIONS BEGIN END EXPORTS IMPORTS FROM APPLICATION PRIVATE UNIVERSAL DEFAULT OPTIONAL FALSE TRUE" list_types = Set.fromList $ words $ "BOOLEAN INTEGER OCTET STRING NULL REAL ENUMERATED SEQUENCE SET CHOICE OF VisibleString StringStore" -defaultAttributes = [("Normal Text","Normal Text"),("Comment","Comment")]+defaultAttributes = [("Normal Text",NormalTok),("Comment",CommentTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)+parseRules "Normal Text" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "Comment")) -parseRules "Comment" = +parseRules "Comment" = pzero parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Asp.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file asp.xml, version 1.04,- by Antonio Salazar (savedfastcool@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file asp.xml, version 1.04, by Antonio Salazar (savedfastcool@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Asp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Asp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "ASP"@@ -19,66 +22,53 @@ syntaxExtensions = "*.asp;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "ASP" } context <- currentContext <|> (pushContext "nosource" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("ASP",["nosource"])], synStLanguage = "ASP", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("ASP",["nosource"])], synStLanguage = "ASP", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "nosource" -> return () >> pHandleEndLine- "aspsource" -> return () >> pHandleEndLine+ "nosource" -> return ()+ "aspsource" -> return () "asp_onelinecomment" -> (popContext) >> pEndLine- "doublequotestring" -> return () >> pHandleEndLine- "singlequotestring" -> return () >> pHandleEndLine- "htmltag" -> return () >> pHandleEndLine- "htmlcomment" -> return () >> pHandleEndLine- "identifiers" -> return () >> pHandleEndLine- "types1" -> return () >> pHandleEndLine- "types2" -> return () >> pHandleEndLine- "scripts" -> return () >> pHandleEndLine+ "doublequotestring" -> return ()+ "singlequotestring" -> return ()+ "htmltag" -> return ()+ "htmlcomment" -> return ()+ "identifiers" -> return ()+ "types1" -> return ()+ "types2" -> return ()+ "scripts" -> return () "scripts_onelinecomment" -> (popContext) >> pEndLine- "twolinecomment" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "twolinecomment" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","kw"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("String","st"),("Comment","co"),("Variable","kw"),("Control Structures","kw"),("Escape Code","kw"),("Other","ot"),("HTML Tag","kw"),("HTML Comment","co"),("Identifier","ot"),("Types","dt")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_control_structures = Set.fromList $ words $ "select case end select if then else elseif end if while do until loop wend for each to in next exit continue" list_keywords = Set.fromList $ words $ "dim redim preserve const erase nothing set new me function sub call class private public with randomize open close movenext execute eof not true false or and xor"@@ -118,211 +108,198 @@ regex_'5cs'2a'3d'5cs'2a = compileRegex "\\s*=\\s*" regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a = compileRegex "\\s*#?[a-zA-Z0-9]*" -defaultAttributes = [("nosource","Normal Text"),("aspsource","ASP Text"),("asp_onelinecomment","Comment"),("doublequotestring","String"),("singlequotestring","String"),("htmltag","Identifier"),("htmlcomment","HTML Comment"),("identifiers","Identifier"),("types1","Types"),("types2","Types"),("scripts","Normal Text"),("scripts_onelinecomment","Comment"),("twolinecomment","Comment")]+defaultAttributes = [("nosource",NormalTok),("aspsource",NormalTok),("asp_onelinecomment",CommentTok),("doublequotestring",StringTok),("singlequotestring",StringTok),("htmltag",OtherTok),("htmlcomment",CommentTok),("identifiers",OtherTok),("types1",DataTypeTok),("types2",DataTypeTok),("scripts",NormalTok),("scripts_onelinecomment",CommentTok),("twolinecomment",CommentTok)] -parseRules "nosource" = - do (attr, result) <- (((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pRegExpr regex_'3c'5cs'2ascript'5cs'2alanguage'3d'22VBScript'22'5b'5e'3e'5d'2a'3e >>= withAttribute "HTML Tag") >>~ pushContext "aspsource")- <|>- ((pRegExpr regex_'3c'5cs'2ascript'28'5cs'7c'3e'29 >>= withAttribute "HTML Tag") >>~ pushContext "scripts")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "htmltag")- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "htmlcomment"))- return (attr, result)+parseRules "nosource" =+ (((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pRegExpr regex_'3c'5cs'2ascript'5cs'2alanguage'3d'22VBScript'22'5b'5e'3e'5d'2a'3e >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pRegExpr regex_'3c'5cs'2ascript'28'5cs'7c'3e'29 >>= withAttribute KeywordTok) >>~ pushContext "scripts")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "htmltag")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "htmlcomment")) -parseRules "aspsource" = - do (attr, result) <- (((pString False "%>" >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Comment") >>~ pushContext "asp_onelinecomment")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "doublequotestring")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "singlequotestring")- <|>- ((pDetectChar False '&' >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_ >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5b0123456789'5d'2a'5c'2e'5c'2e'5c'2e'5b0123456789'5d'2a >>= withAttribute "String"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pAnyChar ";()}{:,[]" >>= withAttribute "Other"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute "Other"))- <|>- ((pRegExpr regex_'5cbelseif'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbelse'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbif'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbend_if'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbexit_function'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend_function'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbexit_sub'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbsub'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend_sub'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbclass'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend_class'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbexit_do'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbdo'28'5cs'2b'28while'29'29'3f'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbloop'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbexit_while'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbwhile'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbwend'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbexit_for'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbfor'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbnext'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbselect_case'5cb >>= withAttribute "Control Structures"))- <|>- ((pRegExpr regex_'5cbend_select'5cb >>= withAttribute "Control Structures"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_control_structures >>= withAttribute "Control Structures"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function")))- return (attr, result)+parseRules "aspsource" =+ (((pString False "%>" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CommentTok) >>~ pushContext "asp_onelinecomment")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "doublequotestring")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "singlequotestring")+ <|>+ ((pDetectChar False '&' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_ >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5b0123456789'5d'2a'5c'2e'5c'2e'5c'2e'5b0123456789'5d'2a >>= withAttribute StringTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pAnyChar ";()}{:,[]" >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cbelseif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbelse'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend_if'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbexit_function'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend_function'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbexit_sub'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbsub'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend_sub'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbclass'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend_class'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbexit_do'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdo'28'5cs'2b'28while'29'29'3f'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbloop'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbexit_while'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbwhile'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbwend'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbexit_for'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfor'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbnext'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbselect_case'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend_select'5cb >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_control_structures >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute KeywordTok))) -parseRules "asp_onelinecomment" = - do (attr, result) <- ((pString False "%>" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- return (attr, result)+parseRules "asp_onelinecomment" =+ ((pString False "%>" >>= withAttribute KeywordTok) >>~ (popContext >> popContext)) -parseRules "doublequotestring" = - do (attr, result) <- (((pDetect2Chars False '"' '"' >>= withAttribute "Escape Code"))- <|>- ((pRegExpr regex_'5c'5c'5b0'2d7'5d'7b1'2c3'7d >>= withAttribute "Escape Code"))- <|>- ((pRegExpr regex_'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b1'2c2'7d >>= withAttribute "Escape Code"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "doublequotestring" =+ (((pDetect2Chars False '"' '"' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'5c'5b0'2d7'5d'7b1'2c3'7d >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b1'2c2'7d >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "singlequotestring" = - do (attr, result) <- (((pDetect2Chars False '\'' '\'' >>= withAttribute "Escape Code"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "singlequotestring" =+ (((pDetect2Chars False '\'' '\'' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "htmltag" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Identifier") >>~ pushContext "identifiers"))- return (attr, result)+parseRules "htmltag" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "identifiers")) -parseRules "htmlcomment" = - do (attr, result) <- (((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "identifiers"))- return (attr, result)+parseRules "htmlcomment" =+ (((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "identifiers")) -parseRules "identifiers" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "types1")- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "types2"))- return (attr, result)+parseRules "identifiers" =+ (((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ pushContext "types1")+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "types2")) -parseRules "types1" = - do (attr, result) <- (((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "types1" =+ (((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "types2" = - do (attr, result) <- (((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "types2" =+ (((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "scripts" = - do (attr, result) <- (((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "scripts_onelinecomment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "twolinecomment")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_control_structures >>= withAttribute "Control Structures"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pString False "<%" >>= withAttribute "Keyword") >>~ pushContext "aspsource")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "doublequotestring")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "singlequotestring")- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text"))- <|>- ((pAnyChar ";()}{:,[]" >>= withAttribute "Other"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute "Other")))- return (attr, result)+parseRules "scripts" =+ (((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "scripts_onelinecomment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "twolinecomment")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_control_structures >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute KeywordTok))+ <|>+ ((pString False "<%" >>= withAttribute KeywordTok) >>~ pushContext "aspsource")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "doublequotestring")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "singlequotestring")+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ";()}{:,[]" >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute OtherTok))) -parseRules "scripts_onelinecomment" = - do (attr, result) <- ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute "HTML Tag") >>~ (popContext >> popContext))- return (attr, result)+parseRules "scripts_onelinecomment" =+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'5cs'2ascript'5cs'2a'3e >>= withAttribute KeywordTok) >>~ (popContext >> popContext)) -parseRules "twolinecomment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "twolinecomment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "nosource"
Text/Highlighting/Kate/Syntax/Awk.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file awk.xml, version 0.91,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file awk.xml, version 0.91, by -} -module Text.Highlighting.Kate.Syntax.Awk ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Awk+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "AWK"@@ -20,56 +23,43 @@ syntaxExtensions = "*.awk" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "AWK" } context <- currentContext <|> (pushContext "Base" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("AWK",["Base"])], synStLanguage = "AWK", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("AWK",["Base"])], synStLanguage = "AWK", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Base" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine+ "Base" -> return ()+ "String" -> return () "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Builtin","dt"),("Function","fu"),("Decimal","dv"),("Float","fl"),("String","st"),("Comment","co"),("Pattern","st"),("Field","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "if else while do for in continue break print printf getline function return next exit" list_builtins = Set.fromList $ words $ "ARGC ARGV CONVFMT ENVIRON FILENAME FNR FS NF NR OFMT OFS ORS RS RSTART RLENGTH SUBSEP"@@ -78,41 +68,38 @@ regex_'5cb'28BEGIN'7cEND'29'5cb = compileRegex "\\b(BEGIN|END)\\b" regex_'5c'24'5bA'2dZa'2dz0'2d9'5f'5d'2b = compileRegex "\\$[A-Za-z0-9_]+" -defaultAttributes = [("Base","Normal"),("String","String"),("Comment","Comment")]+defaultAttributes = [("Base",NormalTok),("String",StringTok),("Comment",CommentTok)] -parseRules "Base" = - do (attr, result) <- (((pRegExpr regex_'5cb'28BEGIN'7cEND'29'5cb >>= withAttribute "Pattern"))- <|>- ((pDetectChar False '{' >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '}' >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute "Builtin"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5c'24'5bA'2dZa'2dz0'2d9'5f'5d'2b >>= withAttribute "Field")))- return (attr, result)+parseRules "Base" =+ (((pRegExpr regex_'5cb'28BEGIN'7cEND'29'5cb >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5c'24'5bA'2dZa'2dz0'2d9'5f'5d'2b >>= withAttribute OtherTok))) -parseRules "String" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String")))- return (attr, result)+parseRules "String" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute StringTok))) -parseRules "Comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)+parseRules "Comment" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))) parseRules "" = parseRules "Base"
Text/Highlighting/Kate/Syntax/Bash.hs view
@@ -1,730 +1,671 @@-{- This module was generated from data in the Kate syntax highlighting file bash.xml, version 2.12,- by Wilbert Berendsen (wilbert@kde.nl) -}--module Text.Highlighting.Kate.Syntax.Bash ( 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 Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "Bash"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.sh;*.bash;*.ebuild;*.eclass;.bashrc;.bash_profile;.bash_login;.profile"---- | 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 = "Bash" }- context <- currentContext <|> (pushContext "Start" >> 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 [("Bash",["Start"])], synStLanguage = "Bash", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Start" -> return () >> pHandleEndLine- "FindAll" -> return () >> pHandleEndLine- "FindMost" -> return () >> pHandleEndLine- "FindComments" -> (popContext) >> pEndLine- "Comment" -> (popContext) >> pEndLine- "FindCommentsParen" -> (popContext) >> pEndLine- "CommentParen" -> (popContext) >> pEndLine- "FindCommentsBackq" -> (popContext) >> pEndLine- "CommentBackq" -> (popContext) >> pEndLine- "FindCommands" -> return () >> pHandleEndLine- "FindOthers" -> return () >> pHandleEndLine- "FindStrings" -> return () >> pHandleEndLine- "FindSubstitutions" -> return () >> pHandleEndLine- "FindTests" -> return () >> pHandleEndLine- "ExprDblParen" -> return () >> pHandleEndLine- "ExprDblParenSubst" -> return () >> pHandleEndLine- "ExprSubParen" -> return () >> pHandleEndLine- "ExprBracket" -> return () >> pHandleEndLine- "ExprDblBracket" -> return () >> pHandleEndLine- "Group" -> return () >> pHandleEndLine- "SubShell" -> return () >> pHandleEndLine- "Assign" -> (popContext) >> pEndLine- "AssignArray" -> (popContext) >> pEndLine- "AssignSubscr" -> (popContext) >> pEndLine- "Subscript" -> return () >> pHandleEndLine- "FunctionDef" -> (popContext) >> pEndLine- "VarName" -> (popContext) >> pEndLine- "ProcessSubst" -> return () >> pHandleEndLine- "StringSQ" -> return () >> pHandleEndLine- "StringDQ" -> return () >> pHandleEndLine- "StringEsc" -> return () >> pHandleEndLine- "VarBrace" -> return () >> pHandleEndLine- "VarAlt" -> return () >> pHandleEndLine- "VarSubst" -> return () >> pHandleEndLine- "VarSubst2" -> return () >> pHandleEndLine- "VarSub" -> return () >> pHandleEndLine- "VarSub2" -> return () >> pHandleEndLine- "SubstFile" -> return () >> pHandleEndLine- "SubstCommand" -> return () >> pHandleEndLine- "SubstBackq" -> return () >> pHandleEndLine- "Case" -> return () >> pHandleEndLine- "CaseIn" -> return () >> pHandleEndLine- "CaseExpr" -> return () >> pHandleEndLine- "HereDoc" -> return () >> pHandleEndLine- "HereDocRemainder" -> (popContext) >> pEndLine- "HereDocQ" -> return () >> pHandleEndLine- "HereDocNQ" -> return () >> pHandleEndLine- "HereDocIQ" -> return () >> pHandleEndLine- "HereDocINQ" -> return () >> pHandleEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Keyword","kw"),("Control","kw"),("Builtin","kw"),("Command","kw"),("Redirection","kw"),("Escape","dt"),("String SingleQ","st"),("String DoubleQ","st"),("Backquote","kw"),("String Transl.","st"),("String Escape","dt"),("Variable","ot"),("Expression","ot"),("Function","fu"),("Error","er")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_keywords = Set.fromList $ words $ "else for function in select until while elif then set"-list_builtins = Set.fromList $ words $ ": source alias bg bind break builtin cd caller command compgen complete continue dirs disown echo enable eval exec exit fc fg getopts hash help history jobs kill let logout popd printf pushd pwd return set shift shopt suspend test time times trap type ulimit umask unalias wait"-list_builtins'5fvar = Set.fromList $ words $ "export unset declare typeset local read readonly"-list_unixcommands = Set.fromList $ words $ "arch awk bash bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep bzip2 bzip2recover bzless bzmore cat chattr chgrp chmod chown chvt cp date dd deallocvt df dir dircolors dmesg dnsdomainname domainname du dumpkeys echo ed egrep false fgconsole fgrep fuser gawk getkeycodes gocr grep groff groups gunzip gzexe gzip hostname igawk install kbd_mode kbdrate killall last lastb link ln loadkeys loadunimap login ls lsattr lsmod lsmod.old lzcat lzcmp lzdiff lzegrep lzfgrep lzgrep lzless lzcat lzma lzmainfo lzmore mapscrn mesg mkdir mkfifo mknod mktemp more mount mv nano netstat nisdomainname nroff openvt pgawk pidof ping ps pstree pwd rbash readlink red resizecons rm rmdir run-parts sash sed setfont setkeycodes setleds setmetamode setserial sh showkey shred sleep ssed stat stty su sync tar tempfile touch troff true umount uname unicode_start unicode_stop unlink unlzma unxz utmpdump uuidgen vdir wall wc xz xzcat ypdomainname zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew zsh aclocal aconnect aplay apm apmsleep apropos ar arecord as as86 autoconf autoheader automake awk basename bc bison c++ cal cat cc cdda2wav cdparanoia cdrdao cd-read cdrecord chfn chgrp chmod chown chroot chsh clear cmp co col comm cp cpio cpp cut dc dd df diff diff3 dir dircolors directomatic dirname du env expr fbset file find flex flex++ fmt free ftp funzip fuser g++ gawk gc gcc gdb getent getopt gettext gettextize gimp gimp-remote gimptool gmake gs head hexdump id install join kill killall ld ld86 ldd less lex ln locate lockfile logname lp lpr ls lynx m4 make man mkdir mknod msgfmt mv namei nasm nawk nice nl nm nm86 nmap nohup nop od passwd patch pcregrep pcretest perl perror pidof pr printf procmail prune ps2ascii ps2epsi ps2frag ps2pdf ps2ps psbook psmerge psnup psresize psselect pstops rcs rev rm scp sed seq setterm shred size size86 skill slogin snice sort sox split ssh ssh-add ssh-agent ssh-keygen ssh-keyscan stat strings strip sudo suidperl sum tac tail tee test tr uniq unlink unzip updatedb updmap uptime users vmstat w wc wget whatis whereis which who whoami write xargs yacc yes zip zsoelim dcop kdialog kfile xhost xmodmap xset"--regex_'5b'5cs'3b'5d'28'3f'3d'23'29 = compileRegex "[\\s;](?=#)"-regex_'5b'5e'29'5d'28'3f'3d'5c'29'29 = compileRegex "[^)](?=\\))"-regex_'5b'5e'60'5d'28'3f'3d'60'29 = compileRegex "[^`](?=`)"-regex_'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\[\\[(?=($|\\s))"-regex_'5cs'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\s\\[\\[(?=($|\\s))"-regex_'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\[(?=($|\\s))"-regex_'5cs'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\s\\[(?=($|\\s))"-regex_'5c'7b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\{(?=($|\\s))"-regex_'5cbdo'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bdo(?![\\w$+-])"-regex_'5cbdone'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bdone(?![\\w$+-])"-regex_'5cbif_'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bif (?![\\w$+-])"-regex_'5cbfi'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bfi(?![\\w$+-])"-regex_'5cbcase'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bcase(?![\\w$+-])"-regex_'2d'5bA'2dZa'2dz0'2d9'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "-[A-Za-z0-9][A-Za-z0-9_]*"-regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a = compileRegex "--[a-z][A-Za-z0-9_-]*"-regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'2b'3f'3d = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*\\+?="-regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'3f'3d'5c'5b'2e'2b'5c'5d'5c'2b'3f'3d'29 = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*(?=\\[.+\\]\\+?=)"-regex_'5cbfunction'5cb = compileRegex "\\bfunction\\b"-regex_'5c'2e'28'3f'3d'5cs'29 = compileRegex "\\.(?=\\s)"-regex_'5cd'2a'3c'3c'3c = compileRegex "\\d*<<<"-regex_'5b'3c'3e'5d'5c'28 = compileRegex "[<>]\\("-regex_'28'5b0'2d9'5d'2a'28'3e'7b1'2c2'7d'7c'3c'29'28'26'5b0'2d9'5d'2b'2d'3f'29'3f'7c'26'3e'7c'3e'26'7c'5b0'2d9'5d'2a'3c'3e'29 = compileRegex "([0-9]*(>{1,2}|<)(&[0-9]+-?)?|&>|>&|[0-9]*<>)"-regex_'28'5b'7c'26'5d'29'5c1'3f = compileRegex "([|&])\\1?"-regex_'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'5cs'2a'5c'28'5c'29 = compileRegex "[A-Za-z_:][A-Za-z0-9_:#%@-]*\\s*\\(\\)"-regex_'5c'5c'5b'5d'5b'3b'5c'5c'24'60'7b'7d'28'29'7c'26'3c'3e'2a_'5d = compileRegex "\\\\[][;\\\\$`{}()|&<>* ]"-regex_'5c'5c'24 = compileRegex "\\\\$"-regex_'5c'7b'28'3f'21'28'5cs'7c'24'29'29'5cS'2a'5c'7d = compileRegex "\\{(?!(\\s|$))\\S*\\}"-regex_'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'2f'29 = compileRegex "([\\w_@.%*?+-]|\\\\ )*(?=/)"-regex_'7e'5cw'2a = compileRegex "~\\w*"-regex_'2f'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'28'5b'5cs'2f'29'3a'3b'24'60'27'22'5d'7c'24'29'29 = compileRegex "/([\\w_@.%*?+-]|\\\\ )*(?=([\\s/):;$`'\"]|$))"-regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'5b = compileRegex "\\$[A-Za-z_][A-Za-z0-9_]*\\["-regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\$[A-Za-z_][A-Za-z0-9_]*"-regex_'5c'24'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d = compileRegex "\\$[*@#?$!_0-9-]"-regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'5c'7d = compileRegex "\\$\\{[*@#?$!_0-9-]\\}"-regex_'5c'24'5c'7b'23'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'29'3f'5c'7d = compileRegex "\\$\\{#[A-Za-z_][A-Za-z0-9_]*(\\[[*@]\\])?\\}"-regex_'5c'24'5c'7b'21'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'7c'5b'2a'40'5d'29'3f'5c'7d = compileRegex "\\$\\{![A-Za-z_][A-Za-z0-9_]*(\\[[*@]\\]|[*@])?\\}"-regex_'5c'24'5c'7b'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\$\\{[A-Za-z_][A-Za-z0-9_]*"-regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'28'3f'3d'5b'3a'23'25'2f'3d'3f'2b'2d'5d'29 = compileRegex "\\$\\{[*@#?$!_0-9-](?=[:#%/=?+-])"-regex_'5c'5c'5b'60'24'5c'5c'5d = compileRegex "\\\\[`$\\\\]"-regex_'2d'5babcdefghkprstuwxOGLSNozn'5d'28'3f'3d'5cs'29 = compileRegex "-[abcdefghkprstuwxOGLSNozn](?=\\s)"-regex_'2d'28'5bno'5dt'7cef'29'28'3f'3d'5cs'29 = compileRegex "-([no]t|ef)(?=\\s)"-regex_'28'5b'21'3d'5d'3d'3f'7c'5b'3e'3c'5d'29'28'3f'3d'5cs'29 = compileRegex "([!=]=?|[><])(?=\\s)"-regex_'2d'28eq'7cne'7c'5bgl'5d'5bte'5d'29'28'3f'3d'5cs'29 = compileRegex "-(eq|ne|[gl][te])(?=\\s)"-regex_'5cs'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\s\\](?=($|[\\s;|&]))"-regex_'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\](?=($|[\\s;|&]))"-regex_'5cs'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\s\\]\\](?=($|[\\s;|&]))"-regex_'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\]\\](?=($|[\\s;|&]))"-regex_'5b'5cw'3a'2c'2b'5f'2e'2f'2d'5d = compileRegex "[\\w:,+_./-]"-regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'28'5cs'2a'5c'28'5c'29'29'3f = compileRegex "\\s+[A-Za-z_:][A-Za-z0-9_:#%@-]*(\\s*\\(\\))?"-regex_'2d'5bA'2dZa'2dz0'2d9'5d'2b = compileRegex "-[A-Za-z0-9]+"-regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*"-regex_'5b'5e'5d'7d'29'7c'3b'60'26'3e'3c'5d = compileRegex "[^]})|;`&><]"-regex_'5c'5c'5b'60'22'5c'5c'24'5cn'5d = compileRegex "\\\\[`\"\\\\$\\n]"-regex_'5c'5c'5babefnrtv'5c'5c'27'5d = compileRegex "\\\\[abefnrtv\\\\']"-regex_'5c'5c'28'5b0'2d7'5d'7b1'2c3'7d'7cx'5bA'2dFa'2df0'2d9'5d'7b1'2c2'7d'7cc'2e'29 = compileRegex "\\\\([0-7]{1,3}|x[A-Fa-f0-9]{1,2}|c.)"-regex_'28'3a'3f'5b'2d'3d'3f'2b'5d'7c'23'23'3f'7c'25'25'3f'29 = compileRegex "(:?[-=?+]|##?|%%?)"-regex_'2f'2f'3f = compileRegex "//?"-regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "[A-Za-z_][A-Za-z0-9_]*"-regex_'5b0'2d9'5d'2b'28'3f'3d'5b'3a'7d'5d'29 = compileRegex "[0-9]+(?=[:}])"-regex_'5b0'2d9'5d'28'3f'3d'5b'3a'7d'5d'29 = compileRegex "[0-9](?=[:}])"-regex_'5csin'5cb = compileRegex "\\sin\\b"-regex_'5cbesac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 = compileRegex "\\besac(?=$|[\\s;)])"-regex_esac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 = compileRegex "esac(?=$|[\\s;)])"-regex_'28'3c'3c'2d'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29 = compileRegex "(<<-\\s*\"([^|&;()<>\\s]+)\")"-regex_'28'3c'3c'2d'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29 = compileRegex "(<<-\\s*'([^|&;()<>\\s]+)')"-regex_'28'3c'3c'2d'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<-\\s*\\\\([^|&;()<>\\s]+))"-regex_'28'3c'3c'2d'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<-\\s*([^|&;()<>\\s]+))"-regex_'28'3c'3c'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29 = compileRegex "(<<\\s*\"([^|&;()<>\\s]+)\")"-regex_'28'3c'3c'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29 = compileRegex "(<<\\s*'([^|&;()<>\\s]+)')"-regex_'28'3c'3c'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<\\s*\\\\([^|&;()<>\\s]+))"-regex_'28'3c'3c'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<\\s*([^|&;()<>\\s]+))"--defaultAttributes = [("Start","Normal Text"),("FindAll","Normal Text"),("FindMost","Normal Text"),("FindComments","Normal Text"),("Comment","Comment"),("FindCommentsParen","Normal Text"),("CommentParen","Comment"),("FindCommentsBackq","Normal Text"),("CommentBackq","Comment"),("FindCommands","Normal Text"),("FindOthers","Normal Text"),("FindStrings","Normal Text"),("FindSubstitutions","Normal Text"),("FindTests","Normal Text"),("ExprDblParen","Normal Text"),("ExprDblParenSubst","Normal Text"),("ExprSubParen","Normal Text"),("ExprBracket","Normal Text"),("ExprDblBracket","Normal Text"),("Group","Normal Text"),("SubShell","Normal Text"),("Assign","Normal Text"),("AssignArray","Normal Text"),("AssignSubscr","Normal Text"),("Subscript","Variable"),("FunctionDef","Function"),("VarName","Normal Text"),("ProcessSubst","Normal Text"),("StringSQ","String SingleQ"),("StringDQ","String DoubleQ"),("StringEsc","String SingleQ"),("VarBrace","Error"),("VarAlt","Normal Text"),("VarSubst","Normal Text"),("VarSubst2","Normal Text"),("VarSub","Error"),("VarSub2","Error"),("SubstFile","Normal Text"),("SubstCommand","Normal Text"),("SubstBackq","Normal Text"),("Case","Normal Text"),("CaseIn","Normal Text"),("CaseExpr","Normal Text"),("HereDoc","Normal Text"),("HereDocRemainder","Normal Text"),("HereDocQ","Normal Text"),("HereDocNQ","Normal Text"),("HereDocIQ","Normal Text"),("HereDocINQ","Normal Text")]--parseRules "Start" = - do (attr, result) <- ((parseRules "FindAll"))- return (attr, result)--parseRules "FindAll" = - do (attr, result) <- (((parseRules "FindComments"))- <|>- ((parseRules "FindCommands"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "FindMost" = - do (attr, result) <- (((parseRules "FindComments"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "FindComments" = - do (attr, result) <- (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute "Normal Text") >>~ pushContext "Comment"))- return (attr, result)--parseRules "Comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)--parseRules "FindCommentsParen" = - do (attr, result) <- (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "CommentParen")- <|>- ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute "Normal Text") >>~ pushContext "CommentParen"))- return (attr, result)--parseRules "CommentParen" = - do (attr, result) <- (((pRegExpr regex_'5b'5e'29'5d'28'3f'3d'5c'29'29 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)--parseRules "FindCommentsBackq" = - do (attr, result) <- (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "CommentBackq")- <|>- ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute "Normal Text") >>~ pushContext "CommentBackq"))- return (attr, result)--parseRules "CommentBackq" = - do (attr, result) <- (((pRegExpr regex_'5b'5e'60'5d'28'3f'3d'60'29 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)--parseRules "FindCommands" = - do (attr, result) <- (((pDetect2Chars False '(' '(' >>= withAttribute "Keyword") >>~ pushContext "ExprDblParen")- <|>- ((pColumn 0 >> pRegExpr regex_'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute "Keyword") >>~ pushContext "ExprDblBracket")- <|>- ((pRegExpr regex_'5cs'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute "Keyword") >>~ pushContext "ExprDblBracket")- <|>- ((pColumn 0 >> pRegExpr regex_'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute "Builtin") >>~ pushContext "ExprBracket")- <|>- ((pRegExpr regex_'5cs'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute "Builtin") >>~ pushContext "ExprBracket")- <|>- ((pRegExpr regex_'5c'7b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute "Keyword") >>~ pushContext "Group")- <|>- ((pDetectChar False '(' >>= withAttribute "Keyword") >>~ pushContext "SubShell")- <|>- ((pRegExpr regex_'5cbdo'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbdone'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbif_'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbfi'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbcase'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute "Keyword") >>~ pushContext "Case")- <|>- ((pRegExpr regex_'2d'5bA'2dZa'2dz0'2d9'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Option"))- <|>- ((pRegExpr regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a >>= withAttribute "Option"))- <|>- ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'2b'3f'3d >>= withAttribute "Variable") >>~ pushContext "Assign")- <|>- ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'3f'3d'5c'5b'2e'2b'5c'5d'5c'2b'3f'3d'29 >>= withAttribute "Variable") >>~ pushContext "AssignSubscr")- <|>- ((pString False ":()" >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute "Keyword") >>~ pushContext "FunctionDef")- <|>- ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_keywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'2e'28'3f'3d'5cs'29 >>= withAttribute "Builtin"))- <|>- ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_builtins >>= withAttribute "Builtin"))- <|>- ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_unixcommands >>= withAttribute "Command"))- <|>- ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_builtins'5fvar >>= withAttribute "Builtin") >>~ pushContext "VarName")- <|>- ((pRegExpr regex_'5cd'2a'3c'3c'3c >>= withAttribute "Redirection"))- <|>- ((lookAhead (pString False "<<") >> return ([],"") ) >>~ pushContext "HereDoc")- <|>- ((pRegExpr regex_'5b'3c'3e'5d'5c'28 >>= withAttribute "Redirection") >>~ pushContext "ProcessSubst")- <|>- ((pRegExpr regex_'28'5b0'2d9'5d'2a'28'3e'7b1'2c2'7d'7c'3c'29'28'26'5b0'2d9'5d'2b'2d'3f'29'3f'7c'26'3e'7c'3e'26'7c'5b0'2d9'5d'2a'3c'3e'29 >>= withAttribute "Redirection"))- <|>- ((pRegExpr regex_'28'5b'7c'26'5d'29'5c1'3f >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'5cs'2a'5c'28'5c'29 >>= withAttribute "Function")))- return (attr, result)--parseRules "FindOthers" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5b'5d'5b'3b'5c'5c'24'60'7b'7d'28'29'7c'26'3c'3e'2a_'5d >>= withAttribute "Escape"))- <|>- ((pRegExpr regex_'5c'5c'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'7b'28'3f'21'28'5cs'7c'24'29'29'5cS'2a'5c'7d >>= withAttribute "Escape"))- <|>- ((pRegExpr regex_'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'2f'29 >>= withAttribute "Path"))- <|>- ((pRegExpr regex_'7e'5cw'2a >>= withAttribute "Path"))- <|>- ((pRegExpr regex_'2f'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'28'5b'5cs'2f'29'3a'3b'24'60'27'22'5d'7c'24'29'29 >>= withAttribute "Path")))- return (attr, result)--parseRules "FindStrings" = - do (attr, result) <- (((pDetect2Chars False '\\' '\'' >>= withAttribute "Escape"))- <|>- ((pDetect2Chars False '\\' '"' >>= withAttribute "Escape"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String SingleQ") >>~ pushContext "StringSQ")- <|>- ((pDetectChar False '"' >>= withAttribute "String DoubleQ") >>~ pushContext "StringDQ")- <|>- ((pDetect2Chars False '$' '\'' >>= withAttribute "String SingleQ") >>~ pushContext "StringEsc")- <|>- ((pDetect2Chars False '$' '"' >>= withAttribute "String Transl.") >>~ pushContext "StringDQ"))- return (attr, result)--parseRules "FindSubstitutions" = - do (attr, result) <- (((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'5b >>= withAttribute "Variable") >>~ pushContext "Subscript")- <|>- ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'23'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'29'3f'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'21'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'7c'5b'2a'40'5d'29'3f'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable") >>~ pushContext "VarBrace")- <|>- ((pRegExpr regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'28'3f'3d'5b'3a'23'25'2f'3d'3f'2b'2d'5d'29 >>= withAttribute "Variable") >>~ pushContext "VarBrace")- <|>- ((pString False "$((" >>= withAttribute "Variable") >>~ pushContext "ExprDblParenSubst")- <|>- ((pString False "$(<" >>= withAttribute "Redirection") >>~ pushContext "SubstFile")- <|>- ((pString False "$(" >>= withAttribute "Variable") >>~ pushContext "SubstCommand")- <|>- ((pDetectChar False '`' >>= withAttribute "Backquote") >>~ pushContext "SubstBackq")- <|>- ((pRegExpr regex_'5c'5c'5b'60'24'5c'5c'5d >>= withAttribute "Escape")))- return (attr, result)--parseRules "FindTests" = - do (attr, result) <- (((pRegExpr regex_'2d'5babcdefghkprstuwxOGLSNozn'5d'28'3f'3d'5cs'29 >>= withAttribute "Expression"))- <|>- ((pRegExpr regex_'2d'28'5bno'5dt'7cef'29'28'3f'3d'5cs'29 >>= withAttribute "Expression"))- <|>- ((pRegExpr regex_'28'5b'21'3d'5d'3d'3f'7c'5b'3e'3c'5d'29'28'3f'3d'5cs'29 >>= withAttribute "Expression"))- <|>- ((pRegExpr regex_'2d'28eq'7cne'7c'5bgl'5d'5bte'5d'29'28'3f'3d'5cs'29 >>= withAttribute "Expression")))- return (attr, result)--parseRules "ExprDblParen" = - do (attr, result) <- (((pDetect2Chars False ')' ')' >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "ExprSubParen")- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "ExprDblParenSubst" = - do (attr, result) <- (((pDetect2Chars False ')' ')' >>= withAttribute "Variable") >>~ (popContext))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "ExprSubParen")- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "ExprSubParen" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "ExprSubParen")- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "ExprBracket" = - do (attr, result) <- (((pRegExpr regex_'5cs'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute "Builtin") >>~ (popContext))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute "Builtin") >>~ (popContext))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "ExprSubParen")- <|>- ((parseRules "FindTests"))- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "ExprDblBracket" = - do (attr, result) <- (((pRegExpr regex_'5cs'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "ExprSubParen")- <|>- ((parseRules "FindTests"))- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "Group" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((parseRules "FindAll")))- return (attr, result)--parseRules "SubShell" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((parseRules "FindAll")))- return (attr, result)--parseRules "Assign" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Variable") >>~ pushContext "AssignArray")- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers"))- <|>- ((pRegExpr regex_'5b'5cw'3a'2c'2b'5f'2e'2f'2d'5d >>= withAttribute "Normal Text"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "AssignArray" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Variable") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Variable") >>~ pushContext "Subscript")- <|>- ((pDetectChar False '=' >>= withAttribute "Variable") >>~ pushContext "Assign")- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "AssignSubscr" = - do (attr, result) <- (((pDetectChar False '[' >>= withAttribute "Variable") >>~ pushContext "Subscript")- <|>- ((pDetect2Chars False '+' '=' >>= withAttribute "Variable") >>~ pushContext "Assign")- <|>- ((pDetectChar False '=' >>= withAttribute "Variable") >>~ pushContext "Assign")- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "Subscript" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Variable") >>~ (popContext))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "FunctionDef" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'28'5cs'2a'5c'28'5c'29'29'3f >>= withAttribute "Function") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "VarName" = - do (attr, result) <- (((pRegExpr regex_'2d'5bA'2dZa'2dz0'2d9'5d'2b >>= withAttribute "Option"))- <|>- ((pRegExpr regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a >>= withAttribute "Option"))- <|>- ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable"))- <|>- ((pDetectChar False '[' >>= withAttribute "Variable") >>~ pushContext "Subscript")- <|>- ((pDetectChar False '=' >>= withAttribute "Variable") >>~ pushContext "Assign")- <|>- ((parseRules "FindMost"))- <|>- ((pRegExpr regex_'5b'5e'5d'7d'29'7c'3b'60'26'3e'3c'5d >>= withAttribute "Normal Text"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "ProcessSubst" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Redirection") >>~ (popContext))- <|>- ((parseRules "FindCommentsParen"))- <|>- ((parseRules "FindCommands"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "StringSQ" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "String SingleQ") >>~ (popContext))- return (attr, result)--parseRules "StringDQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String DoubleQ") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'5b'60'22'5c'5c'24'5cn'5d >>= withAttribute "String Escape"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "StringEsc" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "String SingleQ") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'5babefnrtv'5c'5c'27'5d >>= withAttribute "String Escape"))- <|>- ((pRegExpr regex_'5c'5c'28'5b0'2d7'5d'7b1'2c3'7d'7cx'5bA'2dFa'2df0'2d9'5d'7b1'2c2'7d'7cc'2e'29 >>= withAttribute "String Escape")))- return (attr, result)--parseRules "VarBrace" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Variable") >>~ pushContext "Subscript")- <|>- ((pRegExpr regex_'28'3a'3f'5b'2d'3d'3f'2b'5d'7c'23'23'3f'7c'25'25'3f'29 >>= withAttribute "Variable") >>~ pushContext "VarAlt")- <|>- ((pRegExpr regex_'2f'2f'3f >>= withAttribute "Variable") >>~ pushContext "VarSubst")- <|>- ((pDetectChar False ':' >>= withAttribute "Variable") >>~ pushContext "VarSub"))- return (attr, result)--parseRules "VarAlt" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext >> popContext))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "VarSubst" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '/' >>= withAttribute "Variable") >>~ pushContext "VarSubst2")- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "VarSubst2" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "VarSub" = - do (attr, result) <- (((pDetectChar False ':' >>= withAttribute "Variable") >>~ pushContext "VarSub2")- <|>- ((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5b0'2d9'5d'2b'28'3f'3d'5b'3a'7d'5d'29 >>= withAttribute "Variable"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "VarSub2" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Variable") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5b0'2d9'5d'28'3f'3d'5b'3a'7d'5d'29 >>= withAttribute "Variable"))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "SubstFile" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Redirection") >>~ (popContext))- <|>- ((parseRules "FindCommentsParen"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "SubstCommand" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Variable") >>~ (popContext))- <|>- ((parseRules "FindCommentsParen"))- <|>- ((parseRules "FindCommands"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "SubstBackq" = - do (attr, result) <- (((pDetectChar False '`' >>= withAttribute "Backquote") >>~ (popContext))- <|>- ((parseRules "FindCommentsBackq"))- <|>- ((parseRules "FindCommands"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindSubstitutions"))- <|>- ((parseRules "FindOthers")))- return (attr, result)--parseRules "Case" = - do (attr, result) <- (((pRegExpr regex_'5csin'5cb >>= withAttribute "Keyword") >>~ pushContext "CaseIn")- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "CaseIn" = - do (attr, result) <- (((pRegExpr regex_'5cbesac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((pDetectChar False ')' >>= withAttribute "Keyword") >>~ pushContext "CaseExpr")- <|>- ((pAnyChar "(|" >>= withAttribute "Keyword"))- <|>- ((parseRules "FindMost")))- return (attr, result)--parseRules "CaseExpr" = - do (attr, result) <- (((pDetect2Chars False ';' ';' >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pFirstNonSpace >> lookAhead (pRegExpr regex_esac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "FindAll")))- return (attr, result)--parseRules "HereDoc" = - do (attr, result) <- (((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29) >> return ([],"") ) >>~ pushContext "HereDocIQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29) >> return ([],"") ) >>~ pushContext "HereDocIQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return ([],"") ) >>~ pushContext "HereDocIQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return ([],"") ) >>~ pushContext "HereDocINQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29) >> return ([],"") ) >>~ pushContext "HereDocQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29) >> return ([],"") ) >>~ pushContext "HereDocQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return ([],"") ) >>~ pushContext "HereDocQ")- <|>- ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return ([],"") ) >>~ pushContext "HereDocNQ")- <|>- ((pString False "<<" >>= withAttribute "Redirection") >>~ (popContext)))- return (attr, result)--parseRules "HereDocRemainder" = - do (attr, result) <- ((parseRules "FindAll"))- return (attr, result)--parseRules "HereDocQ" = - do (attr, result) <- (((pRegExprDynamic "%1" >>= withAttribute "Redirection") >>~ pushContext "HereDocRemainder")- <|>- ((pColumn 0 >> pRegExprDynamic "%2\\b" >>= withAttribute "Redirection") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "HereDocNQ" = - do (attr, result) <- (((pRegExprDynamic "%1" >>= withAttribute "Redirection") >>~ pushContext "HereDocRemainder")- <|>- ((pColumn 0 >> pRegExprDynamic "%2\\b" >>= withAttribute "Redirection") >>~ (popContext >> popContext))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)--parseRules "HereDocIQ" = - do (attr, result) <- (((pRegExprDynamic "%1" >>= withAttribute "Redirection") >>~ pushContext "HereDocRemainder")- <|>- ((pColumn 0 >> pRegExprDynamic "\\t*%2\\b" >>= withAttribute "Redirection") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "HereDocINQ" = - do (attr, result) <- (((pRegExprDynamic "%1" >>= withAttribute "Redirection") >>~ pushContext "HereDocRemainder")- <|>- ((pColumn 0 >> pRegExprDynamic "\\t*%2\\b" >>= withAttribute "Redirection") >>~ (popContext >> popContext))- <|>- ((parseRules "FindSubstitutions")))- return (attr, result)+{- This module was generated from data in the Kate syntax+ highlighting file bash.xml, version 2.12, by Wilbert Berendsen (wilbert@kde.nl) -}++module Text.Highlighting.Kate.Syntax.Bash+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Common+import qualified Text.Highlighting.Kate.Syntax.Alert+import Text.ParserCombinators.Parsec hiding (State)+import Data.Map (fromList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe)+import qualified Data.Set as Set++-- | Full name of language.+syntaxName :: String+syntaxName = "Bash"++-- | Filename extensions for this language.+syntaxExtensions :: String+syntaxExtensions = "*.sh;*.bash;*.ebuild;*.eclass;.bashrc;.bash_profile;.bash_login;.profile"++-- | Highlight source code using this syntax definition.+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState++parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine++-- | Parse an expression using appropriate local context.+parseExpression :: KateParser Token+parseExpression = do+ st <- getState+ let oldLang = synStLanguage st+ setState $ st { synStLanguage = "Bash" }+ context <- currentContext <|> (pushContext "Start" >> currentContext)+ result <- parseRules context+ optional $ eof >> pEndLine+ updateState $ \st -> st { synStLanguage = oldLang }+ return result++startingState = SyntaxState {synStContexts = fromList [("Bash",["Start"])], synStLanguage = "Bash", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}++pEndLine = do+ context <- currentContext+ case context of+ "Start" -> return ()+ "FindAll" -> return ()+ "FindMost" -> return ()+ "FindComments" -> (popContext) >> pEndLine+ "Comment" -> (popContext) >> pEndLine+ "FindCommentsParen" -> (popContext) >> pEndLine+ "CommentParen" -> (popContext) >> pEndLine+ "FindCommentsBackq" -> (popContext) >> pEndLine+ "CommentBackq" -> (popContext) >> pEndLine+ "FindCommands" -> return ()+ "FindOthers" -> return ()+ "FindStrings" -> return ()+ "FindSubstitutions" -> return ()+ "FindTests" -> return ()+ "ExprDblParen" -> return ()+ "ExprDblParenSubst" -> return ()+ "ExprSubParen" -> return ()+ "ExprBracket" -> return ()+ "ExprDblBracket" -> return ()+ "Group" -> return ()+ "SubShell" -> return ()+ "Assign" -> (popContext) >> pEndLine+ "AssignArray" -> (popContext) >> pEndLine+ "AssignSubscr" -> (popContext) >> pEndLine+ "Subscript" -> return ()+ "FunctionDef" -> (popContext) >> pEndLine+ "VarName" -> (popContext) >> pEndLine+ "ProcessSubst" -> return ()+ "StringSQ" -> return ()+ "StringDQ" -> return ()+ "StringEsc" -> return ()+ "VarBrace" -> return ()+ "VarAlt" -> return ()+ "VarSubst" -> return ()+ "VarSubst2" -> return ()+ "VarSub" -> return ()+ "VarSub2" -> return ()+ "SubstFile" -> return ()+ "SubstCommand" -> return ()+ "SubstBackq" -> return ()+ "Case" -> return ()+ "CaseIn" -> return ()+ "CaseExpr" -> return ()+ "HereDoc" -> return ()+ "HereDocRemainder" -> (popContext) >> pEndLine+ "HereDocQ" -> return ()+ "HereDocNQ" -> return ()+ "HereDocIQ" -> return ()+ "HereDocINQ" -> return ()+ _ -> return ()++withAttribute attr txt = do+ when (null txt) $ fail "Parser matched no text"+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt)++parseExpressionInternal = do+ context <- currentContext+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))++list_keywords = Set.fromList $ words $ "else for function in select until while elif then set"+list_builtins = Set.fromList $ words $ ": source alias bg bind break builtin cd caller command compgen complete continue dirs disown echo enable eval exec exit fc fg getopts hash help history jobs kill let logout popd printf pushd pwd return set shift shopt suspend test time times trap type ulimit umask unalias wait"+list_builtins'5fvar = Set.fromList $ words $ "export unset declare typeset local read readonly"+list_unixcommands = Set.fromList $ words $ "arch awk bash bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep bzip2 bzip2recover bzless bzmore cat chattr chgrp chmod chown chvt cp date dd deallocvt df dir dircolors dmesg dnsdomainname domainname du dumpkeys echo ed egrep false fgconsole fgrep fuser gawk getkeycodes gocr grep groff groups gunzip gzexe gzip hostname igawk install kbd_mode kbdrate killall last lastb link ln loadkeys loadunimap login ls lsattr lsmod lsmod.old lzcat lzcmp lzdiff lzegrep lzfgrep lzgrep lzless lzcat lzma lzmainfo lzmore mapscrn mesg mkdir mkfifo mknod mktemp more mount mv nano netstat nisdomainname nroff openvt pgawk pidof ping ps pstree pwd rbash readlink red resizecons rm rmdir run-parts sash sed setfont setkeycodes setleds setmetamode setserial sh showkey shred sleep ssed stat stty su sync tar tempfile touch troff true umount uname unicode_start unicode_stop unlink unlzma unxz utmpdump uuidgen vdir wall wc xz xzcat ypdomainname zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew zsh aclocal aconnect aplay apm apmsleep apropos ar arecord as as86 autoconf autoheader automake awk basename bc bison c++ cal cat cc cdda2wav cdparanoia cdrdao cd-read cdrecord chfn chgrp chmod chown chroot chsh clear cmp co col comm cp cpio cpp cut dc dd df diff diff3 dir dircolors directomatic dirname du env expr fbset file find flex flex++ fmt free ftp funzip fuser g++ gawk gc gcc gdb getent getopt gettext gettextize gimp gimp-remote gimptool gmake gs head hexdump id install join kill killall ld ld86 ldd less lex ln locate lockfile logname lp lpr ls lynx m4 make man mkdir mknod msgfmt mv namei nasm nawk nice nl nm nm86 nmap nohup nop od passwd patch pcregrep pcretest perl perror pidof pr printf procmail prune ps2ascii ps2epsi ps2frag ps2pdf ps2ps psbook psmerge psnup psresize psselect pstops rcs rev rm scp sed seq setterm shred size size86 skill slogin snice sort sox split ssh ssh-add ssh-agent ssh-keygen ssh-keyscan stat strings strip sudo suidperl sum tac tail tee test tr uniq unlink unzip updatedb updmap uptime users vmstat w wc wget whatis whereis which who whoami write xargs yacc yes zip zsoelim dcop kdialog kfile xhost xmodmap xset"++regex_'5b'5cs'3b'5d'28'3f'3d'23'29 = compileRegex "[\\s;](?=#)"+regex_'5b'5e'29'5d'28'3f'3d'5c'29'29 = compileRegex "[^)](?=\\))"+regex_'5b'5e'60'5d'28'3f'3d'60'29 = compileRegex "[^`](?=`)"+regex_'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\[\\[(?=($|\\s))"+regex_'5cs'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\s\\[\\[(?=($|\\s))"+regex_'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\[(?=($|\\s))"+regex_'5cs'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\s\\[(?=($|\\s))"+regex_'5c'7b'28'3f'3d'28'24'7c'5cs'29'29 = compileRegex "\\{(?=($|\\s))"+regex_'5cbdo'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bdo(?![\\w$+-])"+regex_'5cbdone'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bdone(?![\\w$+-])"+regex_'5cbif_'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bif (?![\\w$+-])"+regex_'5cbfi'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bfi(?![\\w$+-])"+regex_'5cbcase'28'3f'21'5b'5cw'24'2b'2d'5d'29 = compileRegex "\\bcase(?![\\w$+-])"+regex_'2d'5bA'2dZa'2dz0'2d9'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "-[A-Za-z0-9][A-Za-z0-9_]*"+regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a = compileRegex "--[a-z][A-Za-z0-9_-]*"+regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'2b'3f'3d = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*\\+?="+regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'3f'3d'5c'5b'2e'2b'5c'5d'5c'2b'3f'3d'29 = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*(?=\\[.+\\]\\+?=)"+regex_'5cbfunction'5cb = compileRegex "\\bfunction\\b"+regex_'5c'2e'28'3f'3d'5cs'29 = compileRegex "\\.(?=\\s)"+regex_'5cd'2a'3c'3c'3c = compileRegex "\\d*<<<"+regex_'5b'3c'3e'5d'5c'28 = compileRegex "[<>]\\("+regex_'28'5b0'2d9'5d'2a'28'3e'7b1'2c2'7d'7c'3c'29'28'26'5b0'2d9'5d'2b'2d'3f'29'3f'7c'26'3e'7c'3e'26'7c'5b0'2d9'5d'2a'3c'3e'29 = compileRegex "([0-9]*(>{1,2}|<)(&[0-9]+-?)?|&>|>&|[0-9]*<>)"+regex_'28'5b'7c'26'5d'29'5c1'3f = compileRegex "([|&])\\1?"+regex_'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'5cs'2a'5c'28'5c'29 = compileRegex "[A-Za-z_:][A-Za-z0-9_:#%@-]*\\s*\\(\\)"+regex_'5c'5c'5b'5d'5b'3b'5c'5c'24'60'7b'7d'28'29'7c'26'3c'3e'2a_'5d = compileRegex "\\\\[][;\\\\$`{}()|&<>* ]"+regex_'5c'5c'24 = compileRegex "\\\\$"+regex_'5c'7b'28'3f'21'28'5cs'7c'24'29'29'5cS'2a'5c'7d = compileRegex "\\{(?!(\\s|$))\\S*\\}"+regex_'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'2f'29 = compileRegex "([\\w_@.%*?+-]|\\\\ )*(?=/)"+regex_'7e'5cw'2a = compileRegex "~\\w*"+regex_'2f'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'28'5b'5cs'2f'29'3a'3b'24'60'27'22'5d'7c'24'29'29 = compileRegex "/([\\w_@.%*?+-]|\\\\ )*(?=([\\s/):;$`'\"]|$))"+regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'5b = compileRegex "\\$[A-Za-z_][A-Za-z0-9_]*\\["+regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\$[A-Za-z_][A-Za-z0-9_]*"+regex_'5c'24'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d = compileRegex "\\$[*@#?$!_0-9-]"+regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'5c'7d = compileRegex "\\$\\{[*@#?$!_0-9-]\\}"+regex_'5c'24'5c'7b'23'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'29'3f'5c'7d = compileRegex "\\$\\{#[A-Za-z_][A-Za-z0-9_]*(\\[[*@]\\])?\\}"+regex_'5c'24'5c'7b'21'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'7c'5b'2a'40'5d'29'3f'5c'7d = compileRegex "\\$\\{![A-Za-z_][A-Za-z0-9_]*(\\[[*@]\\]|[*@])?\\}"+regex_'5c'24'5c'7b'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\$\\{[A-Za-z_][A-Za-z0-9_]*"+regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'28'3f'3d'5b'3a'23'25'2f'3d'3f'2b'2d'5d'29 = compileRegex "\\$\\{[*@#?$!_0-9-](?=[:#%/=?+-])"+regex_'5c'5c'5b'60'24'5c'5c'5d = compileRegex "\\\\[`$\\\\]"+regex_'2d'5babcdefghkprstuwxOGLSNozn'5d'28'3f'3d'5cs'29 = compileRegex "-[abcdefghkprstuwxOGLSNozn](?=\\s)"+regex_'2d'28'5bno'5dt'7cef'29'28'3f'3d'5cs'29 = compileRegex "-([no]t|ef)(?=\\s)"+regex_'28'5b'21'3d'5d'3d'3f'7c'5b'3e'3c'5d'29'28'3f'3d'5cs'29 = compileRegex "([!=]=?|[><])(?=\\s)"+regex_'2d'28eq'7cne'7c'5bgl'5d'5bte'5d'29'28'3f'3d'5cs'29 = compileRegex "-(eq|ne|[gl][te])(?=\\s)"+regex_'5cs'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\s\\](?=($|[\\s;|&]))"+regex_'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\](?=($|[\\s;|&]))"+regex_'5cs'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\s\\]\\](?=($|[\\s;|&]))"+regex_'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 = compileRegex "\\]\\](?=($|[\\s;|&]))"+regex_'5b'5cw'3a'2c'2b'5f'2e'2f'2d'5d = compileRegex "[\\w:,+_./-]"+regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'28'5cs'2a'5c'28'5c'29'29'3f = compileRegex "\\s+[A-Za-z_:][A-Za-z0-9_:#%@-]*(\\s*\\(\\))?"+regex_'2d'5bA'2dZa'2dz0'2d9'5d'2b = compileRegex "-[A-Za-z0-9]+"+regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "\\b[A-Za-z_][A-Za-z0-9_]*"+regex_'5b'5e'5d'7d'29'7c'3b'60'26'3e'3c'5d = compileRegex "[^]})|;`&><]"+regex_'5c'5c'5b'60'22'5c'5c'24'5cn'5d = compileRegex "\\\\[`\"\\\\$\\n]"+regex_'5c'5c'5babefnrtv'5c'5c'27'5d = compileRegex "\\\\[abefnrtv\\\\']"+regex_'5c'5c'28'5b0'2d7'5d'7b1'2c3'7d'7cx'5bA'2dFa'2df0'2d9'5d'7b1'2c2'7d'7cc'2e'29 = compileRegex "\\\\([0-7]{1,3}|x[A-Fa-f0-9]{1,2}|c.)"+regex_'28'3a'3f'5b'2d'3d'3f'2b'5d'7c'23'23'3f'7c'25'25'3f'29 = compileRegex "(:?[-=?+]|##?|%%?)"+regex_'2f'2f'3f = compileRegex "//?"+regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "[A-Za-z_][A-Za-z0-9_]*"+regex_'5b0'2d9'5d'2b'28'3f'3d'5b'3a'7d'5d'29 = compileRegex "[0-9]+(?=[:}])"+regex_'5b0'2d9'5d'28'3f'3d'5b'3a'7d'5d'29 = compileRegex "[0-9](?=[:}])"+regex_'5csin'5cb = compileRegex "\\sin\\b"+regex_'5cbesac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 = compileRegex "\\besac(?=$|[\\s;)])"+regex_esac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 = compileRegex "esac(?=$|[\\s;)])"+regex_'28'3c'3c'2d'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29 = compileRegex "(<<-\\s*\"([^|&;()<>\\s]+)\")"+regex_'28'3c'3c'2d'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29 = compileRegex "(<<-\\s*'([^|&;()<>\\s]+)')"+regex_'28'3c'3c'2d'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<-\\s*\\\\([^|&;()<>\\s]+))"+regex_'28'3c'3c'2d'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<-\\s*([^|&;()<>\\s]+))"+regex_'28'3c'3c'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29 = compileRegex "(<<\\s*\"([^|&;()<>\\s]+)\")"+regex_'28'3c'3c'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29 = compileRegex "(<<\\s*'([^|&;()<>\\s]+)')"+regex_'28'3c'3c'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<\\s*\\\\([^|&;()<>\\s]+))"+regex_'28'3c'3c'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29 = compileRegex "(<<\\s*([^|&;()<>\\s]+))"++defaultAttributes = [("Start",NormalTok),("FindAll",NormalTok),("FindMost",NormalTok),("FindComments",NormalTok),("Comment",CommentTok),("FindCommentsParen",NormalTok),("CommentParen",CommentTok),("FindCommentsBackq",NormalTok),("CommentBackq",CommentTok),("FindCommands",NormalTok),("FindOthers",NormalTok),("FindStrings",NormalTok),("FindSubstitutions",NormalTok),("FindTests",NormalTok),("ExprDblParen",NormalTok),("ExprDblParenSubst",NormalTok),("ExprSubParen",NormalTok),("ExprBracket",NormalTok),("ExprDblBracket",NormalTok),("Group",NormalTok),("SubShell",NormalTok),("Assign",NormalTok),("AssignArray",NormalTok),("AssignSubscr",NormalTok),("Subscript",OtherTok),("FunctionDef",FunctionTok),("VarName",NormalTok),("ProcessSubst",NormalTok),("StringSQ",StringTok),("StringDQ",StringTok),("StringEsc",StringTok),("VarBrace",ErrorTok),("VarAlt",NormalTok),("VarSubst",NormalTok),("VarSubst2",NormalTok),("VarSub",ErrorTok),("VarSub2",ErrorTok),("SubstFile",NormalTok),("SubstCommand",NormalTok),("SubstBackq",NormalTok),("Case",NormalTok),("CaseIn",NormalTok),("CaseExpr",NormalTok),("HereDoc",NormalTok),("HereDocRemainder",NormalTok),("HereDocQ",NormalTok),("HereDocNQ",NormalTok),("HereDocIQ",NormalTok),("HereDocINQ",NormalTok)]++parseRules "Start" =+ ((parseRules "FindAll"))++parseRules "FindAll" =+ (((parseRules "FindComments"))+ <|>+ ((parseRules "FindCommands"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "FindMost" =+ (((parseRules "FindComments"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "FindComments" =+ (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute NormalTok) >>~ pushContext "Comment"))++parseRules "Comment" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))++parseRules "FindCommentsParen" =+ (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "CommentParen")+ <|>+ ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute NormalTok) >>~ pushContext "CommentParen"))++parseRules "CommentParen" =+ (((pRegExpr regex_'5b'5e'29'5d'28'3f'3d'5c'29'29 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))))++parseRules "FindCommentsBackq" =+ (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "CommentBackq")+ <|>+ ((pRegExpr regex_'5b'5cs'3b'5d'28'3f'3d'23'29 >>= withAttribute NormalTok) >>~ pushContext "CommentBackq"))++parseRules "CommentBackq" =+ (((pRegExpr regex_'5b'5e'60'5d'28'3f'3d'60'29 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))))++parseRules "FindCommands" =+ (((pDetect2Chars False '(' '(' >>= withAttribute KeywordTok) >>~ pushContext "ExprDblParen")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "ExprDblBracket")+ <|>+ ((pRegExpr regex_'5cs'5c'5b'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "ExprDblBracket")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "ExprBracket")+ <|>+ ((pRegExpr regex_'5cs'5c'5b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "ExprBracket")+ <|>+ ((pRegExpr regex_'5c'7b'28'3f'3d'28'24'7c'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "Group")+ <|>+ ((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "SubShell")+ <|>+ ((pRegExpr regex_'5cbdo'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdone'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbif_'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfi'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbcase'28'3f'21'5b'5cw'24'2b'2d'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "Case")+ <|>+ ((pRegExpr regex_'2d'5bA'2dZa'2dz0'2d9'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'2b'3f'3d >>= withAttribute OtherTok) >>~ pushContext "Assign")+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'3f'3d'5c'5b'2e'2b'5c'5d'5c'2b'3f'3d'29 >>= withAttribute OtherTok) >>~ pushContext "AssignSubscr")+ <|>+ ((pString False ":()" >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute KeywordTok) >>~ pushContext "FunctionDef")+ <|>+ ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'2e'28'3f'3d'5cs'29 >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_builtins >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_unixcommands >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t()!+,<=>&*;?|~\\`" list_builtins'5fvar >>= withAttribute KeywordTok) >>~ pushContext "VarName")+ <|>+ ((pRegExpr regex_'5cd'2a'3c'3c'3c >>= withAttribute KeywordTok))+ <|>+ ((lookAhead (pString False "<<") >> return (NormalTok,"") ) >>~ pushContext "HereDoc")+ <|>+ ((pRegExpr regex_'5b'3c'3e'5d'5c'28 >>= withAttribute KeywordTok) >>~ pushContext "ProcessSubst")+ <|>+ ((pRegExpr regex_'28'5b0'2d9'5d'2a'28'3e'7b1'2c2'7d'7c'3c'29'28'26'5b0'2d9'5d'2b'2d'3f'29'3f'7c'26'3e'7c'3e'26'7c'5b0'2d9'5d'2a'3c'3e'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5b'7c'26'5d'29'5c1'3f >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'5cs'2a'5c'28'5c'29 >>= withAttribute FunctionTok)))++parseRules "FindOthers" =+ (((pRegExpr regex_'5c'5c'5b'5d'5b'3b'5c'5c'24'60'7b'7d'28'29'7c'26'3c'3e'2a_'5d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'5c'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'7b'28'3f'21'28'5cs'7c'24'29'29'5cS'2a'5c'7d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'2f'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'7e'5cw'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2f'28'5b'5cw'5f'40'2e'25'2a'3f'2b'2d'5d'7c'5c'5c_'29'2a'28'3f'3d'28'5b'5cs'2f'29'3a'3b'24'60'27'22'5d'7c'24'29'29 >>= withAttribute NormalTok)))++parseRules "FindStrings" =+ (((pDetect2Chars False '\\' '\'' >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False '\\' '"' >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "StringSQ")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "StringDQ")+ <|>+ ((pDetect2Chars False '$' '\'' >>= withAttribute StringTok) >>~ pushContext "StringEsc")+ <|>+ ((pDetect2Chars False '$' '"' >>= withAttribute StringTok) >>~ pushContext "StringDQ"))++parseRules "FindSubstitutions" =+ (((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'5b >>= withAttribute OtherTok) >>~ pushContext "Subscript")+ <|>+ ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'5c'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'23'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'29'3f'5c'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'21'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'28'5c'5b'5b'2a'40'5d'5c'5d'7c'5b'2a'40'5d'29'3f'5c'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok) >>~ pushContext "VarBrace")+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5b'2a'40'23'3f'24'21'5f0'2d9'2d'5d'28'3f'3d'5b'3a'23'25'2f'3d'3f'2b'2d'5d'29 >>= withAttribute OtherTok) >>~ pushContext "VarBrace")+ <|>+ ((pString False "$((" >>= withAttribute OtherTok) >>~ pushContext "ExprDblParenSubst")+ <|>+ ((pString False "$(<" >>= withAttribute KeywordTok) >>~ pushContext "SubstFile")+ <|>+ ((pString False "$(" >>= withAttribute OtherTok) >>~ pushContext "SubstCommand")+ <|>+ ((pDetectChar False '`' >>= withAttribute KeywordTok) >>~ pushContext "SubstBackq")+ <|>+ ((pRegExpr regex_'5c'5c'5b'60'24'5c'5c'5d >>= withAttribute DataTypeTok)))++parseRules "FindTests" =+ (((pRegExpr regex_'2d'5babcdefghkprstuwxOGLSNozn'5d'28'3f'3d'5cs'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'2d'28'5bno'5dt'7cef'29'28'3f'3d'5cs'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'28'5b'21'3d'5d'3d'3f'7c'5b'3e'3c'5d'29'28'3f'3d'5cs'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'2d'28eq'7cne'7c'5bgl'5d'5bte'5d'29'28'3f'3d'5cs'29 >>= withAttribute OtherTok)))++parseRules "ExprDblParen" =+ (((pDetect2Chars False ')' ')' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "ExprSubParen")+ <|>+ ((parseRules "FindMost")))++parseRules "ExprDblParenSubst" =+ (((pDetect2Chars False ')' ')' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "ExprSubParen")+ <|>+ ((parseRules "FindMost")))++parseRules "ExprSubParen" =+ (((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "ExprSubParen")+ <|>+ ((parseRules "FindMost")))++parseRules "ExprBracket" =+ (((pRegExpr regex_'5cs'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "ExprSubParen")+ <|>+ ((parseRules "FindTests"))+ <|>+ ((parseRules "FindMost")))++parseRules "ExprDblBracket" =+ (((pRegExpr regex_'5cs'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'5d'5c'5d'28'3f'3d'28'24'7c'5b'5cs'3b'7c'26'5d'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "ExprSubParen")+ <|>+ ((parseRules "FindTests"))+ <|>+ ((parseRules "FindMost")))++parseRules "Group" =+ (((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindAll")))++parseRules "SubShell" =+ (((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindAll")))++parseRules "Assign" =+ (((pDetectChar False '(' >>= withAttribute OtherTok) >>~ pushContext "AssignArray")+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers"))+ <|>+ ((pRegExpr regex_'5b'5cw'3a'2c'2b'5f'2e'2f'2d'5d >>= withAttribute NormalTok))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "AssignArray" =+ (((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "Subscript")+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Assign")+ <|>+ ((parseRules "FindMost")))++parseRules "AssignSubscr" =+ (((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "Subscript")+ <|>+ ((pDetect2Chars False '+' '=' >>= withAttribute OtherTok) >>~ pushContext "Assign")+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Assign")+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers"))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "Subscript" =+ (((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "FunctionDef" =+ (((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5bA'2dZa'2dz0'2d9'5f'3a'23'25'40'2d'5d'2a'28'5cs'2a'5c'28'5c'29'29'3f >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "VarName" =+ (((pRegExpr regex_'2d'5bA'2dZa'2dz0'2d9'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'2d'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "Subscript")+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Assign")+ <|>+ ((parseRules "FindMost"))+ <|>+ ((pRegExpr regex_'5b'5e'5d'7d'29'7c'3b'60'26'3e'3c'5d >>= withAttribute NormalTok))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "ProcessSubst" =+ (((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindCommentsParen"))+ <|>+ ((parseRules "FindCommands"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "StringSQ" =+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))++parseRules "StringDQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'5b'60'22'5c'5c'24'5cn'5d >>= withAttribute DataTypeTok))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "StringEsc" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'5babefnrtv'5c'5c'27'5d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'5c'28'5b0'2d7'5d'7b1'2c3'7d'7cx'5bA'2dFa'2df0'2d9'5d'7b1'2c2'7d'7cc'2e'29 >>= withAttribute DataTypeTok)))++parseRules "VarBrace" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "Subscript")+ <|>+ ((pRegExpr regex_'28'3a'3f'5b'2d'3d'3f'2b'5d'7c'23'23'3f'7c'25'25'3f'29 >>= withAttribute OtherTok) >>~ pushContext "VarAlt")+ <|>+ ((pRegExpr regex_'2f'2f'3f >>= withAttribute OtherTok) >>~ pushContext "VarSubst")+ <|>+ ((pDetectChar False ':' >>= withAttribute OtherTok) >>~ pushContext "VarSub"))++parseRules "VarAlt" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "VarSubst" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '/' >>= withAttribute OtherTok) >>~ pushContext "VarSubst2")+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "VarSubst2" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "VarSub" =+ (((pDetectChar False ':' >>= withAttribute OtherTok) >>~ pushContext "VarSub2")+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'2b'28'3f'3d'5b'3a'7d'5d'29 >>= withAttribute OtherTok))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "VarSub2" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'28'3f'3d'5b'3a'7d'5d'29 >>= withAttribute OtherTok))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "SubstFile" =+ (((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindCommentsParen"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "SubstCommand" =+ (((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "FindCommentsParen"))+ <|>+ ((parseRules "FindCommands"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "SubstBackq" =+ (((pDetectChar False '`' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindCommentsBackq"))+ <|>+ ((parseRules "FindCommands"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindSubstitutions"))+ <|>+ ((parseRules "FindOthers")))++parseRules "Case" =+ (((pRegExpr regex_'5csin'5cb >>= withAttribute KeywordTok) >>~ pushContext "CaseIn")+ <|>+ ((parseRules "FindMost")))++parseRules "CaseIn" =+ (((pRegExpr regex_'5cbesac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29 >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ pushContext "CaseExpr")+ <|>+ ((pAnyChar "(|" >>= withAttribute KeywordTok))+ <|>+ ((parseRules "FindMost")))++parseRules "CaseExpr" =+ (((pDetect2Chars False ';' ';' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> lookAhead (pRegExpr regex_esac'28'3f'3d'24'7c'5b'5cs'3b'29'5d'29) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "FindAll")))++parseRules "HereDoc" =+ (((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocIQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocIQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocIQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'2d'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocINQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'22'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'22'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'27'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'27'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'5c'5c'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocQ")+ <|>+ ((lookAhead (pRegExpr regex_'28'3c'3c'5cs'2a'28'5b'5e'7c'26'3b'28'29'3c'3e'5cs'5d'2b'29'29) >> return (NormalTok,"") ) >>~ pushContext "HereDocNQ")+ <|>+ ((pString False "<<" >>= withAttribute KeywordTok) >>~ (popContext)))++parseRules "HereDocRemainder" =+ ((parseRules "FindAll"))++parseRules "HereDocQ" =+ (((pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ pushContext "HereDocRemainder")+ <|>+ ((pColumn 0 >> pRegExprDynamic "%2\\b" >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "HereDocNQ" =+ (((pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ pushContext "HereDocRemainder")+ <|>+ ((pColumn 0 >> pRegExprDynamic "%2\\b" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindSubstitutions")))++parseRules "HereDocIQ" =+ (((pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ pushContext "HereDocRemainder")+ <|>+ ((pColumn 0 >> pRegExprDynamic "\\t*%2\\b" >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "HereDocINQ" =+ (((pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ pushContext "HereDocRemainder")+ <|>+ ((pColumn 0 >> pRegExprDynamic "\\t*%2\\b" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindSubstitutions"))) parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Bibtex.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file bibtex.xml, version 1.17,- by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)+Thomas Braun (thomas.braun@virtuell-zuhause.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file bibtex.xml, version 1.17, by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)+Thomas Braun (thomas.braun@virtuell-zuhause.de) -} -module Text.Highlighting.Kate.Syntax.Bibtex ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Bibtex+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "BibTeX"@@ -19,60 +22,47 @@ syntaxExtensions = "*.bib" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "BibTeX" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("BibTeX",["Normal"])], synStLanguage = "BibTeX", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("BibTeX",["Normal"])], synStLanguage = "BibTeX", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "PreambleCommand" -> return () >> pHandleEndLine- "StringCommand" -> return () >> pHandleEndLine- "Entry" -> return () >> pHandleEndLine- "Field" -> return () >> pHandleEndLine- "CurlyBracket" -> return () >> pHandleEndLine- "QuotedText" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Normal" -> return ()+ "PreambleCommand" -> return ()+ "StringCommand" -> return ()+ "Entry" -> return ()+ "Field" -> return ()+ "CurlyBracket" -> return ()+ "QuotedText" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Entry","kw"),("Command","fu"),("Field","dt"),("Ref Key","ot"),("LatexCommand","ch"),("Comment","co"),("Error","al"),("String","st")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_kw'5fentry = Set.fromList $ words $ "@article @book @booklet @conference @collection @electronic @inbook @incollection @inproceedings @manual @mastersthesis @misc @online @patent @periodical @proceedings @report @phdthesis @set @thesis @techreport @unpublished @www @person @company @place" @@ -84,85 +74,78 @@ regex_'5c'5c'28'5ba'2dzA'2dZ'40'5d'2b'7c'5b'5e_'5d'29 = compileRegex "\\\\([a-zA-Z@]+|[^ ])" regex_'7d'24 = compileRegex "}$" -defaultAttributes = [("Normal","Comment"),("PreambleCommand","Normal Text"),("StringCommand","Normal Text"),("Entry","Normal Text"),("Field","Normal Text"),("CurlyBracket","Normal Text"),("QuotedText","String")]+defaultAttributes = [("Normal",CommentTok),("PreambleCommand",NormalTok),("StringCommand",NormalTok),("Entry",NormalTok),("Field",NormalTok),("CurlyBracket",NormalTok),("QuotedText",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~" list_kw'5fentry >>= withAttribute "Entry") >>~ pushContext "Entry")- <|>- ((pString False "@string" >>= withAttribute "Command") >>~ pushContext "StringCommand")- <|>- ((pString False "@preamble" >>= withAttribute "Command") >>~ pushContext "PreambleCommand")- <|>- ((pString False "@comment" >>= withAttribute "Comment")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~" list_kw'5fentry >>= withAttribute KeywordTok) >>~ pushContext "Entry")+ <|>+ ((pString False "@string" >>= withAttribute FunctionTok) >>~ pushContext "StringCommand")+ <|>+ ((pString False "@preamble" >>= withAttribute FunctionTok) >>~ pushContext "PreambleCommand")+ <|>+ ((pString False "@comment" >>= withAttribute CommentTok))) -parseRules "PreambleCommand" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CurlyBracket")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "PreambleCommand" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CurlyBracket")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "StringCommand" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CurlyBracket")- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5d'2b >>= withAttribute "String") >>~ pushContext "CurlyBracket")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "StringCommand" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CurlyBracket")+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5d'2b >>= withAttribute StringTok) >>~ pushContext "CurlyBracket")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Entry" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5f'40'5c'5c'2d'5c'5c'3a'5d'2b >>= withAttribute "Ref Key"))- <|>- ((pDetectChar False ',' >>= withAttribute "Normal Text") >>~ pushContext "Field")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)+parseRules "Entry" =+ (((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5f'40'5c'5c'2d'5c'5c'3a'5d'2b >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False ',' >>= withAttribute NormalTok) >>~ pushContext "Field")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "Field" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5c'2e'5d'2b >>= withAttribute "Field"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CurlyBracket")- <|>- ((lookAhead (pDetectChar False '}') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Normal Text") >>~ pushContext "QuotedText")- <|>- ((pDetectChar False ',' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '#' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5b0'2d9'5d'2b >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5d'2b >>= withAttribute "String"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'2e >>= withAttribute "Error")))- return (attr, result)+parseRules "Field" =+ (((pFirstNonSpace >> pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5c'2e'5d'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CurlyBracket")+ <|>+ ((lookAhead (pDetectChar False '}') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "QuotedText")+ <|>+ ((pDetectChar False ',' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5c'2d'5d'2b >>= withAttribute StringTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute AlertTok))) -parseRules "CurlyBracket" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CurlyBracket")- <|>- ((pRegExpr regex_'5c'5c'28'5ba'2dzA'2dZ'40'5d'2b'7c'5b'5e_'5d'29 >>= withAttribute "LatexCommand"))- <|>- ((pRegExpr regex_'7d'24 >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)+parseRules "CurlyBracket" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CurlyBracket")+ <|>+ ((pRegExpr regex_'5c'5c'28'5ba'2dzA'2dZ'40'5d'2b'7c'5b'5e_'5d'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'7d'24 >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "QuotedText" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'28'5ba'2dzA'2dZ'40'5d'2b'7c'5b'5e_'5d'29 >>= withAttribute "LatexCommand")))- return (attr, result)+parseRules "QuotedText" =+ (((pDetectChar False '"' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'28'5ba'2dzA'2dZ'40'5d'2b'7c'5b'5e_'5d'29 >>= withAttribute CharTok))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Boo.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file boo.xml, version 0.91,- by Marc Dassonneville -}+{- This module was generated from data in the Kate syntax+ highlighting file boo.xml, version 0.91, by Marc Dassonneville -} -module Text.Highlighting.Kate.Syntax.Boo ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Boo+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Boo"@@ -19,69 +22,56 @@ syntaxExtensions = "*.boo" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Boo" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Boo",["Normal"])], synStLanguage = "Boo", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Boo",["Normal"])], synStLanguage = "Boo", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "parenthesised" -> return () >> pHandleEndLine- "Quasi-Quotation" -> return () >> pHandleEndLine- "Tripple A-comment" -> return () >> pHandleEndLine- "Tripple Q-comment" -> return () >> pHandleEndLine- "Tripple A-string" -> return () >> pHandleEndLine- "Raw Tripple A-string" -> return () >> pHandleEndLine- "Tripple Q-string" -> return () >> pHandleEndLine- "Raw Tripple Q-string" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "parenthesised" -> return ()+ "Quasi-Quotation" -> return ()+ "Tripple A-comment" -> return ()+ "Tripple Q-comment" -> return ()+ "Tripple A-string" -> return ()+ "Raw Tripple A-string" -> return ()+ "Tripple Q-string" -> return ()+ "Raw Tripple Q-string" -> return () "Comment SlashSlash" -> (popContext) >> pEndLine- "Single A-comment" -> return () >> pHandleEndLine- "Single Q-comment" -> return () >> pHandleEndLine- "Single A-string" -> return () >> pHandleEndLine- "Single Q-string" -> return () >> pHandleEndLine- "Raw A-string" -> return () >> pHandleEndLine- "Raw Q-string" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Single A-comment" -> return ()+ "Single Q-comment" -> return ()+ "Single A-string" -> return ()+ "Single Q-string" -> return ()+ "Raw A-string" -> return ()+ "Raw Q-string" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Definition Keyword","kw"),("Data Type","dt"),("Flow Control Keyword","kw"),("Builtin Function","dt"),("Special Variable","ot"),("Preprocessor","ch"),("String Char","ch"),("Long","ot"),("Float","fl"),("Int","dv"),("Hex","ot"),("Octal","ot"),("Complex","ot"),("Comment","co"),("String","st"),("Raw String","st")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_namespace = Set.fromList $ words $ "import from as namespace" list_operators = Set.fromList $ words $ "and assert in is not or"@@ -112,189 +102,173 @@ regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d = compileRegex "%\\([a-zA-Z0-9_]+\\)[a-zA-Z]" regex_'27'27'27 = compileRegex "'''" -defaultAttributes = [("Normal","Normal Text"),("parenthesised","Normal Text"),("Quasi-Quotation","Operator"),("Tripple A-comment","Comment"),("Tripple Q-comment","Comment"),("Tripple A-string","String"),("Raw Tripple A-string","Raw String"),("Tripple Q-string","String"),("Raw Tripple Q-string","Raw String"),("Comment SlashSlash","Comment"),("Single A-comment","Comment"),("Single Q-comment","Comment"),("Single A-string","String"),("Single Q-string","String"),("Raw A-string","Raw String"),("Raw Q-string","Raw String")]+defaultAttributes = [("Normal",NormalTok),("parenthesised",NormalTok),("Quasi-Quotation",NormalTok),("Tripple A-comment",CommentTok),("Tripple Q-comment",CommentTok),("Tripple A-string",StringTok),("Raw Tripple A-string",StringTok),("Tripple Q-string",StringTok),("Raw Tripple Q-string",StringTok),("Comment SlashSlash",CommentTok),("Single A-comment",CommentTok),("Single Q-comment",CommentTok),("Single A-string",StringTok),("Single Q-string",StringTok),("Raw A-string",StringTok),("Raw Q-string",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_namespace >>= withAttribute "Preprocessor"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_definition >>= withAttribute "Definition Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Flow Control Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute "Builtin Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_literals >>= withAttribute "Special Variable"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_boolean >>= withAttribute "Special Variable"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_primitive >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Normal"))- <|>- ((pRegExpr regex__'28'28'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'7c'28'5b0'2d9'5d'2b'7c'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'29'5beE'5d'28'5c'2b'7c'2d'29'3f'5b0'2d9'5d'2b'29'7c'5b0'2d9'5d'2b'29'5bjJ'5d >>= withAttribute "Complex"))- <|>- ((pRegExpr regex_'28'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2a'7c'5c'2e'5b0'2d9'5d'2b'29'28'5beE'5d'5b0'2d9'5d'2b'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'28'5b1'2d9'5d'5b0'2d9'5d'2a'28'5beE'5d'5b0'2d9'5d'2b'29'3f'7c0'29 >>= withAttribute "Int"))- <|>- ((pRegExpr regex_'5b1'2d9'5d'5b0'2d9'5d'2a'28'5beE'5d'5b0'2d9'2e'5d'2b'29'3f'5bLl'5d >>= withAttribute "Long"))- <|>- ((pRegExpr regex_0'5bXx'5d'5b0'2d9a'2dfA'2dF'5d'2b >>= withAttribute "Hex"))- <|>- ((pRegExpr regex_0'5b1'2d9'5d'5b0'2d9'5d'2a >>= withAttribute "Octal"))- <|>- ((pRegExpr regex_'5brR'5d'27'27'27 >>= withAttribute "Raw String") >>~ pushContext "Raw Tripple A-string")- <|>- ((pRegExpr regex_'5brR'5d'22'22'22 >>= withAttribute "Raw String") >>~ pushContext "Raw Tripple Q-string")- <|>- ((pRegExpr regex_'5brR'5d'27 >>= withAttribute "Raw String") >>~ pushContext "Raw A-string")- <|>- ((pRegExpr regex_'5brR'5d'22 >>= withAttribute "Raw String") >>~ pushContext "Raw Q-string")- <|>- ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2au'3f'27'27'27 >>= withAttribute "Comment") >>~ pushContext "Tripple A-comment")- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2au'3f'22'22'22 >>= withAttribute "Comment") >>~ pushContext "Tripple Q-comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Comment SlashSlash")- <|>- ((pString False "'''" >>= withAttribute "String") >>~ pushContext "Tripple A-string")- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ pushContext "Tripple Q-string")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "Single A-string")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Single Q-string")- <|>- ((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "parenthesised")- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pString False "[|" >>= withAttribute "Operator") >>~ pushContext "Quasi-Quotation")- <|>- ((pString False "|]" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'2b'2a'2f'25'5c'7c'3d'3b'5c'21'3c'3e'21'5e'26'7e'2d'5d >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_namespace >>= withAttribute CharTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_definition >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_literals >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_boolean >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_primitive >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex__'28'28'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'7c'28'5b0'2d9'5d'2b'7c'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'29'5beE'5d'28'5c'2b'7c'2d'29'3f'5b0'2d9'5d'2b'29'7c'5b0'2d9'5d'2b'29'5bjJ'5d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'28'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2a'7c'5c'2e'5b0'2d9'5d'2b'29'28'5beE'5d'5b0'2d9'5d'2b'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'28'5b1'2d9'5d'5b0'2d9'5d'2a'28'5beE'5d'5b0'2d9'5d'2b'29'3f'7c0'29 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5b1'2d9'5d'5b0'2d9'5d'2a'28'5beE'5d'5b0'2d9'2e'5d'2b'29'3f'5bLl'5d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_0'5bXx'5d'5b0'2d9a'2dfA'2dF'5d'2b >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_0'5b1'2d9'5d'5b0'2d9'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5brR'5d'27'27'27 >>= withAttribute StringTok) >>~ pushContext "Raw Tripple A-string")+ <|>+ ((pRegExpr regex_'5brR'5d'22'22'22 >>= withAttribute StringTok) >>~ pushContext "Raw Tripple Q-string")+ <|>+ ((pRegExpr regex_'5brR'5d'27 >>= withAttribute StringTok) >>~ pushContext "Raw A-string")+ <|>+ ((pRegExpr regex_'5brR'5d'22 >>= withAttribute StringTok) >>~ pushContext "Raw Q-string")+ <|>+ ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2au'3f'27'27'27 >>= withAttribute CommentTok) >>~ pushContext "Tripple A-comment")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2au'3f'22'22'22 >>= withAttribute CommentTok) >>~ pushContext "Tripple Q-comment")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Comment SlashSlash")+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ pushContext "Tripple A-string")+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Tripple Q-string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Single A-string")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Single Q-string")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "parenthesised")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "[|" >>= withAttribute NormalTok) >>~ pushContext "Quasi-Quotation")+ <|>+ ((pString False "|]" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'2b'2a'2f'25'5c'7c'3d'3b'5c'21'3c'3e'21'5e'26'7e'2d'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))) -parseRules "parenthesised" = - do (attr, result) <- ((parseRules "Normal"))- return (attr, result)+parseRules "parenthesised" =+ ((parseRules "Normal")) -parseRules "Quasi-Quotation" = - do (attr, result) <- ((parseRules "Normal"))- return (attr, result)+parseRules "Quasi-Quotation" =+ ((parseRules "Normal")) -parseRules "Tripple A-comment" = - do (attr, result) <- ((pString False "'''" >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Tripple A-comment" =+ ((pString False "'''" >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Tripple Q-comment" = - do (attr, result) <- (((pHlCChar >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'22'22'22 >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Tripple Q-comment" =+ (((pHlCChar >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'22'22'22 >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Tripple A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'27'27'27 >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Tripple A-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'27'27 >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Tripple A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'27'27'27 >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Tripple A-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'27'27 >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Tripple Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'22'22'22 >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Tripple Q-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'22'22 >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Tripple Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'22'22'22 >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Tripple Q-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'22'22 >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Comment SlashSlash" = - do (attr, result) <- ((pLineContinue >>= withAttribute "Comment"))- return (attr, result)+parseRules "Comment SlashSlash" =+ ((pLineContinue >>= withAttribute CommentTok)) -parseRules "Single A-comment" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Comment"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Single A-comment" =+ (((pHlCStringChar >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Single Q-comment" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Single Q-comment" =+ (((pHlCStringChar >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Single A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Single A-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Single Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Single Q-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)+parseRules "Raw A-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute "String Substitution"))- <|>- ((pDetectChar False '"' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Q-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'25'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/C.hs view
@@ -1,17 +1,20 @@-{- This module was generated from data in the Kate syntax highlighting file c.xml, version 1.44,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file c.xml, version 1.44, by -} -module Text.Highlighting.Kate.Syntax.C ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.C+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "C"@@ -21,64 +24,51 @@ syntaxExtensions = "*.c;*.C;*.h" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "C" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("C",["Normal"])], synStLanguage = "C", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("C",["Normal"])], synStLanguage = "C", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Region Marker" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine+ "Commentar 2" -> return () "AfterHash" -> (popContext) >> pEndLine "Preprocessor" -> (popContext) >> pEndLine "Define" -> (popContext) >> pEndLine- "Commentar/Preprocessor" -> return () >> pHandleEndLine- "Outscoped" -> return () >> pHandleEndLine- "Outscoped intern" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar/Preprocessor" -> return ()+ "Outscoped" -> return ()+ "Outscoped intern" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Preprocessor","ot"),("Prep. Lib","ot"),("Alert","al"),("Region Marker","re"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case continue default do else enum extern for goto if inline return sizeof struct switch typedef union while" list_types = Set.fromList $ words $ "auto char const double float int long register restrict short signed static unsigned void volatile int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t wchar_t _Imaginary _Complex _Bool"@@ -92,160 +82,150 @@ regex_'23'5cs'2aif = compileRegex "#\\s*if" regex_'23'5cs'2ael'28'3f'3ase'7cif'29 = compileRegex "#\\s*el(?:se|if)" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Region Marker","Region Marker"),("Commentar 1","Comment"),("Commentar 2","Comment"),("AfterHash","Error"),("Preprocessor","Preprocessor"),("Define","Preprocessor"),("Commentar/Preprocessor","Comment"),("Outscoped","Comment"),("Outscoped intern","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Region Marker",RegionMarkerTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("AfterHash",ErrorTok),("Preprocessor",OtherTok),("Define",OtherTok),("Commentar/Preprocessor",CommentTok),("Outscoped",CommentTok),("Outscoped intern",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0'5cs'2a'24 >>= withAttribute "Preprocessor") >>~ pushContext "Outscoped")- <|>- ((pFirstNonSpace >> lookAhead (pDetectChar False '#') >> return ([],"") ) >>~ pushContext "AfterHash")- <|>- ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pFirstNonSpace >> pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\'\"" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\'\"" list_types >>= withAttribute "Data Type"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0'5cs'2a'24 >>= withAttribute OtherTok) >>~ pushContext "Outscoped")+ <|>+ ((pFirstNonSpace >> lookAhead (pDetectChar False '#') >> return (NormalTok,"") ) >>~ pushContext "AfterHash")+ <|>+ ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pFirstNonSpace >> pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\'\"" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\'\"" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Region Marker" = +parseRules "Region Marker" = pzero -parseRules "Commentar 1" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "Commentar 1" =+ (((pLineContinue >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Commentar 2" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "Commentar 2" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "AfterHash" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute "Preprocessor") >>~ pushContext "Define")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2b'5b0'2d9'5d'2b >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor"))- return (attr, result)+parseRules "AfterHash" =+ (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute OtherTok) >>~ pushContext "Define")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2b'5b0'2d9'5d'2b >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar/Preprocessor"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute OtherTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute OtherTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar/Preprocessor")) -parseRules "Define" = - do (attr, result) <- ((pLineContinue >>= withAttribute "Preprocessor"))- return (attr, result)+parseRules "Define" =+ ((pLineContinue >>= withAttribute OtherTok)) -parseRules "Commentar/Preprocessor" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar/Preprocessor" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Outscoped" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2ael'28'3f'3ase'7cif'29 >>= withAttribute "Preprocessor") >>~ (popContext))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Preprocessor") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2ael'28'3f'3ase'7cif'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute OtherTok) >>~ (popContext))) -parseRules "Outscoped intern" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped intern" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute CommentTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Changelog.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file changelog.xml, version 1.04,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file changelog.xml, version 1.04, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Changelog ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Changelog+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,56 +21,43 @@ syntaxExtensions = "ChangeLog" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "ChangeLog" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("ChangeLog",["Normal"])], synStLanguage = "ChangeLog", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("ChangeLog",["Normal"])], synStLanguage = "ChangeLog", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "line" -> (popContext) >> pEndLine "entry" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Name","kw"),("E-Mail","ot"),("Date","dt"),("Entry","dv")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'5cd'5cd'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a = compileRegex "\\d\\d\\d\\d\\s*-\\s*\\d\\d\\s*-\\s*\\d\\d\\s*"@@ -75,23 +65,20 @@ regex_'3c'2e'2a'3e'5cs'2a'24 = compileRegex "<.*>\\s*$" regex_'2e'2a'3a = compileRegex ".*:" -defaultAttributes = [("Normal","Normal Text"),("line","Normal Text"),("entry","Normal Text")]+defaultAttributes = [("Normal",NormalTok),("line",NormalTok),("entry",NormalTok)] -parseRules "Normal" = - do (attr, result) <- (((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Entry") >>~ pushContext "entry")- <|>- ((pColumn 0 >> pRegExpr regex_'5cd'5cd'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a >>= withAttribute "Date") >>~ pushContext "line"))- return (attr, result)+parseRules "Normal" =+ (((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute DecValTok) >>~ pushContext "entry")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cd'5cd'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a'2d'5cs'2a'5cd'5cd'5cs'2a >>= withAttribute DataTypeTok) >>~ pushContext "line")) -parseRules "line" = - do (attr, result) <- (((pRegExpr regex_'28'5cw'5cs'2a'29'2b >>= withAttribute "Name"))- <|>- ((pRegExpr regex_'3c'2e'2a'3e'5cs'2a'24 >>= withAttribute "E-Mail") >>~ (popContext)))- return (attr, result)+parseRules "line" =+ (((pRegExpr regex_'28'5cw'5cs'2a'29'2b >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'3c'2e'2a'3e'5cs'2a'24 >>= withAttribute OtherTok) >>~ (popContext))) -parseRules "entry" = - do (attr, result) <- ((pRegExpr regex_'2e'2a'3a >>= withAttribute "Entry") >>~ (popContext))- return (attr, result)+parseRules "entry" =+ ((pRegExpr regex_'2e'2a'3a >>= withAttribute DecValTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Clojure.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file clojure.xml, version 1.05,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file clojure.xml, version 1.05, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Clojure ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Clojure+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Clojure"@@ -19,57 +22,44 @@ syntaxExtensions = "*.clj" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Clojure" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Clojure",["Normal"])], synStLanguage = "Clojure", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Clojure",["Normal"])], synStLanguage = "Clojure", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "function_decl" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "function_decl" -> return () "SpecialNumber" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Operator","kw"),("Modifier","kw"),("Variable","kw"),("Definition","kw"),("Data","dt"),("Decimal","dv"),("BaseN","bn"),("Float","fl"),("Function","fu"),("Char","ch"),("String","st"),("Comment","co"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_definitions = Set.fromList $ words $ "def def- defalias defhinted definline defmacro defmacro- defmethod defmulti defn defn- defnk defn-memo defonce defonce- defprotocol defrecord defstruct defstruct- deftest deftest- deftype defunbound defunbound- defvar defvar-" list_keywords = Set.fromList $ words $ "< <= = == > >= - -> ->> / . .. * + accessor aclone add-classpath add-watcher agent agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and append-child apply apply-template are areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assert-any assert-expr assert-predicate assoc assoc! associative? assoc-in atom atom? attrs await await1 await-for bases bean bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* branch? butlast byte byte-array bytes case cast catch char char? char-array char-escape-string char-name-string chars children chunk chunk-append chunk-buffer chunk-cons chunked-seq? chunk-first chunk-next chunk-rest class class? clear-agent-errors clojure-version coll? collection-tag comment commute comp comparator compare compare-and-set! compile complement compose-fixtures concat cond condp conj conj! cons constantly construct-proxy contains? content content-handler count counted? create-ns create-struct cycle dec decimal? declare delay delay? deliver deref derive descendants destructure difference disj disj! dissoc dissoc! distinct distinct? do doall doc dorun doseq dosync do-template dotimes doto double double-array doubles down drop drop-last drop-while e edit element emit emit-element empty empty? end? ensure enumeration-seq eval even? every? extend extenders extend-protocol extends? extend-type false? ffirst file-position file-seq filter finally find find-doc find-ns find-var first float float? float-array floats flush fn fn? fnext for force format function? future future? future-call future-cancel future-cancelled? future-done? gen-and-load-class gen-and-save-class gen-class gen-interface gensym get get-child get-child-count get-in get-method get-possibly-unbound-var get-proxy-class get-thread-bindings get-validator handle handler-case hash hash-map hash-set identical? identity if if-let ifn? if-not import inc inc-report-counter index init-proxy in-ns insert-child insert-left insert-right inspect inspect-table inspect-tree instance? int int-array integer? interleave intern interpose intersection into into-array ints io! is isa? is-leaf iterate iterator-seq join join-fixtures juxt key keys keyword keyword? keywordize-keys last lazy-cat lazy-seq left leftmost lefts let letfn line-seq list list* list? list-model list-provider load loaded-libs load-file load-reader load-script load-string locking long long-array longs loop macroexpand macroexpand-1 macroexpand-all main make-array make-hierarchy make-node map map? mapcat map-invert max max-key memfn memoize merge merge-with meta methods method-sig min min-key mod name namespace neg? newline next nfirst nil? nnext node not not= not-any? not-empty not-every? ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? or parents partial partition path pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? postwalk postwalk-demo postwalk-replace pr prefer-method prefers prev prewalk prewalk-demo prewalk-replace primitives-classnames print print-cause-trace print-ctor print-doc print-dup printf println println-str print-method print-namespace-doc print-simple print-special-doc print-stack-trace print-str print-throwable print-trace-element prn prn-str project promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super pr-str push-thread-bindings pvalues quot rand rand-int range ratio? rational? rationalize read read-line read-string recur reduce ref refer refer-clojure ref-history-count re-find ref-max-history ref-min-history ref-set re-groups reify release-pending-sends rem re-matcher re-matches remove remove-method remove-ns remove-watcher rename rename-keys re-pattern repeat repeatedly repl replace repl-caught repl-exception replicate repl-prompt repl-read report require re-seq reset! reset-meta! resolve rest resultset-seq reverse reversible? right rightmost rights root rseq rsubseq run-all-tests run-tests satisfies? second select select-keys send send-off seq seq? seque sequence sequential? seq-zip set set? set-test set-validator! short short-array shorts shutdown-agents skip-if-eol skip-whitespace slurp some sort sort-by sorted? sorted-map sorted-map-by sorted-set sorted-set-by special-form-anchor special-symbol? split-at split-with str stream? string? stringify-keys struct struct-map subs subseq subvec successful? supers swap! symbol symbol? sync syntax-symbol-anchor take take-last take-nth take-while test test-all-vars testing testing-contexts-str testing-vars-str test-ns test-var the-ns throw time to-array to-array-2d trampoline transient tree-seq true? try try-expr type unchecked-add unchecked-dec unchecked-divide unchecked-inc unchecked-multiply unchecked-negate unchecked-remainder unchecked-subtract underive unimport union unquote unquote-splicing up update-in update-proxy use use-fixtures val vals var? var-get var-set vary-meta vec vector vector? walk when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision with-test with-test-out xml-seq"@@ -82,75 +72,71 @@ regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a = compileRegex "\\s*[A-Za-z0-9-+\\<\\>//\\*]*\\s*" regex_'23'5c'5c'2e = compileRegex "#\\\\." -defaultAttributes = [("Normal","Normal"),("function_decl","Function"),("SpecialNumber","Normal"),("String","String")]+defaultAttributes = [("Normal",NormalTok),("function_decl",FunctionTok),("SpecialNumber",NormalTok),("String",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '#' '_' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3a'5cS'2b >>= withAttribute "Modifier"))- <|>- ((pRegExpr regex_'5b'40'7e'5d'5cS'2b >>= withAttribute "Modifier"))- <|>- ((pDetect2Chars False '#' '(' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False '(' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets"))- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Brackets"))- <|>- ((pDetect2Chars False '^' '{' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False '{' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False '}' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False '[' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False ']' >>= withAttribute "Brackets"))- <|>- ((pDetect2Chars False '#' '\'' >>= withAttribute "Variable"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_variables >>= withAttribute "Variable"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_definitions >>= withAttribute "Definition") >>~ pushContext "function_decl")- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetect2Chars False '#' '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal")))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '#' '_' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'3a'5cS'2b >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5b'40'7e'5d'5cS'2b >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '#' '(' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '^' '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '#' '\'' >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_variables >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_definitions >>= withAttribute KeywordTok) >>~ pushContext "function_decl")+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '#' '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))) -parseRules "function_decl" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute "Function") >>~ (popContext))- return (attr, result)+parseRules "function_decl" =+ ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute FunctionTok) >>~ (popContext)) -parseRules "SpecialNumber" = - do (attr, result) <- (((pFloat >>= withAttribute "Float") >>~ (popContext))- <|>- ((pInt >>= withAttribute "Decimal") >>~ (popContext))- <|>- ((pHlCOct >>= withAttribute "BaseN") >>~ (popContext))- <|>- ((pHlCHex >>= withAttribute "Float") >>~ (popContext)))- return (attr, result)+parseRules "SpecialNumber" =+ (((pFloat >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pHlCHex >>= withAttribute FloatTok) >>~ (popContext))) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'23'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'23'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pHlCStringChar >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Cmake.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file cmake.xml, version 1.13,- by Alexander Neundorf (neundorf@kde.org) -}+{- This module was generated from data in the Kate syntax+ highlighting file cmake.xml, version 1.13, by Alexander Neundorf (neundorf@kde.org) -} -module Text.Highlighting.Kate.Syntax.Cmake ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Cmake+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "CMake"@@ -20,59 +23,46 @@ syntaxExtensions = "CMakeLists.txt;*.cmake;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "CMake" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("CMake",["Normal Text"])], synStLanguage = "CMake", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("CMake",["Normal Text"])], synStLanguage = "CMake", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine- "Detect Variables" -> return () >> pHandleEndLine- "Command Args" -> return () >> pHandleEndLine- "Macro Args" -> return () >> pHandleEndLine+ "Normal Text" -> return ()+ "Detect Variables" -> return ()+ "Command Args" -> return ()+ "Macro Args" -> return () "Comment" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Special Args","ot"),("Properties","ot"),("Commands","kw"),("Third-Party Commands","fu"),("Macros","fu"),("Strings","st"),("Escapes","ch"),("CMake Variable","dv"),("Environment Variable","fl"),("Comment","co"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_commands = Set.fromList $ words $ "add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command build_name cmake_minimum_required cmake_policy configure_file create_test_sourcelist define_property else elseif enable_language enable_testing endforeach endfunction endif endmacro endwhile exec_program execute_process export export_library_dependencies file find_file find_library find_package find_path find_program fltk_wrap_ui foreach function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property if include include_directories include_external_msproject include_regular_expression install install_files install_programs install_targets link_directories link_libraries list load_cache load_command macro make_directory mark_as_advanced math message option output_required_files project qt_wrap_cpp qt_wrap_ui remove remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string subdir_depends subdirs target_link_libraries try_compile try_run unset use_mangled_mesa utility_source variable_requires variable_watch while write_file" list_itkvtk'5fcommands = Set.fromList $ words $ "itk_wrap_tcl vtk_make_instantiator vtk_wrap_java vtk_wrap_python vtk_wrap_tcl"@@ -90,67 +80,61 @@ regex_'22'28'3f'3d'5b_'29'3b'5d'7c'24'29 = compileRegex "\"(?=[ );]|$)" regex_'5c'5c'5b'22'24n'5c'5c'5d = compileRegex "\\\\[\"$n\\\\]" -defaultAttributes = [("Normal Text","Normal Text"),("Detect Variables","Normal Text"),("Command Args","Normal Text"),("Macro Args","Normal Text"),("Comment","Comment"),("String","Strings")]+defaultAttributes = [("Normal Text",NormalTok),("Detect Variables",NormalTok),("Command Args",NormalTok),("Macro Args",NormalTok),("Comment",CommentTok),("String",StringTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_commands >>= withAttribute "Commands") >>~ pushContext "Command Args")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_itkvtk'5fcommands >>= withAttribute "Third-Party Commands"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((parseRules "Detect Variables"))- <|>- ((pRegExpr regex_'5cw'2b'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute "Macros") >>~ pushContext "Macro Args"))- return (attr, result)+parseRules "Normal Text" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_commands >>= withAttribute KeywordTok) >>~ pushContext "Command Args")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_itkvtk'5fcommands >>= withAttribute FunctionTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((parseRules "Detect Variables"))+ <|>+ ((pRegExpr regex_'5cw'2b'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute FunctionTok) >>~ pushContext "Macro Args")) -parseRules "Detect Variables" = - do (attr, result) <- (((pRegExpr regex_'5c'24ENV'5c'7b'5cs'2a'5cw'2b'5cs'2a'5c'7d >>= withAttribute "Environment Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'5cs'2a'5cw'2b'5cs'2a'5c'7d >>= withAttribute "CMake Variable")))- return (attr, result)+parseRules "Detect Variables" =+ (((pRegExpr regex_'5c'24ENV'5c'7b'5cs'2a'5cw'2b'5cs'2a'5c'7d >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5cs'2a'5cw'2b'5cs'2a'5c'7d >>= withAttribute DecValTok))) -parseRules "Command Args" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special'5fargs >>= withAttribute "Special Args"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extra'5fspecial'5fargs >>= withAttribute "Special Args"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute "Properties"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extra'5fproperties >>= withAttribute "Properties"))- <|>- ((parseRules "Macro Args")))- return (attr, result)+parseRules "Command Args" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special'5fargs >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extra'5fspecial'5fargs >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extra'5fproperties >>= withAttribute OtherTok))+ <|>+ ((parseRules "Macro Args"))) -parseRules "Macro Args" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pString False "\\\"" >>= withAttribute "Escapes"))- <|>- ((pDetectChar False '"' >>= withAttribute "Strings") >>~ pushContext "String")- <|>- ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((parseRules "Detect Variables")))- return (attr, result)+parseRules "Macro Args" =+ (((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "\\\"" >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((parseRules "Detect Variables"))) -parseRules "Comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)+parseRules "Comment" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'22'28'3f'3d'5b_'29'3b'5d'7c'24'29 >>= withAttribute "Strings") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'5b'22'24n'5c'5c'5d >>= withAttribute "Escapes"))- <|>- ((parseRules "Detect Variables")))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'22'28'3f'3d'5b_'29'3b'5d'7c'24'29 >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'5b'22'24n'5c'5c'5d >>= withAttribute CharTok))+ <|>+ ((parseRules "Detect Variables"))) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Coffeescript.hs view
@@ -1,17 +1,20 @@-{- This module was generated from data in the Kate syntax highlighting file coffeescript.xml, version 1.1,- by Max Shawabkeh (max99x@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file coffeescript.xml, version 1.1, by Max Shawabkeh (max99x@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Coffeescript ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Coffeescript+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert_indent import qualified Text.Highlighting.Kate.Syntax.Javascript-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "CofeeScript"@@ -21,64 +24,51 @@ syntaxExtensions = "Cakefile;*.coffee;*.coco" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "CofeeScript" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("CofeeScript",["Normal"])], synStLanguage = "CofeeScript", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("CofeeScript",["Normal"])], synStLanguage = "CofeeScript", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Multiline Regex" -> return () >> pHandleEndLine- "Class" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "Multiline Regex" -> return ()+ "Class" -> return () "Comment" -> (popContext) >> pEndLine- "Multiline Comment" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine- "Rich String" -> return () >> pHandleEndLine- "Heredoc" -> return () >> pHandleEndLine- "Rich Heredoc" -> return () >> pHandleEndLine- "Embedding" -> return () >> pHandleEndLine- "Javascript" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Multiline Comment" -> return ()+ "String" -> return ()+ "Rich String" -> return ()+ "Heredoc" -> return ()+ "Rich Heredoc" -> return ()+ "Embedding" -> return ()+ "Javascript" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Decimal","dv"),("Float","fl"),("Oct","bn"),("Hex","bn"),("String","st"),("Comment","co"),("Symbol","kw"),("Embedding","ch"),("Accessor","dt"),("Class","dt"),("Javascript","al"),("Regex","st"),("Reserved","al"),("Value Keywords","ot"),("Globals","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_value'5fkeywords = Set.fromList $ words $ "false true yes no on off undefined null NaN Infinity" list_keywords = Set.fromList $ words $ "return break continue throw for while until loop if else unless switch when then and or in of by is isnt not typeof delete where super try catch finally try catch finally constructor"@@ -96,121 +86,110 @@ regex_'2f'2f'2f'5bmig'5d'7b0'2c3'7d = compileRegex "///[mig]{0,3}" regex_'5b'40'24'3a'2e'5cw'5c'5b'5c'5d'5d'2b = compileRegex "[@$:.\\w\\[\\]]+" -defaultAttributes = [("Normal","Normal"),("Multiline Regex","Regex"),("Class","Normal"),("Comment","Comment"),("Multiline Comment","Comment"),("String","String"),("Rich String","String"),("Heredoc","String"),("Rich Heredoc","String"),("Embedding","Normal"),("Javascript","Javascript")]+defaultAttributes = [("Normal",NormalTok),("Multiline Regex",StringTok),("Class",NormalTok),("Comment",CommentTok),("Multiline Comment",CommentTok),("String",StringTok),("Rich String",StringTok),("Heredoc",StringTok),("Rich Heredoc",StringTok),("Embedding",NormalTok),("Javascript",AlertTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pHlCOct >>= withAttribute "Oct"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_class'5fkeywords >>= withAttribute "Keyword") >>~ pushContext "Class")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_value'5fkeywords >>= withAttribute "Value Keywords"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_reserved >>= withAttribute "Reserved"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_globals >>= withAttribute "Globals"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_browser'5fglobals >>= withAttribute "Browser Globals"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_nodejs'5fglobals >>= withAttribute "Node.js Globals"))- <|>- ((pRegExpr regex_'28'40'5b'5f'24a'2dzA'2dZ'5d'5b'24'5cw'5d'2b'7c'5cbthis'29'5cb >>= withAttribute "Accessor"))- <|>- ((pRegExpr regex_'28'5c'28'28'5c'27'5b'5e'27'5d'2a'27'7c'22'5b'5e'22'5d'2a'22'7c'5b'5e'28'29'5d'29'2a'5c'29'29'3f'5cs'2a'28'2d'7c'3d'29'3e >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5b'5f'24a'2dz'5d'5b'24'5cw'5d'2b'5cb >>= withAttribute "Identifier"))- <|>- ((pString False "'''" >>= withAttribute "String") >>~ pushContext "Heredoc")- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ pushContext "Rich Heredoc")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Rich String")- <|>- ((pDetectChar False '`' >>= withAttribute "Javascript") >>~ pushContext "Javascript")- <|>- ((pString False "###" >>= withAttribute "Comment") >>~ pushContext "Multiline Comment")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'2f'2f'2f >>= withAttribute "Regex") >>~ pushContext "Multiline Regex")- <|>- ((pRegExpr regex_'2f'28'5b'5e'2f'5c'5c'5cr'5cn'5d'7c'5c'5c'2e'29'2a'2f'5bmig'5d'7b0'2c3'7d >>= withAttribute "Regex"))- <|>- ((pAnyChar "():!%&+,-/.*<=>?[]|~^;{}" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_class'5fkeywords >>= withAttribute KeywordTok) >>~ pushContext "Class")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_value'5fkeywords >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_reserved >>= withAttribute AlertTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_globals >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_browser'5fglobals >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_nodejs'5fglobals >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'40'5b'5f'24a'2dzA'2dZ'5d'5b'24'5cw'5d'2b'7c'5cbthis'29'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'28'5c'28'28'5c'27'5b'5e'27'5d'2a'27'7c'22'5b'5e'22'5d'2a'22'7c'5b'5e'28'29'5d'29'2a'5c'29'29'3f'5cs'2a'28'2d'7c'3d'29'3e >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'5f'24a'2dz'5d'5b'24'5cw'5d'2b'5cb >>= withAttribute NormalTok))+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ pushContext "Heredoc")+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Rich Heredoc")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Rich String")+ <|>+ ((pDetectChar False '`' >>= withAttribute AlertTok) >>~ pushContext "Javascript")+ <|>+ ((pString False "###" >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'2f'2f'2f >>= withAttribute StringTok) >>~ pushContext "Multiline Regex")+ <|>+ ((pRegExpr regex_'2f'28'5b'5e'2f'5c'5c'5cr'5cn'5d'7c'5c'5c'2e'29'2a'2f'5bmig'5d'7b0'2c3'7d >>= withAttribute StringTok))+ <|>+ ((pAnyChar "():!%&+,-/.*<=>?[]|~^;{}" >>= withAttribute KeywordTok))) -parseRules "Multiline Regex" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Regex"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'2f'2f'2f'5bmig'5d'7b0'2c3'7d >>= withAttribute "Regex") >>~ (popContext)))- return (attr, result)+parseRules "Multiline Regex" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'2f'2f'2f'5bmig'5d'7b0'2c3'7d >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Class" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'5b'40'24'3a'2e'5cw'5c'5b'5c'5d'5d'2b >>= withAttribute "Class") >>~ (popContext)))- return (attr, result)+parseRules "Class" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b'40'24'3a'2e'5cw'5c'5b'5c'5d'5d'2b >>= withAttribute DataTypeTok) >>~ (popContext))) -parseRules "Comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression))- return (attr, result)+parseRules "Comment" =+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "Multiline Comment" = - do (attr, result) <- (((pString False "###" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression)))- return (attr, result)+parseRules "Multiline Comment" =+ (((pString False "###" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "String" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Rich String" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String"))- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Embedding") >>~ pushContext "Embedding")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Rich String" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute CharTok) >>~ pushContext "Embedding")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Heredoc" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String"))- <|>- ((pString False "'''" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Heredoc" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Rich Heredoc" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String"))- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Embedding") >>~ pushContext "Embedding")- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Rich Heredoc" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute CharTok) >>~ pushContext "Embedding")+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Embedding" = - do (attr, result) <- ((pDetectChar False '}' >>= withAttribute "Embedding") >>~ (popContext))- return (attr, result)+parseRules "Embedding" =+ ((pDetectChar False '}' >>= withAttribute CharTok) >>~ (popContext)) -parseRules "Javascript" = - do (attr, result) <- (((pDetectChar False '`' >>= withAttribute "Javascript") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))- return (attr, result)+parseRules "Javascript" =+ (((pDetectChar False '`' >>= withAttribute AlertTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Coldfusion.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file coldfusion.xml, version 1.04,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file coldfusion.xml, version 1.04, by -} -module Text.Highlighting.Kate.Syntax.Coldfusion ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Coldfusion+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "ColdFusion"@@ -19,74 +22,61 @@ syntaxExtensions = "*.cfm;*.cfc;*.cfml;*.dbm" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "ColdFusion" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("ColdFusion",["Normal Text"])], synStLanguage = "ColdFusion", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("ColdFusion",["Normal Text"])], synStLanguage = "ColdFusion", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine- "ctxCFSCRIPT Tag" -> return () >> pHandleEndLine- "ctxSCRIPT Tag" -> return () >> pHandleEndLine- "ctxSTYLE Tag" -> return () >> pHandleEndLine- "ctxTag" -> return () >> pHandleEndLine- "ctxTable Tag" -> return () >> pHandleEndLine- "ctxAnchor Tag" -> return () >> pHandleEndLine- "ctxImage Tag" -> return () >> pHandleEndLine- "ctxCF Tag" -> return () >> pHandleEndLine- "ctxCustom Tag" -> return () >> pHandleEndLine- "ctxCFX Tag" -> return () >> pHandleEndLine- "ctxHTML Comment" -> return () >> pHandleEndLine- "ctxCF Comment" -> return () >> pHandleEndLine- "ctxC Style Comment" -> return () >> pHandleEndLine+ "Normal Text" -> return ()+ "ctxCFSCRIPT Tag" -> return ()+ "ctxSCRIPT Tag" -> return ()+ "ctxSTYLE Tag" -> return ()+ "ctxTag" -> return ()+ "ctxTable Tag" -> return ()+ "ctxAnchor Tag" -> return ()+ "ctxImage Tag" -> return ()+ "ctxCF Tag" -> return ()+ "ctxCustom Tag" -> return ()+ "ctxCFX Tag" -> return ()+ "ctxHTML Comment" -> return ()+ "ctxCF Comment" -> return ()+ "ctxC Style Comment" -> return () "ctxOne Line Comment" -> (popContext) >> pEndLine "ctxHTML Entities" -> (popContext) >> pEndLine- "ctxCFSCRIPT Block" -> return () >> pHandleEndLine- "ctxSCRIPT Block" -> return () >> pHandleEndLine- "ctxSTYLE Block" -> return () >> pHandleEndLine- "ctxStyle Properties" -> return () >> pHandleEndLine+ "ctxCFSCRIPT Block" -> return ()+ "ctxSCRIPT Block" -> return ()+ "ctxSTYLE Block" -> return ()+ "ctxStyle Properties" -> return () "ctxStyle Values" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("HTML Comment","co"),("CF Comment","co"),("Script Comment","co"),("Script Functions","fu")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_Script_Keywords = Set.fromList $ words $ "if else for in while do continue break with try catch switch case new var function return this delete true false void throw typeof const default" list_Script_Objects = Set.fromList $ words $ "anchor applet area array boolean button checkbox date document event fileupload form frame function hidden history image layer linke location math navigator number object option password radio regexp reset screen select string submit text textarea window"@@ -111,238 +101,218 @@ regex_'3c'2f'5bsS'5d'5btT'5d'5byY'5d'5blL'5d'5beE'5d'3e = compileRegex "</[sS][tT][yY][lL][eE]>" regex_'23'28'5b0'2d9a'2dfA'2dF'5d'7b3'7d'29'7c'28'5b0'2d9a'2dfA'2dF'5d'7b6'7d'29 = compileRegex "#([0-9a-fA-F]{3})|([0-9a-fA-F]{6})" -defaultAttributes = [("Normal Text","Normal Text"),("ctxCFSCRIPT Tag","Script Tags"),("ctxSCRIPT Tag","Script Tags"),("ctxSTYLE Tag","Style Tags"),("ctxTag","Tags"),("ctxTable Tag","Table Tags"),("ctxAnchor Tag","Anchor Tags"),("ctxImage Tag","Image Tags"),("ctxCF Tag","CF Tags"),("ctxCustom Tag","Custom Tags"),("ctxCFX Tag","CFX Tags"),("ctxHTML Comment","HTML Comment"),("ctxCF Comment","CF Comment"),("ctxC Style Comment","Script Comment"),("ctxOne Line Comment","Script Comment"),("ctxHTML Entities","HTML Entities"),("ctxCFSCRIPT Block","Normal Text"),("ctxSCRIPT Block","Normal Text"),("ctxSTYLE Block","Style Selectors"),("ctxStyle Properties","Style Properties"),("ctxStyle Values","Style Values")]+defaultAttributes = [("Normal Text",NormalTok),("ctxCFSCRIPT Tag",NormalTok),("ctxSCRIPT Tag",NormalTok),("ctxSTYLE Tag",NormalTok),("ctxTag",NormalTok),("ctxTable Tag",NormalTok),("ctxAnchor Tag",NormalTok),("ctxImage Tag",NormalTok),("ctxCF Tag",NormalTok),("ctxCustom Tag",NormalTok),("ctxCFX Tag",NormalTok),("ctxHTML Comment",CommentTok),("ctxCF Comment",CommentTok),("ctxC Style Comment",CommentTok),("ctxOne Line Comment",CommentTok),("ctxHTML Entities",NormalTok),("ctxCFSCRIPT Block",NormalTok),("ctxSCRIPT Block",NormalTok),("ctxSTYLE Block",NormalTok),("ctxStyle Properties",NormalTok),("ctxStyle Values",NormalTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pString False "<!---" >>= withAttribute "CF Comment") >>~ pushContext "ctxCF Comment")- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "ctxHTML Comment")- <|>- ((pRegExpr regex_'3c'5bcC'5d'5bfF'5d'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d >>= withAttribute "Script Tags") >>~ pushContext "ctxCFSCRIPT Tag")- <|>- ((pRegExpr regex_'3c'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d >>= withAttribute "Script Tags") >>~ pushContext "ctxSCRIPT Tag")- <|>- ((pRegExpr regex_'3c'5bsS'5d'5btT'5d'5byY'5d'5blL'5d'5beE'5d >>= withAttribute "Style Tags") >>~ pushContext "ctxSTYLE Tag")- <|>- ((pDetectChar False '&' >>= withAttribute "HTML Entities") >>~ pushContext "ctxHTML Entities")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d'5f >>= withAttribute "Custom Tags") >>~ pushContext "ctxCustom Tag")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d'5bxX'5d'5f >>= withAttribute "CFX Tags") >>~ pushContext "ctxCFX Tag")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d >>= withAttribute "CF Tags") >>~ pushContext "ctxCF Tag")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'28'5btT'5d'5baAhHbBfFrRdD'5d'29'7c'28'5bcC'5d'5baA'5d'5bpP'5d'5btT'5d'29 >>= withAttribute "Table Tags") >>~ pushContext "ctxTable Tag")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5baA'5d_ >>= withAttribute "Anchor Tags") >>~ pushContext "ctxAnchor Tag")- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5biI'5d'5bmM'5d'5bgG'5d_ >>= withAttribute "Image Tags") >>~ pushContext "ctxImage Tag")- <|>- ((pRegExpr regex_'3c'21'3f'5c'2f'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2b >>= withAttribute "Tags") >>~ pushContext "ctxTag"))- return (attr, result)+parseRules "Normal Text" =+ (((pString False "<!---" >>= withAttribute CommentTok) >>~ pushContext "ctxCF Comment")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "ctxHTML Comment")+ <|>+ ((pRegExpr regex_'3c'5bcC'5d'5bfF'5d'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d >>= withAttribute NormalTok) >>~ pushContext "ctxCFSCRIPT Tag")+ <|>+ ((pRegExpr regex_'3c'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d >>= withAttribute NormalTok) >>~ pushContext "ctxSCRIPT Tag")+ <|>+ ((pRegExpr regex_'3c'5bsS'5d'5btT'5d'5byY'5d'5blL'5d'5beE'5d >>= withAttribute NormalTok) >>~ pushContext "ctxSTYLE Tag")+ <|>+ ((pDetectChar False '&' >>= withAttribute NormalTok) >>~ pushContext "ctxHTML Entities")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d'5f >>= withAttribute NormalTok) >>~ pushContext "ctxCustom Tag")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d'5bxX'5d'5f >>= withAttribute NormalTok) >>~ pushContext "ctxCFX Tag")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5bcC'5d'5bfF'5d >>= withAttribute NormalTok) >>~ pushContext "ctxCF Tag")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'28'5btT'5d'5baAhHbBfFrRdD'5d'29'7c'28'5bcC'5d'5baA'5d'5bpP'5d'5btT'5d'29 >>= withAttribute NormalTok) >>~ pushContext "ctxTable Tag")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5baA'5d_ >>= withAttribute NormalTok) >>~ pushContext "ctxAnchor Tag")+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5biI'5d'5bmM'5d'5bgG'5d_ >>= withAttribute NormalTok) >>~ pushContext "ctxImage Tag")+ <|>+ ((pRegExpr regex_'3c'21'3f'5c'2f'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2b >>= withAttribute NormalTok) >>~ pushContext "ctxTag")) -parseRules "ctxCFSCRIPT Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Script Tags") >>~ pushContext "ctxCFSCRIPT Block")- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxCFSCRIPT Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ pushContext "ctxCFSCRIPT Block")+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxSCRIPT Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Script Tags") >>~ pushContext "ctxSCRIPT Block")- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxSCRIPT Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ pushContext "ctxSCRIPT Block")+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxSTYLE Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Style Tags") >>~ pushContext "ctxSTYLE Block")- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxSTYLE Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ pushContext "ctxSTYLE Block")+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxTag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxTag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxTable Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Table Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxTable Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxAnchor Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Anchor Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxAnchor Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxImage Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Image Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxImage Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxCF Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "CF Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxCF Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxCustom Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Custom Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxCustom Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxCFX Tag" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "CFX Tags") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxCFX Tag" =+ (((pDetectChar False '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) -parseRules "ctxHTML Comment" = - do (attr, result) <- (((pString False "<!---" >>= withAttribute "CF Comment") >>~ pushContext "ctxCF Comment")- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext)))- return (attr, result)+parseRules "ctxHTML Comment" =+ (((pString False "<!---" >>= withAttribute CommentTok) >>~ pushContext "ctxCF Comment")+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "ctxCF Comment" = - do (attr, result) <- ((pString False "--->" >>= withAttribute "CF Comment") >>~ (popContext))- return (attr, result)+parseRules "ctxCF Comment" =+ ((pString False "--->" >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "ctxC Style Comment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Script Comment") >>~ (popContext))- return (attr, result)+parseRules "ctxC Style Comment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "ctxOne Line Comment" = +parseRules "ctxOne Line Comment" = pzero -parseRules "ctxHTML Entities" = - do (attr, result) <- ((pDetectChar False ';' >>= withAttribute "HTML Entities") >>~ (popContext))- return (attr, result)+parseRules "ctxHTML Entities" =+ ((pDetectChar False ';' >>= withAttribute NormalTok) >>~ (popContext)) -parseRules "ctxCFSCRIPT Block" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Script Comment") >>~ pushContext "ctxC Style Comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Script Comment") >>~ pushContext "ctxOne Line Comment")- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Script Strings"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Script Strings"))- <|>- ((pInt >>= withAttribute "Script Numbers"))- <|>- ((pFloat >>= withAttribute "Script Numbers"))- <|>- ((pAnyChar "[()[\\]=+-*/]+" >>= withAttribute "Script Operators"))- <|>- ((pAnyChar "{}" >>= withAttribute "Brackets"))- <|>- ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_CFSCRIPT_Keywords >>= withAttribute "Script Keywords"))- <|>- ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_CFSCRIPT_Functions >>= withAttribute "Script Functions"))- <|>- ((pRegExpr regex_'3c'2f'5bcC'5d'5bfF'5d'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d'3e >>= withAttribute "Script Tags") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "ctxCFSCRIPT Block" =+ (((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "ctxC Style Comment")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "ctxOne Line Comment")+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute NormalTok))+ <|>+ ((pFloat >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "[()[\\]=+-*/]+" >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "{}" >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_CFSCRIPT_Keywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_CFSCRIPT_Functions >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'3c'2f'5bcC'5d'5bfF'5d'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "ctxSCRIPT Block" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Script Comment") >>~ pushContext "ctxC Style Comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Script Comment") >>~ pushContext "ctxOne Line Comment")- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Script Strings"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Script Strings"))- <|>- ((pInt >>= withAttribute "Script Numbers"))- <|>- ((pFloat >>= withAttribute "Script Numbers"))- <|>- ((pAnyChar "[()[\\]=+-*/]+" >>= withAttribute "Script Operators"))- <|>- ((pAnyChar "{}" >>= withAttribute "Brackets"))- <|>- ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Keywords >>= withAttribute "Script Keywords"))- <|>- ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Objects >>= withAttribute "Script Objects"))- <|>- ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Methods >>= withAttribute "Script Functions"))- <|>- ((pRegExpr regex_'3c'2f'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d'3e >>= withAttribute "Script Tags") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "ctxSCRIPT Block" =+ (((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "ctxC Style Comment")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "ctxOne Line Comment")+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute NormalTok))+ <|>+ ((pFloat >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "[()[\\]=+-*/]+" >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "{}" >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Keywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Objects >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>%&*/;?[]^{|}~\\" list_Script_Methods >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'3c'2f'5bsS'5d'5bcC'5d'5brR'5d'5biI'5d'5bpP'5d'5btT'5d'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "ctxSTYLE Block" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Script Comment") >>~ pushContext "ctxC Style Comment")- <|>- ((pDetectChar False '{' >>= withAttribute "Brackets") >>~ pushContext "ctxStyle Properties")- <|>- ((pRegExpr regex_'3c'2f'5bsS'5d'5btT'5d'5byY'5d'5blL'5d'5beE'5d'3e >>= withAttribute "Style Tags") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "ctxSTYLE Block" =+ (((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "ctxC Style Comment")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "ctxStyle Properties")+ <|>+ ((pRegExpr regex_'3c'2f'5bsS'5d'5btT'5d'5byY'5d'5blL'5d'5beE'5d'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "ctxStyle Properties" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Brackets") >>~ (popContext))- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Script Comment") >>~ pushContext "ctxC Style Comment")- <|>- ((pDetectChar False ':' >>= withAttribute "Normal Text") >>~ pushContext "ctxStyle Values"))- return (attr, result)+parseRules "ctxStyle Properties" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "ctxC Style Comment")+ <|>+ ((pDetectChar False ':' >>= withAttribute NormalTok) >>~ pushContext "ctxStyle Values")) -parseRules "ctxStyle Values" = - do (attr, result) <- (((pDetectChar False ';' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False ',' >>= withAttribute "Normal Text"))- <|>- ((pInt >>= withAttribute "Numbers"))- <|>- ((pFloat >>= withAttribute "Numbers"))- <|>- ((pRegExpr regex_'23'28'5b0'2d9a'2dfA'2dF'5d'7b3'7d'29'7c'28'5b0'2d9a'2dfA'2dF'5d'7b6'7d'29 >>= withAttribute "Numbers"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "Attribute Values"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute "Attribute Values")))- return (attr, result)+parseRules "ctxStyle Values" =+ (((pDetectChar False ';' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False ',' >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute NormalTok))+ <|>+ ((pFloat >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'23'28'5b0'2d9a'2dfA'2dF'5d'7b3'7d'29'7c'28'5b0'2d9a'2dfA'2dF'5d'7b6'7d'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'27 >>= withAttribute NormalTok))) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Commonlisp.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file commonlisp.xml, version 1.05,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file commonlisp.xml, version 1.05, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Commonlisp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Commonlisp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Common Lisp"@@ -19,58 +22,45 @@ syntaxExtensions = "*.lisp;*.cl;*.lsp" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Common Lisp" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Common Lisp",["Normal"])], synStLanguage = "Common Lisp", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Common Lisp",["Normal"])], synStLanguage = "Common Lisp", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "MultiLineComment" -> return () >> pHandleEndLine- "function_decl" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "MultiLineComment" -> return ()+ "function_decl" -> return () "SpecialNumber" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Operator","kw"),("Modifier","kw"),("Variable","kw"),("Definition","kw"),("Data","dt"),("Decimal","dv"),("BaseN","bn"),("Float","fl"),("Function","fu"),("Char","ch"),("String","st"),("Comment","co"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_symbols = Set.fromList $ words $ "< <= = > >= => - / /= // /// * ** *** + ++ +++ 1- 1+" list_definitions = Set.fromList $ words $ "defclass defconstant defgeneric define-compiler-macro define-condition define-method-combination define-modify-macro define-setf-expander define-setf-method define-symbol-macro defmacro defmethod defpackage defparameter defsetf deftype defvar defun defstruct"@@ -86,69 +76,64 @@ regex_'23'5btf'5d = compileRegex "#[tf]" regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a = compileRegex "\\s*[A-Za-z0-9-+\\<\\>//\\*]*\\s*" -defaultAttributes = [("Normal","Normal"),("MultiLineComment","Comment"),("function_decl","Function"),("SpecialNumber","Normal"),("String","String")]+defaultAttributes = [("Normal",NormalTok),("MultiLineComment",CommentTok),("function_decl",FunctionTok),("SpecialNumber",NormalTok),("String",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'3b'2b'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'3b'2b'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '#' '|' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pDetectChar False '(' >>= withAttribute "Brackets"))- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_symbols >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_modifiers >>= withAttribute "Modifier"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_variables >>= withAttribute "Variable"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_definitions >>= withAttribute "Definition") >>~ pushContext "function_decl")- <|>- ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'23'5bbodxei'5d >>= withAttribute "Char") >>~ pushContext "SpecialNumber")- <|>- ((pRegExpr regex_'23'5btf'5d >>= withAttribute "Decimal"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal")))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'3b'2b'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'3b'2b'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '#' '|' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_symbols >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_modifiers >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_variables >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_definitions >>= withAttribute KeywordTok) >>~ pushContext "function_decl")+ <|>+ ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'23'5bbodxei'5d >>= withAttribute CharTok) >>~ pushContext "SpecialNumber")+ <|>+ ((pRegExpr regex_'23'5btf'5d >>= withAttribute DecValTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))) -parseRules "MultiLineComment" = - do (attr, result) <- ((pDetect2Chars False '|' '#' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "MultiLineComment" =+ ((pDetect2Chars False '|' '#' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "function_decl" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute "Function") >>~ (popContext))- return (attr, result)+parseRules "function_decl" =+ ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute FunctionTok) >>~ (popContext)) -parseRules "SpecialNumber" = - do (attr, result) <- (((pFloat >>= withAttribute "Float") >>~ (popContext))- <|>- ((pInt >>= withAttribute "Decimal") >>~ (popContext))- <|>- ((pHlCOct >>= withAttribute "BaseN") >>~ (popContext))- <|>- ((pHlCHex >>= withAttribute "Float") >>~ (popContext)))- return (attr, result)+parseRules "SpecialNumber" =+ (((pFloat >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pHlCHex >>= withAttribute FloatTok) >>~ (popContext))) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'23'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'23'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pHlCStringChar >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Cpp.hs view
@@ -1,17 +1,20 @@-{- This module was generated from data in the Kate syntax highlighting file cpp.xml, version 1.49,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file cpp.xml, version 1.49, by -} -module Text.Highlighting.Kate.Syntax.Cpp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Cpp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "C++"@@ -21,64 +24,51 @@ syntaxExtensions = "*.c++;*.cxx;*.cpp;*.cc;*.C;*.h;*.hh;*.H;*.h++;*.hxx;*.hpp;*.hcc;*.moc" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "C++" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("C++",["Normal"])], synStLanguage = "C++", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("C++",["Normal"])], synStLanguage = "C++", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Region Marker" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine+ "Commentar 2" -> return () "AfterHash" -> (popContext) >> pEndLine "Preprocessor" -> (popContext) >> pEndLine "Define" -> (popContext) >> pEndLine- "Commentar/Preprocessor" -> return () >> pHandleEndLine- "Outscoped" -> return () >> pHandleEndLine- "Outscoped intern" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar/Preprocessor" -> return ()+ "Outscoped" -> return ()+ "Outscoped intern" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Extensions","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Preprocessor","ot"),("Prep. Lib","ot"),("Region Marker","re"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "asm break case catch class constexpr const_cast continue decltype default delete do dynamic_cast else enum explicit export extern false friend for goto if inline namespace new nullptr operator private protected public qobject_cast reinterpret_cast return sizeof static_assert static_cast struct switch template this throw true try typedef typeid type_info typename union using virtual while and and_eq bad_cast bad_typeid bitand bitor compl not not_eq or or_eq xor xor_eq" list_extensions = Set.fromList $ words $ "K_DCOP Q_ARG Q_ASSERT Q_ASSERT_X Q_CHECK_PTR Q_CLASSINFO Q_CLEANUP_RESOURCE Q_D Q_DECLARE_FLAGS Q_DECLARE_FLAGS Q_DECLARE_INTERFACE Q_DECLARE_METATYPE Q_DECLARE_OPERATORS_FOR_FLAGS Q_DECLARE_PRIVATE Q_DECLARE_PUBLIC Q_DECLARE_SHARED Q_DECLARE_TYPEINFO Q_DISABLE_COPY Q_ENUMS Q_EXPORT Q_FLAGS Q_FOREACH Q_FOREVER Q_GADGET Q_GLOBAL_STATIC Q_GLOBAL_STATIC_WITH_ARGS Q_INIT_RESOURCE Q_INTERFACES Q_INVOKABLE Q_NOREPLY Q_OBJECT Q_OVERRIDE Q_PRIVATE_SLOT Q_PROPERTY Q_Q Q_RETURN_ARG Q_SCRIPTABLE Q_SETS Q_SIGNALS Q_SLOTS Q_UNUSED SIGNAL SLOT TRUE FALSE connect disconnect emit signals slots foreach forever qint8 qint16 qint32 qint64 qlonglong qptrdiff qreal quint8 quint16 quint32 quint64 quintptr qulonglong"@@ -93,174 +83,164 @@ regex_'23'5cs'2aif = compileRegex "#\\s*if" regex_'23'5cs'2ael'28'3f'3ase'7cif'29 = compileRegex "#\\s*el(?:se|if)" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Region Marker","Region Marker"),("Commentar 1","Comment"),("Commentar 2","Comment"),("AfterHash","Error"),("Preprocessor","Preprocessor"),("Define","Preprocessor"),("Commentar/Preprocessor","Comment"),("Outscoped","Comment"),("Outscoped intern","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Region Marker",RegionMarkerTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("AfterHash",ErrorTok),("Preprocessor",OtherTok),("Define",OtherTok),("Commentar/Preprocessor",CommentTok),("Outscoped",CommentTok),("Outscoped intern",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0'5cs'2a'24 >>= withAttribute "Preprocessor") >>~ pushContext "Outscoped")- <|>- ((pFirstNonSpace >> lookAhead (pDetectChar False '#') >> return ([],"") ) >>~ pushContext "AfterHash")- <|>- ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pFirstNonSpace >> pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extensions >>= withAttribute "Extensions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]{|}~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0'5cs'2a'24 >>= withAttribute OtherTok) >>~ pushContext "Outscoped")+ <|>+ ((pFirstNonSpace >> lookAhead (pDetectChar False '#') >> return (NormalTok,"") ) >>~ pushContext "AfterHash")+ <|>+ ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pFirstNonSpace >> pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extensions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]{|}~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Region Marker" = +parseRules "Region Marker" = pzero -parseRules "Commentar 1" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment"))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 1" =+ (((pLineContinue >>= withAttribute CommentTok))+ <|>+ ((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Commentar 2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 2" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "AfterHash" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute "Preprocessor") >>~ pushContext "Define")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2b'5b0'2d9'5d'2b >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor"))- return (attr, result)+parseRules "AfterHash" =+ (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute OtherTok) >>~ pushContext "Define")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2b'5b0'2d9'5d'2b >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar/Preprocessor")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute OtherTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute OtherTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar/Preprocessor")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")) -parseRules "Define" = - do (attr, result) <- ((pLineContinue >>= withAttribute "Preprocessor"))- return (attr, result)+parseRules "Define" =+ ((pLineContinue >>= withAttribute OtherTok)) -parseRules "Commentar/Preprocessor" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar/Preprocessor" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Outscoped" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2ael'28'3f'3ase'7cif'29 >>= withAttribute "Preprocessor") >>~ (popContext))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Preprocessor") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2ael'28'3f'3ase'7cif'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute OtherTok) >>~ (popContext))) -parseRules "Outscoped intern" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped intern" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute CommentTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Cs.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file cs.xml, version 1.15,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file cs.xml, version 1.15, by -} -module Text.Highlighting.Kate.Syntax.Cs ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Cs+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "C#"@@ -20,58 +23,45 @@ syntaxExtensions = "*.cs" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "C#" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("C#",["Normal"])], synStLanguage = "C#", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("C#",["Normal"])], synStLanguage = "C#", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Member" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar 2" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "abstract as base break case catch class checked continue default delegate do else enum event explicit extern false for foreach finally fixed goto if implicit in interface internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw true try typeof unchecked unsafe using virtual while #if #else #elif #endif #define #undef #warning #error #line" list_types = Set.fromList $ words $ "bool byte char const decimal double float int long object uint ushort ulong sbyte short string void"@@ -87,90 +77,86 @@ regex_'5b'2e'5d'7b1'2c1'7d = compileRegex "[.]{1,1}" regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'29 = compileRegex "\\b[_\\w][_\\w\\d]*(?=[\\s]*)" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Member","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Member",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pRegExpr regex_'5cbpartial'28'3f'3d'5cs'2b'28class'7cstruct'7cinterface'7cvoid'29'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbvar'28'3f'3d'5cs'2b'5cw'2b'5cs'2a'3d'5cs'2a'5cw'2b'29 >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbyield'28'3f'3d'5cs'2b'28return'7cbreak'29'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28set'7cget'29'28'3f'3d'5cs'2a'5b'3b'7b'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbglobal'28'3f'3d'5cs'2a'3a'3a'5cs'2a'5cw'2b'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'23region'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'23endregion'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute "Symbol") >>~ pushContext "Member")- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cbpartial'28'3f'3d'5cs'2b'28class'7cstruct'7cinterface'7cvoid'29'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbvar'28'3f'3d'5cs'2b'5cw'2b'5cs'2a'3d'5cs'2a'5cw'2b'29 >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbyield'28'3f'3d'5cs'2b'28return'7cbreak'29'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28set'7cget'29'28'3f'3d'5cs'2a'5b'3b'7b'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbglobal'28'3f'3d'5cs'2a'3a'3a'5cs'2a'5cw'2b'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'23region'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'23endregion'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute NormalTok) >>~ pushContext "Member")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Member" = - do (attr, result) <- (((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute "Function") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Member" =+ (((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Commentar 1" = +parseRules "Commentar 1" = pzero -parseRules "Commentar 2" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar 2" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Css.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file css.xml, version 2.05,- by Wilbert Berendsen (wilbert@kde.nl) -}+{- This module was generated from data in the Kate syntax+ highlighting file css.xml, version 2.05, by Wilbert Berendsen (wilbert@kde.nl) -} -module Text.Highlighting.Kate.Syntax.Css ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Css+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "CSS"@@ -20,72 +23,59 @@ syntaxExtensions = "*.css" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "CSS" } context <- currentContext <|> (pushContext "Base" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("CSS",["Base"])], synStLanguage = "CSS", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("CSS",["Base"])], synStLanguage = "CSS", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Base" -> return () >> pHandleEndLine- "FindRuleSets" -> return () >> pHandleEndLine- "FindValues" -> return () >> pHandleEndLine- "FindStrings" -> return () >> pHandleEndLine- "FindComments" -> return () >> pHandleEndLine- "Media" -> return () >> pHandleEndLine- "Media2" -> return () >> pHandleEndLine- "SelAttr" -> return () >> pHandleEndLine+ "Base" -> return ()+ "FindRuleSets" -> return ()+ "FindValues" -> return ()+ "FindStrings" -> return ()+ "FindComments" -> return ()+ "Media" -> return ()+ "Media2" -> return ()+ "SelAttr" -> return () "SelPseudo" -> (popContext) >> pEndLine- "Import" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "RuleSet" -> return () >> pHandleEndLine- "Rule" -> return () >> pHandleEndLine- "Rule2" -> return () >> pHandleEndLine- "PropParen" -> return () >> pHandleEndLine- "PropParen2" -> return () >> pHandleEndLine- "StringDQ" -> return () >> pHandleEndLine- "StringSQ" -> return () >> pHandleEndLine- "InsideString" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Import" -> return ()+ "Comment" -> return ()+ "RuleSet" -> return ()+ "Rule" -> return ()+ "Rule2" -> return ()+ "PropParen" -> return ()+ "PropParen2" -> return ()+ "StringDQ" -> return ()+ "StringSQ" -> return ()+ "InsideString" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Property","kw"),("Unknown Property","kw"),("Media","dv"),("At Rule","dv"),("String","st"),("Value","dt"),("Important","kw"),("Selector Attr","ch"),("Selector Id","fl"),("Selector Class","fl"),("Selector Pseudo","dv"),("Comment","co"),("Region Marker","re"),("Alert","al"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_properties = Set.fromList $ words $ "azimuth background background-attachment background-color background-image background-position background-repeat border border-bottom border-bottom-color border-bottom-style border-bottom-width border-collapse border-color border-left border-left-color border-left-style border-left-width border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-style border-top-width border-width bottom caption-side clear clip color content counter-increment counter-reset cue cue-after cue-before cursor direction display elevation empty-cells float font font-family font-size font-size-adjust font-stretch font-style font-variant font-weight height left letter-spacing line-height list-style list-style-image list-style-keyword list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top marker-offset max-height max-width min-height min-width orphans outline outline-color outline-style outline-width overflow padding padding-bottom padding-left padding-right padding-top page page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes richness right size speak speak-header speak-numeral speak-punctuation speech-rate stress table-layout text-align text-decoration text-decoration-color text-indent text-shadow text-transform top unicode-bidi vertical-align visibility voice-family volume white-space widows width word-spacing z-index border-bottom-image border-bottom-left-image border-bottom-left-radius border-bottom-right-image border-bottom-right-radius border-corner-image border-image border-left-image border-radius border-right-image border-top-image border-top-left-image border-top-left-radius border-top-right-image border-top-right-radius box-shadow box-sizing opacity outline-offset overflow-x overflow-y text-overflow text-shadow -moz-border-bottom-colors -moz-border-left-colors -moz-border-radius -moz-border-right-colors -moz-border-top-colors -moz-box-flex -o-background-size -o-text-overflow -khtml-background-size konq_bgpos_x konq_bgpos_y -webkit-background-size font-family font-size font-stretch font-style font-variant font-weight unicode-range units-per-em src panose-1 stemv stemh slope cap-height x-height ascent descent widths bbox definition-src baseline centerline mathline topline" list_types = Set.fromList $ words $ "inherit none hidden dotted dashed solid double groove ridge inset outset xx-small x-small small medium large x-large xx-large smaller larger italic oblique small-caps normal bold bolder lighter light 100 200 300 400 500 600 700 800 900 transparent repeat repeat-x repeat-y no-repeat baseline sub super top text-top middle bottom text-bottom left right center justify konq-center disc circle square box decimal decimal-leading-zero lower-roman upper-roman lower-greek lower-alpha lower-latin upper-alpha upper-latin hebrew armenian georgian cjk-ideographic hiragana katakana hiragana-iroha katakana-iroha inline inline-block block list-item run-in compact marker table inline-table table-row-group table-header-group table-footer-group table-row table-column-group table-column table-cell table-caption auto crosshair default pointer move e-resize ne-resize nw-resize n-resize se-resize sw-resize s-resize w-resize text wait help above absolute always avoid below bidi-override blink both capitalize caption clip close-quote collapse condensed crop cross ellipsis ellipsis-word embed expanded extra-condensed extra-expanded fixed hand hide higher icon inside invert landscape level line-through loud lower lowercase ltr menu message-box mix narrower no-close-quote no-open-quote nowrap open-quote outside overline portrait pre pre-line pre-wrap relative rtl scroll semi-condensed semi-expanded separate show small-caption static static-position status-bar thick thin ultra-condensed ultra-expanded underline uppercase visible wider break serif sans-serif cursive fantasy monospace border-box content-box -moz-box"@@ -112,189 +102,170 @@ regex_'21important'5cb = compileRegex "!important\\b" regex_'5c'5c'5b'22'27'5d = compileRegex "\\\\[\"']" -defaultAttributes = [("Base","Normal Text"),("FindRuleSets","Normal Text"),("FindValues","Normal Text"),("FindStrings","Normal Text"),("FindComments","Normal Text"),("Media","Normal Text"),("Media2","Normal Text"),("SelAttr","Selector Attr"),("SelPseudo","Selector Pseudo"),("Import","Normal Text"),("Comment","Comment"),("RuleSet","Normal Text"),("Rule","Normal Text"),("Rule2","Normal Text"),("PropParen","Normal Text"),("PropParen2","Normal Text"),("StringDQ","String"),("StringSQ","String"),("InsideString","String")]+defaultAttributes = [("Base",NormalTok),("FindRuleSets",NormalTok),("FindValues",NormalTok),("FindStrings",NormalTok),("FindComments",NormalTok),("Media",NormalTok),("Media2",NormalTok),("SelAttr",CharTok),("SelPseudo",DecValTok),("Import",NormalTok),("Comment",CommentTok),("RuleSet",NormalTok),("Rule",NormalTok),("Rule2",NormalTok),("PropParen",NormalTok),("PropParen2",NormalTok),("StringDQ",StringTok),("StringSQ",StringTok),("InsideString",StringTok)] -parseRules "Base" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Normal Text"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((parseRules "FindRuleSets")))- return (attr, result)+parseRules "Base" =+ (((pLineContinue >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((parseRules "FindRuleSets"))) -parseRules "FindRuleSets" = - do (attr, result) <- (((pRegExpr regex_'40media'5cb >>= withAttribute "Media") >>~ pushContext "Media")- <|>- ((pRegExpr regex_'40import'5cb >>= withAttribute "At Rule") >>~ pushContext "Import")- <|>- ((pRegExpr regex_'40'28font'2dface'7ccharset'29'5cb >>= withAttribute "At Rule"))- <|>- ((pDetectChar False '{' >>= withAttribute "Property") >>~ pushContext "RuleSet")- <|>- ((pDetectChar False '[' >>= withAttribute "Selector Attr") >>~ pushContext "SelAttr")- <|>- ((pRegExpr regex_'23'28'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5d'7c'5b'5cx80'2d'5cxFF'5d'7c'5c'5c'5b0'2d9A'2dFa'2df'5d'7b1'2c6'7d'29'2a >>= withAttribute "Selector Id"))- <|>- ((pRegExpr regex_'5c'2e'28'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5d'7c'5b'5cx80'2d'5cxFF'5d'7c'5c'5c'5b0'2d9A'2dFa'2df'5d'7b1'2c6'7d'29'2a >>= withAttribute "Selector Class"))- <|>- ((pRegExpr regex_'3alang'5c'28'5b'5cw'5f'2d'5d'2b'5c'29 >>= withAttribute "Selector Pseudo"))- <|>- ((pDetectChar False ':' >>= withAttribute "Selector Pseudo") >>~ pushContext "SelPseudo")- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindComments")))- return (attr, result)+parseRules "FindRuleSets" =+ (((pRegExpr regex_'40media'5cb >>= withAttribute DecValTok) >>~ pushContext "Media")+ <|>+ ((pRegExpr regex_'40import'5cb >>= withAttribute DecValTok) >>~ pushContext "Import")+ <|>+ ((pRegExpr regex_'40'28font'2dface'7ccharset'29'5cb >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "RuleSet")+ <|>+ ((pDetectChar False '[' >>= withAttribute CharTok) >>~ pushContext "SelAttr")+ <|>+ ((pRegExpr regex_'23'28'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5d'7c'5b'5cx80'2d'5cxFF'5d'7c'5c'5c'5b0'2d9A'2dFa'2df'5d'7b1'2c6'7d'29'2a >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'2e'28'5ba'2dzA'2dZ0'2d9'5c'2d'5f'5d'7c'5b'5cx80'2d'5cxFF'5d'7c'5c'5c'5b0'2d9A'2dFa'2df'5d'7b1'2c6'7d'29'2a >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'3alang'5c'28'5b'5cw'5f'2d'5d'2b'5c'29 >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False ':' >>= withAttribute DecValTok) >>~ pushContext "SelPseudo")+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindComments"))) -parseRules "FindValues" = - do (attr, result) <- (((pRegExpr regex_'5b'2d'2b'5d'3f'5b0'2d9'2e'5d'2b'28em'7cex'7cch'7crem'7cvw'7cvh'7cvm'7cpx'7cin'7ccm'7cmm'7cpt'7cpc'7cdeg'7crad'7cgrad'7cturn'7cms'7cs'7cHz'7ckHz'29'5cb >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'5b'2d'2b'5d'3f'5b0'2d9'2e'5d'2b'5b'25'5d'3f >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'5b'5cw'5c'2d'5d'2b >>= withAttribute "Normal Text")))- return (attr, result)+parseRules "FindValues" =+ (((pRegExpr regex_'5b'2d'2b'5d'3f'5b0'2d9'2e'5d'2b'28em'7cex'7cch'7crem'7cvw'7cvh'7cvm'7cpx'7cin'7ccm'7cmm'7cpt'7cpc'7cdeg'7crad'7cgrad'7cturn'7cms'7cs'7cHz'7ckHz'29'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'2d'2b'5d'3f'5b0'2d9'2e'5d'2b'5b'25'5d'3f >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'5cw'5c'2d'5d'2b >>= withAttribute NormalTok))) -parseRules "FindStrings" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "StringDQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "StringSQ"))- return (attr, result)+parseRules "FindStrings" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "StringDQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "StringSQ")) -parseRules "FindComments" = - do (attr, result) <- (((pRegExpr regex_'2f'5c'2aBEGIN'2e'2a'5c'2a'2f >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'2f'5c'2aEND'2e'2a'5c'2a'2f >>= withAttribute "Region Marker"))- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)+parseRules "FindComments" =+ (((pRegExpr regex_'2f'5c'2aBEGIN'2e'2a'5c'2a'2f >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'2f'5c'2aEND'2e'2a'5c'2a'2f >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment")) -parseRules "Media" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Media") >>~ pushContext "Media2")- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_mediatypes >>= withAttribute "Media"))- <|>- ((pDetectChar False ',' >>= withAttribute "Media"))- <|>- ((parseRules "FindComments"))- <|>- ((pRegExpr regex_'5cS'2b >>= withAttribute "Error")))- return (attr, result)+parseRules "Media" =+ (((pDetectChar False '{' >>= withAttribute DecValTok) >>~ pushContext "Media2")+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_mediatypes >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False ',' >>= withAttribute DecValTok))+ <|>+ ((parseRules "FindComments"))+ <|>+ ((pRegExpr regex_'5cS'2b >>= withAttribute ErrorTok))) -parseRules "Media2" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Media") >>~ (popContext >> popContext))- <|>- ((parseRules "FindRuleSets")))- return (attr, result)+parseRules "Media2" =+ (((pDetectChar False '}' >>= withAttribute DecValTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindRuleSets"))) -parseRules "SelAttr" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Selector Attr") >>~ (popContext))- <|>- ((parseRules "FindStrings")))- return (attr, result)+parseRules "SelAttr" =+ (((pDetectChar False ']' >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((parseRules "FindStrings"))) -parseRules "SelPseudo" = - do (attr, result) <- (((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_pseudoclasses >>= withAttribute "Selector Pseudo") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "SelPseudo" =+ (((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_pseudoclasses >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Import" = - do (attr, result) <- (((pDetectChar False ';' >>= withAttribute "At Rule") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_mediatypes >>= withAttribute "Media"))- <|>- ((parseRules "FindValues"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindComments")))- return (attr, result)+parseRules "Import" =+ (((pDetectChar False ';' >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_mediatypes >>= withAttribute DecValTok))+ <|>+ ((parseRules "FindValues"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindComments"))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "RuleSet" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Property") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_properties >>= withAttribute "Property") >>~ pushContext "Rule")- <|>- ((pRegExpr regex_'2d'3f'5bA'2dZa'2dz'5f'2d'5d'2b'28'3f'3d'5cs'2a'3a'29 >>= withAttribute "Unknown Property") >>~ pushContext "Rule")- <|>- ((parseRules "FindComments"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "RuleSet" =+ (((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_properties >>= withAttribute KeywordTok) >>~ pushContext "Rule")+ <|>+ ((pRegExpr regex_'2d'3f'5bA'2dZa'2dz'5f'2d'5d'2b'28'3f'3d'5cs'2a'3a'29 >>= withAttribute KeywordTok) >>~ pushContext "Rule")+ <|>+ ((parseRules "FindComments"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Rule" = - do (attr, result) <- (((pDetectChar False ':' >>= withAttribute "Property") >>~ pushContext "Rule2")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Rule" =+ (((pDetectChar False ':' >>= withAttribute KeywordTok) >>~ pushContext "Rule2")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Rule2" = - do (attr, result) <- (((pDetectChar False ';' >>= withAttribute "Property") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '}' >>= withAttribute "Property") >>~ (popContext >> popContext >> popContext))- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_types >>= withAttribute "Value"))- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_colors >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'23'28'5b0'2d9A'2dFa'2df'5d'7b3'7d'29'7b1'2c4'7d'5cb >>= withAttribute "Value"))- <|>- ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_paren >>= withAttribute "Value") >>~ pushContext "PropParen")- <|>- ((pRegExpr regex_'21important'5cb >>= withAttribute "Important"))- <|>- ((parseRules "FindValues"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindComments")))- return (attr, result)+parseRules "Rule2" =+ (((pDetectChar False ';' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_colors >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'23'28'5b0'2d9A'2dFa'2df'5d'7b3'7d'29'7b1'2c4'7d'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,<=>&*/;?[]^{|}~\\" list_paren >>= withAttribute DataTypeTok) >>~ pushContext "PropParen")+ <|>+ ((pRegExpr regex_'21important'5cb >>= withAttribute KeywordTok))+ <|>+ ((parseRules "FindValues"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindComments"))) -parseRules "PropParen" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Value") >>~ pushContext "PropParen2")- <|>- ((parseRules "FindComments"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "PropParen" =+ (((pDetectChar False '(' >>= withAttribute DataTypeTok) >>~ pushContext "PropParen2")+ <|>+ ((parseRules "FindComments"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "PropParen2" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindValues"))- <|>- ((parseRules "FindStrings"))- <|>- ((parseRules "FindComments")))- return (attr, result)+parseRules "PropParen2" =+ (((pDetectChar False ')' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindValues"))+ <|>+ ((parseRules "FindStrings"))+ <|>+ ((parseRules "FindComments"))) -parseRules "StringDQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "InsideString")))- return (attr, result)+parseRules "StringDQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "InsideString"))) -parseRules "StringSQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "InsideString")))- return (attr, result)+parseRules "StringSQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "InsideString"))) -parseRules "InsideString" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5b'22'27'5d >>= withAttribute "String"))- <|>- ((pDetectIdentifier >>= withAttribute "String")))- return (attr, result)+parseRules "InsideString" =+ (((pRegExpr regex_'5c'5c'5b'22'27'5d >>= withAttribute StringTok))+ <|>+ ((pDetectIdentifier >>= withAttribute StringTok))) parseRules "" = parseRules "Base"
Text/Highlighting/Kate/Syntax/D.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file d.xml, version 1.62,- by Diggory Hardy (diggory.hardy@gmail.com), Aziz Köksal (aziz.koeksal@gmail.com), Jari-Matti Mäkelä (jmjm@iki.fi), Simon J Mackenzie (project.katedxml@smackoz.fastmail.fm) -}+{- This module was generated from data in the Kate syntax+ highlighting file d.xml, version 1.62, by Diggory Hardy (diggory.hardy@gmail.com), Aziz Köksal (aziz.koeksal@gmail.com), Jari-Matti Mäkelä (jmjm@iki.fi), Simon J Mackenzie (project.katedxml@smackoz.fastmail.fm) -} -module Text.Highlighting.Kate.Syntax.D ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.D+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "D"@@ -20,92 +23,79 @@ syntaxExtensions = "*.d;*.D;*.di;*.DI;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "D" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("D",["normal"])], synStLanguage = "D", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("D",["normal"])], synStLanguage = "D", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine+ "normal" -> return () "StartingLetter" -> (popContext) >> pEndLine- "Properties" -> return () >> pHandleEndLine- "NumberLiteral" -> return () >> pHandleEndLine+ "Properties" -> return ()+ "NumberLiteral" -> return () "LinePragma" -> (popContext) >> pEndLine "UnicodeShort" -> (popContext) >> pEndLine "UnicodeLong" -> (popContext) >> pEndLine "HTMLEntity" -> (popContext) >> pEndLine- "ModuleName" -> return () >> pHandleEndLine- "Linkage" -> return () >> pHandleEndLine- "Linkage2" -> return () >> pHandleEndLine- "Version" -> return () >> pHandleEndLine- "Version2" -> return () >> pHandleEndLine- "Scope" -> return () >> pHandleEndLine- "Scope2" -> return () >> pHandleEndLine- "Pragma" -> return () >> pHandleEndLine- "Pragma2" -> return () >> pHandleEndLine- "RawString" -> return () >> pHandleEndLine- "BQString" -> return () >> pHandleEndLine- "HexString" -> return () >> pHandleEndLine- "CharLiteral" -> pushContext "CharLiteralClosing" >> pHandleEndLine+ "ModuleName" -> return ()+ "Linkage" -> return ()+ "Linkage2" -> return ()+ "Version" -> return ()+ "Version2" -> return ()+ "Scope" -> return ()+ "Scope2" -> return ()+ "Pragma" -> return ()+ "Pragma2" -> return ()+ "RawString" -> return ()+ "BQString" -> return ()+ "HexString" -> return ()+ "CharLiteral" -> pushContext "CharLiteralClosing" >> return () "CharLiteralClosing" -> (popContext >> popContext) >> pEndLine- "String" -> return () >> pHandleEndLine+ "String" -> return () "CommentRules" -> (popContext) >> pEndLine "Region Marker" -> (popContext) >> pEndLine "CommentLine" -> (popContext) >> pEndLine- "CommentBlock" -> return () >> pHandleEndLine- "CommentNested" -> return () >> pHandleEndLine- "DdocNormal" -> return () >> pHandleEndLine+ "CommentBlock" -> return ()+ "CommentNested" -> return ()+ "DdocNormal" -> return () "DdocLine" -> (popContext) >> pEndLine- "DdocBlock" -> return () >> pHandleEndLine- "DdocNested" -> return () >> pHandleEndLine- "DdocNested2" -> return () >> pHandleEndLine- "DdocMacro" -> return () >> pHandleEndLine- "DdocMacro2" -> return () >> pHandleEndLine- "DdocMacro3" -> return () >> pHandleEndLine- "MacroRules" -> return () >> pHandleEndLine- "DdocBlockCode" -> return () >> pHandleEndLine- "DdocNestedCode" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "DdocBlock" -> return ()+ "DdocNested" -> return ()+ "DdocNested2" -> return ()+ "DdocMacro" -> return ()+ "DdocMacro2" -> return ()+ "DdocMacro3" -> return ()+ "MacroRules" -> return ()+ "DdocBlockCode" -> return ()+ "DdocNestedCode" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Statement","kw"),("Expression","kw"),("Declarator","kw"),("Template","kw"),("Attribute","kw"),("Deprecated","kw"),("Property","dt"),("Type","dt"),("LibrarySymbols","dt"),("UserKeywords","dt"),("Module","kw"),("Pragma","kw"),("Version","kw"),("Linkage","kw"),("Tests","kw"),("Comment","co"),("Region Marker","re"),("Error","er"),("Integer","dv"),("Binary","bn"),("Octal","bn"),("Hex","bn"),("Float","fl"),("EscapeSequence","st"),("String","st"),("Char","ch"),("RawString","st"),("BQString","st"),("HexString","st"),("Macros","ot"),("Ddoc","co"),("DdocSection","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_userkeywords = Set.fromList $ words $ "" list_statements = Set.fromList $ words $ "asm body break case catch continue default do else finally for foreach foreach_reverse goto if mixin return switch throw try while with synchronized"@@ -166,480 +156,442 @@ regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 = compileRegex "-{3,}($|\\s)" regex_'5c'2b'2b'2f = compileRegex "\\++/" -defaultAttributes = [("normal","Normal Text"),("StartingLetter","Normal Text"),("Properties","Normal Text"),("NumberLiteral","Normal Text"),("LinePragma","Pragma"),("UnicodeShort","EscapeSequence"),("UnicodeLong","EscapeSequence"),("HTMLEntity","EscapeSequence"),("ModuleName","Module Name"),("Linkage","Normal Text"),("Linkage2","Normal Text"),("Version","Normal Text"),("Version2","Normal Text"),("Scope","Normal Text"),("Scope2","Normal Text"),("Pragma","Pragma"),("Pragma2","Pragma"),("RawString","RawString"),("BQString","BQString"),("HexString","HexString"),("CharLiteral","Char"),("CharLiteralClosing","Error"),("String","String"),("CommentRules","Normal Text"),("Region Marker","Region Marker"),("CommentLine","Comment"),("CommentBlock","Comment"),("CommentNested","Comment"),("DdocNormal","Normal Text"),("DdocLine","Ddoc"),("DdocBlock","Ddoc"),("DdocNested","Ddoc"),("DdocNested2","Ddoc"),("DdocMacro","Error"),("DdocMacro2","Macro Text"),("DdocMacro3","Macro Text"),("MacroRules","Macro Text"),("DdocBlockCode","DdocCode"),("DdocNestedCode","DdocCode")]+defaultAttributes = [("normal",NormalTok),("StartingLetter",NormalTok),("Properties",NormalTok),("NumberLiteral",NormalTok),("LinePragma",KeywordTok),("UnicodeShort",StringTok),("UnicodeLong",StringTok),("HTMLEntity",StringTok),("ModuleName",NormalTok),("Linkage",NormalTok),("Linkage2",NormalTok),("Version",NormalTok),("Version2",NormalTok),("Scope",NormalTok),("Scope2",NormalTok),("Pragma",KeywordTok),("Pragma2",KeywordTok),("RawString",StringTok),("BQString",StringTok),("HexString",StringTok),("CharLiteral",CharTok),("CharLiteralClosing",ErrorTok),("String",StringTok),("CommentRules",NormalTok),("Region Marker",RegionMarkerTok),("CommentLine",CommentTok),("CommentBlock",CommentTok),("CommentNested",CommentTok),("DdocNormal",NormalTok),("DdocLine",CommentTok),("DdocBlock",CommentTok),("DdocNested",CommentTok),("DdocNested2",CommentTok),("DdocMacro",ErrorTok),("DdocMacro2",NormalTok),("DdocMacro3",NormalTok),("MacroRules",NormalTok),("DdocBlockCode",NormalTok),("DdocNestedCode",NormalTok)] -parseRules "normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5f'5d) >> return ([],"") ) >>~ pushContext "StartingLetter")- <|>- ((pHlCStringChar >>= withAttribute "EscapeSequence"))- <|>- ((pDetect2Chars False '\\' 'u' >>= withAttribute "EscapeSequence") >>~ pushContext "UnicodeShort")- <|>- ((pDetect2Chars False '\\' 'U' >>= withAttribute "EscapeSequence") >>~ pushContext "UnicodeLong")- <|>- ((pDetect2Chars False '\\' '&' >>= withAttribute "EscapeSequence") >>~ pushContext "HTMLEntity")- <|>- ((pDetectChar False '\'' >>= withAttribute "Char") >>~ pushContext "CharLiteral")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '`' >>= withAttribute "BQString") >>~ pushContext "BQString")- <|>- ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pFirstNonSpace >> pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((parseRules "CommentRules"))- <|>- ((pString False "..." >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5c'2e'5cd'5b'5cd'5f'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5cd'5f'5d'2a'29'3f'5bfFL'5d'3fi'3f >>= withAttribute "Float"))- <|>- ((pDetectChar False '.' >>= withAttribute "Normal Text") >>~ pushContext "Properties")- <|>- ((lookAhead (pRegExpr regex_'5cd) >> return ([],"") ) >>~ pushContext "NumberLiteral")- <|>- ((pString False "#line" >>= withAttribute "Pragma") >>~ pushContext "LinePragma")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5f'5d) >> return (NormalTok,"") ) >>~ pushContext "StartingLetter")+ <|>+ ((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' 'u' >>= withAttribute StringTok) >>~ pushContext "UnicodeShort")+ <|>+ ((pDetect2Chars False '\\' 'U' >>= withAttribute StringTok) >>~ pushContext "UnicodeLong")+ <|>+ ((pDetect2Chars False '\\' '&' >>= withAttribute StringTok) >>~ pushContext "HTMLEntity")+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ pushContext "CharLiteral")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "BQString")+ <|>+ ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pFirstNonSpace >> pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pString False "..." >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2e'5cd'5b'5cd'5f'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5cd'5f'5d'2a'29'3f'5bfFL'5d'3fi'3f >>= withAttribute FloatTok))+ <|>+ ((pDetectChar False '.' >>= withAttribute NormalTok) >>~ pushContext "Properties")+ <|>+ ((lookAhead (pRegExpr regex_'5cd) >> return (NormalTok,"") ) >>~ pushContext "NumberLiteral")+ <|>+ ((pString False "#line" >>= withAttribute KeywordTok) >>~ pushContext "LinePragma")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "StartingLetter" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((lookAhead (pRegExpr regex_'5b'5ea'2dzA'2dZ'5f'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_in'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute "Statement"))- <|>- ((pRegExpr regex_out'5cs'2a'28'3f'3d'28'5c'28'28'5ba'2dzA'2dZ'5f'5d'5b'5cw'5f'5d'2a'29'3f'5c'29'5cs'2a'29'3f'5c'7b'29 >>= withAttribute "Statement"))- <|>- ((pRegExpr regex_scope'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute "Statement") >>~ pushContext "Scope")- <|>- ((pRegExpr regex_import'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute "Expression"))- <|>- ((pRegExpr regex_function'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute "Declarator"))- <|>- ((pRegExpr regex_delegate'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute "Declarator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_statements >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attributes >>= withAttribute "Attribute"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_expressions >>= withAttribute "Expression"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_declarators >>= withAttribute "Declarator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_templates >>= withAttribute "Template"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_modules >>= withAttribute "Module") >>~ pushContext "ModuleName")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_libsymbols >>= withAttribute "LibrarySymbols"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_linkage >>= withAttribute "Linkage") >>~ pushContext "Linkage")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_specialtokens >>= withAttribute "SpecialTokens"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_tests >>= withAttribute "Tests"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragma >>= withAttribute "Pragma") >>~ pushContext "Pragma")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_version >>= withAttribute "Version") >>~ pushContext "Version")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_deprecated >>= withAttribute "Deprecated"))- <|>- ((pDetect2Chars False 'r' '"' >>= withAttribute "RawString") >>~ pushContext "RawString")- <|>- ((pDetect2Chars False 'x' '"' >>= withAttribute "HexString") >>~ pushContext "HexString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_userkeywords >>= withAttribute "UserKeywords"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text")))- return (attr, result)+parseRules "StartingLetter" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pRegExpr regex_'5b'5ea'2dzA'2dZ'5f'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pRegExpr regex_in'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_out'5cs'2a'28'3f'3d'28'5c'28'28'5ba'2dzA'2dZ'5f'5d'5b'5cw'5f'5d'2a'29'3f'5c'29'5cs'2a'29'3f'5c'7b'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_scope'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute KeywordTok) >>~ pushContext "Scope")+ <|>+ ((pRegExpr regex_import'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_function'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_delegate'5cs'2a'28'3f'3d'5c'28'29 >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_statements >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attributes >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_expressions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_declarators >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_templates >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_modules >>= withAttribute KeywordTok) >>~ pushContext "ModuleName")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_libsymbols >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_linkage >>= withAttribute KeywordTok) >>~ pushContext "Linkage")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_specialtokens >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_tests >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragma >>= withAttribute KeywordTok) >>~ pushContext "Pragma")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_version >>= withAttribute KeywordTok) >>~ pushContext "Version")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_deprecated >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False 'r' '"' >>= withAttribute StringTok) >>~ pushContext "RawString")+ <|>+ ((pDetect2Chars False 'x' '"' >>= withAttribute StringTok) >>~ pushContext "HexString")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_userkeywords >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))) -parseRules "Properties" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute "Property") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Properties" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_properties >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "NumberLiteral" = - do (attr, result) <- (((pRegExpr regex_0'5bxX'5d'5b'5cda'2dfA'2dF'5f'5d'2a'28'5c'2e'5b'5cda'2dfA'2dF'5f'5d'2a'29'3f'5bpP'5d'5b'2d'2b'5d'3f'5cd'5b'5cd'5f'5d'2a'5bfFL'5d'3fi'3f >>= withAttribute "Float") >>~ (popContext))- <|>- ((pRegExpr regex_'5cd'5b'5f'5cd'5d'2a'28'5c'2e'28'3f'21'5c'2e'29'5b'5f'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5f'5cd'5d'2a'29'3f'5bfFL'5d'3fi'3f'7c'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5f'5cd'5d'2a'5bfFL'5d'3fi'3f'7c'5bfF'5di'3f'7c'5bfFL'5d'3fi'29 >>= withAttribute "Float") >>~ (popContext))- <|>- ((pRegExpr regex_0'5bbB'5d'5f'2a'5b01'5d'5b01'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Binary") >>~ (popContext))- <|>- ((pRegExpr regex_0'5b0'2d7'5f'5d'2b'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Octal") >>~ (popContext))- <|>- ((pRegExpr regex_0'5bxX'5d'5f'2a'5b'5cda'2dfA'2dF'5d'5b'5cda'2dfA'2dF'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Hex") >>~ (popContext))- <|>- ((pRegExpr regex_'5cd'2b'5b'5cd'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Integer") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "NumberLiteral" =+ (((pRegExpr regex_0'5bxX'5d'5b'5cda'2dfA'2dF'5f'5d'2a'28'5c'2e'5b'5cda'2dfA'2dF'5f'5d'2a'29'3f'5bpP'5d'5b'2d'2b'5d'3f'5cd'5b'5cd'5f'5d'2a'5bfFL'5d'3fi'3f >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cd'5b'5f'5cd'5d'2a'28'5c'2e'28'3f'21'5c'2e'29'5b'5f'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5f'5cd'5d'2a'29'3f'5bfFL'5d'3fi'3f'7c'5beE'5d'5b'2d'2b'5d'3f'5cd'5b'5f'5cd'5d'2a'5bfFL'5d'3fi'3f'7c'5bfF'5di'3f'7c'5bfFL'5d'3fi'29 >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_0'5bbB'5d'5f'2a'5b01'5d'5b01'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_0'5b0'2d7'5f'5d'2b'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_0'5bxX'5d'5f'2a'5b'5cda'2dfA'2dF'5d'5b'5cda'2dfA'2dF'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cd'2b'5b'5cd'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "LinePragma" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Pragma"))- <|>- ((pRegExpr regex_'28'280'28'5b0'2d7'5f'5d'2b'7c'5bbB'5d'5f'2a'5b01'5d'5b01'5f'5d'2a'7c'5bxX'5d'5f'2a'5b'5cda'2dfA'2dF'5d'5b'5cda'2dfA'2dF'5f'5d'2a'29'29'7c'5cd'2b'5b'5cd'5f'5d'2a'29'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Integer"))- <|>- ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute "String"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_specialtokens >>= withAttribute "SpecialTokens"))- <|>- ((parseRules "CommentRules"))- <|>- ((pRegExpr regex_'2e'2b >>= withAttribute "Error") >>~ (popContext)))- return (attr, result)+parseRules "LinePragma" =+ (((pDetectSpaces >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'280'28'5b0'2d7'5f'5d'2b'7c'5bbB'5d'5f'2a'5b01'5d'5b01'5f'5d'2a'7c'5bxX'5d'5f'2a'5b'5cda'2dfA'2dF'5d'5b'5cda'2dfA'2dF'5f'5d'2a'29'29'7c'5cd'2b'5b'5cd'5f'5d'2a'29'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'22'5b'5e'22'5d'2a'22 >>= withAttribute StringTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_specialtokens >>= withAttribute NormalTok))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pRegExpr regex_'2e'2b >>= withAttribute ErrorTok) >>~ (popContext))) -parseRules "UnicodeShort" = - do (attr, result) <- ((pRegExpr regex_'5b'5cda'2dfA'2dF'5d'7b4'7d >>= withAttribute "EscapeSequence") >>~ (popContext))- return (attr, result)+parseRules "UnicodeShort" =+ ((pRegExpr regex_'5b'5cda'2dfA'2dF'5d'7b4'7d >>= withAttribute StringTok) >>~ (popContext)) -parseRules "UnicodeLong" = - do (attr, result) <- ((pRegExpr regex_'5b'5cda'2dfA'2dF'5d'7b8'7d >>= withAttribute "EscapeSequence") >>~ (popContext))- return (attr, result)+parseRules "UnicodeLong" =+ ((pRegExpr regex_'5b'5cda'2dfA'2dF'5d'7b8'7d >>= withAttribute StringTok) >>~ (popContext)) -parseRules "HTMLEntity" = - do (attr, result) <- (((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2b'3b >>= withAttribute "EscapeSequence") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "HTMLEntity" =+ (((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2b'3b >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "ModuleName" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Module Name"))- <|>- ((parseRules "CommentRules"))- <|>- ((lookAhead (pRegExpr regex_'5b'5e'5cs'5cw'2e'3a'2c'3d'5d) >> return ([],"") ) >>~ (popContext)))- return (attr, result)+parseRules "ModuleName" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((lookAhead (pRegExpr regex_'5b'5e'5cs'5cw'2e'3a'2c'3d'5d) >> return (NormalTok,"") ) >>~ (popContext))) -parseRules "Linkage" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "Linkage2")- <|>- ((parseRules "CommentRules"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Linkage" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Linkage2")+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Linkage2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "C++" >>= withAttribute "Linkage Type") >>~ (popContext >> popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ltypes >>= withAttribute "Linkage Type") >>~ (popContext >> popContext))- <|>- ((parseRules "CommentRules"))- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Linkage2" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "C++" >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ltypes >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext >> popContext))) -parseRules "Version" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '=' >>= withAttribute "Normal Text") >>~ pushContext "Version2")- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "Version2")- <|>- ((parseRules "CommentRules"))- <|>- ((pRegExpr regex_'5b'5e'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext)))- return (attr, result)+parseRules "Version" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '=' >>= withAttribute NormalTok) >>~ pushContext "Version2")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Version2")+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pRegExpr regex_'5b'5e'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext))) -parseRules "Version2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_vtypes >>= withAttribute "Version Type") >>~ (popContext >> popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cd'2b'5b'5cd'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute "Integer") >>~ (popContext >> popContext))- <|>- ((parseRules "CommentRules"))- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Version2" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_vtypes >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cd'2b'5b'5cd'5f'5d'2a'28L'5buU'5d'3f'7c'5buU'5dL'3f'29'3f >>= withAttribute DecValTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext >> popContext))) -parseRules "Scope" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "Scope2")- <|>- ((parseRules "CommentRules"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Scope" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Scope2")+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Scope2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_scope'5fkeywords >>= withAttribute "Expression") >>~ (popContext >> popContext))- <|>- ((parseRules "CommentRules"))- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Scope2" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_scope'5fkeywords >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext >> popContext))) -parseRules "Pragma" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Pragma"))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "Pragma2")- <|>- ((parseRules "CommentRules"))- <|>- ((pRegExpr regex_'5b'5e'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext)))- return (attr, result)+parseRules "Pragma" =+ (((pDetectSpaces >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Pragma2")+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pRegExpr regex_'5b'5e'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext))) -parseRules "Pragma2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Pragma"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ptypes >>= withAttribute "Version Type") >>~ (popContext >> popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((parseRules "CommentRules"))- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute "Error") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Pragma2" =+ (((pDetectSpaces >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ptypes >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "CommentRules"))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5b'5e'29'5cs'5cn'5d'2b >>= withAttribute ErrorTok) >>~ (popContext >> popContext))) -parseRules "RawString" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "RawString") >>~ (popContext))- return (attr, result)+parseRules "RawString" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "BQString" = - do (attr, result) <- ((pDetectChar False '`' >>= withAttribute "BQString") >>~ (popContext))- return (attr, result)+parseRules "BQString" =+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "HexString" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "HexString") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5e'5csa'2dfA'2dF'5cd'22'5d'2b >>= withAttribute "Error")))- return (attr, result)+parseRules "HexString" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5e'5csa'2dfA'2dF'5cd'22'5d'2b >>= withAttribute ErrorTok))) -parseRules "CharLiteral" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Char") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "EscapeSequence") >>~ pushContext "CharLiteralClosing")- <|>- ((pRegExpr regex_'5c'5c'28u'5b'5cda'2dfA'2dF'5d'7b4'7d'7cU'5b'5cda'2dfA'2dF'5d'7b8'7d'7c'26'5ba'2dzA'2dZ'5d'5cw'2b'3b'29 >>= withAttribute "EscapeSequence") >>~ pushContext "CharLiteralClosing")- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Error") >>~ pushContext "CharLiteralClosing")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Char") >>~ pushContext "CharLiteralClosing")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "CharLiteral" =+ (((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute StringTok) >>~ pushContext "CharLiteralClosing")+ <|>+ ((pRegExpr regex_'5c'5c'28u'5b'5cda'2dfA'2dF'5d'7b4'7d'7cU'5b'5cda'2dfA'2dF'5d'7b8'7d'7c'26'5ba'2dzA'2dZ'5d'5cw'2b'3b'29 >>= withAttribute StringTok) >>~ pushContext "CharLiteralClosing")+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute ErrorTok) >>~ pushContext "CharLiteralClosing")+ <|>+ ((pRegExpr regex_'2e >>= withAttribute CharTok) >>~ pushContext "CharLiteralClosing")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "CharLiteralClosing" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Char") >>~ (popContext >> popContext))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)+parseRules "CharLiteralClosing" =+ (((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext >> popContext))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules)) -parseRules "String" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "EscapeSequence"))- <|>- ((pDetect2Chars False '"' 'c' >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetect2Chars False '"' 'w' >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetect2Chars False '"' 'd' >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' 'u' >>= withAttribute "EscapeSequence") >>~ pushContext "UnicodeShort")- <|>- ((pDetect2Chars False '\\' 'U' >>= withAttribute "EscapeSequence") >>~ pushContext "UnicodeLong")- <|>- ((pDetect2Chars False '\\' '&' >>= withAttribute "EscapeSequence") >>~ pushContext "HTMLEntity"))- return (attr, result)+parseRules "String" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '"' 'c' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '"' 'w' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '"' 'd' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' 'u' >>= withAttribute StringTok) >>~ pushContext "UnicodeShort")+ <|>+ ((pDetect2Chars False '\\' 'U' >>= withAttribute StringTok) >>~ pushContext "UnicodeLong")+ <|>+ ((pDetect2Chars False '\\' '&' >>= withAttribute StringTok) >>~ pushContext "HTMLEntity")) -parseRules "CommentRules" = - do (attr, result) <- (((parseRules "DdocNormal"))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "CommentLine")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "CommentBlock")- <|>- ((pDetect2Chars False '/' '+' >>= withAttribute "Comment") >>~ pushContext "CommentNested"))- return (attr, result)+parseRules "CommentRules" =+ (((parseRules "DdocNormal"))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "CommentLine")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "CommentBlock")+ <|>+ ((pDetect2Chars False '/' '+' >>= withAttribute CommentTok) >>~ pushContext "CommentNested")) -parseRules "Region Marker" = +parseRules "Region Marker" = pzero -parseRules "CommentLine" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "CommentLine" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "CommentBlock" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "CommentBlock" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "CommentNested" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '/' '+' >>= withAttribute "Comment") >>~ pushContext "CommentNested")- <|>- ((pDetect2Chars False '+' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "CommentNested" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '/' '+' >>= withAttribute CommentTok) >>~ pushContext "CommentNested")+ <|>+ ((pDetect2Chars False '+' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "DdocNormal" = - do (attr, result) <- (((pRegExpr regex_'2f'7b3'2c'7d >>= withAttribute "Comment") >>~ pushContext "DdocLine")- <|>- ((pRegExpr regex_'2f'5c'2a'7b2'2c'7d'28'3f'21'2f'29 >>= withAttribute "Comment") >>~ pushContext "DdocBlock")- <|>- ((pRegExpr regex_'2f'5c'2b'7b2'2c'7d'28'3f'21'2f'29 >>= withAttribute "Comment") >>~ pushContext "DdocNested"))- return (attr, result)+parseRules "DdocNormal" =+ (((pRegExpr regex_'2f'7b3'2c'7d >>= withAttribute CommentTok) >>~ pushContext "DdocLine")+ <|>+ ((pRegExpr regex_'2f'5c'2a'7b2'2c'7d'28'3f'21'2f'29 >>= withAttribute CommentTok) >>~ pushContext "DdocBlock")+ <|>+ ((pRegExpr regex_'2f'5c'2b'7b2'2c'7d'28'3f'21'2f'29 >>= withAttribute CommentTok) >>~ pushContext "DdocNested")) -parseRules "DdocLine" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Ddoc"))- <|>- ((pDetectIdentifier >>= withAttribute "Ddoc"))- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Macros") >>~ pushContext "DdocMacro")- <|>- ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute "DdocSection"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "DdocLine" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute OtherTok) >>~ pushContext "DdocMacro")+ <|>+ ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute KeywordTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "DdocBlock" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Ddoc"))- <|>- ((pDetectIdentifier >>= withAttribute "Ddoc"))- <|>- ((pRegExpr regex_'5c'2a'2b'2f >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Macros") >>~ pushContext "DdocMacro")- <|>- ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute "DdocSection"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute "Ddoc"))- <|>- ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute "Comment") >>~ pushContext "DdocBlockCode"))- return (attr, result)+parseRules "DdocBlock" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5c'2a'2b'2f >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute OtherTok) >>~ pushContext "DdocMacro")+ <|>+ ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute KeywordTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute CommentTok) >>~ pushContext "DdocBlockCode")) -parseRules "DdocNested" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Ddoc"))- <|>- ((pDetectIdentifier >>= withAttribute "Ddoc"))- <|>- ((pDetect2Chars False '/' '+' >>= withAttribute "Ddoc") >>~ pushContext "DdocNested2")- <|>- ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pFirstNonSpace >> pDetectChar False '+' >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Macros") >>~ pushContext "DdocMacro")- <|>- ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute "DdocSection"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute "Ddoc"))- <|>- ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute "Comment") >>~ pushContext "DdocNestedCode"))- return (attr, result)+parseRules "DdocNested" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '/' '+' >>= withAttribute CommentTok) >>~ pushContext "DdocNested2")+ <|>+ ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> pDetectChar False '+' >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute OtherTok) >>~ pushContext "DdocMacro")+ <|>+ ((pRegExpr regex_'5b'5cw'5f'5d'2b'3a'28'24'7c'5cs'29 >>= withAttribute KeywordTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute CommentTok) >>~ pushContext "DdocNestedCode")) -parseRules "DdocNested2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Ddoc"))- <|>- ((pDetectIdentifier >>= withAttribute "Ddoc"))- <|>- ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute "Ddoc") >>~ (popContext))- <|>- ((parseRules "DdocNested")))- return (attr, result)+parseRules "DdocNested2" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((parseRules "DdocNested"))) -parseRules "DdocMacro" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Macro Text"))- <|>- ((pDetectChar False ')' >>= withAttribute "Macros") >>~ (popContext))- <|>- ((parseRules "MacroRules"))- <|>- ((pDetectIdentifier >>= withAttribute "Macros") >>~ pushContext "DdocMacro2"))- return (attr, result)+parseRules "DdocMacro" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "MacroRules"))+ <|>+ ((pDetectIdentifier >>= withAttribute OtherTok) >>~ pushContext "DdocMacro2")) -parseRules "DdocMacro2" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Macros") >>~ (popContext >> popContext))- <|>- ((parseRules "MacroRules")))- return (attr, result)+parseRules "DdocMacro2" =+ (((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "MacroRules"))) -parseRules "DdocMacro3" = - do (attr, result) <- (((pDetectChar False ')' >>= withAttribute "Macro Text") >>~ (popContext))- <|>- ((parseRules "MacroRules")))- return (attr, result)+parseRules "DdocMacro3" =+ (((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "MacroRules"))) -parseRules "MacroRules" = - do (attr, result) <- (((pDetect2Chars False '$' '(' >>= withAttribute "Macros") >>~ pushContext "DdocMacro")- <|>- ((pDetectChar False '(' >>= withAttribute "Macro Text") >>~ pushContext "DdocMacro3")- <|>- ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Comment")))- return (attr, result)+parseRules "MacroRules" =+ (((pDetect2Chars False '$' '(' >>= withAttribute OtherTok) >>~ pushContext "DdocMacro")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "DdocMacro3")+ <|>+ ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute CommentTok))) -parseRules "DdocBlockCode" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "DdocCode"))- <|>- ((pRegExpr regex_'5c'2a'2b'2f >>= withAttribute "Comment") >>~ (popContext >> popContext))- <|>- ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute "DdocCode"))- <|>- ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.D.parseExpression)))- return (attr, result)+parseRules "DdocBlockCode" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2a'2b'2f >>= withAttribute CommentTok) >>~ (popContext >> popContext))+ <|>+ ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.D.parseExpression))) -parseRules "DdocNestedCode" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "DdocCode"))- <|>- ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute "Comment") >>~ (popContext >> popContext))- <|>- ((pFirstNonSpace >> pDetectChar False '+' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute "DdocCode"))- <|>- ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.D.parseExpression)))- return (attr, result)+parseRules "DdocNestedCode" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2b'2b'2f >>= withAttribute CommentTok) >>~ (popContext >> popContext))+ <|>+ ((pFirstNonSpace >> pDetectChar False '+' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5b'5e'2d'5d'2d'7b3'2c'7d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'7b3'2c'7d'28'24'7c'5cs'29 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.D.parseExpression))) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Diff.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file diff.xml, version 1.11,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file diff.xml, version 1.11, by -} -module Text.Highlighting.Kate.Syntax.Diff ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Diff+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,68 +21,55 @@ syntaxExtensions = "*.diff;*patch" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Diff" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Diff",["Normal"])], synStLanguage = "Diff", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Diff",["Normal"])], synStLanguage = "Diff", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "FindDiff" -> return () >> pHandleEndLine- "File" -> return () >> pHandleEndLine- "Chunk" -> return () >> pHandleEndLine- "ChunkInFile" -> return () >> pHandleEndLine- "RFile" -> return () >> pHandleEndLine- "RChunk" -> return () >> pHandleEndLine- "RChunkInFile" -> return () >> pHandleEndLine- "RChunkNew" -> return () >> pHandleEndLine- "RChunkInFileNew" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "FindDiff" -> return ()+ "File" -> return ()+ "Chunk" -> return ()+ "ChunkInFile" -> return ()+ "RFile" -> return ()+ "RChunk" -> return ()+ "RChunkInFile" -> return ()+ "RChunkNew" -> return ()+ "RChunkInFileNew" -> return () "File" -> (popContext) >> pEndLine "Removed" -> (popContext) >> pEndLine "Added" -> (popContext) >> pEndLine "ChangedOld" -> (popContext) >> pEndLine "ChangedNew" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("File","kw"),("Header","dt"),("Removed line","st"),("Added line","ot"),("Changed line (old)","st"),("Changed line (new)","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24 = compileRegex "(\\@\\@|\\d).*$"@@ -96,125 +86,115 @@ regex_'5c'2a'5c'2a'5c'2a_'2e'2a_'5c'2a'5c'2a'5c'2a'5c'2a'24 = compileRegex "\\*\\*\\* .* \\*\\*\\*\\*$" regex_'5c'2d'5c'2d'5c'2d_'2e'2a_'5c'2d'5c'2d'5c'2d'5c'2d'24 = compileRegex "\\-\\-\\- .* \\-\\-\\-\\-$" -defaultAttributes = [("Normal","Normal Text"),("FindDiff","Normal Text"),("File","Normal Text"),("Chunk","Normal Text"),("ChunkInFile","Normal Text"),("RFile","Normal Text"),("RChunk","Normal Text"),("RChunkInFile","Normal Text"),("RChunkNew","Normal Text"),("RChunkInFileNew","Normal Text"),("File","File"),("Removed","Removed line"),("Added","Added line"),("ChangedOld","Changed line (old)"),("ChangedNew","Changed line (new)")]+defaultAttributes = [("Normal",NormalTok),("FindDiff",NormalTok),("File",NormalTok),("Chunk",NormalTok),("ChunkInFile",NormalTok),("RFile",NormalTok),("RChunk",NormalTok),("RChunkInFile",NormalTok),("RChunkNew",NormalTok),("RChunkInFileNew",NormalTok),("File",KeywordTok),("Removed",StringTok),("Added",OtherTok),("ChangedOld",StringTok),("ChangedNew",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24 >>= withAttribute "Header") >>~ pushContext "Chunk")- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute "Header") >>~ pushContext "RChunk")- <|>- ((pColumn 0 >> pRegExpr regex_Only_in_'2e'2a'3a'2e'2a'24 >>= withAttribute "File"))- <|>- ((pColumn 0 >> pRegExpr regex_diff'2e'2a'24 >>= withAttribute "File") >>~ pushContext "RFile")- <|>- ((pColumn 0 >> pRegExpr regex_'3d'3d'3d'3d'2e'2a'24 >>= withAttribute "File"))- <|>- ((pColumn 0 >> pRegExpr regex_'28'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'29'2e'2a'24 >>= withAttribute "File") >>~ pushContext "File")- <|>- ((parseRules "FindDiff"))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line") >>~ pushContext "ChangedOld"))- return (attr, result)+parseRules "Normal" =+ (((pColumn 0 >> pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24 >>= withAttribute DataTypeTok) >>~ pushContext "Chunk")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute DataTypeTok) >>~ pushContext "RChunk")+ <|>+ ((pColumn 0 >> pRegExpr regex_Only_in_'2e'2a'3a'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_diff'2e'2a'24 >>= withAttribute KeywordTok) >>~ pushContext "RFile")+ <|>+ ((pColumn 0 >> pRegExpr regex_'3d'3d'3d'3d'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'29'2e'2a'24 >>= withAttribute KeywordTok) >>~ pushContext "File")+ <|>+ ((parseRules "FindDiff"))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute NormalTok) >>~ pushContext "ChangedOld")) -parseRules "FindDiff" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d'2e'2a'24 >>= withAttribute "File"))- <|>- ((pColumn 0 >> pRegExpr regex_'28'5c'2b'5c'2b'5c'2b'7c'5c'2d'5c'2d'5c'2d'29'2e'2a'24 >>= withAttribute "Header"))- <|>- ((pColumn 0 >> pAnyChar "+>" >>= withAttribute "Added line") >>~ pushContext "Added")- <|>- ((pColumn 0 >> pAnyChar "-<" >>= withAttribute "Removed line") >>~ pushContext "Removed"))- return (attr, result)+parseRules "FindDiff" =+ (((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'5c'2b'5c'2b'5c'2b'7c'5c'2d'5c'2d'5c'2d'29'2e'2a'24 >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pAnyChar "+>" >>= withAttribute OtherTok) >>~ pushContext "Added")+ <|>+ ((pColumn 0 >> pAnyChar "-<" >>= withAttribute StringTok) >>~ pushContext "Removed")) -parseRules "File" = - do (attr, result) <- (((parseRules "FindDiff"))- <|>- ((pColumn 0 >> pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24 >>= withAttribute "Header") >>~ pushContext "ChunkInFile")- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute "Header") >>~ pushContext "RChunkInFile")- <|>- ((pColumn 0 >> pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24 >>= withAttribute "File") >>~ (popContext))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line (old)") >>~ pushContext "ChangedOld"))- return (attr, result)+parseRules "File" =+ (((parseRules "FindDiff"))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24 >>= withAttribute DataTypeTok) >>~ pushContext "ChunkInFile")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute DataTypeTok) >>~ pushContext "RChunkInFile")+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute StringTok) >>~ pushContext "ChangedOld")) -parseRules "Chunk" = - do (attr, result) <- (((parseRules "FindDiff"))- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return ([],"") ) >>~ (popContext))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line (old)") >>~ pushContext "ChangedOld"))- return (attr, result)+parseRules "Chunk" =+ (((parseRules "FindDiff"))+ <|>+ ((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute StringTok) >>~ pushContext "ChangedOld")) -parseRules "ChunkInFile" = - do (attr, result) <- (((parseRules "FindDiff"))- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return ([],"") ) >>~ (popContext))- <|>- ((pColumn 0 >> pRegExpr regex_Index'3a'2e'2a >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return ([],"") ) >>~ (popContext))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line (old)") >>~ pushContext "ChangedOld"))- return (attr, result)+parseRules "ChunkInFile" =+ (((parseRules "FindDiff"))+ <|>+ ((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pColumn 0 >> pRegExpr regex_Index'3a'2e'2a >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pColumn 0 >> lookAhead (pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute StringTok) >>~ pushContext "ChangedOld")) -parseRules "RFile" = - do (attr, result) <- (((pColumn 0 >> lookAhead (pRegExpr regex_'28diff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return ([],"") ) >>~ (popContext))- <|>- ((pColumn 0 >> pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24 >>= withAttribute "Header"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute "Header") >>~ pushContext "RChunkInFile")- <|>- ((parseRules "File")))- return (attr, result)+parseRules "RFile" =+ (((pColumn 0 >> lookAhead (pRegExpr regex_'28diff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24 >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2a'2b'24 >>= withAttribute DataTypeTok) >>~ pushContext "RChunkInFile")+ <|>+ ((parseRules "File"))) -parseRules "RChunk" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5c'2a'5c'2a'5c'2a_'2e'2a_'5c'2a'5c'2a'5c'2a'5c'2a'24 >>= withAttribute "Header"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d_'2e'2a_'5c'2d'5c'2d'5c'2d'5c'2d'24 >>= withAttribute "Header") >>~ pushContext "RChunkNew")- <|>- ((parseRules "Chunk")))- return (attr, result)+parseRules "RChunk" =+ (((pColumn 0 >> pRegExpr regex_'5c'2a'5c'2a'5c'2a_'2e'2a_'5c'2a'5c'2a'5c'2a'5c'2a'24 >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d_'2e'2a_'5c'2d'5c'2d'5c'2d'5c'2d'24 >>= withAttribute DataTypeTok) >>~ pushContext "RChunkNew")+ <|>+ ((parseRules "Chunk"))) -parseRules "RChunkInFile" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5c'2a'5c'2a'5c'2a_'2e'2a_'5c'2a'5c'2a'5c'2a'5c'2a'24 >>= withAttribute "Header"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d_'2e'2a_'5c'2d'5c'2d'5c'2d'5c'2d'24 >>= withAttribute "Header") >>~ pushContext "RChunkInFileNew")- <|>- ((parseRules "ChunkInFile")))- return (attr, result)+parseRules "RChunkInFile" =+ (((pColumn 0 >> pRegExpr regex_'5c'2a'5c'2a'5c'2a_'2e'2a_'5c'2a'5c'2a'5c'2a'5c'2a'24 >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2d'5c'2d'5c'2d_'2e'2a_'5c'2d'5c'2d'5c'2d'5c'2d'24 >>= withAttribute DataTypeTok) >>~ pushContext "RChunkInFileNew")+ <|>+ ((parseRules "ChunkInFile"))) -parseRules "RChunkNew" = - do (attr, result) <- (((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line (new)") >>~ pushContext "ChangedNew")- <|>- ((parseRules "FindDiff")))- return (attr, result)+parseRules "RChunkNew" =+ (((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext >> popContext))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute OtherTok) >>~ pushContext "ChangedNew")+ <|>+ ((parseRules "FindDiff"))) -parseRules "RChunkInFileNew" = - do (attr, result) <- (((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Changed line (new)") >>~ pushContext "ChangedNew")- <|>- ((parseRules "FindDiff")))- return (attr, result)+parseRules "RChunkInFileNew" =+ (((pColumn 0 >> lookAhead (pRegExpr regex_'28'5c'40'5c'40'7c'5cd'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext >> popContext))+ <|>+ ((pColumn 0 >> lookAhead (pRegExpr regex_'28'3d'3d'3d'3d'7c'5c'2a'5c'2a'5c'2a'7c'5c'2d'5c'2d'5c'2d'7cdiff'7cOnly_in_'2e'2a'3a'29'2e'2a'24) >> return (NormalTok,"") ) >>~ (popContext >> popContext))+ <|>+ ((pColumn 0 >> pDetectChar False '!' >>= withAttribute OtherTok) >>~ pushContext "ChangedNew")+ <|>+ ((parseRules "FindDiff"))) -parseRules "File" = +parseRules "File" = pzero -parseRules "Removed" = +parseRules "Removed" = pzero -parseRules "Added" = +parseRules "Added" = pzero -parseRules "ChangedOld" = +parseRules "ChangedOld" = pzero -parseRules "ChangedNew" = +parseRules "ChangedNew" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Djangotemplate.hs view
@@ -1,18 +1,21 @@-{- This module was generated from data in the Kate syntax highlighting file djangotemplate.xml, version 1.3,- by Matthew Marshall (matthew@matthewmarshall.org) -}+{- This module was generated from data in the Kate syntax+ highlighting file djangotemplate.xml, version 1.3, by Matthew Marshall (matthew@matthewmarshall.org) -} -module Text.Highlighting.Kate.Syntax.Djangotemplate ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Djangotemplate+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert import qualified Text.Highlighting.Kate.Syntax.Css import qualified Text.Highlighting.Kate.Syntax.Javascript-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Django HTML Template"@@ -22,92 +25,79 @@ syntaxExtensions = "*.htm;*.html" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Django HTML Template" } context <- currentContext <|> (pushContext "Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Django HTML Template",["Start"])], synStLanguage = "Django HTML Template", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Django HTML Template",["Start"])], synStLanguage = "Django HTML Template", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Start" -> return () >> pHandleEndLine- "In Block" -> return () >> pHandleEndLine- "FindTemplate" -> return () >> pHandleEndLine- "Template Comment" -> return () >> pHandleEndLine- "Template Var" -> return () >> pHandleEndLine- "Template Filter" -> return () >> pHandleEndLine- "Template Tag" -> return () >> pHandleEndLine- "Found Block Tag" -> return () >> pHandleEndLine- "In Block Tag" -> return () >> pHandleEndLine- "Non Matching Tag" -> return () >> pHandleEndLine- "In Template Tag" -> return () >> pHandleEndLine- "Single A-string" -> return () >> pHandleEndLine- "Single Q-string" -> return () >> pHandleEndLine- "FindHTML" -> return () >> pHandleEndLine- "FindEntityRefs" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "FindAttributes" -> return () >> pHandleEndLine- "FindDTDRules" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "El Open" -> return () >> pHandleEndLine- "El Close" -> return () >> pHandleEndLine- "El Close 2" -> return () >> pHandleEndLine- "El Close 3" -> return () >> pHandleEndLine- "CSS" -> return () >> pHandleEndLine- "CSS content" -> return () >> pHandleEndLine- "JS" -> return () >> pHandleEndLine- "JS content" -> return () >> pHandleEndLine+ "Start" -> return ()+ "In Block" -> return ()+ "FindTemplate" -> return ()+ "Template Comment" -> return ()+ "Template Var" -> return ()+ "Template Filter" -> return ()+ "Template Tag" -> return ()+ "Found Block Tag" -> return ()+ "In Block Tag" -> return ()+ "Non Matching Tag" -> return ()+ "In Template Tag" -> return ()+ "Single A-string" -> return ()+ "Single Q-string" -> return ()+ "FindHTML" -> return ()+ "FindEntityRefs" -> return ()+ "FindPEntityRefs" -> return ()+ "FindAttributes" -> return ()+ "FindDTDRules" -> return ()+ "Comment" -> return ()+ "CDATA" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "El Open" -> return ()+ "El Close" -> return ()+ "El Close 2" -> return ()+ "El Close 3" -> return ()+ "CSS" -> return ()+ "CSS content" -> return ()+ "JS" -> return ()+ "JS content" -> return () "JS comment close" -> (popContext) >> pEndLine- "Value" -> return () >> pHandleEndLine+ "Value" -> return () "Value NQ" -> (popContext >> popContext) >> pEndLine- "Value DQ" -> return () >> pHandleEndLine- "Value SQ" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Value DQ" -> return ()+ "Value SQ" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("Element","kw"),("Attribute","ot"),("Value","st"),("EntityRef","dv"),("PEntityRef","dv"),("Error","er"),("Template Var","fu"),("Template Tag","fu"),("Template Tag Argument","fu"),("Template String","st"),("Template Comment","co"),("Template Filter","ot"),("Mismatched Block Tag","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_blocktags = Set.fromList $ words $ "for block if ifequal ifnotequal ifchanged blocktrans spaceless autoescape" list_endblocktags = Set.fromList $ words $ "endfor endblock endif endifequal endifnotequal endifchanged endblocktrans endspaceless endautoescape"@@ -141,361 +131,322 @@ regex_'2f'28'3f'21'3e'29 = compileRegex "/(?!>)" regex_'5b'5e'2f'3e'3c'22'27'5cs'5d = compileRegex "[^/><\"'\\s]" -defaultAttributes = [("Start","Normal Text"),("In Block","Normal Text"),("FindTemplate","Normal Text"),("Template Comment","Template Comment"),("Template Var","Template Var"),("Template Filter","Template Filter"),("Template Tag","Template Tag"),("Found Block Tag","Template Tag"),("In Block Tag","Template Tag Argument"),("Non Matching Tag","Template Tag"),("In Template Tag","Template Tag Argument"),("Single A-string","Template String"),("Single Q-string","Template String"),("FindHTML","Normal Text"),("FindEntityRefs","Normal Text"),("FindPEntityRefs","Normal Text"),("FindAttributes","Normal Text"),("FindDTDRules","Normal Text"),("Comment","Comment"),("CDATA","Normal Text"),("PI","Normal Text"),("Doctype","Normal Text"),("Doctype Internal Subset","Normal Text"),("Doctype Markupdecl","Normal Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("El Open","Normal Text"),("El Close","Normal Text"),("El Close 2","Normal Text"),("El Close 3","Normal Text"),("CSS","Normal Text"),("CSS content","Normal Text"),("JS","Normal Text"),("JS content","Normal Text"),("JS comment close","Comment"),("Value","Normal Text"),("Value NQ","Normal Text"),("Value DQ","Value"),("Value SQ","Value")]+defaultAttributes = [("Start",NormalTok),("In Block",NormalTok),("FindTemplate",NormalTok),("Template Comment",CommentTok),("Template Var",FunctionTok),("Template Filter",OtherTok),("Template Tag",FunctionTok),("Found Block Tag",FunctionTok),("In Block Tag",FunctionTok),("Non Matching Tag",FunctionTok),("In Template Tag",FunctionTok),("Single A-string",StringTok),("Single Q-string",StringTok),("FindHTML",NormalTok),("FindEntityRefs",NormalTok),("FindPEntityRefs",NormalTok),("FindAttributes",NormalTok),("FindDTDRules",NormalTok),("Comment",CommentTok),("CDATA",NormalTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",StringTok),("Doctype Markupdecl SQ",StringTok),("El Open",NormalTok),("El Close",NormalTok),("El Close 2",NormalTok),("El Close 3",NormalTok),("CSS",NormalTok),("CSS content",NormalTok),("JS",NormalTok),("JS content",NormalTok),("JS comment close",CommentTok),("Value",NormalTok),("Value NQ",NormalTok),("Value DQ",StringTok),("Value SQ",StringTok)] -parseRules "Start" = - do (attr, result) <- (((pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d >>= withAttribute "Mismatched Block Tag"))- <|>- ((parseRules "FindTemplate"))- <|>- ((parseRules "FindHTML")))- return (attr, result)+parseRules "Start" =+ (((pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d >>= withAttribute ErrorTok))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((parseRules "FindHTML"))) -parseRules "In Block" = - do (attr, result) <- (((lookAhead (pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "FindTemplate"))- <|>- ((parseRules "FindHTML")))- return (attr, result)+parseRules "In Block" =+ (((lookAhead (pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((parseRules "FindHTML"))) -parseRules "FindTemplate" = - do (attr, result) <- (((pRegExpr regex_'5c'7b'25'5cs'2acomment'5cs'2a'25'5c'7d >>= withAttribute "Template Comment") >>~ pushContext "Template Comment")- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Template Var") >>~ pushContext "Template Var")- <|>- ((pDetect2Chars False '{' '%' >>= withAttribute "Template Tag") >>~ pushContext "Template Tag"))- return (attr, result)+parseRules "FindTemplate" =+ (((pRegExpr regex_'5c'7b'25'5cs'2acomment'5cs'2a'25'5c'7d >>= withAttribute CommentTok) >>~ pushContext "Template Comment")+ <|>+ ((pDetect2Chars False '{' '{' >>= withAttribute FunctionTok) >>~ pushContext "Template Var")+ <|>+ ((pDetect2Chars False '{' '%' >>= withAttribute FunctionTok) >>~ pushContext "Template Tag")) -parseRules "Template Comment" = - do (attr, result) <- ((pRegExpr regex_'5c'7b'25'5cs'2aendcomment'5cs'2a'25'5c'7d >>= withAttribute "Template Comment") >>~ (popContext))- return (attr, result)+parseRules "Template Comment" =+ ((pRegExpr regex_'5c'7b'25'5cs'2aendcomment'5cs'2a'25'5c'7d >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Template Var" = - do (attr, result) <- (((pDetect2Chars False '}' '}' >>= withAttribute "Template Var") >>~ (popContext))- <|>- ((pDetectChar False '|' >>= withAttribute "Template Filter") >>~ pushContext "Template Filter")- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '{' '%' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '%' '}' >>= withAttribute "Error")))- return (attr, result)+parseRules "Template Var" =+ (((pDetect2Chars False '}' '}' >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((pDetectChar False '|' >>= withAttribute OtherTok) >>~ pushContext "Template Filter")+ <|>+ ((pDetect2Chars False '{' '{' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '{' '%' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '%' '}' >>= withAttribute ErrorTok))) -parseRules "Template Filter" = - do (attr, result) <- (((pDetect2Chars False '}' '}' >>= withAttribute "Template Var") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Template String") >>~ pushContext "Single A-string")- <|>- ((pDetectChar False '"' >>= withAttribute "Template String") >>~ pushContext "Single Q-string")- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '{' '%' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '%' '}' >>= withAttribute "Error")))- return (attr, result)+parseRules "Template Filter" =+ (((pDetect2Chars False '}' '}' >>= withAttribute FunctionTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Single A-string")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Single Q-string")+ <|>+ ((pDetect2Chars False '{' '{' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '{' '%' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '%' '}' >>= withAttribute ErrorTok))) -parseRules "Template Tag" = - do (attr, result) <- (((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_blocktags) >> return ([],"") ) >>~ pushContext "Found Block Tag")- <|>- ((pDetectIdentifier >>= withAttribute "Template Tag") >>~ pushContext "In Template Tag"))- return (attr, result)+parseRules "Template Tag" =+ (((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_blocktags) >> return (NormalTok,"") ) >>~ pushContext "Found Block Tag")+ <|>+ ((pDetectIdentifier >>= withAttribute FunctionTok) >>~ pushContext "In Template Tag")) -parseRules "Found Block Tag" = - do (attr, result) <- ((pRegExpr regex_'28'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29 >>= withAttribute "Template Tag") >>~ pushContext "In Block Tag")- return (attr, result)+parseRules "Found Block Tag" =+ ((pRegExpr regex_'28'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29 >>= withAttribute FunctionTok) >>~ pushContext "In Block Tag") -parseRules "In Block Tag" = - do (attr, result) <- (((pRegExprDynamic "\\{%\\s*end%1\\s*%\\}" >>= withAttribute "Template Tag") >>~ (popContext >> popContext >> popContext))- <|>- ((lookAhead (pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d) >> return ([],"") ) >>~ pushContext "Non Matching Tag")- <|>- ((pDetect2Chars False '%' '}' >>= withAttribute "Template Tag") >>~ pushContext "In Block")- <|>- ((parseRules "In Template Tag")))- return (attr, result)+parseRules "In Block Tag" =+ (((pRegExprDynamic "\\{%\\s*end%1\\s*%\\}" >>= withAttribute FunctionTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((lookAhead (pRegExpr regex_'5c'7b'25'5cs'2aend'5ba'2dz'5d'2b'5cs'2a'25'5c'7d) >> return (NormalTok,"") ) >>~ pushContext "Non Matching Tag")+ <|>+ ((pDetect2Chars False '%' '}' >>= withAttribute FunctionTok) >>~ pushContext "In Block")+ <|>+ ((parseRules "In Template Tag"))) -parseRules "Non Matching Tag" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_endblocktags >>= withAttribute "Mismatched Block Tag") >>~ (popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Template Tag") >>~ (popContext)))- return (attr, result)+parseRules "Non Matching Tag" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_endblocktags >>= withAttribute ErrorTok) >>~ (popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute FunctionTok) >>~ (popContext))) -parseRules "In Template Tag" = - do (attr, result) <- (((pDetect2Chars False '%' '}' >>= withAttribute "Template Tag") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Template String") >>~ pushContext "Single A-string")- <|>- ((pDetectChar False '"' >>= withAttribute "Template String") >>~ pushContext "Single Q-string")- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '{' '%' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '}' '}' >>= withAttribute "Error")))- return (attr, result)+parseRules "In Template Tag" =+ (((pDetect2Chars False '%' '}' >>= withAttribute FunctionTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Single A-string")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Single Q-string")+ <|>+ ((pDetect2Chars False '{' '{' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '{' '%' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '}' '}' >>= withAttribute ErrorTok))) -parseRules "Single A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Template String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Template String") >>~ (popContext)))- return (attr, result)+parseRules "Single A-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Single Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Template String"))- <|>- ((pDetectChar False '"' >>= withAttribute "Template String") >>~ (popContext)))- return (attr, result)+parseRules "Single Q-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "FindHTML" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pRegExpr regex_'3cstyle'5cb >>= withAttribute "Element") >>~ pushContext "CSS")- <|>- ((pRegExpr regex_'3cscript'5cb >>= withAttribute "Element") >>~ pushContext "JS")- <|>- ((pRegExpr regex_'3cpre'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3cdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3ctable'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((parseRules "FindDTDRules"))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "FindHTML" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pRegExpr regex_'3cstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "CSS")+ <|>+ ((pRegExpr regex_'3cscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "JS")+ <|>+ ((pRegExpr regex_'3cpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3cdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3ctable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "FindEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pAnyChar "&<" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&<" >>= withAttribute ErrorTok))) -parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntityRef"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute ErrorTok))) -parseRules "FindAttributes" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pDetectChar False '=' >>= withAttribute "Attribute") >>~ pushContext "Value"))- return (attr, result)+parseRules "FindAttributes" =+ (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value")) -parseRules "FindDTDRules" = - do (attr, result) <- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- return (attr, result)+parseRules "FindDTDRules" =+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl") -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((parseRules "FindTemplate"))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Error")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok))) -parseRules "CDATA" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "EntityRef")))- return (attr, result)+parseRules "CDATA" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)+parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset")) -parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((parseRules "FindDTDRules"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)+parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl SQ")) -parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "El Open" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((parseRules "FindAttributes"))- <|>- ((parseRules "FindTemplate"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Open" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close 2" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close 2" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close 3" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close 3" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "CSS" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "CSS content")- <|>- ((parseRules "FindAttributes"))- <|>- ((parseRules "FindTemplate"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "CSS" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "CSS content")+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "CSS content" = - do (attr, result) <- (((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((parseRules "FindTemplate"))- <|>- ((Text.Highlighting.Kate.Syntax.Css.parseExpression)))- return (attr, result)+parseRules "CSS content" =+ (((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Css.parseExpression))) -parseRules "JS" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "JS content")- <|>- ((parseRules "FindTemplate"))- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "JS" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "JS content")+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "JS content" = - do (attr, result) <- (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute "Comment") >>~ pushContext "JS comment close")- <|>- ((parseRules "FindTemplate"))- <|>- ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))- return (attr, result)+parseRules "JS content" =+ (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute CommentTok) >>~ pushContext "JS comment close")+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression))) -parseRules "JS comment close" = - do (attr, result) <- (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 3")- <|>- ((parseRules "FindTemplate"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "JS comment close" =+ (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 3")+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Value DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Value SQ")- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- (pushContext "Value NQ" >> return ([], "")))- return (attr, result)+parseRules "Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Value DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Value SQ")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ (pushContext "Value NQ" >> currentContext >>= parseRules)) -parseRules "Value NQ" = - do (attr, result) <- (((parseRules "FindEntityRefs"))- <|>- ((parseRules "FindTemplate"))- <|>- ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute "Value"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)+parseRules "Value NQ" =+ (((parseRules "FindEntityRefs"))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute StringTok))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules)) -parseRules "Value DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindTemplate"))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "Value SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindTemplate"))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindTemplate"))+ <|>+ ((parseRules "FindEntityRefs"))) parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Doxygen.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file doxygen.xml, version 1.32,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file doxygen.xml, version 1.32, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Doxygen ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Doxygen+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Doxygen"@@ -20,51 +23,43 @@ 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Doxygen" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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+startingState = SyntaxState {synStContexts = fromList [("Doxygen",["Normal"])], synStLanguage = "Doxygen", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "LineComment" -> (popContext) >> pEndLine- "BlockComment" -> return () >> pHandleEndLine+ "BlockComment" -> return () "ML_TagWord" -> (popContext) >> pEndLine "ML_TagParam" -> (popContext) >> pEndLine "ML_TagWordWord" -> (popContext) >> pEndLine "ML_Tag2ndWord" -> (popContext >> popContext) >> pEndLine "ML_TagString" -> (popContext) >> pEndLine "ML_TagWordString" -> (popContext) >> pEndLine- "ML_htmltag" -> return () >> pHandleEndLine- "ML_htmlcomment" -> return () >> pHandleEndLine- "ML_identifiers" -> return () >> pHandleEndLine- "ML_types1" -> return () >> pHandleEndLine- "ML_types2" -> return () >> pHandleEndLine+ "ML_htmltag" -> return ()+ "ML_htmlcomment" -> return ()+ "ML_identifiers" -> return ()+ "ML_types1" -> return ()+ "ML_types2" -> return () "SL_TagWord" -> (popContext) >> pEndLine "SL_TagParam" -> (popContext) >> pEndLine "SL_TagWordWord" -> (popContext) >> pEndLine@@ -78,27 +73,22 @@ "SL_types2" -> (popContext) >> pEndLine "SL_DetectEnv" -> (popContext) >> pEndLine "SL_DetectComment" -> (popContext) >> pEndLine- "Code" -> return () >> pHandleEndLine- "Verbatim" -> return () >> pHandleEndLine- "Formula" -> return () >> pHandleEndLine- "Msc" -> return () >> pHandleEndLine- "Dot" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Code" -> return ()+ "Verbatim" -> return ()+ "Formula" -> return ()+ "Msc" -> return ()+ "Dot" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Tags","kw"),("Word","kw"),("HTML Tag","kw"),("Description","st"),("Comment","co"),("Region","re"),("Identifier","ot"),("HTML Comment","co"),("Types","dt"),("Code","co"),("Dot Graph","co"),("Formulas","co"),("Message Sequence Chart","co"),("Verbatim","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_TagOnly = Set.fromList $ words $ "\\arg \\attention \\author \\callgraph \\callergraph \\details \\dot \\else \\endcond \\enddot \\endhtmlonly \\endif \\endlatexonly \\endlink \\endmanonly \\endmsc \\endverbatim \\endxmlonly \\f[ \\f] \\f$ \\hideinitializer \\htmlonly \\interface \\internal \\invariant \\~ \\@ \\$ \\\\ \\# \\latexonly \\li \\manonly \\msc \\n \\nosubgrouping \\note \\only \\post \\pre \\private \\privatesection \\protected \\protectedsection \\public \\publicsection \\remarks \\return \\returns \\showinitializer \\since \\test \\todo \\verbatim \\warning \\xmlonly @arg @attention @author @callgraph @callergraph @details @dot @else @endcond @enddot @endhtmlonly @endif @endlatexonly @endlink @endmanonly @endmsc @endverbatim @endxmlonly @f[ @f] @f$ @hideinitializer @htmlonly @interface @internal @invariant @~ @@ @$ @\\ @# @latexonly @li @manonly @msc @n @nosubgrouping @note @only @post @pre @pivate @pivatesection @protected @protectedsection @public @publicsection @remarks @return @returns @showinitializer @since @test @todo @verbatim @warning @xmlonly" list_TagWord = Set.fromList $ words $ "\\addtogroup \\a \\anchor \\b \\c \\class \\cond \\copybrief \\copydetails \\copydoc \\def \\dir \\dontinclude \\dotfile \\e \\elseif \\em \\enum \\example \\exception \\exceptions \\extends \\file \\htmlinclude \\if \\ifnot \\implements \\include \\includelineno \\link \\memberof \\namespace \\p \\package \\property \\protocol \\ref \\relatesalso \\relates \\retval \\throw \\throws \\verbinclude \\version \\xrefitem @addtogroup @a @anchor @b @c @class @cond @copybrief @copydetails @copydoc @def @dir @dontinclude @dotfile @e @elseif @em @enum @example @exception @exceptions @extends @file @htmlinclude @if @ifnot @implements @include @includelineno @link @memberof @namespace @p @package @property @prtocol @ref @relatesalso @relates @retval @throw @throws @verbinclude @version @xrefitem"@@ -131,321 +121,289 @@ regex_'5b'40'5c'5c'5dendmsc = compileRegex "[@\\\\]endmsc" regex_'5b'40'5c'5c'5denddot = compileRegex "[@\\\\]enddot" -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"),("SL_DetectEnv",""),("SL_DetectComment",""),("Code","Code"),("Verbatim","Verbatim"),("Formula","Formulas"),("Msc","Message Sequence Chart"),("Dot","Dot Graph")]+defaultAttributes = [("Normal",NormalTok),("LineComment",CommentTok),("BlockComment",CommentTok),("ML_TagWord",CommentTok),("ML_TagParam",CommentTok),("ML_TagWordWord",CommentTok),("ML_Tag2ndWord",CommentTok),("ML_TagString",CommentTok),("ML_TagWordString",CommentTok),("ML_htmltag",OtherTok),("ML_htmlcomment",CommentTok),("ML_identifiers",OtherTok),("ML_types1",DataTypeTok),("ML_types2",DataTypeTok),("SL_TagWord",CommentTok),("SL_TagParam",CommentTok),("SL_TagWordWord",CommentTok),("SL_Tag2ndWord",CommentTok),("SL_TagString",CommentTok),("SL_TagWordString",CommentTok),("SL_htmltag",OtherTok),("SL_htmlcomment",CommentTok),("SL_identifiers",OtherTok),("SL_types1",DataTypeTok),("SL_types2",DataTypeTok),("SL_DetectEnv",NormalTok),("SL_DetectComment",NormalTok),("Code",CommentTok),("Verbatim",CommentTok),("Formula",CommentTok),("Msc",CommentTok),("Dot",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'2f'2f'28'21'7c'28'2f'28'3f'3d'5b'5e'2f'5d'7c'24'29'29'29'3c'3f >>= withAttribute "Comment") >>~ pushContext "LineComment")- <|>- ((pRegExpr regex_'2f'5c'2a'28'5c'2a'5b'5e'2a'2f'5d'7c'21'7c'5b'2a'21'5d'3c'7c'5c'2a'24'29 >>= withAttribute "Comment") >>~ pushContext "BlockComment")- <|>- ((pRegExpr regex_'2f'2f'5cs'2a'40'5c'7b'5cs'2a'24 >>= withAttribute "Region"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2a'40'5c'7d'5cs'2a'24 >>= withAttribute "Region"))- <|>- ((pRegExpr regex_'2f'5c'2a'5cs'2a'40'5c'7b'5cs'2a'5c'2a'2f >>= withAttribute "Region"))- <|>- ((pRegExpr regex_'2f'5c'2a'5cs'2a'40'5c'7d'5cs'2a'5c'2a'2f >>= withAttribute "Region")))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'2f'2f'28'21'7c'28'2f'28'3f'3d'5b'5e'2f'5d'7c'24'29'29'29'3c'3f >>= withAttribute CommentTok) >>~ pushContext "LineComment")+ <|>+ ((pRegExpr regex_'2f'5c'2a'28'5c'2a'5b'5e'2a'2f'5d'7c'21'7c'5b'2a'21'5d'3c'7c'5c'2a'24'29 >>= withAttribute CommentTok) >>~ pushContext "BlockComment")+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2a'40'5c'7b'5cs'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2a'40'5c'7d'5cs'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'2f'5c'2a'5cs'2a'40'5c'7b'5cs'2a'5c'2a'2f >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'2f'5c'2a'5cs'2a'40'5c'7d'5cs'2a'5c'2a'2f >>= withAttribute RegionMarkerTok))) -parseRules "LineComment" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment"))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((parseRules "SL_DetectEnv"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute "Tags"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute "Tags") >>~ pushContext "SL_TagWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute "Tags") >>~ pushContext "SL_TagParam")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute "Tags") >>~ pushContext "SL_TagWordWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute "Tags") >>~ pushContext "SL_TagString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute "Tags") >>~ pushContext "SL_TagWordString")- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "SL_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "SL_htmltag"))- return (attr, result)+parseRules "LineComment" =+ (((pLineContinue >>= withAttribute CommentTok))+ <|>+ ((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((parseRules "SL_DetectEnv"))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute KeywordTok) >>~ pushContext "SL_TagWord")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute KeywordTok) >>~ pushContext "SL_TagParam")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute KeywordTok) >>~ pushContext "SL_TagWordWord")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute KeywordTok) >>~ pushContext "SL_TagString")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute KeywordTok) >>~ pushContext "SL_TagWordString")+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "SL_htmlcomment")+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "SL_htmltag")) -parseRules "BlockComment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '@' '{' >>= withAttribute "Region"))- <|>- ((pDetect2Chars False '@' '}' >>= withAttribute "Region"))- <|>- ((parseRules "SL_DetectEnv"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute "Tags"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute "Tags") >>~ pushContext "ML_TagWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute "Tags") >>~ pushContext "ML_TagParam")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute "Tags") >>~ pushContext "ML_TagWordWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute "Tags") >>~ pushContext "ML_TagString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute "Tags") >>~ pushContext "ML_TagWordString")- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5c'5c'28'3c'7c'3e'29 >>= withAttribute "Tags"))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "ML_htmltag")- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "ML_htmlcomment"))- return (attr, result)+parseRules "BlockComment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '@' '{' >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetect2Chars False '@' '}' >>= withAttribute RegionMarkerTok))+ <|>+ ((parseRules "SL_DetectEnv"))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute KeywordTok) >>~ pushContext "ML_TagWord")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute KeywordTok) >>~ pushContext "ML_TagParam")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute KeywordTok) >>~ pushContext "ML_TagWordWord")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute KeywordTok) >>~ pushContext "ML_TagString")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute KeywordTok) >>~ pushContext "ML_TagWordString")+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5c'5c'28'3c'7c'3e'29 >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "ML_htmltag")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "ML_htmlcomment")) -parseRules "ML_TagWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "SL_TagWord")))- return (attr, result)+parseRules "ML_TagWord" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "SL_TagWord"))) -parseRules "ML_TagParam" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "[in]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pString False "[out]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pString False "[in,out]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "ML_TagParam" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "[in]" >>= withAttribute KeywordTok) >>~ pushContext "ML_Tag2ndWord")+ <|>+ ((pString False "[out]" >>= withAttribute KeywordTok) >>~ pushContext "ML_Tag2ndWord")+ <|>+ ((pString False "[in,out]" >>= withAttribute KeywordTok) >>~ pushContext "ML_Tag2ndWord")+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "ML_TagWordWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "ML_TagWordWord" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "ML_Tag2ndWord")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "ML_Tag2ndWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((parseRules "SL_Tag2ndWord")))- return (attr, result)+parseRules "ML_Tag2ndWord" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext >> popContext))+ <|>+ ((parseRules "SL_Tag2ndWord"))) -parseRules "ML_TagString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "ML_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "ML_htmltag")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Description")))- return (attr, result)+parseRules "ML_TagString" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "ML_htmlcomment")+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "ML_htmltag")+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "ML_TagWordString" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "SL_TagWordString")))- return (attr, result)+parseRules "ML_TagWordString" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "SL_TagWordString"))) -parseRules "ML_htmltag" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetect2Chars False '/' '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Identifier") >>~ pushContext "ML_identifiers"))- return (attr, result)+parseRules "ML_htmltag" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "ML_identifiers")) -parseRules "ML_htmlcomment" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext)))- return (attr, result)+parseRules "ML_htmlcomment" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "ML_identifiers" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "ML_types1")- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "ML_types2"))- return (attr, result)+parseRules "ML_identifiers" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ pushContext "ML_types1")+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "ML_types2")) -parseRules "ML_types1" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "ML_types1" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "ML_types2" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "ML_types2" =+ (((lookAhead (pDetect2Chars False '*' '/') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "SL_TagWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord) >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "SL_TagWord" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -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 regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "SL_TagParam" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "[in]" >>= withAttribute KeywordTok) >>~ pushContext "SL_Tag2ndWord")+ <|>+ ((pString False "[out]" >>= withAttribute KeywordTok) >>~ pushContext "SL_Tag2ndWord")+ <|>+ ((pString False "[in,out]" >>= withAttribute KeywordTok) >>~ pushContext "SL_Tag2ndWord")+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "SL_TagWordWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ pushContext "SL_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "SL_TagWordWord" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ pushContext "SL_Tag2ndWord")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "SL_Tag2ndWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "SL_Tag2ndWord" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "SL_TagString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "SL_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "SL_htmltag")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Description")))- return (attr, result)+parseRules "SL_TagString" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "SL_htmlcomment")+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'3c'5c'2f'3f'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "SL_htmltag")+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "SL_TagWordString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)+parseRules "SL_TagWordString" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute KeywordTok))) -parseRules "SL_htmltag" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Identifier") >>~ pushContext "SL_identifiers"))- return (attr, result)+parseRules "SL_htmltag" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "SL_identifiers")) -parseRules "SL_htmlcomment" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext)))- return (attr, result)+parseRules "SL_htmlcomment" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "SL_identifiers" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "SL_types1")- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "SL_types2"))- return (attr, result)+parseRules "SL_identifiers" =+ (((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ pushContext "SL_types1")+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "SL_types2")) -parseRules "SL_types1" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext))- return (attr, result)+parseRules "SL_types1" =+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext)) -parseRules "SL_types2" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext))- return (attr, result)+parseRules "SL_types2" =+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext)) -parseRules "SL_DetectEnv" = - do (attr, result) <- (((pRegExpr regex_'5b'40'5c'5c'5dcode >>= withAttribute "Tags") >>~ pushContext "Code")- <|>- ((pRegExpr regex_'5b'40'5c'5c'5dverbatim >>= withAttribute "Tags") >>~ pushContext "Verbatim")- <|>- ((pRegExpr regex_'5b'40'5c'5c'5df'5c'5b >>= withAttribute "Tags") >>~ pushContext "Formula")- <|>- ((pRegExpr regex_'5b'40'5c'5c'5dmsc >>= withAttribute "Tags") >>~ pushContext "Msc")- <|>- ((pRegExpr regex_'5b'40'5c'5c'5ddot >>= withAttribute "Tags") >>~ pushContext "Dot"))- return (attr, result)+parseRules "SL_DetectEnv" =+ (((pRegExpr regex_'5b'40'5c'5c'5dcode >>= withAttribute KeywordTok) >>~ pushContext "Code")+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5dverbatim >>= withAttribute KeywordTok) >>~ pushContext "Verbatim")+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5df'5c'5b >>= withAttribute KeywordTok) >>~ pushContext "Formula")+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5dmsc >>= withAttribute KeywordTok) >>~ pushContext "Msc")+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5ddot >>= withAttribute KeywordTok) >>~ pushContext "Dot")) -parseRules "SL_DetectComment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext >> popContext))- return (attr, result)+parseRules "SL_DetectComment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext)) -parseRules "Code" = - do (attr, result) <- (((parseRules "SL_DetectComment"))- <|>- ((pRegExpr regex_'5b'40'5c'5c'5dendcode >>= withAttribute "Tags") >>~ (popContext)))- return (attr, result)+parseRules "Code" =+ (((parseRules "SL_DetectComment"))+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5dendcode >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Verbatim" = - do (attr, result) <- (((parseRules "SL_DetectComment"))- <|>- ((pRegExpr regex_'5b'40'5c'5c'5dendverbatim >>= withAttribute "Tags") >>~ (popContext)))- return (attr, result)+parseRules "Verbatim" =+ (((parseRules "SL_DetectComment"))+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5dendverbatim >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Formula" = - do (attr, result) <- (((parseRules "SL_DetectComment"))- <|>- ((pRegExpr regex_'5b'40'5c'5c'5df'5c'5d >>= withAttribute "Tags") >>~ (popContext)))- return (attr, result)+parseRules "Formula" =+ (((parseRules "SL_DetectComment"))+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5df'5c'5d >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Msc" = - do (attr, result) <- (((parseRules "SL_DetectComment"))- <|>- ((pRegExpr regex_'5b'40'5c'5c'5dendmsc >>= withAttribute "Tags") >>~ (popContext)))- return (attr, result)+parseRules "Msc" =+ (((parseRules "SL_DetectComment"))+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5dendmsc >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Dot" = - do (attr, result) <- (((parseRules "SL_DetectComment"))- <|>- ((pRegExpr regex_'5b'40'5c'5c'5denddot >>= withAttribute "Tags") >>~ (popContext)))- return (attr, result)+parseRules "Dot" =+ (((parseRules "SL_DetectComment"))+ <|>+ ((pRegExpr regex_'5b'40'5c'5c'5denddot >>= withAttribute KeywordTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
− Text/Highlighting/Kate/Syntax/Doxygenlua.hs
@@ -1,369 +0,0 @@-{- This module was generated from data in the Kate syntax highlighting file doxygenlua.xml, version 1.01,- by Bruno Massa (brmassa@gmail.com) -}--module Text.Highlighting.Kate.Syntax.Doxygenlua ( 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 Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "DoxygenLua"---- | 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 = "DoxygenLua" }- 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 [("DoxygenLua",["Normal"])], synStLanguage = "DoxygenLua", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Normal" -> return () >> pHandleEndLine- "LineComment" -> (popContext) >> pEndLine- "BlockComment" -> return () >> pHandleEndLine- "ML_TagWord" -> (popContext) >> pEndLine- "ML_TagParam" -> (popContext) >> pEndLine- "ML_TagWordWord" -> (popContext) >> pEndLine- "ML_Tag2ndWord" -> (popContext >> popContext) >> pEndLine- "ML_TagString" -> (popContext) >> pEndLine- "ML_TagWordString" -> (popContext) >> pEndLine- "ML_htmltag" -> return () >> pHandleEndLine- "ML_htmlcomment" -> return () >> pHandleEndLine- "ML_identifiers" -> return () >> pHandleEndLine- "ML_types1" -> return () >> pHandleEndLine- "ML_types2" -> return () >> pHandleEndLine- "SL_TagWord" -> (popContext) >> pEndLine- "SL_TagParam" -> (popContext) >> pEndLine- "SL_TagWordWord" -> (popContext) >> pEndLine- "SL_Tag2ndWord" -> (popContext >> popContext) >> pEndLine- "SL_TagString" -> (popContext) >> pEndLine- "SL_TagWordString" -> (popContext) >> pEndLine- "SL_htmltag" -> (popContext) >> pEndLine- "SL_htmlcomment" -> (popContext) >> pEndLine- "SL_identifiers" -> (popContext) >> pEndLine- "SL_types1" -> (popContext) >> pEndLine- "SL_types2" -> (popContext) >> pEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Tags","kw"),("Word","kw"),("HTML Tag","kw"),("Description","st"),("Comment","co"),("Region","re"),("Identifier","ot"),("HTML Comment","co"),("Types","dt")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_TagOnly = 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"-list_TagWord = 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"-list_TagParam = Set.fromList $ words $ "\\param @param"-list_TagWordWord = Set.fromList $ words $ "\\image @image"-list_TagWordString = Set.fromList $ words $ "\\defgroup \\page \\paragraph \\section \\struct \\subsection \\subsubsection \\union \\weakgroup @defgroup @page @paragraph @section @struct @subsection @subsubsection @union @weakgroup"-list_TagString = 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"--regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a = compileRegex "<\\s*\\/?\\s*[a-zA-Z_:][a-zA-Z0-9._:-]*"-regex_'5c'5c'28'3c'7c'3e'29 = compileRegex "\\\\(<|>)"-regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 = compileRegex "\\S(?=([][,?;()]|\\.$|\\.?\\s))"-regex_'5cS = compileRegex "\\S"-regex_'2e = compileRegex "."-regex_'5cs'2a'3d'5cs'2a = compileRegex "\\s*=\\s*"-regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a = compileRegex "\\s*#?[a-zA-Z0-9]*"--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) <- (((pRegExprDynamic "--\\[(=*)\\[" >>= withAttribute "Comment") >>~ pushContext "BlockComment")- <|>- ((pString False "--" >>= withAttribute "Comment") >>~ pushContext "LineComment"))- return (attr, result)--parseRules "LineComment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute "Tags"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute "Tags") >>~ pushContext "SL_TagWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute "Tags") >>~ pushContext "SL_TagParam")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute "Tags") >>~ pushContext "SL_TagWordWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute "Tags") >>~ pushContext "SL_TagString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute "Tags") >>~ pushContext "SL_TagWordString")- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "SL_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "SL_htmltag"))- return (attr, result)--parseRules "BlockComment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExprDynamic "\\]%1\\]" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '@' '{' >>= withAttribute "Region"))- <|>- ((pDetect2Chars False '@' '}' >>= withAttribute "Region"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagOnly >>= withAttribute "Tags"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord >>= withAttribute "Tags") >>~ pushContext "ML_TagWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagParam >>= withAttribute "Tags") >>~ pushContext "ML_TagParam")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordWord >>= withAttribute "Tags") >>~ pushContext "ML_TagWordWord")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagString >>= withAttribute "Tags") >>~ pushContext "ML_TagString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWordString >>= withAttribute "Tags") >>~ pushContext "ML_TagWordString")- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5c'5c'28'3c'7c'3e'29 >>= withAttribute "Tags"))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "ML_htmltag")- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "ML_htmlcomment"))- return (attr, result)--parseRules "ML_TagWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "SL_TagWord")))- return (attr, result)--parseRules "ML_TagParam" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "[in]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pString False "[out]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pString False "[in,out]" >>= withAttribute "Tags") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "ML_TagWordWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ pushContext "ML_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "ML_Tag2ndWord" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((parseRules "SL_Tag2ndWord")))- return (attr, result)--parseRules "ML_TagString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "ML_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "ML_htmltag")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Description")))- return (attr, result)--parseRules "ML_TagWordString" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "SL_TagWordString")))- return (attr, result)--parseRules "ML_htmltag" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetect2Chars False '/' '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Identifier") >>~ pushContext "ML_identifiers"))- return (attr, result)--parseRules "ML_htmlcomment" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext)))- return (attr, result)--parseRules "ML_identifiers" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "String") >>~ (popContext))- <|>- ((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))- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "ML_types2" = - do (attr, result) <- (((lookAhead (pDetect2Chars False '*' '/') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "SL_TagWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((lookAhead (pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}" list_TagWord) >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= 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 regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "SL_TagWordWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ pushContext "SL_Tag2ndWord")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "SL_Tag2ndWord" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "SL_TagString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "<!--" >>= withAttribute "HTML Comment") >>~ pushContext "SL_htmlcomment")- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "HTML Tag") >>~ pushContext "SL_htmltag")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Description")))- return (attr, result)--parseRules "SL_TagWordString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5cS'28'3f'3d'28'5b'5d'5b'2c'3f'3b'28'29'5d'7c'5c'2e'24'7c'5c'2e'3f'5cs'29'29 >>= withAttribute "Word") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Word")))- return (attr, result)--parseRules "SL_htmltag" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "HTML Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Identifier") >>~ pushContext "SL_identifiers"))- return (attr, result)--parseRules "SL_htmlcomment" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pString False "-->" >>= withAttribute "HTML Comment") >>~ (popContext)))- return (attr, result)--parseRules "SL_identifiers" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'23'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "String") >>~ (popContext))- <|>- ((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 (attr, result)--parseRules "SL_types2" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext))- return (attr, result)--parseRules "" = parseRules "Normal"--parseRules x = fail $ "Unknown context" ++ x
Text/Highlighting/Kate/Syntax/Dtd.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file dtd.xml, version 1.02,- by Andriy Lesyuk (s-andy@in.if.ua) -}+{- This module was generated from data in the Kate syntax+ highlighting file dtd.xml, version 1.02, by Andriy Lesyuk (s-andy@in.if.ua) -} -module Text.Highlighting.Kate.Syntax.Dtd ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Dtd+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "DTD"@@ -20,59 +23,46 @@ syntaxExtensions = "*.dtd" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "DTD" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("DTD",["Normal"])], synStLanguage = "DTD", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("DTD",["Normal"])], synStLanguage = "DTD", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Declaration" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "Comment" -> return ()+ "PI" -> return ()+ "Declaration" -> return ()+ "String" -> return () "InlineComment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Processing Instruction","kw"),("Declaration","dt"),("Name","fu"),("Delimiter","dv"),("Symbol","fl"),("Keyword","kw"),("String","st"),("Entity","dv"),("Local","dv")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_Category = Set.fromList $ words $ "EMPTY ANY CDATA ID IDREF IDREFS NMTOKEN NMTOKENS ENTITY ENTITIES NOTATION PUBLIC SYSTEM NDATA" list_Keywords = Set.fromList $ words $ "#PCDATA #REQUIRED #IMPLIED #FIXED"@@ -83,83 +73,77 @@ regex_'5cb'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'5cb = compileRegex "\\b[\\-\\w\\d\\.:_]+\\b" regex_'25'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'3b = compileRegex "%[\\-\\w\\d\\.:_]+;" -defaultAttributes = [("Normal","Normal"),("Comment","Comment"),("PI","Other"),("Declaration","Other"),("String","String"),("InlineComment","Comment")]+defaultAttributes = [("Normal",NormalTok),("Comment",CommentTok),("PI",NormalTok),("Declaration",NormalTok),("String",StringTok),("InlineComment",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<?xml" >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pString False "<!ELEMENT" >>= withAttribute "Declaration") >>~ pushContext "Declaration")- <|>- ((pString False "<!ATTLIST" >>= withAttribute "Declaration") >>~ pushContext "Declaration")- <|>- ((pString False "<!NOTATION" >>= withAttribute "Declaration") >>~ pushContext "Declaration")- <|>- ((pString False "<!ENTITY" >>= withAttribute "Declaration") >>~ pushContext "Declaration")- <|>- ((pDetectIdentifier >>= withAttribute "Normal")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<?xml" >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pString False "<!ELEMENT" >>= withAttribute DataTypeTok) >>~ pushContext "Declaration")+ <|>+ ((pString False "<!ATTLIST" >>= withAttribute DataTypeTok) >>~ pushContext "Declaration")+ <|>+ ((pString False "<!NOTATION" >>= withAttribute DataTypeTok) >>~ pushContext "Declaration")+ <|>+ ((pString False "<!ENTITY" >>= withAttribute DataTypeTok) >>~ pushContext "Declaration")+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Declaration" = - do (attr, result) <- (((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "InlineComment")- <|>- ((pDetectChar False '>' >>= withAttribute "Declaration") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'28'2d'7cO'29'5cs'28'2d'7cO'29 >>= withAttribute "Declaration"))- <|>- ((pAnyChar "(|)," >>= withAttribute "Delimiter"))- <|>- ((pRegExpr regex_'28'25'7c'26'29'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'29'3b >>= withAttribute "Entity"))- <|>- ((pAnyChar "?*+-&" >>= withAttribute "Symbol"))- <|>- ((pRegExpr regex_'25'5cs >>= withAttribute "Local"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Category >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Keywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'5cb >>= withAttribute "Name")))- return (attr, result)+parseRules "Declaration" =+ (((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "InlineComment")+ <|>+ ((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'28'2d'7cO'29'5cs'28'2d'7cO'29 >>= withAttribute DataTypeTok))+ <|>+ ((pAnyChar "(|)," >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'28'25'7c'26'29'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "?*+-&" >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'25'5cs >>= withAttribute DecValTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Category >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Keywords >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'5cb >>= withAttribute FunctionTok))) -parseRules "String" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'25'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'3b >>= withAttribute "Entity")))- return (attr, result)+parseRules "String" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'25'5b'5c'2d'5cw'5cd'5c'2e'3a'5f'5d'2b'3b >>= withAttribute DecValTok))) -parseRules "InlineComment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "InlineComment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Eiffel.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file eiffel.xml, version 1.02,- by Sebastian Vuorinen -}+{- This module was generated from data in the Kate syntax+ highlighting file eiffel.xml, version 1.02, by Sebastian Vuorinen -} -module Text.Highlighting.Kate.Syntax.Eiffel ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Eiffel+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Eiffel"@@ -19,87 +22,72 @@ syntaxExtensions = "*.e" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Eiffel" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Eiffel",["Normal"])], synStLanguage = "Eiffel", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Eiffel",["Normal"])], synStLanguage = "Eiffel", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "Quoted String" -> (popContext) >> pEndLine "Documentation" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Predefined entities","ot"),("Assertions","ot"),("Decimal","dv"),("Float","fl"),("Char","ch"),("String","st"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "agent alias all and as assign class convert create creation debug deferred do else elseif end expanded export external feature from frozen if implies indexing infix inherit inspect is like local loop not obsolete old once or prefix pure redefine reference rename rescue retry separate then undefine" list_predefined'2dentities = Set.fromList $ words $ "Current False Precursor Result True TUPLE" list_assertions = Set.fromList $ words $ "check ensure require variant invariant" -defaultAttributes = [("Normal","Normal Text"),("Quoted String","String"),("Documentation","Comment")]+defaultAttributes = [("Normal",NormalTok),("Quoted String",StringTok),("Documentation",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_predefined'2dentities >>= withAttribute "Predefined entities"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_assertions >>= withAttribute "Assertions"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Quoted String")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "Documentation"))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_predefined'2dentities >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_assertions >>= withAttribute OtherTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Quoted String")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "Documentation")) -parseRules "Quoted String" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "Quoted String" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Documentation" = +parseRules "Documentation" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Email.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file email.xml, version 1.00,- by Carl A Joslin (carl.joslin@joslin.dyndns.org) -}+{- This module was generated from data in the Kate syntax+ highlighting file email.xml, version 1.00, by Carl A Joslin (carl.joslin@joslin.dyndns.org) -} -module Text.Highlighting.Kate.Syntax.Email ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Email+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,54 +21,41 @@ syntaxExtensions = "*.eml" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Email" } context <- currentContext <|> (pushContext "headder" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Email",["headder"])], synStLanguage = "Email", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Email",["headder"])], synStLanguage = "Email", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "headder" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "headder" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("rfc-main","al"),("string","st"),("base64","re"),("marker","al"),("sign","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'5bTt'5do'3a'2e'2a'24 = compileRegex "[Tt]o:.*$"@@ -125,125 +115,124 @@ regex_'5bA'2dZa'2dz0'2d9'2b'3d'2f'5d'2b'3d'24 = compileRegex "[A-Za-z0-9+=/]+=$" regex_'28'2d_'29'3f'2d'2d'28'2d'2d'2e'2a'29'3f = compileRegex "(- )?--(--.*)?" -defaultAttributes = [("headder","Normal Text")]+defaultAttributes = [("headder",NormalTok)] -parseRules "headder" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5bTt'5do'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bFf'5drom'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5d'5bCc'5d'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bBb'5d'5bCc'5d'5bCc'5d'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bSs'5dubject'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bDd'5date'3a'2e'2a'24 >>= withAttribute "rfc-main"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bSs'5dender'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bMm'5dessage'2d'5bIi'5d'5bDd'5d'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bIi'5dn'2d'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5deferences'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5domments'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bKk'5deywors'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bDd'5date'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bFf'5drom'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bSs'5dender'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bTt'5do'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bCc'5d'5bCc'5d'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bBb'5d'5bCc'5d'5bCc'5d'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bMm'5dessage'2d'5bIi'5d'5bDd'5d'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5deturn'2d'5bPp'5dath'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bRr'5deceived'3a >>= withAttribute "rfc"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dozilla'2d'5bSs'5dtatus'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dozilla'2d'5bSs'5dtatus2'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bEe'5dnverlope'2d'5bTt'5do'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bDd'5delivery'2d'5bDd'5date'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bOo'5driginating'2d'5bIi'5d'5bPp'5d'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bOo'5driginating'2d'5bEe'5dmail'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bSs'5dender'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bMm'5dime'2d'5bVv'5dersion'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dype'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dailing'2d'5bLl'5dist'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bLl'5doop'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bPp'5dost'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bHh'5delp'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bUu'5dnsubscribe'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bPp'5drecedence'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dransfer'2d'5bEe'5dncoding'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dype'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bBb'5dulkmail'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bPp'5drecedence'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bDd'5disposition'3a >>= withAttribute "common"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b0'2d9a'2dzA'2dZ'2d'2e'5d'2b'3a >>= withAttribute "other"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b >>= withAttribute "email"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2a'5cs'2a'3c'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'3e >>= withAttribute "email"))- <|>- ((pRegExpr regex_'22'5ba'2dzA'2dZ0'2d9'2e_'5c'2d'5d'2b'22'5cs'2a'3c'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'3e >>= withAttribute "email"))- <|>- ((pRegExpr regex_'22'2e'2a'22 >>= withAttribute "string"))- <|>- ((pRegExpr regex_'27'2e'2a'27 >>= withAttribute "string"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute "indent6"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute "indent5"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute "indent4"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute "indent3"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute "indent2"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'2e'2a >>= withAttribute "indent1"))- <|>- ((pColumn 0 >> pRegExpr regex_'28'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'29'7b10'2c20'7d'24 >>= withAttribute "base64"))- <|>- ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz0'2d9'2b'3d'2f'5d'2b'3d'24 >>= withAttribute "base64"))- <|>- ((pColumn 0 >> pRegExpr regex_'28'2d_'29'3f'2d'2d'28'2d'2d'2e'2a'29'3f >>= withAttribute "marker")))- return (attr, result)+parseRules "headder" =+ (((pColumn 0 >> pRegExpr regex_'5bTt'5do'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bFf'5drom'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5d'5bCc'5d'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bBb'5d'5bCc'5d'5bCc'5d'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bSs'5dubject'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bDd'5date'3a'2e'2a'24 >>= withAttribute AlertTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bSs'5dender'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bMm'5dessage'2d'5bIi'5d'5bDd'5d'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bIi'5dn'2d'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5deferences'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5domments'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bKk'5deywors'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bDd'5date'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bFf'5drom'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bSs'5dender'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bTt'5do'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bCc'5d'5bCc'5d'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bBb'5d'5bCc'5d'5bCc'5d'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bMm'5dessage'2d'5bIi'5d'5bDd'5d'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5desent'2d'5bRr'5deply'2d'5bTt'5do'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5deturn'2d'5bPp'5dath'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bRr'5deceived'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dozilla'2d'5bSs'5dtatus'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dozilla'2d'5bSs'5dtatus2'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bEe'5dnverlope'2d'5bTt'5do'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bDd'5delivery'2d'5bDd'5date'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bOo'5driginating'2d'5bIi'5d'5bPp'5d'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bOo'5driginating'2d'5bEe'5dmail'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bSs'5dender'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bMm'5dime'2d'5bVv'5dersion'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dype'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bMm'5dailing'2d'5bLl'5dist'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bLl'5doop'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bPp'5dost'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bHh'5delp'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bLl'5dist'2d'5bUu'5dnsubscribe'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bPp'5drecedence'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dransfer'2d'5bEe'5dncoding'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bTt'5dype'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bXx'5d'2d'5bBb'5dulkmail'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bPp'5drecedence'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bCc'5dontent'2d'5bDd'5disposition'3a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b0'2d9a'2dzA'2dZ'2d'2e'5d'2b'3a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2a'5cs'2a'3c'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'3e >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'5ba'2dzA'2dZ0'2d9'2e_'5c'2d'5d'2b'22'5cs'2a'3c'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'5c'40'5ba'2dzA'2dZ0'2d9'2e'5c'2d'5d'2b'3e >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'22'2e'2a'22 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'27'2e'2a'27 >>= withAttribute StringTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'5cs'2a'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'7c'3e'5d'2e'2a >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'5bA'2dZa'2dz0'2d9'2b'2f'5d'29'7b10'2c20'7d'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz0'2d9'2b'3d'2f'5d'2b'3d'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'2d_'29'3f'2d'2d'28'2d'2d'2e'2a'29'3f >>= withAttribute AlertTok))) parseRules "" = parseRules "headder"
Text/Highlighting/Kate/Syntax/Erlang.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file erlang.xml, version 1.02,- by Bill Ross (bill@emailme.net.au) -}+{- This module was generated from data in the Kate syntax+ highlighting file erlang.xml, version 1.02, by Bill Ross (bill@emailme.net.au) -} -module Text.Highlighting.Kate.Syntax.Erlang ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Erlang+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Erlang"@@ -20,35 +23,27 @@ syntaxExtensions = "*.erl" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Erlang" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Erlang",["Normal Text"])], synStLanguage = "Erlang", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Erlang",["Normal Text"])], synStLanguage = "Erlang", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of "Normal Text" -> (popContext) >> pEndLine@@ -56,22 +51,17 @@ "atomquote" -> (popContext) >> pEndLine "stringquote" -> (popContext) >> pEndLine "comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Pragma","kw"),("Function","fu"),("Separator","fu"),("Operator","kw"),("Variable","dt"),("Integer","dv"),("Number","bn"),("Float","fl"),("Atom","ch"),("String","st"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "after begin case catch cond end fun if let of query receive all_true some_true" list_operators = Set.fromList $ words $ "div rem or xor bor bxor bsl bsr and band not bnot"@@ -91,65 +81,60 @@ regex_'28'3f'3a'28'3f'3a'5c'5c'27'29'3f'5b'5e'27'5d'2a'29'2a'27 = compileRegex "(?:(?:\\\\')?[^']*)*'" regex_'28'3f'3a'28'3f'3a'5c'5c'22'29'3f'5b'5e'22'5d'2a'29'2a'22 = compileRegex "(?:(?:\\\\\")?[^\"]*)*\"" -defaultAttributes = [("Normal Text","Normal Text"),("isfunction","Function"),("atomquote","Atom"),("stringquote","String"),("comment","Comment")]+defaultAttributes = [("Normal Text",NormalTok),("isfunction",FunctionTok),("atomquote",CharTok),("stringquote",StringTok),("comment",CommentTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'28'3f'3a'2dmodule'7c'2dexport'7c'2ddefine'7c'2dundef'7c'2difdef'7c'2difndef'7c'2delse'7c'2dendif'7c'2dinclude'7c'2dinclude'5flib'29 >>= withAttribute "Pragma"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'28'3f'3a'5c'2b'7c'2d'7c'5c'2a'7c'5c'2f'7c'3d'3d'7c'5c'2f'3d'7c'3d'3a'3d'7c'3d'5c'2f'3d'7c'3c'7c'3d'3c'7c'3e'7c'3e'3d'7c'5c'2b'5c'2b'7c'2d'2d'7c'3d'7c'21'7c'3c'2d'29 >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'28'3f'3a'5c'28'7c'5c'29'7c'5c'7b'7c'5c'7d'7c'5c'5b'7c'5c'5d'7c'5c'2e'7c'5c'3a'7c'5c'7c'7c'5c'7c'5c'7c'7c'3b'7c'5c'2c'7c'5c'3f'7c'2d'3e'7c'5c'23'29 >>= withAttribute "Separator"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29'3a'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute "Function") >>~ (popContext))- <|>- ((lookAhead (pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29'5c'28) >> return ([],"") ) >>~ pushContext "isfunction")- <|>- ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute "Variable") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Atom") >>~ pushContext "atomquote")- <|>- ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute "Atom") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "stringquote")- <|>- ((pRegExpr regex_'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute "Float") >>~ (popContext))- <|>- ((pRegExpr regex_'5cd'2b'23'5ba'2dzA'2dZ0'2d9'5d'2b >>= withAttribute "Number") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'24'5cS >>= withAttribute "Integer") >>~ (popContext))- <|>- ((pRegExpr regex_'5b0'2d9'5d'2b >>= withAttribute "Integer") >>~ (popContext)))- return (attr, result)+parseRules "Normal Text" =+ (((pColumn 0 >> pRegExpr regex_'28'3f'3a'2dmodule'7c'2dexport'7c'2ddefine'7c'2dundef'7c'2difdef'7c'2difndef'7c'2delse'7c'2dendif'7c'2dinclude'7c'2dinclude'5flib'29 >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'3f'3a'5c'2b'7c'2d'7c'5c'2a'7c'5c'2f'7c'3d'3d'7c'5c'2f'3d'7c'3d'3a'3d'7c'3d'5c'2f'3d'7c'3c'7c'3d'3c'7c'3e'7c'3e'3d'7c'5c'2b'5c'2b'7c'2d'2d'7c'3d'7c'21'7c'3c'2d'29 >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'28'3f'3a'5c'28'7c'5c'29'7c'5c'7b'7c'5c'7d'7c'5c'5b'7c'5c'5d'7c'5c'2e'7c'5c'3a'7c'5c'7c'7c'5c'7c'5c'7c'7c'3b'7c'5c'2c'7c'5c'3f'7c'2d'3e'7c'5c'23'29 >>= withAttribute FunctionTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29'3a'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((lookAhead (pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29'5c'28) >> return (NormalTok,"") ) >>~ pushContext "isfunction")+ <|>+ ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ pushContext "atomquote")+ <|>+ ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "stringquote")+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cd'2b'23'5ba'2dzA'2dZ0'2d9'5d'2b >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'24'5cS >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'2b >>= withAttribute DecValTok) >>~ (popContext))) -parseRules "isfunction" = - do (attr, result) <- ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute "Function") >>~ (popContext))- return (attr, result)+parseRules "isfunction" =+ ((pRegExpr regex_'5cb'5ba'2dz'5d'5b'5fa'2dz'40'2dZ0'2d9'5d'2a'28'3f'3a'28'3f'3d'5b'5e'5fa'2dz'40'2dZ0'2d9'5d'29'7c'24'29 >>= withAttribute FunctionTok) >>~ (popContext)) -parseRules "atomquote" = - do (attr, result) <- ((pRegExpr regex_'28'3f'3a'28'3f'3a'5c'5c'27'29'3f'5b'5e'27'5d'2a'29'2a'27 >>= withAttribute "Atom") >>~ (popContext))- return (attr, result)+parseRules "atomquote" =+ ((pRegExpr regex_'28'3f'3a'28'3f'3a'5c'5c'27'29'3f'5b'5e'27'5d'2a'29'2a'27 >>= withAttribute CharTok) >>~ (popContext)) -parseRules "stringquote" = - do (attr, result) <- ((pRegExpr regex_'28'3f'3a'28'3f'3a'5c'5c'22'29'3f'5b'5e'22'5d'2a'29'2a'22 >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "stringquote" =+ ((pRegExpr regex_'28'3f'3a'28'3f'3a'5c'5c'22'29'3f'5b'5e'22'5d'2a'29'2a'22 >>= withAttribute StringTok) >>~ (popContext)) -parseRules "comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Fortran.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file fortran.xml, version 1.12,- by Franchin Matteo (fnch@libero.it) -}+{- This module was generated from data in the Kate syntax+ highlighting file fortran.xml, version 1.12, by Franchin Matteo (fnch@libero.it) -} -module Text.Highlighting.Kate.Syntax.Fortran ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Fortran+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Fortran"@@ -19,73 +22,60 @@ syntaxExtensions = "*.f;*.F;*.for;*.FOR;*.f90;*.F90;*.fpp;*.FPP;*.f95;*.F95;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Fortran" } context <- currentContext <|> (pushContext "default" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Fortran",["default"])], synStLanguage = "Fortran", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Fortran",["default"])], synStLanguage = "Fortran", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "default" -> return () >> pHandleEndLine- "find_preprocessor" -> return () >> pHandleEndLine- "find_op_and_log" -> return () >> pHandleEndLine- "find_comments" -> return () >> pHandleEndLine- "find_symbols" -> return () >> pHandleEndLine- "inside_func_paren" -> return () >> pHandleEndLine- "find_io_stmnts" -> return () >> pHandleEndLine- "find_io_paren" -> return () >> pHandleEndLine- "format_stmnt" -> return () >> pHandleEndLine- "find_begin_stmnts" -> return () >> pHandleEndLine- "find_end_stmnts" -> return () >> pHandleEndLine- "find_mid_stmnts" -> return () >> pHandleEndLine- "find_decls" -> return () >> pHandleEndLine+ "default" -> return ()+ "find_preprocessor" -> return ()+ "find_op_and_log" -> return ()+ "find_comments" -> return ()+ "find_symbols" -> return ()+ "inside_func_paren" -> return ()+ "find_io_stmnts" -> return ()+ "find_io_paren" -> return ()+ "format_stmnt" -> return ()+ "find_begin_stmnts" -> return ()+ "find_end_stmnts" -> return ()+ "find_mid_stmnts" -> return ()+ "find_decls" -> return () "find_paren" -> (popContext) >> pEndLine- "find_intrinsics" -> return () >> pHandleEndLine- "find_numbers" -> return () >> pHandleEndLine- "find_strings" -> return () >> pHandleEndLine- "string_1" -> return () >> pHandleEndLine- "string_2" -> return () >> pHandleEndLine- "end_of_string" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "find_intrinsics" -> return ()+ "find_numbers" -> return ()+ "find_strings" -> return ()+ "string_1" -> return ()+ "string_2" -> return ()+ "end_of_string" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Decimal","dv"),("Float","fl"),("String","st"),("Comment","co"),("Preprocessor","ot"),("Operator","kw"),("Logical","ot"),("IO Function","fu"),("Elemental Procedure","kw"),("Inquiry Function","fu"),("Transformational Function","fu"),("Non elemental subroutine","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "allocate break call case common continue cycle deallocate default forall where elsewhere equivalence exit external for go goto if implicit include interface intrinsic namelist none nullify operator assignment pause procedure pure elemental record recursive result return select selectcase stop to use only entry while" list_io'5ffunctions = Set.fromList $ words $ "access backspace close inquire open print read rewind write format"@@ -143,249 +133,229 @@ regex_'5b'5e'22'5d'2a'22 = compileRegex "[^\"]*\"" regex_'28'21'2e'2a'29'3f'24 = compileRegex "(!.*)?$" -defaultAttributes = [("default","Normal Text"),("find_preprocessor","Normal Text"),("find_op_and_log","Normal Text"),("find_comments","Normal Text"),("find_symbols","Normal Text"),("inside_func_paren","Normal Text"),("find_io_stmnts","Normal Text"),("find_io_paren","Normal Text"),("format_stmnt","Normal Text"),("find_begin_stmnts","Normal Text"),("find_end_stmnts","Normal Text"),("find_mid_stmnts","Normal Text"),("find_decls","Normal Text"),("find_paren","Data Type"),("find_intrinsics","Normal Text"),("find_numbers","Normal Text"),("find_strings","String"),("string_1","String"),("string_2","String"),("end_of_string","String")]+defaultAttributes = [("default",NormalTok),("find_preprocessor",NormalTok),("find_op_and_log",NormalTok),("find_comments",NormalTok),("find_symbols",NormalTok),("inside_func_paren",NormalTok),("find_io_stmnts",NormalTok),("find_io_paren",NormalTok),("format_stmnt",NormalTok),("find_begin_stmnts",NormalTok),("find_end_stmnts",NormalTok),("find_mid_stmnts",NormalTok),("find_decls",NormalTok),("find_paren",DataTypeTok),("find_intrinsics",NormalTok),("find_numbers",NormalTok),("find_strings",StringTok),("string_1",StringTok),("string_2",StringTok),("end_of_string",StringTok)] -parseRules "default" = - do (attr, result) <- (((parseRules "find_strings"))- <|>- ((parseRules "find_decls"))- <|>- ((parseRules "find_intrinsics"))- <|>- ((parseRules "find_io_stmnts"))- <|>- ((parseRules "find_op_and_log"))- <|>- ((parseRules "find_numbers"))- <|>- ((parseRules "find_preprocessor"))- <|>- ((parseRules "find_comments"))- <|>- ((parseRules "find_symbols"))- <|>- ((parseRules "find_begin_stmnts"))- <|>- ((parseRules "find_end_stmnts"))- <|>- ((parseRules "find_mid_stmnts")))- return (attr, result)+parseRules "default" =+ (((parseRules "find_strings"))+ <|>+ ((parseRules "find_decls"))+ <|>+ ((parseRules "find_intrinsics"))+ <|>+ ((parseRules "find_io_stmnts"))+ <|>+ ((parseRules "find_op_and_log"))+ <|>+ ((parseRules "find_numbers"))+ <|>+ ((parseRules "find_preprocessor"))+ <|>+ ((parseRules "find_comments"))+ <|>+ ((parseRules "find_symbols"))+ <|>+ ((parseRules "find_begin_stmnts"))+ <|>+ ((parseRules "find_end_stmnts"))+ <|>+ ((parseRules "find_mid_stmnts"))) -parseRules "find_preprocessor" = - do (attr, result) <- ((pColumn 0 >> pRegExpr regex_'28'23'7ccDEC'5c'24'7cCDEC'5c'24'29'2e'2a'24 >>= withAttribute "Preprocessor"))- return (attr, result)+parseRules "find_preprocessor" =+ ((pColumn 0 >> pRegExpr regex_'28'23'7ccDEC'5c'24'7cCDEC'5c'24'29'2e'2a'24 >>= withAttribute OtherTok)) -parseRules "find_op_and_log" = - do (attr, result) <- (((pRegExpr regex_'5c'2e'28true'7cfalse'29'5c'2e >>= withAttribute "Logical"))- <|>- ((pRegExpr regex_'5c'2e'5bA'2dZa'2dz'5d'2b'5c'2e >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'28'3d'3d'7c'2f'3d'7c'3c'7c'3c'3d'7c'3e'7c'3e'3d'29 >>= withAttribute "Operator")))- return (attr, result)+parseRules "find_op_and_log" =+ (((pRegExpr regex_'5c'2e'28true'7cfalse'29'5c'2e >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'2e'5bA'2dZa'2dz'5d'2b'5c'2e >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'3d'3d'7c'2f'3d'7c'3c'7c'3c'3d'7c'3e'7c'3e'3d'29 >>= withAttribute KeywordTok))) -parseRules "find_comments" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5bcC'5c'2a'5d'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'21'2e'2a'24 >>= withAttribute "Comment")))- return (attr, result)+parseRules "find_comments" =+ (((pColumn 0 >> pRegExpr regex_'5bcC'5c'2a'5d'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'21'2e'2a'24 >>= withAttribute CommentTok))) -parseRules "find_symbols" = - do (attr, result) <- (((pDetect2Chars False '*' '*' >>= withAttribute "Keyword"))- <|>- ((pDetect2Chars False '(' '/' >>= withAttribute "Keyword"))- <|>- ((pDetect2Chars False '/' ')' >>= withAttribute "Keyword"))- <|>- ((pAnyChar "&+-*/=?[]^{|}~" >>= withAttribute "Keyword"))- <|>- ((pAnyChar "()," >>= withAttribute "Symbol")))- return (attr, result)+parseRules "find_symbols" =+ (((pDetect2Chars False '*' '*' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '(' '/' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '/' ')' >>= withAttribute KeywordTok))+ <|>+ ((pAnyChar "&+-*/=?[]^{|}~" >>= withAttribute KeywordTok))+ <|>+ ((pAnyChar "()," >>= withAttribute NormalTok))) -parseRules "inside_func_paren" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "inside_func_paren")- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((parseRules "find_strings"))- <|>- ((parseRules "find_intrinsics"))- <|>- ((parseRules "find_numbers")))- return (attr, result)+parseRules "inside_func_paren" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "inside_func_paren")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "find_strings"))+ <|>+ ((parseRules "find_intrinsics"))+ <|>+ ((parseRules "find_numbers"))) -parseRules "find_io_stmnts" = - do (attr, result) <- (((pRegExpr regex_'5cb'28read'7cwrite'7cbackspace'7crewind'7cend'5cs'2afile'7cclose'29'5cs'2a'5b'28'5d >>= withAttribute "IO Function") >>~ pushContext "find_io_paren")- <|>- ((pRegExpr regex_'5cbopen'5cs'2a'5b'28'5d >>= withAttribute "IO Function") >>~ pushContext "find_io_paren")- <|>- ((pRegExpr regex_'5cbinquire'5cs'2a'5b'28'5d >>= withAttribute "IO Function") >>~ pushContext "find_io_paren")- <|>- ((pRegExpr regex_'5cbformat'5cs'2a'5b'28'5d >>= withAttribute "IO Function") >>~ pushContext "format_stmnt")- <|>- ((pRegExpr regex_'5cbend'5cs'2afile'5cb >>= withAttribute "IO Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_io'5ffunctions >>= withAttribute "IO Function")))- return (attr, result)+parseRules "find_io_stmnts" =+ (((pRegExpr regex_'5cb'28read'7cwrite'7cbackspace'7crewind'7cend'5cs'2afile'7cclose'29'5cs'2a'5b'28'5d >>= withAttribute FunctionTok) >>~ pushContext "find_io_paren")+ <|>+ ((pRegExpr regex_'5cbopen'5cs'2a'5b'28'5d >>= withAttribute FunctionTok) >>~ pushContext "find_io_paren")+ <|>+ ((pRegExpr regex_'5cbinquire'5cs'2a'5b'28'5d >>= withAttribute FunctionTok) >>~ pushContext "find_io_paren")+ <|>+ ((pRegExpr regex_'5cbformat'5cs'2a'5b'28'5d >>= withAttribute FunctionTok) >>~ pushContext "format_stmnt")+ <|>+ ((pRegExpr regex_'5cbend'5cs'2afile'5cb >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_io'5ffunctions >>= withAttribute FunctionTok))) -parseRules "find_io_paren" = - do (attr, result) <- (((pDetectChar False '*' >>= withAttribute "IO Function"))- <|>- ((pDetectChar False '(' >>= withAttribute "Normal Text") >>~ pushContext "inside_func_paren")- <|>- ((pDetectChar False ')' >>= withAttribute "IO Function") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_io'5fkeywords >>= withAttribute "IO Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_inquire'5fkeywords >>= withAttribute "IO Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_open'5fkeywords >>= withAttribute "IO Function"))- <|>- ((parseRules "find_strings"))- <|>- ((parseRules "find_intrinsics"))- <|>- ((parseRules "find_numbers"))- <|>- ((parseRules "find_symbols")))- return (attr, result)+parseRules "find_io_paren" =+ (((pDetectChar False '*' >>= withAttribute FunctionTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "inside_func_paren")+ <|>+ ((pDetectChar False ')' >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_io'5fkeywords >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_inquire'5fkeywords >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_open'5fkeywords >>= withAttribute FunctionTok))+ <|>+ ((parseRules "find_strings"))+ <|>+ ((parseRules "find_intrinsics"))+ <|>+ ((parseRules "find_numbers"))+ <|>+ ((parseRules "find_symbols"))) -parseRules "format_stmnt" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "IO Function") >>~ pushContext "format_stmnt")- <|>- ((pDetectChar False ')' >>= withAttribute "IO Function") >>~ (popContext))- <|>- ((pRegExpr regex_'5b0'2d9'5d'2a'2f >>= withAttribute "IO Function"))- <|>- ((pAnyChar ":" >>= withAttribute "IO Function"))- <|>- ((parseRules "find_strings"))- <|>- ((parseRules "find_symbols")))- return (attr, result)+parseRules "format_stmnt" =+ (((pDetectChar False '(' >>= withAttribute FunctionTok) >>~ pushContext "format_stmnt")+ <|>+ ((pDetectChar False ')' >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b0'2d9'5d'2a'2f >>= withAttribute FunctionTok))+ <|>+ ((pAnyChar ":" >>= withAttribute FunctionTok))+ <|>+ ((parseRules "find_strings"))+ <|>+ ((parseRules "find_symbols"))) -parseRules "find_begin_stmnts" = - do (attr, result) <- (((pRegExpr regex_'5cbmodule'5cs'2bprocedure'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28subroutine'7cfunction'7cblock'5cs'2adata'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28program'7cmodule'7cblock'5cs'2adata'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28then'7cdo'29'5cb >>= withAttribute "Keyword")))- return (attr, result)+parseRules "find_begin_stmnts" =+ (((pRegExpr regex_'5cbmodule'5cs'2bprocedure'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28subroutine'7cfunction'7cblock'5cs'2adata'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28program'7cmodule'7cblock'5cs'2adata'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28then'7cdo'29'5cb >>= withAttribute KeywordTok))) -parseRules "find_end_stmnts" = - do (attr, result) <- (((pRegExpr regex_'5cbend'5cs'2a'28subroutine'7cfunction'7cblock'5cs'2adata'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2a'28program'7cmodule'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2a'28do'7cif'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cs'2a'28select'7cwhere'7cforall'7cinterface'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbelse'5cs'2aif'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cb >>= withAttribute "Keyword")))- return (attr, result)+parseRules "find_end_stmnts" =+ (((pRegExpr regex_'5cbend'5cs'2a'28subroutine'7cfunction'7cblock'5cs'2adata'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2a'28program'7cmodule'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2a'28do'7cif'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2a'28select'7cwhere'7cforall'7cinterface'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbelse'5cs'2aif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cb >>= withAttribute KeywordTok))) -parseRules "find_mid_stmnts" = - do (attr, result) <- (((pRegExpr regex_'5cbelse'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbcontains'5cb >>= withAttribute "Keyword")))- return (attr, result)+parseRules "find_mid_stmnts" =+ (((pRegExpr regex_'5cbelse'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbcontains'5cb >>= withAttribute KeywordTok))) -parseRules "find_decls" = - do (attr, result) <- (((pRegExpr regex_'5cbinteger'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbreal'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbcomplex'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbend'5cs'2atype'5cb >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2adata'5cb >>= withAttribute "Data Type"))- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2areal'5cs'2a'5b'28'5d >>= withAttribute "Data Type") >>~ pushContext "find_paren")- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2areal'28'3f'21'5b'5cw'5c'2a'5d'29 >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbcharacter'5b'2a'5d'5b0'2d9'5d'2b'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cb'28type'7cinteger'7ccomplex'7ccharacter'7clogical'7cintent'7cdimension'29'5cb'5cs'2a'5b'28'5d >>= withAttribute "Data Type") >>~ pushContext "find_paren")- <|>- ((pRegExpr regex_'5cb'28type'7cinteger'7ccomplex'7ccharacter'7clogical'7cintent'7cdimension'29'5cb >>= withAttribute "Data Type"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Data Type")))- return (attr, result)+parseRules "find_decls" =+ (((pRegExpr regex_'5cbinteger'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbreal'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbcomplex'5b'5c'2a'5d'5cd'7b1'2c2'7d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbend'5cs'2atype'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2adata'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2areal'5cs'2a'5b'28'5d >>= withAttribute DataTypeTok) >>~ pushContext "find_paren")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2areal'28'3f'21'5b'5cw'5c'2a'5d'29 >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbcharacter'5b'2a'5d'5b0'2d9'5d'2b'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cb'28type'7cinteger'7ccomplex'7ccharacter'7clogical'7cintent'7cdimension'29'5cb'5cs'2a'5b'28'5d >>= withAttribute DataTypeTok) >>~ pushContext "find_paren")+ <|>+ ((pRegExpr regex_'5cb'28type'7cinteger'7ccomplex'7ccharacter'7clogical'7cintent'7cdimension'29'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute DataTypeTok))) -parseRules "find_paren" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Data Type") >>~ pushContext "find_paren")- <|>- ((pDetectChar False ')' >>= withAttribute "Data Type") >>~ (popContext)))- return (attr, result)+parseRules "find_paren" =+ (((pDetectChar False '(' >>= withAttribute DataTypeTok) >>~ pushContext "find_paren")+ <|>+ ((pDetectChar False ')' >>= withAttribute DataTypeTok) >>~ (popContext))) -parseRules "find_intrinsics" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_elemental'5fprocs >>= withAttribute "Elemental Procedure"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_inquiry'5ffn >>= withAttribute "Inquiry Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_transform'5ffn >>= withAttribute "Transformational Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_non'5felem'5fsubr >>= withAttribute "Non elemental subroutine")))- return (attr, result)+parseRules "find_intrinsics" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_elemental'5fprocs >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_inquiry'5ffn >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_transform'5ffn >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_non'5felem'5fsubr >>= withAttribute KeywordTok))) -parseRules "find_numbers" = - do (attr, result) <- (((pRegExpr regex_'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'28'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2a'28'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f'28'3f'21'5ba'2dz'5d'29 >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dzA'2dZ'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5cb'5bbozx'5d'28'5b'27'5d'5b0'2d9a'2df'5d'2b'5b'27'5d'7c'5b'22'5d'5b0'2d9a'2df'5d'2b'5b'22'5d'29 >>= withAttribute "Decimal")))- return (attr, result)+parseRules "find_numbers" =+ (((pRegExpr regex_'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'28'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'5c'2e'5b0'2d9'5d'2a'28'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f'28'3f'21'5ba'2dz'5d'29 >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'5bde'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dz'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'5b0'2d9'5d'2b'28'5b'5f'5d'28'5b0'2d9'5d'2b'7c'5ba'2dzA'2dZ'5d'5b'5cw'5f'5d'2a'29'29'3f >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'5bbozx'5d'28'5b'27'5d'5b0'2d9a'2df'5d'2b'5b'27'5d'7c'5b'22'5d'5b0'2d9a'2df'5d'2b'5b'22'5d'29 >>= withAttribute DecValTok))) -parseRules "find_strings" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "string_1")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string_2"))- return (attr, result)+parseRules "find_strings" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "string_1")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string_2")) -parseRules "string_1" = - do (attr, result) <- (((pRegExpr regex_'5b'5e'27'5d'2a'27 >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute "Keyword") >>~ pushContext "end_of_string")- <|>- ((pRegExpr regex_'2e'2a'28'3f'3d'26'5cs'2a'24'29 >>= withAttribute "String") >>~ pushContext "end_of_string")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "string_1" =+ (((pRegExpr regex_'5b'5e'27'5d'2a'27 >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute KeywordTok) >>~ pushContext "end_of_string")+ <|>+ ((pRegExpr regex_'2e'2a'28'3f'3d'26'5cs'2a'24'29 >>= withAttribute StringTok) >>~ pushContext "end_of_string")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "string_2" = - do (attr, result) <- (((pRegExpr regex_'5b'5e'22'5d'2a'22 >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute "Keyword") >>~ pushContext "end_of_string")- <|>- ((pRegExpr regex_'2e'2a'28'3f'3d'26'5cs'2a'24'29 >>= withAttribute "String") >>~ pushContext "end_of_string")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "string_2" =+ (((pRegExpr regex_'5b'5e'22'5d'2a'22 >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute KeywordTok) >>~ pushContext "end_of_string")+ <|>+ ((pRegExpr regex_'2e'2a'28'3f'3d'26'5cs'2a'24'29 >>= withAttribute StringTok) >>~ pushContext "end_of_string")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "end_of_string" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "String"))- <|>- ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pDetectChar False '&' >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28'21'2e'2a'29'3f'24 >>= withAttribute "Comment"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)+parseRules "end_of_string" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'26'5cs'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pDetectChar False '&' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28'21'2e'2a'29'3f'24 >>= withAttribute CommentTok))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules)) parseRules "" = parseRules "default"
Text/Highlighting/Kate/Syntax/Fsharp.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file fsharp.xml, version 0.0.1,- by Bas Bossink (bas.bossink@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file fsharp.xml, version 0.0.1, by Bas Bossink (bas.bossink@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Fsharp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Fsharp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "FSharp"@@ -19,64 +22,51 @@ syntaxExtensions = "*.fs;*.fsi;*.fsx" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "FSharp" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("FSharp",["Normal"])], synStLanguage = "FSharp", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("FSharp",["Normal"])], synStLanguage = "FSharp", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "Singleline Comment" -> (popContext) >> pEndLine- "Multiline Comment" -> return () >> pHandleEndLine- "String Constant" -> return () >> pHandleEndLine- "Block" -> return () >> pHandleEndLine- "Sig" -> return () >> pHandleEndLine- "Struct" -> return () >> pHandleEndLine- "Object" -> return () >> pHandleEndLine- "ModuleEnv" -> return () >> pHandleEndLine- "ModuleEnv2" -> return () >> pHandleEndLine- "Camlp4 Quotation Constant" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Multiline Comment" -> return ()+ "String Constant" -> return ()+ "Block" -> return ()+ "Sig" -> return ()+ "Struct" -> return ()+ "Object" -> return ()+ "ModuleEnv" -> return ()+ "ModuleEnv2" -> return ()+ "Camlp4 Quotation Constant" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Core Data Type","dt"),("Decimal","dv"),("Hexadecimal","bn"),("Octal","bn"),("Binary","bn"),("Float","fl"),("Character","ch"),("String","st"),("Escaped characters","ch"),("Comment","co"),("Camlp4 Quotation","st"),("Directive","ot"),("Region Marker","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "abstract and as assert base class delegate dowcast downto elif else exception extern false for fun function functor global if in inherit inline interfaece internal lazy let match member mutable namespace new not null of or override private public rec ref return static then to true try type upcast use val void when while with yield" list_core_types = Set.fromList $ words $ "bool byte sbyte int16 uint16 int uint32 int64 uint64 nativeint unativeint char string decimal unit void float32 single float double bigint option seq"@@ -107,150 +97,140 @@ regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 = compileRegex "\\\\(\\\\|>>|<<)" regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c = compileRegex "\\\\<:[A-Za-z\\0300-\\0326\\0330-\\0366\\0370-\\0377_][A-Za-z\\0300-\\0326\\0330-\\0366\\0370-\\03770-9_']*<" -defaultAttributes = [("Normal","Normal Text"),("Singleline Comment","Comment"),("Multiline Comment","Comment"),("String Constant","String"),("Block","Normal text"),("Sig","Normal text"),("Struct","Normal text"),("Object","Normal text"),("ModuleEnv","Normal text"),("ModuleEnv2","Normal text"),("Camlp4 Quotation Constant","Camlp4 Quotation")]+defaultAttributes = [("Normal",NormalTok),("Singleline Comment",CommentTok),("Multiline Comment",CommentTok),("String Constant",StringTok),("Block",NormalTok),("Sig",NormalTok),("Struct",NormalTok),("Object",NormalTok),("ModuleEnv",NormalTok),("ModuleEnv2",NormalTok),("Camlp4 Quotation Constant",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Multiline Comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Normal Text") >>~ pushContext "Singleline Comment")- <|>- ((pDetectChar False '(' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False ')' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '[' '<' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '>' ']' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '[' '|' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '|' ']' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '[' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False ']' >>= withAttribute "Symbol"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_do >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_done >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_module'5fenvironment >>= withAttribute "Directive") >>~ pushContext "ModuleEnv")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_begin >>= withAttribute "Region Marker") >>~ pushContext "Block")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_object >>= withAttribute "Region Marker") >>~ pushContext "Object")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_sig >>= withAttribute "Region Marker") >>~ pushContext "Sig")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_struct >>= withAttribute "Region Marker") >>~ pushContext "Struct")- <|>- ((pRegExpr regex_'60'5cs'2a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Constructor"))- <|>- ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return ([],"") ) >>~ pushContext "ModuleEnv2")- <|>- ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Constructor"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'2e'2a'24 >>= withAttribute "Directive"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String Constant")- <|>- ((pRegExpr regex_'27'28'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29'7c'5b'5e'27'5d'29'27 >>= withAttribute "Character"))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_core_types >>= withAttribute "Core Data Type"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'2d'3f0'5bxX'5d'5b0'2d9A'2dFa'2df'5f'5d'2b >>= withAttribute "Hexadecimal"))- <|>- ((pRegExpr regex_'2d'3f0'5boO'5d'5b0'2d7'5f'5d'2b >>= withAttribute "Octal"))- <|>- ((pRegExpr regex_'2d'3f0'5bbB'5d'5b01'5f'5d'2b >>= withAttribute "Binary"))- <|>- ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'28'5c'2e'28'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'29'7c'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'29 >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a >>= withAttribute "Decimal")))- return (attr, result)+parseRules "Normal" =+ (((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute NormalTok) >>~ pushContext "Singleline Comment")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '[' '<' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '>' ']' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '[' '|' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '|' ']' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_do >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_done >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_module'5fenvironment >>= withAttribute OtherTok) >>~ pushContext "ModuleEnv")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_begin >>= withAttribute KeywordTok) >>~ pushContext "Block")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_object >>= withAttribute KeywordTok) >>~ pushContext "Object")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_sig >>= withAttribute KeywordTok) >>~ pushContext "Sig")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_struct >>= withAttribute KeywordTok) >>~ pushContext "Struct")+ <|>+ ((pRegExpr regex_'60'5cs'2a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return (NormalTok,"") ) >>~ pushContext "ModuleEnv2")+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'2e'2a'24 >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String Constant")+ <|>+ ((pRegExpr regex_'27'28'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29'7c'5b'5e'27'5d'29'27 >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_core_types >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5bxX'5d'5b0'2d9A'2dFa'2df'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5boO'5d'5b0'2d7'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5bbB'5d'5b01'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'28'5c'2e'28'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'29'7c'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'29 >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a >>= withAttribute DecValTok))) -parseRules "Singleline Comment" = +parseRules "Singleline Comment" = pzero -parseRules "Multiline Comment" = - do (attr, result) <- (((pDetect2Chars False '*' ')' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Multiline Comment"))- return (attr, result)+parseRules "Multiline Comment" =+ (((pDetect2Chars False '*' ')' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")) -parseRules "String Constant" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29 >>= withAttribute "Escaped characters"))- <|>- ((pRegExpr regex_'5c'5c'24 >>= withAttribute "Escaped characters")))- return (attr, result)+parseRules "String Constant" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'24 >>= withAttribute CharTok))) -parseRules "Block" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Block" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Sig" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Sig" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Struct" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Struct" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Object" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Object" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "ModuleEnv" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal text"))- <|>- ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return ([],"") ) >>~ pushContext "ModuleEnv2")- <|>- ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Module") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "ModuleEnv" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return (NormalTok,"") ) >>~ pushContext "ModuleEnv2")+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "ModuleEnv2" = - do (attr, result) <- (((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Module"))- <|>- ((pDetectSpaces >>= withAttribute "Normal text"))- <|>- ((pString False "." >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)+parseRules "ModuleEnv2" =+ (((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "." >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Camlp4 Quotation Constant" = - do (attr, result) <- (((pDetect2Chars False '>' '>' >>= withAttribute "Camlp4 Quotation") >>~ (popContext))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 >>= withAttribute "Escaped characters"))- <|>- ((pRegExpr regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Escaped characters")))- return (attr, result)+parseRules "Camlp4 Quotation Constant" =+ (((pDetect2Chars False '>' '>' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute CharTok))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Gnuassembler.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file gnuassembler.xml, version 1.10,- by John Zaitseff (J.Zaitseff@zap.org.au), Roland Pabel (roland@pabel.name), Miquel Sabaté (mikisabate@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file gnuassembler.xml, version 1.10, by John Zaitseff (J.Zaitseff@zap.org.au), Roland Pabel (roland@pabel.name), Miquel Sabaté (mikisabate@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Gnuassembler ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Gnuassembler+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "GNU Assembler"@@ -20,60 +23,47 @@ syntaxExtensions = "*.s;*.S" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "GNU Assembler" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("GNU Assembler",["Normal"])], synStLanguage = "GNU Assembler", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("GNU Assembler",["Normal"])], synStLanguage = "GNU Assembler", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Commentar 1" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "Commentar 1" -> return () "Commentar 2" -> (popContext) >> pEndLine "String" -> (popContext) >> pEndLine "Preprocessor" -> (popContext) >> pEndLine "Define" -> (popContext) >> pEndLine "Some Context" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Label","kw"),("Keyword","kw"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Binary","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ ".abort .align .app-file .appline .ascii .asciz .att_syntax .balign .balignl .balignw .byte .code16 .code32 .comm .common.s .common .data .dc.b .dc.d .dc.l .dc.s .dc.w .dc.x .dc .dcb.b .dcb.d .dcb.l .dcb.s .dcb.w .dcb.x .dcb .debug .def .desc .dim .double .ds.b .ds.d .ds.l .ds.p .ds.s .ds.w .ds.x .ds .dsect .eject .else .elsec .elseif .end .endc .endef .endfunc .endif .endm .endr .equ .equiv .err .exitm .extend .extern .fail .file .fill .float .format .func .global .globl .hidden .hword .ident .if .ifc .ifdef .ifeq .ifeqs .ifge .ifgt .ifle .iflt .ifnc .ifndef .ifne .ifnes .ifnotdef .include .int .intel_syntax .internal .irep .irepc .irp .irpc .lcomm .lflags .line .linkonce .list .llen .ln .long .lsym .macro .mexit .name .noformat .nolist .nopage noprefix .octa .offset .org .p2align .p2alignl .p2alignw .page .plen .popsection .previous .print .protected .psize .purgem .pushsection .quad .rodata .rep .rept .rva .sbttl .scl .sect.s .sect .section.s .section .set .short .single .size .skip .sleb128 .space .spc .stabd .stabn .stabs .string .struct .subsection .symver .tag .text .title .ttl .type .uleb128 .use .val .version .vtable_entry .vtable_inherit .weak .word .xcom .xdef .xref .xstabs .zero .arm .bss .code .even .force_thumb .ldouble .loc .ltorg .packed .pool .req .thumb .thumb_func .thumb_set" @@ -87,72 +77,67 @@ regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 = compileRegex "#\\s*define.*((?=\\\\))" regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 = compileRegex "#\\s*(?:el(?:se|if)|include(?:_next)?|define|undef|line|error|warning|pragma)" -defaultAttributes = [("Normal","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment"),("String","String"),("Preprocessor","Preprocessor"),("Define","Preprocessor"),("Some Context","Normal Text")]+defaultAttributes = [("Normal",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("String",StringTok),("Preprocessor",OtherTok),("Define",OtherTok),("Some Context",NormalTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'5b'5f'5cw'5cd'2d'5d'2a'5cs'2a'3a >>= withAttribute "Label"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pRegExpr regex_0'5bbB'5d'5b01'5d'2b >>= withAttribute "Binary"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_0'5bfFeEdD'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'2a'5c'2e'3f'5b0'2d9'5d'2a'5beE'5d'3f'5b'2d'2b'5d'3f'5b0'2d9'5d'2b >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'2e'24'5d'5bA'2dZa'2dz0'2d9'5f'2e'24'5d'2a >>= withAttribute "Normal Text"))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'27'28'5c'5cx'5b0'2d9a'2dfA'2dF'5d'5b0'2d9a'2dfA'2dF'5d'3f'7c'5c'5c'5b0'2d7'5d'3f'5b0'2d7'5d'3f'5b0'2d7'5d'3f'7c'5c'5c'2e'7c'2e'29 >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute "Preprocessor") >>~ pushContext "Define")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pAnyChar "@;#" >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pAnyChar "!#%&*()+,-<=>?/:[]^{|}~" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'5b'5f'5cw'5cd'2d'5d'2a'5cs'2a'3a >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_0'5bbB'5d'5b01'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_0'5bfFeEdD'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'2a'5c'2e'3f'5b0'2d9'5d'2a'5beE'5d'3f'5b'2d'2b'5d'3f'5b0'2d9'5d'2b >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'2e'24'5d'5bA'2dZa'2dz0'2d9'5f'2e'24'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'27'28'5c'5cx'5b0'2d9a'2dfA'2dF'5d'5b0'2d9a'2dfA'2dF'5d'3f'7c'5c'5c'5b0'2d7'5d'3f'5b0'2d7'5d'3f'5b0'2d7'5d'3f'7c'5c'5c'2e'7c'2e'29 >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'28'3f'3adef'7cndef'29'3f'28'3f'3d'5cs'2b'5cS'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2adefine'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute OtherTok) >>~ pushContext "Define")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28'3f'3ael'28'3f'3ase'7cif'29'7cinclude'28'3f'3a'5fnext'29'3f'7cdefine'7cundef'7cline'7cerror'7cwarning'7cpragma'29 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pAnyChar "@;#" >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pAnyChar "!#%&*()+,-<=>?/:[]^{|}~" >>= withAttribute NormalTok))) -parseRules "Commentar 1" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Commentar 1" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Commentar 2" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)+parseRules "Commentar 2" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ pushContext "Some Context")- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ pushContext "Some Context")+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Preprocessor" = +parseRules "Preprocessor" = pzero -parseRules "Define" = - do (attr, result) <- ((pLineContinue >>= withAttribute "Preprocessor"))- return (attr, result)+parseRules "Define" =+ ((pLineContinue >>= withAttribute OtherTok)) -parseRules "Some Context" = +parseRules "Some Context" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Go.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file go.xml, version 1.00,- by Miquel Sabaté (mikisabate@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file go.xml, version 1.00, by Miquel Sabaté (mikisabate@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Go ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Go+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Go"@@ -20,58 +23,45 @@ syntaxExtensions = "*.go" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Go" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Go",["normal"])], synStLanguage = "Go", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Go",["normal"])], synStLanguage = "Go", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine+ "normal" -> return () "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine+ "Commentar 2" -> return () "Package" -> (popContext) >> pEndLine "String" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Special","ot"),("Type","dt"),("Builtin","ot"),("String Char","ch"),("String","st"),("Comment","co"),("Char","ch")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case chan const continue default defer else fallthrough for func go goto if import interface map range return select struct switch type var" list_types = Set.fromList $ words $ "bool byte complex64 complex128 float float32 float64 int int8 int16 int32 int64 string uint uint8 uint16 uint32 uint64"@@ -79,62 +69,58 @@ list_special = Set.fromList $ words $ "false nil true" -defaultAttributes = [("normal","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment"),("Package","Package"),("String","String")]+defaultAttributes = [("normal",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("Package",NormalTok),("String",StringTok)] -parseRules "normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special >>= withAttribute "Special"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtin >>= withAttribute "Builtin"))- <|>- ((pString False "package" >>= withAttribute "Package") >>~ pushContext "Package")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String"))- return (attr, result)+parseRules "normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtin >>= withAttribute OtherTok))+ <|>+ ((pString False "package" >>= withAttribute NormalTok) >>~ pushContext "Package")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")) -parseRules "Commentar 1" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment"))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 1" =+ (((pLineContinue >>= withAttribute CommentTok))+ <|>+ ((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Commentar 2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 2" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Package" = +parseRules "Package" = pzero -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Haskell.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file haskell.xml, version 2.0.3,- by Nicolas Wu (zenzike@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file haskell.xml, version 2.0.4, by Nicolas Wu (zenzike@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Haskell ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Haskell+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Haskell"@@ -19,65 +22,53 @@ syntaxExtensions = "*.hs" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Haskell" } context <- currentContext <|> (pushContext "code" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Haskell",["code"])], synStLanguage = "Haskell", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Haskell",["code"])], synStLanguage = "Haskell", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "code" -> return () >> pHandleEndLine+ "code" -> return () "comment" -> (popContext) >> pEndLine- "comments" -> return () >> pHandleEndLine+ "comments" -> return () "char" -> (popContext) >> pEndLine- "string" -> return () >> pHandleEndLine- "infix" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "string" -> return ()+ "infix" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Pragma","ot"),("Keyword","kw"),("Type Prelude","dt"),("Function Prelude","fu"),("Data Prelude","kw"),("Class Prelude","kw"),("Signature","ot"),("Operator","fu"),("Type","dt"),("Special","ot"),("Decimal","dv"),("Float","fl"),("Char","ch"),("String","st"),("Function Infix","ot"),("EnumFromTo","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "as case class data deriving do else hiding if import in infixl infixr instance let module newtype of primitive qualified then type where" list_prelude_function = Set.fromList $ words $ "FilePath IOError abs acos acosh all and any appendFile approxRational asTypeOf asin asinh atan atan2 atanh basicIORun break catch ceiling chr compare concat concatMap const cos cosh curry cycle decodeFloat denominator digitToInt div divMod drop dropWhile either elem encodeFloat enumFrom enumFromThen enumFromThenTo enumFromTo error even exp exponent fail filter flip floatDigits floatRadix floatRange floor fmap foldl foldl1 foldr foldr1 fromDouble fromEnum fromInt fromInteger fromIntegral fromRational fst gcd getChar getContents getLine group head id inRange index init intToDigit interact ioError isAlpha isAlphaNum isAscii isControl isDenormalized isDigit isHexDigit isIEEE isInfinite isLower isNaN isNegativeZero isOctDigit isPrint isSpace isUpper iterate last lcm length lex lexDigits lexLitChar lines log logBase lookup map mapM mapM_ max maxBound maximum maybe min minBound minimum mod negate not notElem null numerator odd or ord otherwise pack pi pred primExitWith print product properFraction putChar putStr putStrLn quot quotRem range rangeSize read readDec readFile readFloat readHex readIO readInt readList readLitChar readLn readOct readParen readSigned reads readsPrec realToFrac recip rem repeat replicate return reverse round scaleFloat scanl scanl1 scanr scanr1 seq sequence sequence_ show showChar showInt showList showLitChar showParen showSigned showString shows showsPrec significand signum sin sinh snd sort span splitAt sqrt subtract succ sum tail take takeWhile tan tanh threadToIOResult toEnum toInt toInteger toLower toRational toUpper truncate uncurry undefined unlines until unwords unzip unzip3 userError words writeFile zip zip3 zipWith zipWith3" list_prelude_class = Set.fromList $ words $ "Bounded Enum Eq Floating Fractional Functor Integral Ix Monad Num Ord Read Real RealFloat RealFrac Show" list_prelude_type = Set.fromList $ words $ "Bool Char Double Either FilePath Float Int Integer IO IOError Maybe Ordering Ratio Rational ReadS ShowS String ByteString" list_prelude_data = Set.fromList $ words $ "False True Left Right Just Nothing EQ LT GT"+list_class = Set.fromList $ words $ "Applicative Foldable Traversable" regex_'5c'7b'2d'23'2e'2a'23'2d'5c'7d = compileRegex "\\{-#.*#-\\}" regex_'5c'7b'2d'5b'5e'23'5d'3f = compileRegex "\\{-[^#]?"@@ -85,82 +76,79 @@ regex_'28'3a'3a'7c'3d'3e'7c'5c'2d'3e'7c'3c'5c'2d'29 = compileRegex "(::|=>|\\->|<\\-)" regex_'5cs'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 = compileRegex "\\s*[a-z][a-zA-Z0-9_']*\\s*(?=::[^\\-!#\\$%&\\*\\+/<=>\\?\\@\\^\\|~\\.:])" regex_'5cs'2a'28'5c'28'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2a'5c'29'29'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 = compileRegex "\\s*(\\([\\-!#\\$%&\\*\\+/<=>\\?\\@\\^\\|~\\.:]*\\))*\\s*(?=::[^\\-!#\\$%&\\*\\+/<=>\\?\\@\\^\\|~\\.:])"+regex_'5cd'2b'5c'2e'5cd'2b = compileRegex "\\d+\\.\\d+" regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a = compileRegex "([A-Z][a-zA-Z0-9_']*\\.)*[a-z][a-zA-Z0-9_']*" regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d0'5f'27'5d'2a'5c'2e'29'2a'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2b = compileRegex "([A-Z][a-zA-Z0-0_']*\\.)*[\\-!#\\$%&\\*\\+/<=>\\?\\@\\^\\|~\\.:]+" regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a = compileRegex "([A-Z][a-zA-Z0-9_']*\\.)*[A-Z][a-zA-Z0-9_']*"-regex_'5cd'2b'5c'2e'5cd'2b = compileRegex "\\d+\\.\\d+" regex_'5c'5c'2e = compileRegex "\\\\." -defaultAttributes = [("code","Normal"),("comment","Comment"),("comments","Comment"),("char","Char"),("string","String"),("infix","Function Infix")]+defaultAttributes = [("code",NormalTok),("comment",CommentTok),("comments",CommentTok),("char",CharTok),("string",StringTok),("infix",OtherTok)] -parseRules "code" = - do (attr, result) <- (((pRegExpr regex_'5c'7b'2d'23'2e'2a'23'2d'5c'7d >>= withAttribute "Pragma"))- <|>- ((pRegExpr regex_'5c'7b'2d'5b'5e'23'5d'3f >>= withAttribute "Comment") >>~ pushContext "comments")- <|>- ((pRegExpr regex_'2d'2d'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2e'2a'24 >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_function >>= withAttribute "Function Prelude"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_type >>= withAttribute "Type Prelude"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_data >>= withAttribute "Data Prelude"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_class >>= withAttribute "Class Prelude"))- <|>- ((pRegExpr regex_'28'3a'3a'7c'3d'3e'7c'5c'2d'3e'7c'3c'5c'2d'29 >>= withAttribute "Special"))- <|>- ((pAnyChar "\8759\8658\8594\8592\8704\8707" >>= withAttribute "Special"))- <|>- ((pRegExpr regex_'5cs'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 >>= withAttribute "Signature"))- <|>- ((pRegExpr regex_'5cs'2a'28'5c'28'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2a'5c'29'29'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 >>= withAttribute "Signature"))- <|>- ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d0'5f'27'5d'2a'5c'2e'29'2a'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2b >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a >>= withAttribute "Type"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5cd'2b'5c'2e'5cd'2b >>= withAttribute "Float"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Char") >>~ pushContext "char")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '`' >>= withAttribute "Function Infix") >>~ pushContext "infix")- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "EnumFromTo"))- <|>- ((pAnyChar "\8229" >>= withAttribute "EnumFromTo")))- return (attr, result)+parseRules "code" =+ (((pRegExpr regex_'5c'7b'2d'23'2e'2a'23'2d'5c'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'7b'2d'5b'5e'23'5d'3f >>= withAttribute CommentTok) >>~ pushContext "comments")+ <|>+ ((pRegExpr regex_'2d'2d'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2e'2a'24 >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_function >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_type >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_data >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_prelude_class >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_class >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'3a'3a'7c'3d'3e'7c'5c'2d'3e'7c'3c'5c'2d'29 >>= withAttribute OtherTok))+ <|>+ ((pAnyChar "\8759\8658\8594\8592\8704\8707" >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cs'2a'28'5c'28'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2a'5c'29'29'2a'5cs'2a'28'3f'3d'3a'3a'5b'5e'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cd'2b'5c'2e'5cd'2b >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5ba'2dz'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d0'5f'27'5d'2a'5c'2e'29'2a'5b'5c'2d'21'23'5c'24'25'26'5c'2a'5c'2b'2f'3c'3d'3e'5c'3f'5c'40'5c'5e'5c'7c'7e'5c'2e'3a'5d'2b >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'28'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a'5c'2e'29'2a'5bA'2dZ'5d'5ba'2dzA'2dZ0'2d9'5f'27'5d'2a >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ pushContext "char")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '`' >>= withAttribute OtherTok) >>~ pushContext "infix")+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute OtherTok))+ <|>+ ((pAnyChar "\8229" >>= withAttribute OtherTok))) -parseRules "comment" = +parseRules "comment" = pzero -parseRules "comments" = - do (attr, result) <- ((pDetect2Chars False '-' '}' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "comments" =+ ((pDetect2Chars False '-' '}' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "char" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Char") >>~ (popContext)))- return (attr, result)+parseRules "char" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "string" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "string" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "infix" = - do (attr, result) <- ((pDetectChar False '`' >>= withAttribute "Function Infix") >>~ (popContext))- return (attr, result)+parseRules "infix" =+ ((pDetectChar False '`' >>= withAttribute OtherTok) >>~ (popContext)) parseRules "" = parseRules "code"
Text/Highlighting/Kate/Syntax/Haxe.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file haxe.xml, version 0.1,- by Chad Joan -}+{- This module was generated from data in the Kate syntax+ highlighting file haxe.xml, version 0.1, by Chad Joan -} -module Text.Highlighting.Kate.Syntax.Haxe ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Haxe+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Haxe"@@ -19,59 +22,46 @@ syntaxExtensions = "*.hx;*.Hx;*.hX;*.HX;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Haxe" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Haxe",["normal"])], synStLanguage = "Haxe", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Haxe",["normal"])], synStLanguage = "Haxe", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine- "ModuleName" -> return () >> pHandleEndLine- "RawString" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine+ "normal" -> return ()+ "ModuleName" -> return ()+ "RawString" -> return ()+ "String" -> return () "CommentLine" -> (popContext) >> pEndLine- "CommentBlock" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "CommentBlock" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Type","dt"),("Integer","dv"),("Hex","bn"),("Float","fl"),("Module","kw"),("EscapeSequence","st"),("String","st"),("RawString","st"),("Comment","co"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case cast catch class continue default else enum extends false for function if implements in inline interface new null override private public return static super switch this throw trace true try typedef untyped var while" list_modules = Set.fromList $ words $ "package import"@@ -86,76 +76,71 @@ regex_'5b'5e'5cs'5cw'2e'3a'2c'5d = compileRegex "[^\\s\\w.:,]" regex_'5c'5c'28u'5b'5cda'2dfA'2dF'5d'7b4'7d'7cU'5b'5cda'2dfA'2dF'5d'7b8'7d'7c'26'5ba'2dzA'2dZ'5d'5cw'2b'3b'29 = compileRegex "\\\\(u[\\da-fA-F]{4}|U[\\da-fA-F]{8}|&[a-zA-Z]\\w+;)" -defaultAttributes = [("normal","Normal Text"),("ModuleName","Module Name"),("RawString","RawString"),("String","String"),("CommentLine","Comment"),("CommentBlock","Comment")]+defaultAttributes = [("normal",NormalTok),("ModuleName",NormalTok),("RawString",StringTok),("String",StringTok),("CommentLine",CommentTok),("CommentBlock",CommentTok)] -parseRules "normal" = - do (attr, result) <- (((pRegExpr regex_'23if'28'5cs'2b'5cw'2b'29'3f >>= withAttribute "Preprocessor") >>~ (popContext))- <|>- ((pRegExpr regex_'23'28else'7celseif'7cend'7cerror'29 >>= withAttribute "Preprocessor") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_modules >>= withAttribute "Module") >>~ pushContext "ModuleName")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pHlCStringChar >>= withAttribute "EscapeString") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "RawString") >>~ pushContext "RawString")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "CommentLine")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "CommentBlock")- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text"))- <|>- ((pString False "..." >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5b'5cd'5d'5b'5cd'5d'2a'28'5c'2e'28'3f'21'5c'2e'29'5b'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5b'5cd'5d'2b'29'3f'29 >>= withAttribute "Float") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'2e'5b'5cd'5d'5b'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5b'5cd'5d'2b'29'3f >>= withAttribute "Float") >>~ (popContext))- <|>- ((pRegExpr regex_0'5bxX'5d'5b'5cda'2dfA'2dF'5d'2b >>= withAttribute "Hex") >>~ (popContext))- <|>- ((pRegExpr regex_'5cd'2b >>= withAttribute "Integer") >>~ (popContext)))- return (attr, result)+parseRules "normal" =+ (((pRegExpr regex_'23if'28'5cs'2b'5cw'2b'29'3f >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'23'28else'7celseif'7cend'7cerror'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_modules >>= withAttribute KeywordTok) >>~ pushContext "ModuleName")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pHlCStringChar >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "RawString")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "CommentLine")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "CommentBlock")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pString False "..." >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b'5cd'5d'5b'5cd'5d'2a'28'5c'2e'28'3f'21'5c'2e'29'5b'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5b'5cd'5d'2b'29'3f'29 >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'2e'5b'5cd'5d'5b'5cd'5d'2a'28'5beE'5d'5b'2d'2b'5d'3f'5b'5cd'5d'2b'29'3f >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_0'5bxX'5d'5b'5cda'2dfA'2dF'5d'2b >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cd'2b >>= withAttribute DecValTok) >>~ (popContext))) -parseRules "ModuleName" = - do (attr, result) <- (((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "CommentLine")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "CommentBlock")- <|>- ((pRegExpr regex_'5b'5e'5cs'5cw'2e'3a'2c'5d >>= withAttribute "Module Name") >>~ (popContext)))- return (attr, result)+parseRules "ModuleName" =+ (((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "CommentLine")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "CommentBlock")+ <|>+ ((pRegExpr regex_'5b'5e'5cs'5cw'2e'3a'2c'5d >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "RawString" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "RawString") >>~ (popContext))- return (attr, result)+parseRules "RawString" =+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "String" = - do (attr, result) <- (((pDetect2Chars False '\\' '"' >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "EscapeSequence"))- <|>- ((pRegExpr regex_'5c'5c'28u'5b'5cda'2dfA'2dF'5d'7b4'7d'7cU'5b'5cda'2dfA'2dF'5d'7b8'7d'7c'26'5ba'2dzA'2dZ'5d'5cw'2b'3b'29 >>= withAttribute "EscapeSequence")))- return (attr, result)+parseRules "String" =+ (((pDetect2Chars False '\\' '"' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'28u'5b'5cda'2dfA'2dF'5d'7b4'7d'7cU'5b'5cda'2dfA'2dF'5d'7b8'7d'7c'26'5ba'2dzA'2dZ'5d'5cw'2b'3b'29 >>= withAttribute StringTok))) -parseRules "CommentLine" = +parseRules "CommentLine" = pzero -parseRules "CommentBlock" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "CommentBlock" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Html.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file html.xml, version 1.99,- by Wilbert Berendsen (wilbert@kde.nl) -}+{- This module was generated from data in the Kate syntax+ highlighting file html.xml, version 1.99, by Wilbert Berendsen (wilbert@kde.nl) -} -module Text.Highlighting.Kate.Syntax.Html ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Html+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert import qualified Text.Highlighting.Kate.Syntax.Css import qualified Text.Highlighting.Kate.Syntax.Javascript-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -21,80 +24,67 @@ syntaxExtensions = "*.htm;*.html;*.shtml;*.shtm" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "HTML" } context <- currentContext <|> (pushContext "Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("HTML",["Start"])], synStLanguage = "HTML", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("HTML",["Start"])], synStLanguage = "HTML", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Start" -> return () >> pHandleEndLine- "FindHTML" -> return () >> pHandleEndLine- "FindEntityRefs" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "FindAttributes" -> return () >> pHandleEndLine- "FindDTDRules" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "El Open" -> return () >> pHandleEndLine- "El Close" -> return () >> pHandleEndLine- "El Close 2" -> return () >> pHandleEndLine- "El Close 3" -> return () >> pHandleEndLine- "CSS" -> return () >> pHandleEndLine- "CSS content" -> return () >> pHandleEndLine- "JS" -> return () >> pHandleEndLine- "JS content" -> return () >> pHandleEndLine+ "Start" -> return ()+ "FindHTML" -> return ()+ "FindEntityRefs" -> return ()+ "FindPEntityRefs" -> return ()+ "FindAttributes" -> return ()+ "FindDTDRules" -> return ()+ "Comment" -> return ()+ "CDATA" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "El Open" -> return ()+ "El Close" -> return ()+ "El Close 2" -> return ()+ "El Close 3" -> return ()+ "CSS" -> return ()+ "CSS content" -> return ()+ "JS" -> return ()+ "JS content" -> return () "JS comment close" -> (popContext) >> pEndLine- "Value" -> return () >> pHandleEndLine+ "Value" -> return () "Value NQ" -> (popContext >> popContext) >> pEndLine- "Value DQ" -> return () >> pHandleEndLine- "Value SQ" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Value DQ" -> return ()+ "Value SQ" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("Element","kw"),("Attribute","ot"),("Value","st"),("EntityRef","dv"),("PEntityRef","dv"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'3c'21DOCTYPE'5cs'2b = compileRegex "<!DOCTYPE\\s+"@@ -128,251 +118,224 @@ regex_'2f'28'3f'21'3e'29 = compileRegex "/(?!>)" regex_'5b'5e'2f'3e'3c'22'27'5cs'5d = compileRegex "[^/><\"'\\s]" -defaultAttributes = [("Start","Normal Text"),("FindHTML","Normal Text"),("FindEntityRefs","Other Text"),("FindPEntityRefs","Other Text"),("FindAttributes","Other Text"),("FindDTDRules","Other Text"),("Comment","Comment"),("CDATA","Other Text"),("PI","Other Text"),("Doctype","Other Text"),("Doctype Internal Subset","Other Text"),("Doctype Markupdecl","Other Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("El Open","Other Text"),("El Close","Other Text"),("El Close 2","Other Text"),("El Close 3","Other Text"),("CSS","Other Text"),("CSS content","Other Text"),("JS","Other Text"),("JS content","Other Text"),("JS comment close","Comment"),("Value","Other Text"),("Value NQ","Other Text"),("Value DQ","Value"),("Value SQ","Value")]+defaultAttributes = [("Start",NormalTok),("FindHTML",NormalTok),("FindEntityRefs",NormalTok),("FindPEntityRefs",NormalTok),("FindAttributes",NormalTok),("FindDTDRules",NormalTok),("Comment",CommentTok),("CDATA",NormalTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",StringTok),("Doctype Markupdecl SQ",StringTok),("El Open",NormalTok),("El Close",NormalTok),("El Close 2",NormalTok),("El Close 3",NormalTok),("CSS",NormalTok),("CSS content",NormalTok),("JS",NormalTok),("JS content",NormalTok),("JS comment close",CommentTok),("Value",NormalTok),("Value NQ",NormalTok),("Value DQ",StringTok),("Value SQ",StringTok)] -parseRules "Start" = - do (attr, result) <- ((parseRules "FindHTML"))- return (attr, result)+parseRules "Start" =+ ((parseRules "FindHTML")) -parseRules "FindHTML" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pRegExpr regex_'3cstyle'5cb >>= withAttribute "Element") >>~ pushContext "CSS")- <|>- ((pRegExpr regex_'3cscript'5cb >>= withAttribute "Element") >>~ pushContext "JS")- <|>- ((pRegExpr regex_'3cpre'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3cdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3ctable'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3cul'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3col'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3cdl'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2ful'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2fol'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2fdl'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((parseRules "FindDTDRules"))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "FindHTML" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pRegExpr regex_'3cstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "CSS")+ <|>+ ((pRegExpr regex_'3cscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "JS")+ <|>+ ((pRegExpr regex_'3cpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3cdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3ctable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3cul'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3col'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3cdl'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2ful'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2fol'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2fdl'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "FindEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pAnyChar "&<" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&<" >>= withAttribute ErrorTok))) -parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntityRef"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute ErrorTok))) -parseRules "FindAttributes" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pDetectChar False '=' >>= withAttribute "Attribute") >>~ pushContext "Value"))- return (attr, result)+parseRules "FindAttributes" =+ (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value")) -parseRules "FindDTDRules" = - do (attr, result) <- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- return (attr, result)+parseRules "FindDTDRules" =+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl") -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Error")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok))) -parseRules "CDATA" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Other Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Other Text"))- <|>- ((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "EntityRef")))- return (attr, result)+parseRules "CDATA" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)+parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset")) -parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((parseRules "FindDTDRules"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)+parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl SQ")) -parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "El Open" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Open" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close 2" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close 2" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Close 3" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El Close 3" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "CSS" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "CSS content")- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "CSS" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "CSS content")+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "CSS content" = - do (attr, result) <- (((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((Text.Highlighting.Kate.Syntax.Css.parseExpression)))- return (attr, result)+parseRules "CSS content" =+ (((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((Text.Highlighting.Kate.Syntax.Css.parseExpression))) -parseRules "JS" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "JS content")- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "JS" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "JS content")+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "JS content" = - do (attr, result) <- (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute "Comment") >>~ pushContext "JS comment close")- <|>- ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))- return (attr, result)+parseRules "JS content" =+ (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute CommentTok) >>~ pushContext "JS comment close")+ <|>+ ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression))) -parseRules "JS comment close" = - do (attr, result) <- (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 3")- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "JS comment close" =+ (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 3")+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Value DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Value SQ")- <|>- ((pDetectSpaces >>= withAttribute "Other Text"))- <|>- (pushContext "Value NQ" >> return ([], "")))- return (attr, result)+parseRules "Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Value DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Value SQ")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ (pushContext "Value NQ" >> currentContext >>= parseRules)) -parseRules "Value NQ" = - do (attr, result) <- (((parseRules "FindEntityRefs"))- <|>- ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute "Value"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)+parseRules "Value NQ" =+ (((parseRules "FindEntityRefs"))+ <|>+ ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute StringTok))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules)) -parseRules "Value DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "Value SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) parseRules "" = parseRules "Start"
− Text/Highlighting/Kate/Syntax/Ilerpg.hs
@@ -1,565 +0,0 @@-{- This module was generated from data in the Kate syntax highlighting file ilerpg.xml, version 1.05,- by -}--module Text.Highlighting.Kate.Syntax.Ilerpg ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions-import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "ILERPG"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "QRPG*.*;qrpg*.*"---- | 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 = "ILERPG" }- context <- currentContext <|> (pushContext "Default" >> 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 [("ILERPG",["Default"])], synStLanguage = "ILERPG", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Default" -> return () >> pHandleEndLine- "CControlLevel" -> (popContext) >> pEndLine- "CIndicators" -> (popContext >> popContext) >> pEndLine- "CFactor1" -> (popContext >> popContext >> popContext) >> pEndLine- "FindOC" -> (popContext >> popContext >> popContext >> popContext) >> pEndLine- "NonEvalOC2" -> pushContext "Default" >> pHandleEndLine- "NonEvalOC3" -> pushContext "Default" >> pHandleEndLine- "NonEvalOC4" -> pushContext "Default" >> pHandleEndLine- "NonEvalOC5" -> pushContext "Default" >> pHandleEndLine- "NonEvalOC6" -> pushContext "Default" >> pHandleEndLine- "NonEvalOC7" -> pushContext "Default" >> pHandleEndLine- "CFactor2" -> pushContext "Default" >> pHandleEndLine- "EvalOC2" -> pushContext "Default" >> pHandleEndLine- "EvalOC3" -> pushContext "Default" >> pHandleEndLine- "EvalOC4" -> pushContext "Default" >> pHandleEndLine- "EvalOC5" -> pushContext "Default" >> pHandleEndLine- "EvalOC6" -> pushContext "Default" >> pHandleEndLine- "EvalOC8" -> pushContext "Default" >> pHandleEndLine- "CExFactor2" -> pushContext "Default" >> pHandleEndLine- "EvalOCCont" -> return () >> pHandleEndLine- "Comments" -> (popContext) >> pEndLine- "StringConstants" -> (popContext) >> pEndLine- "Directives" -> pushContext "Default" >> pHandleEndLine- "Directives2" -> pushContext "Default" >> pHandleEndLine- "Directives3" -> pushContext "Default" >> pHandleEndLine- "Free" -> return () >> pHandleEndLine- "Exec" -> return () >> pHandleEndLine- "Biffs" -> (popContext) >> pEndLine- "CommonCode" -> return () >> pHandleEndLine- "Indicators" -> return () >> pHandleEndLine- "ReservedWords" -> return () >> pHandleEndLine- "AnyCode" -> (popContext) >> pEndLine- "D" -> (popContext) >> pEndLine- "P" -> (popContext) >> pEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Alert","al"),("Keyword","kw"),("Biff","kw"),("RegExpr","bn"),("Decimal","dv"),("Float","fl"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Base-N","bn"),("Float","fl"),("Char","ch"),("Comment","co"),("DivideComment","co"),("Directive","ot")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_dkeywords = Set.fromList $ words $ "extproc extpgm opdesc datfmt dim likeds likerec like procptr timfmt varying ascend const noopt options value qualified inz based"-list_pkeywords = Set.fromList $ words $ "datfmt dim like likeds likerec procptr timfmt"-list_directives = Set.fromList $ words $ "free end-free title eject space copy include define undefine if else exec end-exec elseif endif eof"-list_directives2 = Set.fromList $ words $ "not defined"-list_directives3 = Set.fromList $ words $ "defined"-list_biffs = Set.fromList $ words $ "abs addr alloc bitand bitnot bitor bitxor char check checkr date days dec dech decpos diff div editc editflt editw elem eof equal error fields float found graph hours int inth kds len lookup lookuplt lookuple lookupgt lookupge minutes months mseconds nullind occur open paddr parms realloc rem replace scan seconds shtdn size sqrt status str subarr subdt subst this time timestamp tlookup tlookuplt tlookuple tlookupgt tlookupge trim triml trimr ucs2 uns unsh xfoot xlate years"-list_evalopcodes2 = Set.fromList $ words $ "if"-list_evalopcodes3 = Set.fromList $ words $ "dow dou for"-list_evalopcodes4 = Set.fromList $ words $ "when eval"-list_evalopcodes5 = Set.fromList $ words $ "evalr"-list_evalopcodes6 = Set.fromList $ words $ "return"-list_evalopcodes8 = Set.fromList $ words $ "on-error"-list_nonevalopcodes2 = Set.fromList $ words $ "do in or"-list_nonevalopcodes3 = Set.fromList $ words $ "acq add and cab cas cat div dou end mvr out rel sub tag"-list_nonevalopcodes4 = Set.fromList $ words $ "call comp dump else exsr feod goto ifgt iflt ifeq ifne ifge ifle iter kfld move mult next open orgt orlt oreq orne orge orle parm post read scan sqrt test time"-list_nonevalopcodes5 = Set.fromList $ words $ "alloc andgt andlt andeq andne andge andle begsr biton cabgt cablt cabeq cabne cabge cable callb callp casgt caslt caseq casne casge casle chain check clear close check clear close dowgt dowlt doweq downe dowge dowle dougt doult doueq doune douge doule dsply endcs enddo endif endsl endsr exfmt force klist leave mhhzo mhlzo mlhzo mllzo movea movel occur other plist readc reade readp reset rolbk setgt setll seton shtdn sorta subst testb testn testz write xfoot xlate"-list_nonevalopcodes6 = Set.fromList $ words $ "adddur bitoff checkr commit define delete except extrct lookup readpe return select setoff subdur unlock update whengt whenlt wheneq whennr whenge whenle"-list_nonevalopcodes7 = Set.fromList $ words $ "dealloc realloc"-list_freeopcodes = Set.fromList $ words $ "acq begsr callp chain clear close commit dealloc delete dou dow dsply dump else elseif enddo endfor endif endmon endsl endsr eval evalr except exfmt exsr feod for force if in iter leave leavesr monitor next on-error open other out post read readc reade readp readpe rel reset return rolbk select setgt setll sorta test unlock update when write"--regex_'5bPpOoIiHhFfDdCc_'5d'3f'5c'2a = compileRegex "[PpOoIiHhFfDdCc ]?\\*"-regex_'5bPpOoIiHhFfDdCc_'5d'3f'2f = compileRegex "[PpOoIiHhFfDdCc ]?/"-regex_'5c_'7b2'7d = compileRegex "\\ {2}"-regex_'5bL'7cl'5d'5b0'2d9'5d = compileRegex "[L|l][0-9]"-regex_'5bO'7co'7cL'7cl'7cS'7cs'5d'5bR'7cr'5d = compileRegex "[O|o|L|l|S|s][R|r]"-regex_'5bA'7ca'5d'5bN'7cn'5d = compileRegex "[A|a][N|n]"-regex_'5bL'7cl'7cS'7cs'5d'5bR'7cr'5d = compileRegex "[L|l|S|s][R|r]"-regex_'2e'7b2'7d = compileRegex ".{2}"-regex_'5c_'7b3'7d = compileRegex "\\ {3}"-regex_'5b'5c_'7cN'7cn'5d'5b0'2d9'5d'7b2'7d = compileRegex "[\\ |N|n][0-9]{2}"-regex_'5b'5c_'7cN'7cn'5d'5bK'7ck'5d'5bA'2dN'7cp'2dy'5d = compileRegex "[\\ |N|n][K|k][A-N|p-y]"-regex_'5b'5c_'7cN'7cn'5d'5bK'7ck'5d'5bP'2dY'7cp'2dy'5d'7d = compileRegex "[\\ |N|n][K|k][P-Y|p-y]}"-regex_'5b'5c_'7cN'7cn'5d'5bL'7cl'5d'5b1'2d9'5d = compileRegex "[\\ |N|n][L|l][1-9]"-regex_'5b'5c_'7cN'7cn'5d'5bL'7cl'7cM'7cm'5d'5bR'7cr'5d = compileRegex "[\\ |N|n][L|l|M|m][R|r]"-regex_'5b'5c_'7cN'7cn'5d'5bR'7cr'5d'5bT'7ct'5d = compileRegex "[\\ |N|n][R|r][T|t]"-regex_'5b'5c_'7cN'7cn'5d'5bU'7cu'5d'5b1'2d8'5d = compileRegex "[\\ |N|n][U|u][1-8]"-regex_'5b'5c_'7cN'7cn'5d'5bO'7co'5d'5bA'2dG'7ca'2dg'5d = compileRegex "[\\ |N|n][O|o][A-G|a-g]"-regex_'5b'5c_'7cN'7cn'5d'5bO'7co'5d'5bV'7cv'5d = compileRegex "[\\ |N|n][O|o][V|v]"-regex_'5b'5c_'7cN'7cn'5d'5bH'7ch'5d'5b1'2d9'5d = compileRegex "[\\ |N|n][H|h][1-9]"-regex_'2e'7b3'7d = compileRegex ".{3}"-regex_'2e'7b14'7d = compileRegex ".{14}"-regex_'5bZ'7cz'5d'2d'28'5bA'7ca'5d'5bD'7cd'5d'7b2'7d'7c'5bS'7cs'5d'5bU'7cu'5d'5bB'7cb'5d'29 = compileRegex "[Z|z]-([A|a][D|d]{2}|[S|s][U|u][B|b])"-regex_'5bO'7co'5d'5bN'7cn'5d'2d'28'5bE'7ce'5d'5bR'7cr'5d'7b2'7d'7c'5bO'7co'5d'5bR'7cr'5d'29 = compileRegex "[O|o][N|n]-([E|e][R|r]{2}|[O|o][R|r])"-regex_'5c_'7b10'7d = compileRegex "\\ {10}"-regex_'2e'7b10'7d = compileRegex ".{10}"-regex_'5c_'7b8'7d = compileRegex "\\ {8}"-regex_'5c_'7b7'7d = compileRegex "\\ {7}"-regex_'5c_'7b6'7d = compileRegex "\\ {6}"-regex_'5c_'7b5'7d = compileRegex "\\ {5}"-regex_'5c_'7b4'7d = compileRegex "\\ {4}"-regex_'5c'28'2a'28FIXME'7cTODO'29'5c'29'2a = compileRegex "\\(*(FIXME|TODO)\\)*"-regex_'5c'28'2a'28NOTE'3a'29'5c'29'2a = compileRegex "\\(*(NOTE:)\\)*"-regex_'2d'7c'3d = compileRegex "-|="-regex_'5bF'7cf'5d'5bR'7cr'5d'5bE'7ce'5d'5bE'7ce'5d = compileRegex "[F|f][R|r][E|e][E|e]"-regex_'5bE'7ce'5d'5bX'7cx'5d'5bE'7ce'5d'5bC'7cc'5d = compileRegex "[E|e][X|x][E|e][C|c]"-regex_'5bPOIHFDC_'5d'3f'2f'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'2d'5bF'7cf'5d'5bR'7cr'5d'5bE'7ce'5d'5bE'7ce'5d = compileRegex "[POIHFDC ]?/[E|e][N|n][D|d]-[F|f][R|r][E|e][E|e]"-regex_'2f'2f = compileRegex "//"-regex_'5bPOIHFDC_'5d'3f'2f'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'2d'5bE'7ce'5d'5bX'7cx'5d'5bE'7ce'5d'5bC'7cc'5d = compileRegex "[POIHFDC ]?/[E|e][N|n][D|d]-[E|e][X|x][E|e][C|c]"-regex_'2e = compileRegex "."-regex_'5bXx'5d'27'5b0'2d9a'2dfA'2dF'5d'7b2'2c'7d'27 = compileRegex "[Xx]'[0-9a-fA-F]{2,}'"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5b0'2d9'5d'5b0'2d9'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[0-9][0-9]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f1'5bP'7cp'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?1[P|p]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bH'7ch'7cL'7cl'5d'5b1'2d9'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[H|h|L|l][1-9]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bL'7cl'7cM'7cm'5d'5bR'7cr'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[L|l|M|m][R|r]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bO'7co'5d'5bA'2dG'7ca'2dg'7cV'7cv'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[O|o][A-G|a-g|V|v]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bU'7cu'5d'5b1'2d8'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[U|u][1-8]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bK'7ck'5d'5bA'2dN'7ca'2dn'7cP'2dY'7cp'2dy'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[K|k][A-N|a-n|P-Y|p-y]\\)?"-regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bR'7cr'5d'5bT'7ct'5d'5c'29'3f = compileRegex "\\*[I|i][N|n]\\(?[R|r][T|t]\\)?"-regex_'5b'5c'2a'7cU'7cu'5d'5bD'7cd'5d'5bA'7ca'5d'5bT'7ct'5d'5bE'7ce'5d = compileRegex "[\\*|U|u][D|d][A|a][T|t][E|e]"-regex_'5b'5c'2a'7cU'7cu'5d'5bM'7cm'5d'5bO'7co'5d'5bN'7cn'5d'5bT'7ct'5d'5bH'7ch'5d = compileRegex "[\\*|U|u][M|m][O|o][N|n][T|t][H|h]"-regex_'5b'5c'2a'7cU'7cu'5d'5bY'7cy'5d'5bE'7ce'5d'5bA'7ca'5d'5bR'7cr'5d = compileRegex "[\\*|U|u][Y|y][E|e][A|a][R|r]"-regex_'5b'5c'2a'7cU'7cu'5d'5bD'7cd'5d'5bA'7ca'5d'5bY'7cy'5d = compileRegex "[\\*|U|u][D|d][A|a][Y|y]"-regex_'5c_'5bP'7cp'5d'5bA'7ca'5d'5bG'7cg'5d'5bE'7ce'5d'5b1'2d7'5d'3f = compileRegex "\\ [P|p][A|a][G|g][E|e][1-7]?"-regex_'5c'2a'28'5bA'7ca'5d'5bA'7cl'5d'7b2'7d'5bX'7cx'7cG'7cg'5d'3f'7c'5bB'7cb'5d'5bL'7cl'5d'5bA'7ca'5d'5bN'7cn'5d'5bK'7ck'5d'5bS'7cs'5d'3f'7c'5bO'7co'5d'5bN'7cn'5d'7c'5bO'7co'5d'5bF'7cf'5d'7b2'7d'7c'5bN'7cn'5d'5bU'7cu'5d'5bL'7cl'5d'7b2'7d'7c'5bZ'7cz'5d'5bE'7ce'5d'5bR'7cr'5d'5bO'7co'5d'5bS'7cs'5d'3f'7c'5bH'7ch'5d'5bI'7ci'5d'5bV'7cv'5d'5bA'7ca'5d'5bL'7cl'5d'7c'5bL'7cl'5d'5bO'7co'5d'5bV'7cv'5d'5bA'7ca'5d'5bL'7cl'5d'7c'5bP'7cp'5d'5bS'7cs'5d'7b2'7d'5bR'7cr'5d'7c'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'7c'5bS'7cs'5d'5bT'7ct'5d'5bA'7ca'5d'5bR'7cr'5d'5bT'7ct'5d'29 = compileRegex "\\*([A|a][A|l]{2}[X|x|G|g]?|[B|b][L|l][A|a][N|n][K|k][S|s]?|[O|o][N|n]|[O|o][F|f]{2}|[N|n][U|u][L|l]{2}|[Z|z][E|e][R|r][O|o][S|s]?|[H|h][I|i][V|v][A|a][L|l]|[L|l][O|o][V|v][A|a][L|l]|[P|p][S|s]{2}[R|r]|[E|e][N|n][D|d]|[S|s][T|t][A|a][R|r][T|t])"-regex_'5c'2a'5bC'7cc'5d'5bD'7cd'5d'5bM'7cm'5d'5bY'7cy'5d = compileRegex "\\*[C|c][D|d][M|m][Y|y]"-regex_'5c'2a'5bC'7cc'5d'5bM'7cm'5d'5bD'7cd'5d'5bY'7cy'5d = compileRegex "\\*[C|c][M|m][D|d][Y|y]"-regex_'5c'2a'5bC'7cc'5d'5bY'7cy'5d'5bM'7cm'5d'5bD'7cd'5d = compileRegex "\\*[C|c][Y|y][M|m][D|d]"-regex_'5c'2a'5bD'7cd'5d'5bM'7cm'5d'5bY'7cy'5d = compileRegex "\\*[D|d][M|m][Y|y]"-regex_'5c'2a'5bE'7ce'5d'5bU'7cu'5d'5bR'7cr'5d = compileRegex "\\*[E|e][U|u][R|r]"-regex_'5c'2a'5bH'7ch'5d'5bM'7cm'5d'5bS'7cs'5d = compileRegex "\\*[H|h][M|m][S|s]"-regex_'5c'2a'5bI'7ci'5d'5bS'7cs'5d'5bO'7co'5d = compileRegex "\\*[I|i][S|s][O|o]"-regex_'5c'2a'5bJ'7cj'5d'5bI'7ci'5d'5bS'7cs'5d = compileRegex "\\*[J|j][I|i][S|s]"-regex_'5c'2a'5bJ'7cj'5d'5bO'7co'5d'5bB'7cb'5d'28'5bR'7cr'5d'5bU'7cu'5d'5bN'7cn'5d'29'3f = compileRegex "\\*[J|j][O|o][B|b]([R|r][U|u][N|n])?"-regex_'5c'2a'28'5bL'7cl'5d'5bO'7co'5d'5bN'7cn'5d'5bG'7cg'5d'29'3f'5bJ'7cj'5d'5bU'7cu'5d'5bL'7cl'5d = compileRegex "\\*([L|l][O|o][N|n][G|g])?[J|j][U|u][L|l]"-regex_'5c'2a'5bM'7cm'5d'5bD'7cd'5d'5bY'7cy'5d = compileRegex "\\*[M|m][D|d][Y|y]"-regex_'5c'2a'5bS'7cs'5d'5bY'7cy'5d'5bS'7cs'5d = compileRegex "\\*[S|s][Y|y][S|s]"-regex_'5c'2a'5bU'7cu'5d'5bS'7cs'5d'5bA'7ca'5d = compileRegex "\\*[U|u][S|s][A|a]"-regex_'5c'2a'5bY'7cy'5d'5bM'7cm'5d'5bD'7cd'5d = compileRegex "\\*[Y|y][M|m][D|d]"-regex_'5c'2a'5bA'7ca'5d'5bL'7cl'5d'5bT'7ct'5d'5bS'7cs'5d'5bE'7ce'5d'5bQ'7cq'5d = compileRegex "\\*[A|a][L|l][T|t][S|s][E|e][Q|q]"-regex_'5c'2a'5bE'7ce'5d'5bQ'7cq'5d'5bU'7cu'5d'5bA'7ca'5d'5bT'7ct'5d'5bE'7ce'5d = compileRegex "\\*[E|e][Q|q][U|u][A|a][T|t][E|e]"-regex_'5c'2a'5bF'7cf'5d'5bI'7ci'5d'5bL'7cl'5d'5bE'7ce'5d = compileRegex "\\*[F|f][I|i][L|l][E|e]"-regex_'5c'2a'5bF'7cf'5d'5bT'7ct'5d'5bR'7cr'5d'5bA'7ca'5d'5bN'7cn'5d'5bS'7cs'5d = compileRegex "\\*[F|f][T|t][R|r][A|a][N|n][S|s]"-regex_'5c'2a'5bI'7ci'5d'5bL'7cl'5d'5bE'7ce'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d = compileRegex "\\*[I|i][L|l][E|e][R|r][P|p][G|g]"-regex_'5c'2a'5bC'7cc'5d'5bR'7cr'5d'5bT'7ct'5d'5bB'7cb'5d'5bN'7cn'5d'5bD'7cd'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d = compileRegex "\\*[C|c][R|r][T|t][B|b][N|n][D|d][R|r][P|p][G|g]"-regex_'5c'2a'5bC'7cc'5d'5bR'7cr'5d'5bT'7ct'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d'5bM'7cm'5d'5bO'7co'5d'5bD'7cd'5d = compileRegex "\\*[C|c][R|r][T|t][R|r][P|p][G|g][M|m][O|o][D|d]"-regex_'5c'2a'5bV'7cv'5d'5b0'2d9'5d'5bR'7cr'5d'5b0'2d9'5d'5bM'7cm'5d'5b0'2d9'5d = compileRegex "\\*[V|v][0-9][R|r][0-9][M|m][0-9]"-regex_'5c'2a'5bN'7cn'5d'5bO'7co'5d'5bP'7cp'5d'5bA'7ca'5d'5bS'7cs'5d'7b2'7d = compileRegex "\\*[N|n][O|o][P|p][A|a][S|s]{2}"-regex_'5c'2a'5bO'7co'5d'5bM'7cm'5d'5bI'7ci'5d'5bT'7ct'5d = compileRegex "\\*[O|o][M|m][I|i][T|t]"-regex_'5c'2a'5bV'7cv'5d'5bA'7ca'5d'5bR'7cr'5d'5bS'7cs'5d'5bI'7ci'5d'5bZ'7cz'5d'5bE'7ce'5d = compileRegex "\\*[V|v][A|a][R|r][S|s][I|i][Z|z][E|e]"-regex_'5c'2a'5bR'7cr'5d'5bI'7ci'5d'5bG'7cg'5d'5bH'7ch'5d'5bT'7ct'5d'5bA'7ca'5d'5bD'7cd'5d'5bJ'7cj'5d = compileRegex "\\*[R|r][I|i][G|g][H|h][T|t][A|a][D|d][J|j]"-regex_'5c'2a'5bS'7cs'5d'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bN'7cn'5d'5bG'7cg'5d = compileRegex "\\*[S|s][T|t][R|r][I|i][N|n][G|g]"-regex_'5c'2a'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bM'7cm'5d = compileRegex "\\*[T|t][R|r][I|i][M|m]"--defaultAttributes = [("Default","Normal Text"),("CControlLevel","Normal Text"),("CIndicators","Normal Text"),("CFactor1","Normal Text"),("FindOC","Normal Text"),("NonEvalOC2","Normal Text"),("NonEvalOC3","Normal Text"),("NonEvalOC4","Normal Text"),("NonEvalOC5","Normal Text"),("NonEvalOC6","Normal Text"),("NonEvalOC7","Normal Text"),("CFactor2","Normal Text"),("EvalOC2","Normal Text"),("EvalOC3","Normal Text"),("EvalOC4","Normal Text"),("EvalOC5","Normal Text"),("EvalOC6","Normal Text"),("EvalOC8","Normal Text"),("CExFactor2","Normal Text"),("EvalOCCont","Normal Text"),("Comments","Comment"),("StringConstants","ConstantChar"),("Directives","Normal Text"),("Directives2","Normal Text"),("Directives3","Normal Text"),("Free","Normal Text"),("Exec","Normal Text"),("Biffs","Biff"),("CommonCode","Normal Text"),("Indicators","Normal Text"),("ReservedWords","Normal Text"),("AnyCode","Normal Text"),("D","Normal Text"),("P","Normal Text")]--parseRules "Default" = - do (attr, result) <- (((pRegExpr regex_'5bPpOoIiHhFfDdCc_'5d'3f'5c'2a >>= withAttribute "Comment") >>~ pushContext "Comments")- <|>- ((pRegExpr regex_'5bPpOoIiHhFfDdCc_'5d'3f'2f >>= withAttribute "Directive") >>~ pushContext "Directives")- <|>- ((pAnyChar "OoIiHhFf" >>= withAttribute "Keyword") >>~ pushContext "AnyCode")- <|>- ((pAnyChar "Dd" >>= withAttribute "Keyword") >>~ pushContext "D")- <|>- ((pAnyChar "Pp" >>= withAttribute "Keyword") >>~ pushContext "P")- <|>- ((pAnyChar "Cc" >>= withAttribute "Keyword") >>~ pushContext "CControlLevel"))- return (attr, result)--parseRules "CControlLevel" = - do (attr, result) <- (((pRegExpr regex_'5c_'7b2'7d >>= withAttribute "Indicator") >>~ pushContext "CIndicators")- <|>- ((pRegExpr regex_'5bL'7cl'5d'5b0'2d9'5d >>= withAttribute "Indicator") >>~ pushContext "CIndicators")- <|>- ((pRegExpr regex_'5bO'7co'7cL'7cl'7cS'7cs'5d'5bR'7cr'5d >>= withAttribute "Indicator") >>~ pushContext "CIndicators")- <|>- ((pRegExpr regex_'5bA'7ca'5d'5bN'7cn'5d >>= withAttribute "Indicator") >>~ pushContext "CIndicators")- <|>- ((pRegExpr regex_'5bL'7cl'7cS'7cs'5d'5bR'7cr'5d >>= withAttribute "Indicator") >>~ pushContext "CIndicators")- <|>- ((pRegExpr regex_'2e'7b2'7d >>= withAttribute "Alert") >>~ pushContext "CIndicators"))- return (attr, result)--parseRules "CIndicators" = - do (attr, result) <- (((pRegExpr regex_'5c_'7b3'7d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5b0'2d9'5d'7b2'7d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bK'7ck'5d'5bA'2dN'7cp'2dy'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bK'7ck'5d'5bP'2dY'7cp'2dy'5d'7d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bL'7cl'5d'5b1'2d9'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bL'7cl'7cM'7cm'5d'5bR'7cr'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bR'7cr'5d'5bT'7ct'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bU'7cu'5d'5b1'2d8'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bO'7co'5d'5bA'2dG'7ca'2dg'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bO'7co'5d'5bV'7cv'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'5b'5c_'7cN'7cn'5d'5bH'7ch'5d'5b1'2d9'5d >>= withAttribute "Indicator") >>~ pushContext "CFactor1")- <|>- ((pRegExpr regex_'2e'7b3'7d >>= withAttribute "Alert") >>~ pushContext "CFactor1"))- return (attr, result)--parseRules "CFactor1" = - do (attr, result) <- ((pRegExpr regex_'2e'7b14'7d >>= withAttribute "Normal Text") >>~ pushContext "FindOC")- return (attr, result)--parseRules "FindOC" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes2 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC2")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes3 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC3")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes4 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC4")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes5 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC5")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes6 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC6")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_nonevalopcodes7 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC7")- <|>- ((pRegExpr regex_'5bZ'7cz'5d'2d'28'5bA'7ca'5d'5bD'7cd'5d'7b2'7d'7c'5bS'7cs'5d'5bU'7cu'5d'5bB'7cb'5d'29 >>= withAttribute "Keyword") >>~ pushContext "NonEvalOC5")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_evalopcodes2 >>= withAttribute "Keyword") >>~ pushContext "EvalOC2")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_evalopcodes3 >>= withAttribute "Keyword") >>~ pushContext "EvalOC3")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_evalopcodes4 >>= withAttribute "Keyword") >>~ pushContext "EvalOC4")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_evalopcodes5 >>= withAttribute "Keyword") >>~ pushContext "EvalOC5")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_evalopcodes6 >>= withAttribute "Keyword") >>~ pushContext "EvalOC6")- <|>- ((pRegExpr regex_'5bO'7co'5d'5bN'7cn'5d'2d'28'5bE'7ce'5d'5bR'7cr'5d'7b2'7d'7c'5bO'7co'5d'5bR'7cr'5d'29 >>= withAttribute "Keyword") >>~ pushContext "EvalOC8")- <|>- ((pRegExpr regex_'5c_'7b10'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- <|>- ((pRegExpr regex_'2e'7b10'7d >>= withAttribute "Alert") >>~ pushContext "CFactor2"))- return (attr, result)--parseRules "NonEvalOC2" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b8'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "NonEvalOC3" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b7'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "NonEvalOC4" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b6'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "NonEvalOC5" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b5'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "NonEvalOC6" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b4'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "NonEvalOC7" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b3'7d >>= withAttribute "Normal Text") >>~ pushContext "CFactor2")- return (attr, result)--parseRules "CFactor2" = - do (attr, result) <- (((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((parseRules "CommonCode")))- return (attr, result)--parseRules "EvalOC2" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b8'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "EvalOC3" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b7'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "EvalOC4" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b6'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "EvalOC5" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b5'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "EvalOC6" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b4'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "EvalOC8" = - do (attr, result) <- ((pRegExpr regex_'5c_'7b2'7d >>= withAttribute "Normal Text") >>~ pushContext "CExFactor2")- return (attr, result)--parseRules "CExFactor2" = - do (attr, result) <- (((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((parseRules "CommonCode")))- return (attr, result)--parseRules "EvalOCCont" = - do (attr, result) <- (((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((parseRules "CommonCode")))- return (attr, result)--parseRules "Comments" = - do (attr, result) <- (((pRegExpr regex_'5c'28'2a'28FIXME'7cTODO'29'5c'29'2a >>= withAttribute "BoldComment"))- <|>- ((pRegExpr regex_'5c'28'2a'28NOTE'3a'29'5c'29'2a >>= withAttribute "BoldComment"))- <|>- ((pRegExpr regex_'2d'7c'3d >>= withAttribute "DivideComment")))- return (attr, result)--parseRules "StringConstants" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "ConstantChar") >>~ (popContext))- return (attr, result)--parseRules "Directives" = - do (attr, result) <- (((pRegExpr regex_'5bF'7cf'5d'5bR'7cr'5d'5bE'7ce'5d'5bE'7ce'5d >>= withAttribute "Directive") >>~ pushContext "Free")- <|>- ((pRegExpr regex_'5bE'7ce'5d'5bX'7cx'5d'5bE'7ce'5d'5bC'7cc'5d >>= withAttribute "Directive") >>~ pushContext "Exec")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_directives >>= withAttribute "Directive") >>~ pushContext "Directives2"))- return (attr, result)--parseRules "Directives2" = - do (attr, result) <- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_directives2 >>= withAttribute "Directive") >>~ pushContext "Directives3")- return (attr, result)--parseRules "Directives3" = - do (attr, result) <- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_directives3 >>= withAttribute "Directive"))- return (attr, result)--parseRules "Free" = - do (attr, result) <- (((pRegExpr regex_'5bPOIHFDC_'5d'3f'2f'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'2d'5bF'7cf'5d'5bR'7cr'5d'5bE'7ce'5d'5bE'7ce'5d >>= withAttribute "Directive") >>~ (popContext))- <|>- ((parseRules "CommonCode"))- <|>- ((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((pRegExpr regex_'2f'2f >>= withAttribute "Comment") >>~ pushContext "Comments")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_freeopcodes >>= withAttribute "Keyword")))- return (attr, result)--parseRules "Exec" = - do (attr, result) <- ((pRegExpr regex_'5bPOIHFDC_'5d'3f'2f'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'2d'5bE'7ce'5d'5bX'7cx'5d'5bE'7ce'5d'5bC'7cc'5d >>= withAttribute "Directive") >>~ (popContext))- return (attr, result)--parseRules "Biffs" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_biffs >>= withAttribute "Biff") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "CommonCode" = - do (attr, result) <- (((parseRules "ReservedWords"))- <|>- ((parseRules "Indicators"))- <|>- ((pDetectChar False '\'' >>= withAttribute "ConstantChar") >>~ pushContext "StringConstants")- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5bXx'5d'27'5b0'2d9a'2dfA'2dF'5d'7b2'2c'7d'27 >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal")))))- return (attr, result)--parseRules "Indicators" = - do (attr, result) <- (((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5b0'2d9'5d'5b0'2d9'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f1'5bP'7cp'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bH'7ch'7cL'7cl'5d'5b1'2d9'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bL'7cl'7cM'7cm'5d'5bR'7cr'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bO'7co'5d'5bA'2dG'7ca'2dg'7cV'7cv'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bU'7cu'5d'5b1'2d8'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bK'7ck'5d'5bA'2dN'7ca'2dn'7cP'2dY'7cp'2dy'5d'5c'29'3f >>= withAttribute "Indicator"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bN'7cn'5d'5c'28'3f'5bR'7cr'5d'5bT'7ct'5d'5c'29'3f >>= withAttribute "Indicator")))- return (attr, result)--parseRules "ReservedWords" = - do (attr, result) <- (((pRegExpr regex_'5b'5c'2a'7cU'7cu'5d'5bD'7cd'5d'5bA'7ca'5d'5bT'7ct'5d'5bE'7ce'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5b'5c'2a'7cU'7cu'5d'5bM'7cm'5d'5bO'7co'5d'5bN'7cn'5d'5bT'7ct'5d'5bH'7ch'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5b'5c'2a'7cU'7cu'5d'5bY'7cy'5d'5bE'7ce'5d'5bA'7ca'5d'5bR'7cr'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5b'5c'2a'7cU'7cu'5d'5bD'7cd'5d'5bA'7ca'5d'5bY'7cy'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c_'5bP'7cp'5d'5bA'7ca'5d'5bG'7cg'5d'5bE'7ce'5d'5b1'2d7'5d'3f >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'28'5bA'7ca'5d'5bA'7cl'5d'7b2'7d'5bX'7cx'7cG'7cg'5d'3f'7c'5bB'7cb'5d'5bL'7cl'5d'5bA'7ca'5d'5bN'7cn'5d'5bK'7ck'5d'5bS'7cs'5d'3f'7c'5bO'7co'5d'5bN'7cn'5d'7c'5bO'7co'5d'5bF'7cf'5d'7b2'7d'7c'5bN'7cn'5d'5bU'7cu'5d'5bL'7cl'5d'7b2'7d'7c'5bZ'7cz'5d'5bE'7ce'5d'5bR'7cr'5d'5bO'7co'5d'5bS'7cs'5d'3f'7c'5bH'7ch'5d'5bI'7ci'5d'5bV'7cv'5d'5bA'7ca'5d'5bL'7cl'5d'7c'5bL'7cl'5d'5bO'7co'5d'5bV'7cv'5d'5bA'7ca'5d'5bL'7cl'5d'7c'5bP'7cp'5d'5bS'7cs'5d'7b2'7d'5bR'7cr'5d'7c'5bE'7ce'5d'5bN'7cn'5d'5bD'7cd'5d'7c'5bS'7cs'5d'5bT'7ct'5d'5bA'7ca'5d'5bR'7cr'5d'5bT'7ct'5d'29 >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5c'2a'5bC'7cc'5d'5bD'7cd'5d'5bM'7cm'5d'5bY'7cy'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bC'7cc'5d'5bM'7cm'5d'5bD'7cd'5d'5bY'7cy'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bC'7cc'5d'5bY'7cy'5d'5bM'7cm'5d'5bD'7cd'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bD'7cd'5d'5bM'7cm'5d'5bY'7cy'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bE'7ce'5d'5bU'7cu'5d'5bR'7cr'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bH'7ch'5d'5bM'7cm'5d'5bS'7cs'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bS'7cs'5d'5bO'7co'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bJ'7cj'5d'5bI'7ci'5d'5bS'7cs'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bJ'7cj'5d'5bO'7co'5d'5bB'7cb'5d'28'5bR'7cr'5d'5bU'7cu'5d'5bN'7cn'5d'29'3f >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'28'5bL'7cl'5d'5bO'7co'5d'5bN'7cn'5d'5bG'7cg'5d'29'3f'5bJ'7cj'5d'5bU'7cu'5d'5bL'7cl'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bM'7cm'5d'5bD'7cd'5d'5bY'7cy'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bS'7cs'5d'5bY'7cy'5d'5bS'7cs'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bU'7cu'5d'5bS'7cs'5d'5bA'7ca'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bY'7cy'5d'5bM'7cm'5d'5bD'7cd'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bA'7ca'5d'5bL'7cl'5d'5bT'7ct'5d'5bS'7cs'5d'5bE'7ce'5d'5bQ'7cq'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bE'7ce'5d'5bQ'7cq'5d'5bU'7cu'5d'5bA'7ca'5d'5bT'7ct'5d'5bE'7ce'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bF'7cf'5d'5bI'7ci'5d'5bL'7cl'5d'5bE'7ce'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bF'7cf'5d'5bT'7ct'5d'5bR'7cr'5d'5bA'7ca'5d'5bN'7cn'5d'5bS'7cs'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bI'7ci'5d'5bL'7cl'5d'5bE'7ce'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bC'7cc'5d'5bR'7cr'5d'5bT'7ct'5d'5bB'7cb'5d'5bN'7cn'5d'5bD'7cd'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bC'7cc'5d'5bR'7cr'5d'5bT'7ct'5d'5bR'7cr'5d'5bP'7cp'5d'5bG'7cg'5d'5bM'7cm'5d'5bO'7co'5d'5bD'7cd'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bV'7cv'5d'5b0'2d9'5d'5bR'7cr'5d'5b0'2d9'5d'5bM'7cm'5d'5b0'2d9'5d >>= withAttribute "Reserved")))- return (attr, result)--parseRules "AnyCode" = - do (attr, result) <- ((parseRules "CommonCode"))- return (attr, result)--parseRules "D" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_dkeywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'2a'5bN'7cn'5d'5bO'7co'5d'5bP'7cp'5d'5bA'7ca'5d'5bS'7cs'5d'7b2'7d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bO'7co'5d'5bM'7cm'5d'5bI'7ci'5d'5bT'7ct'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bV'7cv'5d'5bA'7ca'5d'5bR'7cr'5d'5bS'7cs'5d'5bI'7ci'5d'5bZ'7cz'5d'5bE'7ce'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bR'7cr'5d'5bI'7ci'5d'5bG'7cg'5d'5bH'7ch'5d'5bT'7ct'5d'5bA'7ca'5d'5bD'7cd'5d'5bJ'7cj'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bS'7cs'5d'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bN'7cn'5d'5bG'7cg'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bM'7cm'5d >>= withAttribute "Reserved"))- <|>- ((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((parseRules "CommonCode")))- return (attr, result)--parseRules "P" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_dkeywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'2a'5bN'7cn'5d'5bO'7co'5d'5bP'7cp'5d'5bA'7ca'5d'5bS'7cs'5d'7b2'7d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bO'7co'5d'5bM'7cm'5d'5bI'7ci'5d'5bT'7ct'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bV'7cv'5d'5bA'7ca'5d'5bR'7cr'5d'5bS'7cs'5d'5bI'7ci'5d'5bZ'7cz'5d'5bE'7ce'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bR'7cr'5d'5bI'7ci'5d'5bG'7cg'5d'5bH'7ch'5d'5bT'7ct'5d'5bA'7ca'5d'5bD'7cd'5d'5bJ'7cj'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bS'7cs'5d'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bN'7cn'5d'5bG'7cg'5d >>= withAttribute "Reserved"))- <|>- ((pRegExpr regex_'5c'2a'5bT'7ct'5d'5bR'7cr'5d'5bI'7ci'5d'5bM'7cm'5d >>= withAttribute "Reserved"))- <|>- ((pDetectChar False '%' >>= withAttribute "Biff") >>~ pushContext "Biffs")- <|>- ((parseRules "CommonCode")))- return (attr, result)--parseRules "" = parseRules "Default"--parseRules x = fail $ "Unknown context" ++ x
Text/Highlighting/Kate/Syntax/Ini.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file ini.xml, version 1.1,- by Jan Janssen (medhefgo@web.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file ini.xml, version 1.1, by Jan Janssen (medhefgo@web.de) -} -module Text.Highlighting.Kate.Syntax.Ini ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Ini+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "INI Files"@@ -20,93 +23,77 @@ syntaxExtensions = "*.ini;*.pls;*.kcfgc" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "INI Files" } context <- currentContext <|> (pushContext "ini" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("INI Files",["ini"])], synStLanguage = "INI Files", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("INI Files",["ini"])], synStLanguage = "INI Files", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "ini" -> return () >> pHandleEndLine+ "ini" -> return () "Value" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Normal Text","dt"),("Section","kw"),("Comment","co"),("Assignment","ot"),("Value","st"),("Float","fl"),("Int","dv"),("Keyword","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "on off default defaults localhost null true false yes no normal e_all e_error e_warning e_parse e_notice e_strict e_core_error e_core_warning e_compile_error e_compile_warning e_user_error e_user_warning e_user_notice" regex_'3b'2e'2a'24 = compileRegex ";.*$" regex_'23'2e'2a'24 = compileRegex "#.*$" -defaultAttributes = [("ini","Normal Text"),("Value","Value"),("Comment","Comment")]+defaultAttributes = [("ini",DataTypeTok),("Value",StringTok),("Comment",CommentTok)] -parseRules "ini" = - do (attr, result) <- (((pRangeDetect '[' ']' >>= withAttribute "Section") >>~ (popContext))- <|>- ((pDetectChar False '=' >>= withAttribute "Assignment") >>~ pushContext "Value")- <|>- ((pFirstNonSpace >> pDetectChar False ';' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)+parseRules "ini" =+ (((pRangeDetect '[' ']' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value")+ <|>+ ((pFirstNonSpace >> pDetectChar False ';' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")) -parseRules "Value" = - do (attr, result) <- (((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Int"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Value" =+ (((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) parseRules "" = parseRules "ini"
Text/Highlighting/Kate/Syntax/Java.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file java.xml, version 1.20,- by Alfredo Luiz Foltran Fialho (alfoltran@ig.com.br) -}+{- This module was generated from data in the Kate syntax+ highlighting file java.xml, version 1.20, by Alfredo Luiz Foltran Fialho (alfoltran@ig.com.br) -} -module Text.Highlighting.Kate.Syntax.Java ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Java+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Javadoc-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Java"@@ -20,64 +23,51 @@ syntaxExtensions = "*.java" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Java" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Java",["Normal"])], synStLanguage = "Java", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Java",["Normal"])], synStLanguage = "Java", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "InFunctionCall" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "InFunctionCall" -> return () "String" -> (popContext) >> pEndLine- "EnterPrintf" -> return () >> pHandleEndLine- "Printf" -> return () >> pHandleEndLine+ "EnterPrintf" -> return ()+ "Printf" -> return () "PrintfString" -> (popContext) >> pEndLine "Member" -> (popContext) >> pEndLine "StaticImports" -> (popContext) >> pEndLine "Imports" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar 2" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("StaticImports","kw"),("Imports","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("PrintfString","st"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_java15 = Set.fromList $ words $ "ACTIVE ACTIVITY_COMPLETED ACTIVITY_REQUIRED ARG_IN ARG_INOUT ARG_OUT AWTError AWTEvent AWTEventListener AWTEventListenerProxy AWTEventMulticaster AWTException AWTKeyStroke AWTPermission AbstractAction AbstractBorder AbstractButton AbstractCellEditor AbstractCollection AbstractColorChooserPanel AbstractDocument AbstractDocument.AttributeContext AbstractDocument.Content AbstractDocument.ElementEdit AbstractExecutorService AbstractInterruptibleChannel AbstractLayoutCache AbstractLayoutCache.NodeDimensions AbstractList AbstractListModel AbstractMap AbstractMethodError AbstractPreferences AbstractQueue AbstractQueuedSynchronizer AbstractSelectableChannel AbstractSelectionKey AbstractSelector AbstractSequentialList AbstractSet AbstractSpinnerModel AbstractTableModel AbstractUndoableEdit AbstractWriter AccessControlContext AccessControlException AccessController AccessException Accessible AccessibleAction AccessibleAttributeSequence AccessibleBundle AccessibleComponent AccessibleContext AccessibleEditableText AccessibleExtendedComponent AccessibleExtendedTable AccessibleExtendedText AccessibleHyperlink AccessibleHypertext AccessibleIcon AccessibleKeyBinding AccessibleObject AccessibleRelation AccessibleRelationSet AccessibleResourceBundle AccessibleRole AccessibleSelection AccessibleState AccessibleStateSet AccessibleStreamable AccessibleTable AccessibleTableModelChange AccessibleText AccessibleTextSequence AccessibleValue AccountException AccountExpiredException AccountLockedException AccountNotFoundException Acl AclEntry AclNotFoundException Action ActionEvent ActionListener ActionMap ActionMapUIResource Activatable ActivateFailedException ActivationDesc ActivationException ActivationGroup ActivationGroupDesc ActivationGroupDesc.CommandEnvironment ActivationGroupID ActivationGroup_Stub ActivationID ActivationInstantiator ActivationMonitor ActivationSystem Activator ActiveEvent ActivityCompletedException ActivityRequiredException AdapterActivator AdapterActivatorOperations AdapterAlreadyExists AdapterAlreadyExistsHelper AdapterInactive AdapterInactiveHelper AdapterManagerIdHelper AdapterNameHelper AdapterNonExistent AdapterNonExistentHelper AdapterStateHelper AddressHelper Adjustable AdjustmentEvent AdjustmentListener Adler32 AffineTransform AffineTransformOp AlgorithmParameterGenerator AlgorithmParameterGeneratorSpi AlgorithmParameterSpec AlgorithmParameters AlgorithmParametersSpi AllPermission AlphaComposite AlreadyBound AlreadyBoundException AlreadyBoundHelper AlreadyBoundHolder AlreadyConnectedException AncestorEvent AncestorListener AnnotatedElement Annotation Annotation AnnotationFormatError AnnotationTypeMismatchException Any AnyHolder AnySeqHelper AnySeqHelper AnySeqHolder AppConfigurationEntry AppConfigurationEntry.LoginModuleControlFlag Appendable Applet AppletContext AppletInitializer AppletStub ApplicationException Arc2D Arc2D.Double Arc2D.Float Area AreaAveragingScaleFilter ArithmeticException Array Array ArrayBlockingQueue ArrayIndexOutOfBoundsException ArrayList ArrayStoreException ArrayType Arrays AssertionError AsyncBoxView AsynchronousCloseException AtomicBoolean AtomicInteger AtomicIntegerArray AtomicIntegerFieldUpdater AtomicLong AtomicLongArray AtomicLongFieldUpdater AtomicMarkableReference AtomicReference AtomicReferenceArray AtomicReferenceFieldUpdater AtomicStampedReference Attr Attribute Attribute Attribute AttributeChangeNotification AttributeChangeNotificationFilter AttributeException AttributeInUseException AttributeList AttributeList AttributeList AttributeListImpl AttributeModificationException AttributeNotFoundException AttributeSet AttributeSet AttributeSet.CharacterAttribute AttributeSet.ColorAttribute AttributeSet.FontAttribute AttributeSet.ParagraphAttribute AttributeSetUtilities AttributeValueExp AttributedCharacterIterator AttributedCharacterIterator.Attribute AttributedString Attributes Attributes Attributes Attributes.Name Attributes2 Attributes2Impl AttributesImpl AudioClip AudioFileFormat AudioFileFormat.Type AudioFileReader AudioFileWriter AudioFormat AudioFormat.Encoding AudioInputStream AudioPermission AudioSystem AuthPermission AuthProvider AuthenticationException AuthenticationException AuthenticationNotSupportedException Authenticator Authenticator.RequestorType AuthorizeCallback Autoscroll BAD_CONTEXT BAD_INV_ORDER BAD_OPERATION BAD_PARAM BAD_POLICY BAD_POLICY_TYPE BAD_POLICY_VALUE BAD_QOS BAD_TYPECODE BMPImageWriteParam BackingStoreException BadAttributeValueExpException BadBinaryOpValueExpException BadKind BadLocationException BadPaddingException BadStringOperationException BandCombineOp BandedSampleModel BaseRowSet BasicArrowButton BasicAttribute BasicAttributes BasicBorders BasicBorders.ButtonBorder BasicBorders.FieldBorder BasicBorders.MarginBorder BasicBorders.MenuBarBorder BasicBorders.RadioButtonBorder BasicBorders.RolloverButtonBorder BasicBorders.SplitPaneBorder BasicBorders.ToggleButtonBorder BasicButtonListener BasicButtonUI BasicCheckBoxMenuItemUI BasicCheckBoxUI BasicColorChooserUI BasicComboBoxEditor BasicComboBoxEditor.UIResource BasicComboBoxRenderer BasicComboBoxRenderer.UIResource BasicComboBoxUI BasicComboPopup BasicControl BasicDesktopIconUI BasicDesktopPaneUI BasicDirectoryModel BasicEditorPaneUI BasicFileChooserUI BasicFormattedTextFieldUI BasicGraphicsUtils BasicHTML BasicIconFactory BasicInternalFrameTitlePane BasicInternalFrameUI BasicLabelUI BasicListUI BasicLookAndFeel BasicMenuBarUI BasicMenuItemUI BasicMenuUI BasicOptionPaneUI BasicOptionPaneUI.ButtonAreaLayout BasicPanelUI BasicPasswordFieldUI BasicPermission BasicPopupMenuSeparatorUI BasicPopupMenuUI BasicProgressBarUI BasicRadioButtonMenuItemUI BasicRadioButtonUI BasicRootPaneUI BasicScrollBarUI BasicScrollPaneUI BasicSeparatorUI BasicSliderUI BasicSpinnerUI BasicSplitPaneDivider BasicSplitPaneUI BasicStroke BasicTabbedPaneUI BasicTableHeaderUI BasicTableUI BasicTextAreaUI BasicTextFieldUI BasicTextPaneUI BasicTextUI BasicTextUI.BasicCaret BasicTextUI.BasicHighlighter BasicToggleButtonUI BasicToolBarSeparatorUI BasicToolBarUI BasicToolTipUI BasicTreeUI BasicViewportUI BatchUpdateException BeanContext BeanContextChild BeanContextChildComponentProxy BeanContextChildSupport BeanContextContainerProxy BeanContextEvent BeanContextMembershipEvent BeanContextMembershipListener BeanContextProxy BeanContextServiceAvailableEvent BeanContextServiceProvider BeanContextServiceProviderBeanInfo BeanContextServiceRevokedEvent BeanContextServiceRevokedListener BeanContextServices BeanContextServicesListener BeanContextServicesSupport BeanContextServicesSupport.BCSSServiceProvider BeanContextSupport BeanContextSupport.BCSIterator BeanDescriptor BeanInfo Beans BevelBorder Bidi BigDecimal BigInteger BinaryRefAddr BindException Binding Binding BindingHelper BindingHolder BindingIterator BindingIteratorHelper BindingIteratorHolder BindingIteratorOperations BindingIteratorPOA BindingListHelper BindingListHolder BindingType BindingTypeHelper BindingTypeHolder BitSet Blob BlockView BlockingQueue Book Boolean BooleanControl BooleanControl.Type BooleanHolder BooleanSeqHelper BooleanSeqHolder Border BorderFactory BorderLayout BorderUIResource BorderUIResource.BevelBorderUIResource BorderUIResource.CompoundBorderUIResource BorderUIResource.EmptyBorderUIResource BorderUIResource.EtchedBorderUIResource BorderUIResource.LineBorderUIResource BorderUIResource.MatteBorderUIResource BorderUIResource.TitledBorderUIResource BoundedRangeModel Bounds Bounds Box Box.Filler BoxLayout BoxView BoxedValueHelper BreakIterator BrokenBarrierException Buffer BufferCapabilities BufferCapabilities.FlipContents BufferOverflowException BufferStrategy BufferUnderflowException BufferedImage BufferedImageFilter BufferedImageOp BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter Button ButtonGroup ButtonModel ButtonUI Byte ByteArrayInputStream ByteArrayOutputStream ByteBuffer ByteChannel ByteHolder ByteLookupTable ByteOrder CDATASection CMMException CODESET_INCOMPATIBLE COMM_FAILURE CRC32 CRL CRLException CRLSelector CSS CSS.Attribute CTX_RESTRICT_SCOPE CacheRequest CacheResponse CachedRowSet Calendar Callable CallableStatement Callback CallbackHandler CancelablePrintJob CancellationException CancelledKeyException CannotProceed CannotProceedException CannotProceedHelper CannotProceedHolder CannotRedoException CannotUndoException Canvas CardLayout Caret CaretEvent CaretListener CellEditor CellEditorListener CellRendererPane CertPath CertPath.CertPathRep CertPathBuilder CertPathBuilderException CertPathBuilderResult CertPathBuilderSpi CertPathParameters CertPathTrustManagerParameters CertPathValidator CertPathValidatorException CertPathValidatorResult CertPathValidatorSpi CertSelector CertStore CertStoreException CertStoreParameters CertStoreSpi Certificate Certificate Certificate Certificate.CertificateRep CertificateEncodingException CertificateEncodingException CertificateException CertificateException CertificateExpiredException CertificateExpiredException CertificateFactory CertificateFactorySpi CertificateNotYetValidException CertificateNotYetValidException CertificateParsingException CertificateParsingException ChangeEvent ChangeListener ChangedCharSetException Channel ChannelBinding Channels CharArrayReader CharArrayWriter CharBuffer CharConversionException CharHolder CharSeqHelper CharSeqHolder CharSequence Character Character.Subset Character.UnicodeBlock CharacterCodingException CharacterData CharacterIterator Charset CharsetDecoder CharsetEncoder CharsetProvider Checkbox CheckboxGroup CheckboxMenuItem CheckedInputStream CheckedOutputStream Checksum Choice ChoiceCallback ChoiceFormat Chromaticity Cipher CipherInputStream CipherOutputStream CipherSpi Class ClassCastException ClassCircularityError ClassDefinition ClassDesc ClassFileTransformer ClassFormatError ClassLoader ClassLoaderRepository ClassLoadingMXBean ClassNotFoundException ClientRequestInfo ClientRequestInfoOperations ClientRequestInterceptor ClientRequestInterceptorOperations Clip Clipboard ClipboardOwner Clob CloneNotSupportedException Cloneable Closeable ClosedByInterruptException ClosedChannelException ClosedSelectorException CodeSets CodeSigner CodeSource Codec CodecFactory CodecFactoryHelper CodecFactoryOperations CodecOperations CoderMalfunctionError CoderResult CodingErrorAction CollationElementIterator CollationKey Collator Collection CollectionCertStoreParameters Collections Color ColorChooserComponentFactory ColorChooserUI ColorConvertOp ColorModel ColorSelectionModel ColorSpace ColorSupported ColorType ColorUIResource ComboBoxEditor ComboBoxModel ComboBoxUI ComboPopup Comment CommunicationException Comparable Comparator CompilationMXBean Compiler CompletionService CompletionStatus CompletionStatusHelper Component ComponentAdapter ComponentColorModel ComponentEvent ComponentIdHelper ComponentInputMap ComponentInputMapUIResource ComponentListener ComponentOrientation ComponentSampleModel ComponentUI ComponentView Composite CompositeContext CompositeData CompositeDataSupport CompositeName CompositeType CompositeView CompoundBorder CompoundControl CompoundControl.Type CompoundEdit CompoundName Compression ConcurrentHashMap ConcurrentLinkedQueue ConcurrentMap ConcurrentModificationException Condition Configuration ConfigurationException ConfirmationCallback ConnectException ConnectException ConnectIOException Connection ConnectionEvent ConnectionEventListener ConnectionPendingException ConnectionPoolDataSource ConsoleHandler Constructor Container ContainerAdapter ContainerEvent ContainerListener ContainerOrderFocusTraversalPolicy ContentHandler ContentHandler ContentHandlerFactory ContentModel Context Context ContextList ContextNotEmptyException ContextualRenderedImageFactory Control Control Control.Type ControlFactory ControllerEventListener ConvolveOp CookieHandler CookieHolder Copies CopiesSupported CopyOnWriteArrayList CopyOnWriteArraySet CountDownLatch CounterMonitor CounterMonitorMBean CredentialException CredentialExpiredException CredentialNotFoundException CropImageFilter CubicCurve2D CubicCurve2D.Double CubicCurve2D.Float Currency Current Current Current CurrentHelper CurrentHelper CurrentHelper CurrentHolder CurrentOperations CurrentOperations CurrentOperations Cursor CustomMarshal CustomValue Customizer CyclicBarrier DATA_CONVERSION DESKeySpec DESedeKeySpec DGC DHGenParameterSpec DHKey DHParameterSpec DHPrivateKey DHPrivateKeySpec DHPublicKey DHPublicKeySpec DISCARDING DOMConfiguration DOMError DOMErrorHandler DOMException DOMImplementation DOMImplementationLS DOMImplementationList DOMImplementationRegistry DOMImplementationSource DOMLocator DOMLocator DOMResult DOMSource DOMStringList DSAKey DSAKeyPairGenerator DSAParameterSpec DSAParams DSAPrivateKey DSAPrivateKeySpec DSAPublicKey DSAPublicKeySpec DTD DTDConstants DTDHandler DataBuffer DataBufferByte DataBufferDouble DataBufferFloat DataBufferInt DataBufferShort DataBufferUShort DataFlavor DataFormatException DataInput DataInputStream DataInputStream DataLine DataLine.Info DataOutput DataOutputStream DataOutputStream DataSource DataTruncation DatabaseMetaData DatagramChannel DatagramPacket DatagramSocket DatagramSocketImpl DatagramSocketImplFactory DatatypeConfigurationException DatatypeConstants DatatypeConstants.Field DatatypeFactory Date Date DateFormat DateFormat.Field DateFormatSymbols DateFormatter DateTimeAtCompleted DateTimeAtCreation DateTimeAtProcessing DateTimeSyntax DebugGraphics DecimalFormat DecimalFormatSymbols DeclHandler DefaultBoundedRangeModel DefaultButtonModel DefaultCaret DefaultCellEditor DefaultColorSelectionModel DefaultComboBoxModel DefaultDesktopManager DefaultEditorKit DefaultEditorKit.BeepAction DefaultEditorKit.CopyAction DefaultEditorKit.CutAction DefaultEditorKit.DefaultKeyTypedAction DefaultEditorKit.InsertBreakAction DefaultEditorKit.InsertContentAction DefaultEditorKit.InsertTabAction DefaultEditorKit.PasteAction DefaultFocusManager DefaultFocusTraversalPolicy DefaultFormatter DefaultFormatterFactory DefaultHandler DefaultHandler2 DefaultHighlighter DefaultHighlighter.DefaultHighlightPainter DefaultKeyboardFocusManager DefaultListCellRenderer DefaultListCellRenderer.UIResource DefaultListModel DefaultListSelectionModel DefaultLoaderRepository DefaultLoaderRepository DefaultMenuLayout DefaultMetalTheme DefaultMutableTreeNode DefaultPersistenceDelegate DefaultSingleSelectionModel DefaultStyledDocument DefaultStyledDocument.AttributeUndoableEdit DefaultStyledDocument.ElementSpec DefaultTableCellRenderer DefaultTableCellRenderer.UIResource DefaultTableColumnModel DefaultTableModel DefaultTextUI DefaultTreeCellEditor DefaultTreeCellRenderer DefaultTreeModel DefaultTreeSelectionModel DefinitionKind DefinitionKindHelper Deflater DeflaterOutputStream DelayQueue Delayed Delegate Delegate Delegate DelegationPermission Deprecated Descriptor DescriptorAccess DescriptorSupport DesignMode DesktopIconUI DesktopManager DesktopPaneUI Destination DestroyFailedException Destroyable Dialog Dictionary DigestException DigestInputStream DigestOutputStream Dimension Dimension2D DimensionUIResource DirContext DirObjectFactory DirStateFactory DirStateFactory.Result DirectColorModel DirectoryManager DisplayMode DnDConstants Doc DocAttribute DocAttributeSet DocFlavor DocFlavor.BYTE_ARRAY DocFlavor.CHAR_ARRAY DocFlavor.INPUT_STREAM DocFlavor.READER DocFlavor.SERVICE_FORMATTED DocFlavor.STRING DocFlavor.URL DocPrintJob Document Document DocumentBuilder DocumentBuilderFactory DocumentEvent DocumentEvent.ElementChange DocumentEvent.EventType DocumentFilter DocumentFilter.FilterBypass DocumentFragment DocumentHandler DocumentListener DocumentName DocumentParser DocumentType Documented DomainCombiner DomainManager DomainManagerOperations Double DoubleBuffer DoubleHolder DoubleSeqHelper DoubleSeqHolder DragGestureEvent DragGestureListener DragGestureRecognizer DragSource DragSourceAdapter DragSourceContext DragSourceDragEvent DragSourceDropEvent DragSourceEvent DragSourceListener DragSourceMotionListener Driver DriverManager DriverPropertyInfo DropTarget DropTarget.DropTargetAutoScroller DropTargetAdapter DropTargetContext DropTargetDragEvent DropTargetDropEvent DropTargetEvent DropTargetListener DuplicateFormatFlagsException DuplicateName DuplicateNameHelper Duration DynAny DynAny DynAnyFactory DynAnyFactoryHelper DynAnyFactoryOperations DynAnyHelper DynAnyOperations DynAnySeqHelper DynArray DynArray DynArrayHelper DynArrayOperations DynEnum DynEnum DynEnumHelper DynEnumOperations DynFixed DynFixed DynFixedHelper DynFixedOperations DynSequence DynSequence DynSequenceHelper DynSequenceOperations DynStruct DynStruct DynStructHelper DynStructOperations DynUnion DynUnion DynUnionHelper DynUnionOperations DynValue DynValue DynValueBox DynValueBoxOperations DynValueCommon DynValueCommonOperations DynValueHelper DynValueOperations DynamicImplementation DynamicImplementation DynamicMBean ECField ECFieldF2m ECFieldFp ECGenParameterSpec ECKey ECParameterSpec ECPoint ECPrivateKey ECPrivateKeySpec ECPublicKey ECPublicKeySpec ENCODING_CDR_ENCAPS EOFException EditorKit Element Element Element ElementIterator ElementType Ellipse2D Ellipse2D.Double Ellipse2D.Float EllipticCurve EmptyBorder EmptyStackException EncodedKeySpec Encoder Encoding EncryptedPrivateKeyInfo Entity Entity EntityReference EntityResolver EntityResolver2 Enum EnumConstantNotPresentException EnumControl EnumControl.Type EnumMap EnumSet EnumSyntax Enumeration Environment Error ErrorHandler ErrorListener ErrorManager EtchedBorder Event EventContext EventDirContext EventHandler EventListener EventListenerList EventListenerProxy EventObject EventQueue EventSetDescriptor Exception ExceptionDetailMessage ExceptionInInitializerError ExceptionList ExceptionListener Exchanger ExecutionException Executor ExecutorCompletionService ExecutorService Executors ExemptionMechanism ExemptionMechanismException ExemptionMechanismSpi ExpandVetoException ExportException Expression ExtendedRequest ExtendedResponse Externalizable FREE_MEM FactoryConfigurationError FailedLoginException FeatureDescriptor Fidelity Field FieldNameHelper FieldNameHelper FieldPosition FieldView File FileCacheImageInputStream FileCacheImageOutputStream FileChannel FileChannel.MapMode FileChooserUI FileDescriptor FileDialog FileFilter FileFilter FileHandler FileImageInputStream FileImageOutputStream FileInputStream FileLock FileLockInterruptionException FileNameMap FileNotFoundException FileOutputStream FilePermission FileReader FileSystemView FileView FileWriter FilenameFilter Filter FilterInputStream FilterOutputStream FilterReader FilterWriter FilteredImageSource FilteredRowSet Finishings FixedHeightLayoutCache FixedHolder FlatteningPathIterator FlavorEvent FlavorException FlavorListener FlavorMap FlavorTable Float FloatBuffer FloatControl FloatControl.Type FloatHolder FloatSeqHelper FloatSeqHolder FlowLayout FlowView FlowView.FlowStrategy Flushable FocusAdapter FocusEvent FocusListener FocusManager FocusTraversalPolicy Font FontFormatException FontMetrics FontRenderContext FontUIResource FormSubmitEvent FormSubmitEvent.MethodType FormView Format Format.Field FormatConversionProvider FormatFlagsConversionMismatchException FormatMismatch FormatMismatchHelper Formattable FormattableFlags Formatter Formatter FormatterClosedException ForwardRequest ForwardRequest ForwardRequestHelper ForwardRequestHelper Frame Future FutureTask GSSContext GSSCredential GSSException GSSManager GSSName GZIPInputStream GZIPOutputStream GapContent GarbageCollectorMXBean GatheringByteChannel GaugeMonitor GaugeMonitorMBean GeneralPath GeneralSecurityException GenericArrayType GenericDeclaration GenericSignatureFormatError GlyphJustificationInfo GlyphMetrics GlyphVector GlyphView GlyphView.GlyphPainter GradientPaint GraphicAttribute Graphics Graphics2D GraphicsConfigTemplate GraphicsConfiguration GraphicsDevice GraphicsEnvironment GrayFilter GregorianCalendar GridBagConstraints GridBagLayout GridLayout Group Guard GuardedObject HOLDING HTML HTML.Attribute HTML.Tag HTML.UnknownTag HTMLDocument HTMLDocument.Iterator HTMLEditorKit HTMLEditorKit.HTMLFactory HTMLEditorKit.HTMLTextAction HTMLEditorKit.InsertHTMLTextAction HTMLEditorKit.LinkController HTMLEditorKit.Parser HTMLEditorKit.ParserCallback HTMLFrameHyperlinkEvent HTMLWriter Handler HandlerBase HandshakeCompletedEvent HandshakeCompletedListener HasControls HashAttributeSet HashDocAttributeSet HashMap HashPrintJobAttributeSet HashPrintRequestAttributeSet HashPrintServiceAttributeSet HashSet Hashtable HeadlessException HierarchyBoundsAdapter HierarchyBoundsListener HierarchyEvent HierarchyListener Highlighter Highlighter.Highlight Highlighter.HighlightPainter HostnameVerifier HttpRetryException HttpURLConnection HttpsURLConnection HyperlinkEvent HyperlinkEvent.EventType HyperlinkListener ICC_ColorSpace ICC_Profile ICC_ProfileGray ICC_ProfileRGB IDLEntity IDLType IDLTypeHelper IDLTypeOperations ID_ASSIGNMENT_POLICY_ID ID_UNIQUENESS_POLICY_ID IIOByteBuffer IIOException IIOImage IIOInvalidTreeException IIOMetadata IIOMetadataController IIOMetadataFormat IIOMetadataFormatImpl IIOMetadataNode IIOParam IIOParamController IIOReadProgressListener IIOReadUpdateListener IIOReadWarningListener IIORegistry IIOServiceProvider IIOWriteProgressListener IIOWriteWarningListener IMPLICIT_ACTIVATION_POLICY_ID IMP_LIMIT INACTIVE INITIALIZE INTERNAL INTF_REPOS INVALID_ACTIVITY INVALID_TRANSACTION INV_FLAG INV_IDENT INV_OBJREF INV_POLICY IOException IOR IORHelper IORHolder IORInfo IORInfoOperations IORInterceptor IORInterceptorOperations IORInterceptor_3_0 IORInterceptor_3_0Helper IORInterceptor_3_0Holder IORInterceptor_3_0Operations IRObject IRObjectOperations Icon IconUIResource IconView IdAssignmentPolicy IdAssignmentPolicyOperations IdAssignmentPolicyValue IdUniquenessPolicy IdUniquenessPolicyOperations IdUniquenessPolicyValue IdentifierHelper Identity IdentityHashMap IdentityScope IllegalAccessError IllegalAccessException IllegalArgumentException IllegalBlockSizeException IllegalBlockingModeException IllegalCharsetNameException IllegalClassFormatException IllegalComponentStateException IllegalFormatCodePointException IllegalFormatConversionException IllegalFormatException IllegalFormatFlagsException IllegalFormatPrecisionException IllegalFormatWidthException IllegalMonitorStateException IllegalPathStateException IllegalSelectorException IllegalStateException IllegalThreadStateException Image ImageCapabilities ImageConsumer ImageFilter ImageGraphicAttribute ImageIO ImageIcon ImageInputStream ImageInputStreamImpl ImageInputStreamSpi ImageObserver ImageOutputStream ImageOutputStreamImpl ImageOutputStreamSpi ImageProducer ImageReadParam ImageReader ImageReaderSpi ImageReaderWriterSpi ImageTranscoder ImageTranscoderSpi ImageTypeSpecifier ImageView ImageWriteParam ImageWriter ImageWriterSpi ImagingOpException ImplicitActivationPolicy ImplicitActivationPolicyOperations ImplicitActivationPolicyValue IncompatibleClassChangeError IncompleteAnnotationException InconsistentTypeCode InconsistentTypeCode InconsistentTypeCodeHelper IndexColorModel IndexOutOfBoundsException IndexedPropertyChangeEvent IndexedPropertyDescriptor IndirectionException Inet4Address Inet6Address InetAddress InetSocketAddress Inflater InflaterInputStream InheritableThreadLocal Inherited InitialContext InitialContextFactory InitialContextFactoryBuilder InitialDirContext InitialLdapContext InlineView InputContext InputEvent InputMap InputMapUIResource InputMethod InputMethodContext InputMethodDescriptor InputMethodEvent InputMethodHighlight InputMethodListener InputMethodRequests InputMismatchException InputSource InputStream InputStream InputStream InputStreamReader InputSubset InputVerifier Insets InsetsUIResource InstanceAlreadyExistsException InstanceNotFoundException InstantiationError InstantiationException Instrument Instrumentation InsufficientResourcesException IntBuffer IntHolder Integer IntegerSyntax Interceptor InterceptorOperations InternalError InternalFrameAdapter InternalFrameEvent InternalFrameFocusTraversalPolicy InternalFrameListener InternalFrameUI InternationalFormatter InterruptedException InterruptedIOException InterruptedNamingException InterruptibleChannel IntrospectionException IntrospectionException Introspector Invalid InvalidActivityException InvalidAddress InvalidAddressHelper InvalidAddressHolder InvalidAlgorithmParameterException InvalidApplicationException InvalidAttributeIdentifierException InvalidAttributeValueException InvalidAttributeValueException InvalidAttributesException InvalidClassException InvalidDnDOperationException InvalidKeyException InvalidKeyException InvalidKeySpecException InvalidMarkException InvalidMidiDataException InvalidName InvalidName InvalidName InvalidNameException InvalidNameHelper InvalidNameHelper InvalidNameHolder InvalidObjectException InvalidOpenTypeException InvalidParameterException InvalidParameterSpecException InvalidPolicy InvalidPolicyHelper InvalidPreferencesFormatException InvalidPropertiesFormatException InvalidRelationIdException InvalidRelationServiceException InvalidRelationTypeException InvalidRoleInfoException InvalidRoleValueException InvalidSearchControlsException InvalidSearchFilterException InvalidSeq InvalidSlot InvalidSlotHelper InvalidTargetObjectTypeException InvalidTransactionException InvalidTypeForEncoding InvalidTypeForEncodingHelper InvalidValue InvalidValue InvalidValueHelper InvocationEvent InvocationHandler InvocationTargetException InvokeHandler IstringHelper ItemEvent ItemListener ItemSelectable Iterable Iterator IvParameterSpec JApplet JButton JCheckBox JCheckBoxMenuItem JColorChooser JComboBox JComboBox.KeySelectionManager JComponent JDesktopPane JDialog JEditorPane JFileChooser JFormattedTextField JFormattedTextField.AbstractFormatter JFormattedTextField.AbstractFormatterFactory JFrame JInternalFrame JInternalFrame.JDesktopIcon JLabel JLayeredPane JList JMException JMRuntimeException JMXAuthenticator JMXConnectionNotification JMXConnector JMXConnectorFactory JMXConnectorProvider JMXConnectorServer JMXConnectorServerFactory JMXConnectorServerMBean JMXConnectorServerProvider JMXPrincipal JMXProviderException JMXServerErrorException JMXServiceURL JMenu JMenuBar JMenuItem JOptionPane JPEGHuffmanTable JPEGImageReadParam JPEGImageWriteParam JPEGQTable JPanel JPasswordField JPopupMenu JPopupMenu.Separator JProgressBar JRadioButton JRadioButtonMenuItem JRootPane JScrollBar JScrollPane JSeparator JSlider JSpinner JSpinner.DateEditor JSpinner.DefaultEditor JSpinner.ListEditor JSpinner.NumberEditor JSplitPane JTabbedPane JTable JTable.PrintMode JTableHeader JTextArea JTextComponent JTextComponent.KeyBinding JTextField JTextPane JToggleButton JToggleButton.ToggleButtonModel JToolBar JToolBar.Separator JToolTip JTree JTree.DynamicUtilTreeNode JTree.EmptySelectionModel JViewport JWindow JarEntry JarException JarFile JarInputStream JarOutputStream JarURLConnection JdbcRowSet JobAttributes JobAttributes.DefaultSelectionType JobAttributes.DestinationType JobAttributes.DialogType JobAttributes.MultipleDocumentHandlingType JobAttributes.SidesType JobHoldUntil JobImpressions JobImpressionsCompleted JobImpressionsSupported JobKOctets JobKOctetsProcessed JobKOctetsSupported JobMediaSheets JobMediaSheetsCompleted JobMediaSheetsSupported JobMessageFromOperator JobName JobOriginatingUserName JobPriority JobPrioritySupported JobSheets JobState JobStateReason JobStateReasons JoinRowSet Joinable KerberosKey KerberosPrincipal KerberosTicket Kernel Key KeyAdapter KeyAgreement KeyAgreementSpi KeyAlreadyExistsException KeyEvent KeyEventDispatcher KeyEventPostProcessor KeyException KeyFactory KeyFactorySpi KeyGenerator KeyGeneratorSpi KeyListener KeyManagementException KeyManager KeyManagerFactory KeyManagerFactorySpi KeyPair KeyPairGenerator KeyPairGeneratorSpi KeyRep KeyRep.Type KeySpec KeyStore KeyStore.Builder KeyStore.CallbackHandlerProtection KeyStore.Entry KeyStore.LoadStoreParameter KeyStore.PasswordProtection KeyStore.PrivateKeyEntry KeyStore.ProtectionParameter KeyStore.SecretKeyEntry KeyStore.TrustedCertificateEntry KeyStoreBuilderParameters KeyStoreException KeyStoreSpi KeyStroke KeyboardFocusManager Keymap LDAPCertStoreParameters LIFESPAN_POLICY_ID LOCATION_FORWARD LSException LSInput LSLoadEvent LSOutput LSParser LSParserFilter LSProgressEvent LSResourceResolver LSSerializer LSSerializerFilter Label LabelUI LabelView LanguageCallback LastOwnerException LayeredHighlighter LayeredHighlighter.LayerPainter LayoutFocusTraversalPolicy LayoutManager LayoutManager2 LayoutQueue LdapContext LdapName LdapReferralException Lease Level LexicalHandler LifespanPolicy LifespanPolicyOperations LifespanPolicyValue LimitExceededException Line Line.Info Line2D Line2D.Double Line2D.Float LineBorder LineBreakMeasurer LineEvent LineEvent.Type LineListener LineMetrics LineNumberInputStream LineNumberReader LineUnavailableException LinkException LinkLoopException LinkRef LinkageError LinkedBlockingQueue LinkedHashMap LinkedHashSet LinkedList List List ListCellRenderer ListDataEvent ListDataListener ListIterator ListModel ListResourceBundle ListSelectionEvent ListSelectionListener ListSelectionModel ListUI ListView ListenerNotFoundException LoaderHandler LocalObject Locale LocateRegistry Locator Locator2 Locator2Impl LocatorImpl Lock LockSupport LogManager LogRecord LogStream Logger LoggingMXBean LoggingPermission LoginContext LoginException LoginModule Long LongBuffer LongHolder LongLongSeqHelper LongLongSeqHolder LongSeqHelper LongSeqHolder LookAndFeel LookupOp LookupTable MARSHAL MBeanAttributeInfo MBeanConstructorInfo MBeanException MBeanFeatureInfo MBeanInfo MBeanNotificationInfo MBeanOperationInfo MBeanParameterInfo MBeanPermission MBeanRegistration MBeanRegistrationException MBeanServer MBeanServerBuilder MBeanServerConnection MBeanServerDelegate MBeanServerDelegateMBean MBeanServerFactory MBeanServerForwarder MBeanServerInvocationHandler MBeanServerNotification MBeanServerNotificationFilter MBeanServerPermission MBeanTrustPermission MGF1ParameterSpec MLet MLetMBean Mac MacSpi MalformedInputException MalformedLinkException MalformedObjectNameException MalformedParameterizedTypeException MalformedURLException ManageReferralControl ManagementFactory ManagementPermission ManagerFactoryParameters Manifest Map Map.Entry MappedByteBuffer MarshalException MarshalledObject MaskFormatter MatchResult Matcher Math MathContext MatteBorder Media MediaName MediaPrintableArea MediaSize MediaSize.Engineering MediaSize.ISO MediaSize.JIS MediaSize.NA MediaSize.Other MediaSizeName MediaTracker MediaTray Member MemoryCacheImageInputStream MemoryCacheImageOutputStream MemoryHandler MemoryImageSource MemoryMXBean MemoryManagerMXBean MemoryNotificationInfo MemoryPoolMXBean MemoryType MemoryUsage Menu MenuBar MenuBarUI MenuComponent MenuContainer MenuDragMouseEvent MenuDragMouseListener MenuElement MenuEvent MenuItem MenuItemUI MenuKeyEvent MenuKeyListener MenuListener MenuSelectionManager MenuShortcut MessageDigest MessageDigestSpi MessageFormat MessageFormat.Field MessageProp MetaEventListener MetaMessage MetalBorders MetalBorders.ButtonBorder MetalBorders.Flush3DBorder MetalBorders.InternalFrameBorder MetalBorders.MenuBarBorder MetalBorders.MenuItemBorder MetalBorders.OptionDialogBorder MetalBorders.PaletteBorder MetalBorders.PopupMenuBorder MetalBorders.RolloverButtonBorder MetalBorders.ScrollPaneBorder MetalBorders.TableHeaderBorder MetalBorders.TextFieldBorder MetalBorders.ToggleButtonBorder MetalBorders.ToolBarBorder MetalButtonUI MetalCheckBoxIcon MetalCheckBoxUI MetalComboBoxButton MetalComboBoxEditor MetalComboBoxEditor.UIResource MetalComboBoxIcon MetalComboBoxUI MetalDesktopIconUI MetalFileChooserUI MetalIconFactory MetalIconFactory.FileIcon16 MetalIconFactory.FolderIcon16 MetalIconFactory.PaletteCloseIcon MetalIconFactory.TreeControlIcon MetalIconFactory.TreeFolderIcon MetalIconFactory.TreeLeafIcon MetalInternalFrameTitlePane MetalInternalFrameUI MetalLabelUI MetalLookAndFeel MetalMenuBarUI MetalPopupMenuSeparatorUI MetalProgressBarUI MetalRadioButtonUI MetalRootPaneUI MetalScrollBarUI MetalScrollButton MetalScrollPaneUI MetalSeparatorUI MetalSliderUI MetalSplitPaneUI MetalTabbedPaneUI MetalTextFieldUI MetalTheme MetalToggleButtonUI MetalToolBarUI MetalToolTipUI MetalTreeUI Method MethodDescriptor MidiChannel MidiDevice MidiDevice.Info MidiDeviceProvider MidiEvent MidiFileFormat MidiFileReader MidiFileWriter MidiMessage MidiSystem MidiUnavailableException MimeTypeParseException MinimalHTMLWriter MissingFormatArgumentException MissingFormatWidthException MissingResourceException Mixer Mixer.Info MixerProvider ModelMBean ModelMBeanAttributeInfo ModelMBeanConstructorInfo ModelMBeanInfo ModelMBeanInfoSupport ModelMBeanNotificationBroadcaster ModelMBeanNotificationInfo ModelMBeanOperationInfo ModificationItem Modifier Monitor MonitorMBean MonitorNotification MonitorSettingException MouseAdapter MouseDragGestureRecognizer MouseEvent MouseInfo MouseInputAdapter MouseInputListener MouseListener MouseMotionAdapter MouseMotionListener MouseWheelEvent MouseWheelListener MultiButtonUI MultiColorChooserUI MultiComboBoxUI MultiDesktopIconUI MultiDesktopPaneUI MultiDoc MultiDocPrintJob MultiDocPrintService MultiFileChooserUI MultiInternalFrameUI MultiLabelUI MultiListUI MultiLookAndFeel MultiMenuBarUI MultiMenuItemUI MultiOptionPaneUI MultiPanelUI MultiPixelPackedSampleModel MultiPopupMenuUI MultiProgressBarUI MultiRootPaneUI MultiScrollBarUI MultiScrollPaneUI MultiSeparatorUI MultiSliderUI MultiSpinnerUI MultiSplitPaneUI MultiTabbedPaneUI MultiTableHeaderUI MultiTableUI MultiTextUI MultiToolBarUI MultiToolTipUI MultiTreeUI MultiViewportUI MulticastSocket MultipleComponentProfileHelper MultipleComponentProfileHolder MultipleDocumentHandling MultipleMaster MutableAttributeSet MutableComboBoxModel MutableTreeNode NON_EXISTENT NO_IMPLEMENT NO_MEMORY NO_PERMISSION NO_RESOURCES NO_RESPONSE NVList Name NameAlreadyBoundException NameCallback NameClassPair NameComponent NameComponentHelper NameComponentHolder NameDynAnyPair NameDynAnyPairHelper NameDynAnyPairSeqHelper NameHelper NameHolder NameList NameNotFoundException NameParser NameValuePair NameValuePair NameValuePairHelper NameValuePairHelper NameValuePairSeqHelper NamedNodeMap NamedValue NamespaceChangeListener NamespaceContext NamespaceSupport Naming NamingContext NamingContextExt NamingContextExtHelper NamingContextExtHolder NamingContextExtOperations NamingContextExtPOA NamingContextHelper NamingContextHolder NamingContextOperations NamingContextPOA NamingEnumeration NamingEvent NamingException NamingExceptionEvent NamingListener NamingManager NamingSecurityException NavigationFilter NavigationFilter.FilterBypass NegativeArraySizeException NetPermission NetworkInterface NoClassDefFoundError NoConnectionPendingException NoContext NoContextHelper NoInitialContextException NoPermissionException NoRouteToHostException NoServant NoServantHelper NoSuchAlgorithmException NoSuchAttributeException NoSuchElementException NoSuchFieldError NoSuchFieldException NoSuchMethodError NoSuchMethodException NoSuchObjectException NoSuchPaddingException NoSuchProviderException Node NodeChangeEvent NodeChangeListener NodeList NonReadableChannelException NonWritableChannelException NoninvertibleTransformException NotActiveException NotBoundException NotCompliantMBeanException NotContextException NotEmpty NotEmptyHelper NotEmptyHolder NotFound NotFoundHelper NotFoundHolder NotFoundReason NotFoundReasonHelper NotFoundReasonHolder NotOwnerException NotSerializableException NotYetBoundException NotYetConnectedException Notation Notification NotificationBroadcaster NotificationBroadcasterSupport NotificationEmitter NotificationFilter NotificationFilterSupport NotificationListener NotificationResult NullCipher NullPointerException Number NumberFormat NumberFormat.Field NumberFormatException NumberFormatter NumberOfDocuments NumberOfInterveningJobs NumberUp NumberUpSupported NumericShaper OAEPParameterSpec OBJECT_NOT_EXIST OBJ_ADAPTER OMGVMCID ORB ORB ORBIdHelper ORBInitInfo ORBInitInfoOperations ORBInitializer ORBInitializerOperations ObjID Object Object ObjectAlreadyActive ObjectAlreadyActiveHelper ObjectChangeListener ObjectFactory ObjectFactoryBuilder ObjectHelper ObjectHolder ObjectIdHelper ObjectIdHelper ObjectImpl ObjectImpl ObjectInput ObjectInputStream ObjectInputStream.GetField ObjectInputValidation ObjectInstance ObjectName ObjectNotActive ObjectNotActiveHelper ObjectOutput ObjectOutputStream ObjectOutputStream.PutField ObjectReferenceFactory ObjectReferenceFactoryHelper ObjectReferenceFactoryHolder ObjectReferenceTemplate ObjectReferenceTemplateHelper ObjectReferenceTemplateHolder ObjectReferenceTemplateSeqHelper ObjectReferenceTemplateSeqHolder ObjectStreamClass ObjectStreamConstants ObjectStreamException ObjectStreamField ObjectView Observable Observer OceanTheme OctetSeqHelper OctetSeqHolder Oid OpenDataException OpenMBeanAttributeInfo OpenMBeanAttributeInfoSupport OpenMBeanConstructorInfo OpenMBeanConstructorInfoSupport OpenMBeanInfo OpenMBeanInfoSupport OpenMBeanOperationInfo OpenMBeanOperationInfoSupport OpenMBeanParameterInfo OpenMBeanParameterInfoSupport OpenType OpenType OperatingSystemMXBean Operation OperationNotSupportedException OperationsException Option OptionPaneUI OptionalDataException OrientationRequested OutOfMemoryError OutputDeviceAssigned OutputKeys OutputStream OutputStream OutputStream OutputStreamWriter OverlappingFileLockException OverlayLayout Override Owner PBEKey PBEKeySpec PBEParameterSpec PDLOverrideSupported PERSIST_STORE PKCS8EncodedKeySpec PKIXBuilderParameters PKIXCertPathBuilderResult PKIXCertPathChecker PKIXCertPathValidatorResult PKIXParameters POA POAHelper POAManager POAManagerOperations POAOperations PRIVATE_MEMBER PSSParameterSpec PSource PSource.PSpecified PUBLIC_MEMBER Pack200 Pack200.Packer Pack200.Unpacker Package PackedColorModel PageAttributes PageAttributes.ColorType PageAttributes.MediaType PageAttributes.OrientationRequestedType PageAttributes.OriginType PageAttributes.PrintQualityType PageFormat PageRanges Pageable PagedResultsControl PagedResultsResponseControl PagesPerMinute PagesPerMinuteColor Paint PaintContext PaintEvent Panel PanelUI Paper ParagraphView ParagraphView Parameter ParameterBlock ParameterDescriptor ParameterMetaData ParameterMode ParameterModeHelper ParameterModeHolder ParameterizedType ParseException ParsePosition Parser Parser ParserAdapter ParserConfigurationException ParserDelegator ParserFactory PartialResultException PasswordAuthentication PasswordCallback PasswordView Patch PathIterator Pattern PatternSyntaxException Permission Permission PermissionCollection Permissions PersistenceDelegate PersistentMBean PhantomReference Pipe Pipe.SinkChannel Pipe.SourceChannel PipedInputStream PipedOutputStream PipedReader PipedWriter PixelGrabber PixelInterleavedSampleModel PlainDocument PlainView Point Point2D Point2D.Double Point2D.Float PointerInfo Policy Policy Policy PolicyError PolicyErrorCodeHelper PolicyErrorHelper PolicyErrorHolder PolicyFactory PolicyFactoryOperations PolicyHelper PolicyHolder PolicyListHelper PolicyListHolder PolicyNode PolicyOperations PolicyQualifierInfo PolicyTypeHelper Polygon PooledConnection Popup PopupFactory PopupMenu PopupMenuEvent PopupMenuListener PopupMenuUI Port Port.Info PortUnreachableException PortableRemoteObject PortableRemoteObjectDelegate Position Position.Bias Predicate PreferenceChangeEvent PreferenceChangeListener Preferences PreferencesFactory PreparedStatement PresentationDirection Principal Principal PrincipalHolder PrintEvent PrintException PrintGraphics PrintJob PrintJobAdapter PrintJobAttribute PrintJobAttributeEvent PrintJobAttributeListener PrintJobAttributeSet PrintJobEvent PrintJobListener PrintQuality PrintRequestAttribute PrintRequestAttributeSet PrintService PrintServiceAttribute PrintServiceAttributeEvent PrintServiceAttributeListener PrintServiceAttributeSet PrintServiceLookup PrintStream PrintWriter Printable PrinterAbortException PrinterException PrinterGraphics PrinterIOException PrinterInfo PrinterIsAcceptingJobs PrinterJob PrinterLocation PrinterMakeAndModel PrinterMessageFromOperator PrinterMoreInfo PrinterMoreInfoManufacturer PrinterName PrinterResolution PrinterState PrinterStateReason PrinterStateReasons PrinterURI PriorityBlockingQueue PriorityQueue PrivateClassLoader PrivateCredentialPermission PrivateKey PrivateMLet PrivilegedAction PrivilegedActionException PrivilegedExceptionAction Process ProcessBuilder ProcessingInstruction ProfileDataException ProfileIdHelper ProgressBarUI ProgressMonitor ProgressMonitorInputStream Properties PropertyChangeEvent PropertyChangeListener PropertyChangeListenerProxy PropertyChangeSupport PropertyDescriptor PropertyEditor PropertyEditorManager PropertyEditorSupport PropertyPermission PropertyResourceBundle PropertyVetoException ProtectionDomain ProtocolException Provider Provider.Service ProviderException Proxy Proxy Proxy.Type ProxySelector PublicKey PushbackInputStream PushbackReader QName QuadCurve2D QuadCurve2D.Double QuadCurve2D.Float Query QueryEval QueryExp Queue QueuedJobCount RC2ParameterSpec RC5ParameterSpec REBIND REQUEST_PROCESSING_POLICY_ID RGBImageFilter RMIClassLoader RMIClassLoaderSpi RMIClientSocketFactory RMIConnection RMIConnectionImpl RMIConnectionImpl_Stub RMIConnector RMIConnectorServer RMICustomMaxStreamFormat RMIFailureHandler RMIIIOPServerImpl RMIJRMPServerImpl RMISecurityException RMISecurityManager RMIServer RMIServerImpl RMIServerImpl_Stub RMIServerSocketFactory RMISocketFactory RSAKey RSAKeyGenParameterSpec RSAMultiPrimePrivateCrtKey RSAMultiPrimePrivateCrtKeySpec RSAOtherPrimeInfo RSAPrivateCrtKey RSAPrivateCrtKeySpec RSAPrivateKey RSAPrivateKeySpec RSAPublicKey RSAPublicKeySpec RTFEditorKit Random RandomAccess RandomAccessFile Raster RasterFormatException RasterOp Rdn ReadOnlyBufferException ReadWriteLock Readable ReadableByteChannel Reader RealmCallback RealmChoiceCallback Receiver Rectangle Rectangle2D Rectangle2D.Double Rectangle2D.Float RectangularShape ReentrantLock ReentrantReadWriteLock ReentrantReadWriteLock.ReadLock ReentrantReadWriteLock.WriteLock Ref RefAddr Reference Reference ReferenceQueue ReferenceUriSchemesSupported Referenceable ReferralException ReflectPermission ReflectionException RefreshFailedException Refreshable Region RegisterableService Registry RegistryHandler RejectedExecutionException RejectedExecutionHandler Relation RelationException RelationNotFoundException RelationNotification RelationService RelationServiceMBean RelationServiceNotRegisteredException RelationSupport RelationSupportMBean RelationType RelationTypeNotFoundException RelationTypeSupport RemarshalException Remote RemoteCall RemoteException RemoteObject RemoteObjectInvocationHandler RemoteRef RemoteServer RemoteStub RenderContext RenderableImage RenderableImageOp RenderableImageProducer RenderedImage RenderedImageFactory Renderer RenderingHints RenderingHints.Key RepaintManager ReplicateScaleFilter RepositoryIdHelper Request RequestInfo RequestInfoOperations RequestProcessingPolicy RequestProcessingPolicyOperations RequestProcessingPolicyValue RequestingUserName RequiredModelMBean RescaleOp ResolutionSyntax ResolveResult Resolver ResourceBundle ResponseCache ResponseHandler Result ResultSet ResultSetMetaData Retention RetentionPolicy ReverbType Robot Role RoleInfo RoleInfoNotFoundException RoleList RoleNotFoundException RoleResult RoleStatus RoleUnresolved RoleUnresolvedList RootPaneContainer RootPaneUI RoundRectangle2D RoundRectangle2D.Double RoundRectangle2D.Float RoundingMode RowMapper RowSet RowSetEvent RowSetInternal RowSetListener RowSetMetaData RowSetMetaDataImpl RowSetReader RowSetWarning RowSetWriter RuleBasedCollator RunTime RunTimeOperations Runnable Runtime RuntimeErrorException RuntimeException RuntimeMBeanException RuntimeMXBean RuntimeOperationsException RuntimePermission SAXException SAXNotRecognizedException SAXNotSupportedException SAXParseException SAXParser SAXParserFactory SAXResult SAXSource SAXTransformerFactory SERVANT_RETENTION_POLICY_ID SQLData SQLException SQLInput SQLInputImpl SQLOutput SQLOutputImpl SQLPermission SQLWarning SSLContext SSLContextSpi SSLEngine SSLEngineResult SSLEngineResult.HandshakeStatus SSLEngineResult.Status SSLException SSLHandshakeException SSLKeyException SSLPeerUnverifiedException SSLPermission SSLProtocolException SSLServerSocket SSLServerSocketFactory SSLSession SSLSessionBindingEvent SSLSessionBindingListener SSLSessionContext SSLSocket SSLSocketFactory SUCCESSFUL SYNC_WITH_TRANSPORT SYSTEM_EXCEPTION SampleModel Sasl SaslClient SaslClientFactory SaslException SaslServer SaslServerFactory Savepoint Scanner ScatteringByteChannel ScheduledExecutorService ScheduledFuture ScheduledThreadPoolExecutor Schema SchemaFactory SchemaFactoryLoader SchemaViolationException ScrollBarUI ScrollPane ScrollPaneAdjustable ScrollPaneConstants ScrollPaneLayout ScrollPaneLayout.UIResource ScrollPaneUI Scrollable Scrollbar SealedObject SearchControls SearchResult SecretKey SecretKeyFactory SecretKeyFactorySpi SecretKeySpec SecureCacheResponse SecureClassLoader SecureRandom SecureRandomSpi Security SecurityException SecurityManager SecurityPermission Segment SelectableChannel SelectionKey Selector SelectorProvider Semaphore SeparatorUI Sequence SequenceInputStream Sequencer Sequencer.SyncMode SerialArray SerialBlob SerialClob SerialDatalink SerialException SerialJavaObject SerialRef SerialStruct Serializable SerializablePermission Servant ServantActivator ServantActivatorHelper ServantActivatorOperations ServantActivatorPOA ServantAlreadyActive ServantAlreadyActiveHelper ServantLocator ServantLocatorHelper ServantLocatorOperations ServantLocatorPOA ServantManager ServantManagerOperations ServantNotActive ServantNotActiveHelper ServantObject ServantRetentionPolicy ServantRetentionPolicyOperations ServantRetentionPolicyValue ServerCloneException ServerError ServerException ServerIdHelper ServerNotActiveException ServerRef ServerRequest ServerRequestInfo ServerRequestInfoOperations ServerRequestInterceptor ServerRequestInterceptorOperations ServerRuntimeException ServerSocket ServerSocketChannel ServerSocketFactory ServiceContext ServiceContextHelper ServiceContextHolder ServiceContextListHelper ServiceContextListHolder ServiceDetail ServiceDetailHelper ServiceIdHelper ServiceInformation ServiceInformationHelper ServiceInformationHolder ServiceNotFoundException ServicePermission ServiceRegistry ServiceRegistry.Filter ServiceUI ServiceUIFactory ServiceUnavailableException Set SetOfIntegerSyntax SetOverrideType SetOverrideTypeHelper Severity Shape ShapeGraphicAttribute SheetCollate Short ShortBuffer ShortBufferException ShortHolder ShortLookupTable ShortMessage ShortSeqHelper ShortSeqHolder Sides Signature SignatureException SignatureSpi SignedObject Signer SimpleAttributeSet SimpleBeanInfo SimpleDateFormat SimpleDoc SimpleFormatter SimpleTimeZone SimpleType SinglePixelPackedSampleModel SingleSelectionModel Size2DSyntax SizeLimitExceededException SizeRequirements SizeSequence Skeleton SkeletonMismatchException SkeletonNotFoundException SliderUI Socket SocketAddress SocketChannel SocketException SocketFactory SocketHandler SocketImpl SocketImplFactory SocketOptions SocketPermission SocketSecurityException SocketTimeoutException SoftBevelBorder SoftReference SortControl SortKey SortResponseControl SortedMap SortedSet SortingFocusTraversalPolicy Soundbank SoundbankReader SoundbankResource Source SourceDataLine SourceLocator SpinnerDateModel SpinnerListModel SpinnerModel SpinnerNumberModel SpinnerUI SplitPaneUI Spring SpringLayout SpringLayout.Constraints SslRMIClientSocketFactory SslRMIServerSocketFactory Stack StackOverflowError StackTraceElement StandardMBean StartTlsRequest StartTlsResponse State StateEdit StateEditable StateFactory Statement Statement StreamCorruptedException StreamHandler StreamPrintService StreamPrintServiceFactory StreamResult StreamSource StreamTokenizer Streamable StreamableValue StrictMath String StringBuffer StringBufferInputStream StringBuilder StringCharacterIterator StringContent StringHolder StringIndexOutOfBoundsException StringMonitor StringMonitorMBean StringNameHelper StringReader StringRefAddr StringSelection StringSeqHelper StringSeqHolder StringTokenizer StringValueExp StringValueHelper StringWriter Stroke Struct StructMember StructMemberHelper Stub StubDelegate StubNotFoundException Style StyleConstants StyleConstants.CharacterConstants StyleConstants.ColorConstants StyleConstants.FontConstants StyleConstants.ParagraphConstants StyleContext StyleSheet StyleSheet.BoxPainter StyleSheet.ListPainter StyledDocument StyledEditorKit StyledEditorKit.AlignmentAction StyledEditorKit.BoldAction StyledEditorKit.FontFamilyAction StyledEditorKit.FontSizeAction StyledEditorKit.ForegroundAction StyledEditorKit.ItalicAction StyledEditorKit.StyledTextAction StyledEditorKit.UnderlineAction Subject SubjectDelegationPermission SubjectDomainCombiner SupportedValuesAttribute SuppressWarnings SwingConstants SwingPropertyChangeSupport SwingUtilities SyncFactory SyncFactoryException SyncFailedException SyncProvider SyncProviderException SyncResolver SyncScopeHelper SynchronousQueue SynthConstants SynthContext SynthGraphicsUtils SynthLookAndFeel SynthPainter SynthStyle SynthStyleFactory Synthesizer SysexMessage System SystemColor SystemException SystemFlavorMap TAG_ALTERNATE_IIOP_ADDRESS TAG_CODE_SETS TAG_INTERNET_IOP TAG_JAVA_CODEBASE TAG_MULTIPLE_COMPONENTS TAG_ORB_TYPE TAG_POLICIES TAG_RMI_CUSTOM_MAX_STREAM_FORMAT TCKind THREAD_POLICY_ID TIMEOUT TRANSACTION_MODE TRANSACTION_REQUIRED TRANSACTION_ROLLEDBACK TRANSACTION_UNAVAILABLE TRANSIENT TRANSPORT_RETRY TabExpander TabSet TabStop TabableView TabbedPaneUI TableCellEditor TableCellRenderer TableColumn TableColumnModel TableColumnModelEvent TableColumnModelListener TableHeaderUI TableModel TableModelEvent TableModelListener TableUI TableView TabularData TabularDataSupport TabularType TagElement TaggedComponent TaggedComponentHelper TaggedComponentHolder TaggedProfile TaggedProfileHelper TaggedProfileHolder Target TargetDataLine TargetedNotification Templates TemplatesHandler Text TextAction TextArea TextAttribute TextComponent TextEvent TextField TextHitInfo TextInputCallback TextLayout TextLayout.CaretPolicy TextListener TextMeasurer TextOutputCallback TextSyntax TextUI TexturePaint Thread Thread.State Thread.UncaughtExceptionHandler ThreadDeath ThreadFactory ThreadGroup ThreadInfo ThreadLocal ThreadMXBean ThreadPolicy ThreadPolicyOperations ThreadPolicyValue ThreadPoolExecutor ThreadPoolExecutor.AbortPolicy ThreadPoolExecutor.CallerRunsPolicy ThreadPoolExecutor.DiscardOldestPolicy ThreadPoolExecutor.DiscardPolicy Throwable Tie TileObserver Time TimeLimitExceededException TimeUnit TimeZone TimeoutException Timer Timer Timer TimerAlarmClockNotification TimerMBean TimerNotification TimerTask Timestamp Timestamp TitledBorder TooManyListenersException ToolBarUI ToolTipManager ToolTipUI Toolkit Track TransactionRequiredException TransactionRolledbackException TransactionService TransactionalWriter TransferHandler Transferable TransformAttribute Transformer TransformerConfigurationException TransformerException TransformerFactory TransformerFactoryConfigurationError TransformerHandler Transmitter Transparency TreeCellEditor TreeCellRenderer TreeExpansionEvent TreeExpansionListener TreeMap TreeModel TreeModelEvent TreeModelListener TreeNode TreePath TreeSelectionEvent TreeSelectionListener TreeSelectionModel TreeSet TreeUI TreeWillExpandListener TrustAnchor TrustManager TrustManagerFactory TrustManagerFactorySpi Type TypeCode TypeCodeHolder TypeInfo TypeInfoProvider TypeMismatch TypeMismatch TypeMismatch TypeMismatchHelper TypeMismatchHelper TypeNotPresentException TypeVariable Types UID UIDefaults UIDefaults.ActiveValue UIDefaults.LazyInputMap UIDefaults.LazyValue UIDefaults.ProxyLazyValue UIManager UIManager.LookAndFeelInfo UIResource ULongLongSeqHelper ULongLongSeqHolder ULongSeqHelper ULongSeqHolder UNKNOWN UNKNOWN UNSUPPORTED_POLICY UNSUPPORTED_POLICY_VALUE URI URIException URIResolver URISyntax URISyntaxException URL URLClassLoader URLConnection URLDecoder URLEncoder URLStreamHandler URLStreamHandlerFactory URLStringHelper USER_EXCEPTION UShortSeqHelper UShortSeqHolder UTFDataFormatException UUID UndeclaredThrowableException UndoManager UndoableEdit UndoableEditEvent UndoableEditListener UndoableEditSupport UnexpectedException UnicastRemoteObject UnionMember UnionMemberHelper UnknownEncoding UnknownEncodingHelper UnknownError UnknownException UnknownFormatConversionException UnknownFormatFlagsException UnknownGroupException UnknownHostException UnknownHostException UnknownObjectException UnknownServiceException UnknownUserException UnknownUserExceptionHelper UnknownUserExceptionHolder UnmappableCharacterException UnmarshalException UnmodifiableClassException UnmodifiableSetException UnrecoverableEntryException UnrecoverableKeyException Unreferenced UnresolvedAddressException UnresolvedPermission UnsatisfiedLinkError UnsolicitedNotification UnsolicitedNotificationEvent UnsolicitedNotificationListener UnsupportedAddressTypeException UnsupportedAudioFileException UnsupportedCallbackException UnsupportedCharsetException UnsupportedClassVersionError UnsupportedEncodingException UnsupportedFlavorException UnsupportedLookAndFeelException UnsupportedOperationException UserDataHandler UserException Util UtilDelegate Utilities VMID VM_ABSTRACT VM_CUSTOM VM_NONE VM_TRUNCATABLE Validator ValidatorHandler ValueBase ValueBaseHelper ValueBaseHolder ValueExp ValueFactory ValueHandler ValueHandlerMultiFormat ValueInputStream ValueMember ValueMemberHelper ValueOutputStream VariableHeightLayoutCache Vector VerifyError VersionSpecHelper VetoableChangeListener VetoableChangeListenerProxy VetoableChangeSupport View ViewFactory ViewportLayout ViewportUI VirtualMachineError Visibility VisibilityHelper VoiceStatus Void VolatileImage WCharSeqHelper WCharSeqHolder WStringSeqHelper WStringSeqHolder WStringValueHelper WeakHashMap WeakReference WebRowSet WildcardType Window WindowAdapter WindowConstants WindowEvent WindowFocusListener WindowListener WindowStateListener WrappedPlainView WritableByteChannel WritableRaster WritableRenderedImage WriteAbortedException Writer WrongAdapter WrongAdapterHelper WrongPolicy WrongPolicyHelper WrongTransaction WrongTransactionHelper WrongTransactionHolder X500Principal X500PrivateCredential X509CRL X509CRLEntry X509CRLSelector X509CertSelector X509Certificate X509Certificate X509EncodedKeySpec X509ExtendedKeyManager X509Extension X509KeyManager X509TrustManager XAConnection XADataSource XAException XAResource XMLConstants XMLDecoder XMLEncoder XMLFilter XMLFilterImpl XMLFormatter XMLGregorianCalendar XMLParseException XMLReader XMLReaderAdapter XMLReaderFactory XPath XPathConstants XPathException XPathExpression XPathExpressionException XPathFactory XPathFactoryConfigurationException XPathFunction XPathFunctionException XPathFunctionResolver XPathVariableResolver Xid XmlReader XmlWriter ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream ZoneView _BindingIteratorImplBase _BindingIteratorStub _DynAnyFactoryStub _DynAnyStub _DynArrayStub _DynEnumStub _DynFixedStub _DynSequenceStub _DynStructStub _DynUnionStub _DynValueStub _IDLTypeStub _NamingContextExtStub _NamingContextImplBase _NamingContextStub _PolicyStub _Remote_Stub _ServantActivatorStub _ServantLocatorStub AbstractAnnotationValueVisitor6 AbstractElementVisitor6 AbstractMarshallerImpl AbstractOwnableSynchronizer AbstractProcessor AbstractQueuedLongSynchronizer AbstractScriptEngine AbstractTypeVisitor6 AbstractUnmarshallerImpl ActivationDataFlavor AlgorithmMethod AnnotationMirror AnnotationValue AnnotationValueVisitor ArrayDeque AsyncHandler AttachmentMarshaller AttachmentPart AttachmentUnmarshaller Binder BindingProvider Bindings BlockingDeque BreakIteratorProvider C14NMethodParameterSpec CanonicalizationMethod Characters ClientInfoStatus CollapsedStringAdapter CollatorProvider CommandInfo CommandMap CommandObject CommonDataSource Compilable CompiledScript Completion Completions CompositeDataInvocationHandler CompositeDataView ConcurrentNavigableMap ConcurrentSkipListMap ConcurrentSkipListSet ConfigurationSpi Console ConstructorProperties CookieManager CookiePolicy CookieStore CurrencyNameProvider Data DataContentHandler DataContentHandlerFactory DataHandler DatatypeConverter DatatypeConverterInterface DateFormatProvider DateFormatSymbolsProvider DecimalFormatSymbolsProvider DeclaredType DefaultRowSorter DefaultValidationEventHandler DeflaterInputStream Deque DescriptorKey DescriptorRead Desktop Detail DetailEntry Diagnostic DiagnosticCollector DiagnosticListener DigestMethod DigestMethodParameterSpec Dispatch DOMCryptoContext DomHandler DOMSignContext DOMStructure DOMURIReference DOMValidateContext DropMode ElementFilter ElementKind ElementKindVisitor6 Elements ElementScanner6 ElementVisitor EndDocument EndElement Endpoint EntityDeclaration ErrorType EventException EventFilter EventReaderDelegate EventTarget ExcC14NParameterSpec ExecutableElement ExecutableType FileDataSource FileNameExtensionFilter FileObject Filer FilerException FileTypeMap ForwardingFileObject ForwardingJavaFileManager ForwardingJavaFileObject Generated GridBagLayoutInfo GroupLayout HandlerChain HandlerResolver HexBinaryAdapter HMACParameterSpec Holder HTTPBinding HttpCookie HTTPException IDN ImmutableDescriptor InflaterOutputStream InitParam InterfaceAddress Invocable IOError JavaCompiler JavaFileManager JavaFileObject JAXBContext JAXBElement JAXBException JAXBIntrospector JAXBResult JAXBSource JMX JMXAddressable KeyInfo KeyInfoFactory KeyName KeySelector KeySelectorException KeySelectorResult KeyValue LayoutPath LayoutStyle LinearGradientPaint LinkedBlockingDeque LocaleNameProvider LocaleServiceProvider Location LockInfo LogicalHandler LogicalMessage LogicalMessageContext MailcapCommandMap Marshaller MessageContext MessageFactory Messager MimeHeader MimeHeaders MimeType MimeTypeParameterList MimetypesFileTypeMap MirroredTypeException MirroredTypesException MLetContent MonitorInfo MultipleGradientPaint MutationEvent MXBean Namespace NavigableMap NavigableSet NClob NestingKind NodeSetData NormalizedStringAdapter Normalizer NoSuchMechanismException NotationDeclaration NotIdentifiableEvent NotIdentifiableEventImpl NoType NullType NumberFormatProvider OctetStreamData Oneway OptionChecker PackageElement ParseConversionEvent ParseConversionEventImpl Path2D PGPData PolicySpi PortInfo PostConstruct PreDestroy PrimitiveType PrintConversionEvent PrintConversionEventImpl ProcessingEnvironment Processor PropertyException RadialGradientPaint ReferenceType RequestWrapper Resource Resources Response ResponseWrapper RetrievalMethod RoundEnvironment RowFilter RowId RowIdLifetime RowSorter RowSorterEvent RowSorterListener RunnableFuture RunnableScheduledFuture SAAJMetaFactory SAAJResult SchemaOutputResolver ScriptContext ScriptEngine ScriptEngineFactory ScriptEngineManager ScriptException Service ServiceConfigurationError ServiceDelegate ServiceLoader ServiceMode SignatureMethod SignatureMethodParameterSpec SignatureProperties SignatureProperty SignedInfo SimpleAnnotationValueVisitor6 SimpleBindings SimpleElementVisitor6 SimpleJavaFileObject SimpleScriptContext SimpleTypeVisitor6 SOAPBinding SOAPBinding SOAPBody SOAPBodyElement SOAPConnection SOAPConnectionFactory SOAPConstants SOAPElement SOAPElementFactory SOAPEnvelope SOAPException SOAPFactory SOAPFault SOAPFaultElement SOAPFaultException SOAPHandler SOAPHeader SOAPHeaderElement SOAPMessage SOAPMessageContext SOAPMessageHandler SOAPMessageHandlers SOAPPart SortOrder SourceVersion SplashScreen SQLClientInfoException SQLDataException SQLFeatureNotSupportedException SQLIntegrityConstraintViolationException SQLInvalidAuthorizationSpecException SQLNonTransientConnectionException SQLNonTransientException SQLRecoverableException SQLSyntaxErrorException SQLTimeoutException SQLTransactionRollbackException SQLTransientConnectionException SQLTransientException SQLXML SSLParameters StandardEmitterMBean StandardJavaFileManager StandardLocation StartDocument StartElement StatementEvent StatementEventListener StAXResult StAXSource StreamFilter StreamReaderDelegate SupportedAnnotationTypes SupportedOptions SupportedSourceVersion SwingWorker SystemTray TableRowSorter TableStringConverter TimeZoneNameProvider Tool ToolProvider Transform TransformException TransformParameterSpec TransformService TrayIcon TypeConstraintException TypeElement TypeKind TypeKindVisitor6 TypeMirror TypeParameterElement TypeVisitor UIEvent UnknownAnnotationValueException UnknownElementException UnknownTypeException Unmarshaller UnmarshallerHandler UnsupportedDataTypeException URIDereferencer URIParameter URIReference URIReferenceException URLDataSource ValidationEvent ValidationEventCollector ValidationEventHandler ValidationEventImpl ValidationEventLocator ValidationEventLocatorImpl ValidationException VariableElement W3CDomHandler WebEndpoint WebFault WebMethod WebParam WebResult WebService WebServiceClient WebServiceContext WebServiceException WebServicePermission WebServiceProvider WebServiceRef WebServiceRefs Wrapper X509Data X509IssuerSerial XmlAccessOrder XmlAccessorOrder XmlAccessorType XmlAccessType XmlAdapter XmlAnyAttribute XmlAnyElement XmlAttachmentRef XmlAttribute XMLCryptoContext XmlElement XmlElementDecl XmlElementRef XmlElementRefs XmlElements XmlElementWrapper XmlEnum XmlEnumValue XMLEvent XMLEventAllocator XMLEventConsumer XMLEventFactory XMLEventReader XMLEventWriter XmlID XmlIDREF XmlInlineBinaryData XMLInputFactory XmlJavaTypeAdapter XmlJavaTypeAdapters XmlList XmlMimeType XmlMixed XmlNs XmlNsForm XMLObject XMLOutputFactory XmlRegistry XMLReporter XMLResolver XmlRootElement XmlSchema XmlSchemaType XmlSchemaTypes XMLSignature XMLSignatureException XMLSignatureFactory XMLSignContext XMLStreamConstants XMLStreamException XMLStreamReader XMLStreamWriter XMLStructure XmlTransient XmlType XMLValidateContext XmlValue XPathFilter2ParameterSpec XPathFilterParameterSpec XPathType XSLTTransformParameterSpec ZipError" list_keywords = Set.fromList $ words $ "abstract break case catch class continue default do else enum extends false finally for goto if implements instanceof @interface interface native new null private protected public return super strictfp switch synchronized this throws throw transient true try volatile while"@@ -99,124 +89,114 @@ regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 = compileRegex "\\b[_a-zA-Z]\\w*(?=[\\s]*)" regex_'5cs'2a'2e'2a'3b = compileRegex "\\s*.*;" -defaultAttributes = [("Normal","Normal Text"),("InFunctionCall","Normal Text"),("String","String"),("EnterPrintf","Normal Text"),("Printf","Printf"),("PrintfString","PrintfString"),("Member","Normal Text"),("StaticImports","Normal Text"),("Imports","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment")]+defaultAttributes = [("Normal",NormalTok),("InFunctionCall",NormalTok),("String",StringTok),("EnterPrintf",NormalTok),("Printf",NormalTok),("PrintfString",StringTok),("Member",NormalTok),("StaticImports",NormalTok),("Imports",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java15 >>= withAttribute "Java15"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") ((pString False "L" >>= withAttribute "Decimal")))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'27'5c'5cu'5b0'2d9a'2dfA'2dF'5d'7b4'7d'27 >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'5c'2e'28format'7cprintf'29'5cb >>= withAttribute "Function") >>~ pushContext "EnterPrintf")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pRegExpr regex_'5c'2e'7b3'2c3'7d'5cs'2b >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28import'5cs'2bstatic'29'5cb >>= withAttribute "Keyword") >>~ pushContext "StaticImports")- <|>- ((pRegExpr regex_'5cb'28package'7cimport'29'5cb >>= withAttribute "Keyword") >>~ pushContext "Imports")- <|>- ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute "Symbol") >>~ pushContext "Member")- <|>- ((pDetectChar False '(' >>= withAttribute "Symbol") >>~ pushContext "InFunctionCall")- <|>- ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java15 >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) ((pString False "L" >>= withAttribute DecValTok)))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'27'5c'5cu'5b0'2d9a'2dfA'2dF'5d'7b4'7d'27 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'5c'2e'28format'7cprintf'29'5cb >>= withAttribute FunctionTok) >>~ pushContext "EnterPrintf")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2e'7b3'2c3'7d'5cs'2b >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28import'5cs'2bstatic'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "StaticImports")+ <|>+ ((pRegExpr regex_'5cb'28package'7cimport'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "Imports")+ <|>+ ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute NormalTok) >>~ pushContext "Member")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "InFunctionCall")+ <|>+ ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "InFunctionCall" = - do (attr, result) <- (((parseRules "Normal"))- <|>- ((pDetectChar False ')' >>= withAttribute "Symbol") >>~ (popContext)))- return (attr, result)+parseRules "InFunctionCall" =+ (((parseRules "Normal"))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'5c'5cu'5b0'2d9a'2dfA'2dF'5d'7b4'7d >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5cu'5b0'2d9a'2dfA'2dF'5d'7b4'7d >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "EnterPrintf" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Symbol") >>~ pushContext "Printf")- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "EnterPrintf" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Printf")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Printf" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "PrintfString")- <|>- ((parseRules "InFunctionCall")))- return (attr, result)+parseRules "Printf" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "PrintfString")+ <|>+ ((parseRules "InFunctionCall"))) -parseRules "PrintfString" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28'5c'2e'5cd'2b'29'3f'5ba'2dhosxA'2dCEGHSX'5d >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28t'7cT'29'28a'7cA'7cb'7cB'7cc'7cC'7cd'7cD'7ce'7cF'7ch'7cH'7cI'7cj'7ck'7cl'7cL'7cm'7cM'7cN'7cp'7cP'7cQ'7cr'7cR'7cs'7cS'7cT'7cy'7cY'7cz'7cZ'29 >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'28'25'7cn'29 >>= withAttribute "String Char")))- return (attr, result)+parseRules "PrintfString" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28'5c'2e'5cd'2b'29'3f'5ba'2dhosxA'2dCEGHSX'5d >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28t'7cT'29'28a'7cA'7cb'7cB'7cc'7cC'7cd'7cD'7ce'7cF'7ch'7cH'7cI'7cj'7ck'7cl'7cL'7cm'7cM'7cN'7cp'7cP'7cQ'7cr'7cR'7cs'7cS'7cT'7cy'7cY'7cz'7cZ'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'28'25'7cn'29 >>= withAttribute CharTok))) -parseRules "Member" = - do (attr, result) <- (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute "Function") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Member" =+ (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "StaticImports" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'2e'2a'3b >>= withAttribute "StaticImports") >>~ (popContext))- return (attr, result)+parseRules "StaticImports" =+ ((pRegExpr regex_'5cs'2a'2e'2a'3b >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Imports" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'2e'2a'3b >>= withAttribute "Imports") >>~ (popContext))- return (attr, result)+parseRules "Imports" =+ ((pRegExpr regex_'5cs'2a'2e'2a'3b >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Commentar 1" = +parseRules "Commentar 1" = pzero -parseRules "Commentar 2" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar 2" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Javadoc.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file javadoc.xml, version 1.04,- by Alfredo Luiz Foltran Fialho (alfoltran@ig.com.br) -}+{- This module was generated from data in the Kate syntax+ highlighting file javadoc.xml, version 1.04, by Alfredo Luiz Foltran Fialho (alfoltran@ig.com.br) -} -module Text.Highlighting.Kate.Syntax.Javadoc ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Javadoc+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Html-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,61 +22,48 @@ syntaxExtensions = "" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Javadoc" } context <- currentContext <|> (pushContext "Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Javadoc",["Start"])], synStLanguage = "Javadoc", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Javadoc",["Start"])], synStLanguage = "Javadoc", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Start" -> return () >> pHandleEndLine- "FindJavadoc" -> return () >> pHandleEndLine- "JavadocFSar" -> return () >> pHandleEndLine- "Javadocar" -> return () >> pHandleEndLine+ "Start" -> return ()+ "FindJavadoc" -> return ()+ "JavadocFSar" -> return ()+ "Javadocar" -> return () "JavadocParam" -> (popContext) >> pEndLine- "InlineTagar" -> return () >> pHandleEndLine- "LiteralTagar" -> return () >> pHandleEndLine+ "InlineTagar" -> return ()+ "LiteralTagar" -> return () "SeeTag" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("BlockTag","kw"),("InlineTag","kw"),("JavadocParam","kw"),("SeeTag","kw"),("JavadocFS","co"),("Javadoc","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'28'21'7c'5c'3f'29 = compileRegex "(!|\\?)"@@ -84,167 +74,159 @@ regex_'5cS'2a'28'3f'3d'5c'2a'2f'29 = compileRegex "\\S*(?=\\*/)" regex_'5cS'2a'28'5cs'7c'24'29 = compileRegex "\\S*(\\s|$)" -defaultAttributes = [("Start","Normal Text"),("FindJavadoc","Normal Text"),("JavadocFSar","JavadocFS"),("Javadocar","Javadoc"),("JavadocParam","Javadoc"),("InlineTagar","InlineTag"),("LiteralTagar","InlineTag"),("SeeTag","SeeTag")]+defaultAttributes = [("Start",NormalTok),("FindJavadoc",NormalTok),("JavadocFSar",CommentTok),("Javadocar",CommentTok),("JavadocParam",CommentTok),("InlineTagar",KeywordTok),("LiteralTagar",KeywordTok),("SeeTag",KeywordTok)] -parseRules "Start" = - do (attr, result) <- ((parseRules "FindJavadoc"))- return (attr, result)+parseRules "Start" =+ ((parseRules "FindJavadoc")) -parseRules "FindJavadoc" = - do (attr, result) <- (((pString False "/**/" >>= withAttribute "JavadocFS"))- <|>- ((pString False "/**" >>= withAttribute "JavadocFS") >>~ pushContext "JavadocFSar"))- return (attr, result)+parseRules "FindJavadoc" =+ (((pString False "/**/" >>= withAttribute CommentTok))+ <|>+ ((pString False "/**" >>= withAttribute CommentTok) >>~ pushContext "JavadocFSar")) -parseRules "JavadocFSar" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "JavadocFS") >>~ (popContext))- <|>- ((pRegExpr regex_'28'21'7c'5c'3f'29 >>= withAttribute "JavadocFS") >>~ pushContext "Javadocar")- <|>- ((pRegExpr regex_'28'5c'2e'5cs'2a'24'29 >>= withAttribute "JavadocFS") >>~ pushContext "Javadocar")- <|>- ((pRegExpr regex_'28'5c'2e'5cs'29'28'3f'21'5b'5cda'2dz'5d'29 >>= withAttribute "JavadocFS") >>~ pushContext "Javadocar")- <|>- ((pFirstNonSpace >> pRegExpr regex_'5c'2a'2a'5cs'2a'28'3f'3d'40'28author'7cdeprecated'7cexception'7cparam'7creturn'7csee'7cserial'7cserialData'7cserialField'7csince'7cthrows'7cversion'29'28'5cs'7c'24'29'29 >>= withAttribute "JavadocFS") >>~ pushContext "Javadocar")- <|>- ((pString False "{@code " >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@code\t" >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@docRoot}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@inheritDoc}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@link " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@link\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@linkplain " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@linkplain\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@literal " >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@literal\t" >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@value}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@value " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@value\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "JavadocFSar" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'28'21'7c'5c'3f'29 >>= withAttribute CommentTok) >>~ pushContext "Javadocar")+ <|>+ ((pRegExpr regex_'28'5c'2e'5cs'2a'24'29 >>= withAttribute CommentTok) >>~ pushContext "Javadocar")+ <|>+ ((pRegExpr regex_'28'5c'2e'5cs'29'28'3f'21'5b'5cda'2dz'5d'29 >>= withAttribute CommentTok) >>~ pushContext "Javadocar")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5c'2a'2a'5cs'2a'28'3f'3d'40'28author'7cdeprecated'7cexception'7cparam'7creturn'7csee'7cserial'7cserialData'7cserialField'7csince'7cthrows'7cversion'29'28'5cs'7c'24'29'29 >>= withAttribute CommentTok) >>~ pushContext "Javadocar")+ <|>+ ((pString False "{@code " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@code " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@docRoot}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@inheritDoc}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@link " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@link " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@linkplain " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@linkplain " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@literal " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@literal " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@value}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@value " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@value " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Javadocar" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "JavadocFS") >>~ (popContext >> popContext))- <|>- ((pFirstNonSpace >> pRegExpr regex_'5c'2a'2b'28'3f'21'2f'29 >>= withAttribute "JavadocFS"))- <|>- ((pString False "@author " >>= withAttribute "BlockTag"))- <|>- ((pString False "@deprecated " >>= withAttribute "BlockTag"))- <|>- ((pString False "@exception " >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@param " >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@return " >>= withAttribute "BlockTag"))- <|>- ((pString False "@see " >>= withAttribute "BlockTag") >>~ pushContext "SeeTag")- <|>- ((pString False "@serial " >>= withAttribute "BlockTag"))- <|>- ((pString False "@serialData " >>= withAttribute "BlockTag"))- <|>- ((pString False "@serialField " >>= withAttribute "BlockTag"))- <|>- ((pString False "@since " >>= withAttribute "BlockTag"))- <|>- ((pString False "@throws " >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@version " >>= withAttribute "BlockTag"))- <|>- ((pString False "@author\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@deprecated\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@exception\t" >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@param\t" >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@return\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@see\t" >>= withAttribute "BlockTag") >>~ pushContext "SeeTag")- <|>- ((pString False "@serial\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@serialData\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@serialField\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@since\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "@throws\t" >>= withAttribute "BlockTag") >>~ pushContext "JavadocParam")- <|>- ((pString False "@version\t" >>= withAttribute "BlockTag"))- <|>- ((pString False "{@code " >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@code\t" >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@docRoot}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@inheritDoc}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@link " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@link\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@linkplain " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@linkplain\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@literal " >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@literal\t" >>= withAttribute "InlineTag") >>~ pushContext "LiteralTagar")- <|>- ((pString False "{@value}" >>= withAttribute "InlineTag"))- <|>- ((pString False "{@value " >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((pString False "{@value\t" >>= withAttribute "InlineTag") >>~ pushContext "InlineTagar")- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "Javadocar" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5c'2a'2b'28'3f'21'2f'29 >>= withAttribute CommentTok))+ <|>+ ((pString False "@author " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@deprecated " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@exception " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@param " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@return " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@see " >>= withAttribute KeywordTok) >>~ pushContext "SeeTag")+ <|>+ ((pString False "@serial " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@serialData " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@serialField " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@since " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@throws " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@version " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@author " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@deprecated " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@exception " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@param " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@return " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@see " >>= withAttribute KeywordTok) >>~ pushContext "SeeTag")+ <|>+ ((pString False "@serial " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@serialData " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@serialField " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@since " >>= withAttribute KeywordTok))+ <|>+ ((pString False "@throws " >>= withAttribute KeywordTok) >>~ pushContext "JavadocParam")+ <|>+ ((pString False "@version " >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@code " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@code " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@docRoot}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@inheritDoc}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@link " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@link " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@linkplain " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@linkplain " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@literal " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@literal " >>= withAttribute KeywordTok) >>~ pushContext "LiteralTagar")+ <|>+ ((pString False "{@value}" >>= withAttribute KeywordTok))+ <|>+ ((pString False "{@value " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((pString False "{@value " >>= withAttribute KeywordTok) >>~ pushContext "InlineTagar")+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "JavadocParam" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Javadoc"))- <|>- ((pRegExpr regex_'5cS'2a'28'3f'3d'5c'2a'2f'29 >>= withAttribute "JavadocParam") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cS'2a'28'5cs'7c'24'29 >>= withAttribute "JavadocParam") >>~ (popContext)))- return (attr, result)+parseRules "JavadocParam" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5cS'2a'28'3f'3d'5c'2a'2f'29 >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS'2a'28'5cs'7c'24'29 >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "InlineTagar" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "InlineTag") >>~ (popContext))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "JavadocFS") >>~ (popContext >> popContext >> popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "InlineTagar" =+ (((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression >>= ((withAttribute KeywordTok) . snd)))) -parseRules "LiteralTagar" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "InlineTag") >>~ (popContext))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "JavadocFS") >>~ (popContext >> popContext >> popContext)))- return (attr, result)+parseRules "LiteralTagar" =+ (((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext >> popContext))) -parseRules "SeeTag" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "JavadocFS") >>~ (popContext >> popContext >> popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "SeeTag" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression >>= ((withAttribute KeywordTok) . snd)))) parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Javascript.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file javascript.xml, version 1.18,- by Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net) -}+{- This module was generated from data in the Kate syntax+ highlighting file javascript.xml, version 1.18, by Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net) -} -module Text.Highlighting.Kate.Syntax.Javascript ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Javascript+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "JavaScript"@@ -20,65 +23,52 @@ syntaxExtensions = "*.js" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "JavaScript" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("JavaScript",["Normal"])], synStLanguage = "JavaScript", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("JavaScript",["Normal"])], synStLanguage = "JavaScript", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "String 1" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- "Multi/inline Comment" -> return () >> pHandleEndLine- "Regular Expression" -> return () >> pHandleEndLine- "(Internal regex catch)" -> return () >> pHandleEndLine- "Regular Expression Character Class" -> return () >> pHandleEndLine+ "Multi/inline Comment" -> return ()+ "Regular Expression" -> return ()+ "(Internal regex catch)" -> return ()+ "Regular Expression Character Class" -> return () "(regex caret first check)" -> (popContext) >> pEndLine "(charclass caret first check)" -> (popContext) >> pEndLine "region_marker" -> (popContext) >> pEndLine- "ObjectMember" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "ObjectMember" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Objects","kw"),("Object Member","fu"),("Math","kw"),("Events","kw"),("Decimal","dv"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Regular Expression","ot"),("Pattern Internal Operator","fl"),("Pattern Character Class","bn"),("Region Marker","re"),("JSON","dt")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "if else for in while do continue break with try catch finally switch case new var function return delete true false void throw typeof const default" list_functions = Set.fromList $ words $ "escape isFinite isNaN Number parseFloat parseInt reload taint unescape untaint write"@@ -99,157 +89,145 @@ regex_'2f'2f'28'3f'3d'3b'29 = compileRegex "//(?=;)" regex_'5c'5c'5b'5c'5b'5c'5d'5d = compileRegex "\\\\[\\[\\]]" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("String 1","String Char"),("Comment","Comment"),("Multi/inline Comment","Comment"),("Regular Expression","Regular Expression"),("(Internal regex catch)","Normal Text"),("Regular Expression Character Class","Pattern Character Class"),("(regex caret first check)","Pattern Internal Operator"),("(charclass caret first check)","Pattern Internal Operator"),("region_marker","Region Marker"),("ObjectMember","Normal Text")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("String 1",CharTok),("Comment",CommentTok),("Multi/inline Comment",CommentTok),("Regular Expression",OtherTok),("(Internal regex catch)",NormalTok),("Regular Expression Character Class",BaseNTok),("(regex caret first check)",FloatTok),("(charclass caret first check)",FloatTok),("region_marker",RegionMarkerTok),("ObjectMember",NormalTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "region_marker")- <|>- ((pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "region_marker")- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5cb'5b'5cw'5c'2e'5d'2b'5cb'5cs'2a'28'3f'3d'3a'29 >>= withAttribute "JSON"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_objects >>= withAttribute "Objects"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_math >>= withAttribute "Math"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_events >>= withAttribute "Events"))- <|>- ((pDetectChar False '.' >>= withAttribute "Normal Text") >>~ pushContext "ObjectMember")- <|>- ((pRegExpr regex_'5cb'5b'5cw'5c'2e'5d'2b'28'3f'3d'5c'2e'29 >>= withAttribute "Objects") >>~ pushContext "ObjectMember")- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '\'' >>= withAttribute "String Char") >>~ pushContext "String 1")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Multi/inline Comment")- <|>- ((pRegExpr regex_'5b'3d'3f'3a'5d >>= withAttribute "Normal Text") >>~ pushContext "(Internal regex catch)")- <|>- ((pRegExpr regex_'5c'28 >>= withAttribute "Normal Text") >>~ pushContext "(Internal regex catch)")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "region_marker")+ <|>+ ((pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "region_marker")+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5cw'5c'2e'5d'2b'5cb'5cs'2a'28'3f'3d'3a'29 >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_objects >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_math >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_events >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '.' >>= withAttribute NormalTok) >>~ pushContext "ObjectMember")+ <|>+ ((pRegExpr regex_'5cb'5b'5cw'5c'2e'5d'2b'28'3f'3d'5c'2e'29 >>= withAttribute KeywordTok) >>~ pushContext "ObjectMember")+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ pushContext "String 1")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Multi/inline Comment")+ <|>+ ((pRegExpr regex_'5b'3d'3f'3a'5d >>= withAttribute NormalTok) >>~ pushContext "(Internal regex catch)")+ <|>+ ((pRegExpr regex_'5c'28 >>= withAttribute NormalTok) >>~ pushContext "(Internal regex catch)")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pLineContinue >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "String 1" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String Char"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pLineContinue >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String Char") >>~ (popContext)))- return (attr, result)+parseRules "String 1" =+ (((pDetectIdentifier >>= withAttribute CharTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Multi/inline Comment" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Multi/inline Comment" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Regular Expression" = - do (attr, result) <- (((pRegExpr regex_'2f'5big'5d'7b0'2c2'7d >>= withAttribute "Regular Expression") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'5c'5bbB'5d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'5c'5bnrtvfDdSsWw'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pDetectChar False '[' >>= withAttribute "Pattern Character Class") >>~ pushContext "(charclass caret first check)")- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute "Pattern Internal Operator"))- <|>- ((pAnyChar "?+*()|" >>= withAttribute "Pattern Internal Operator")))- return (attr, result)+parseRules "Regular Expression" =+ (((pRegExpr regex_'2f'5big'5d'7b0'2c2'7d >>= withAttribute OtherTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bbB'5d >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bnrtvfDdSsWw'5d >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute BaseNTok) >>~ pushContext "(charclass caret first check)")+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute FloatTok))+ <|>+ ((pAnyChar "?+*()|" >>= withAttribute FloatTok))) -parseRules "(Internal regex catch)" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'2f'2f'28'3f'3d'3b'29 >>= withAttribute "Regular Expression") >>~ (popContext))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Multi/inline Comment")- <|>- ((pDetectChar False '/' >>= withAttribute "Regular Expression") >>~ pushContext "(regex caret first check)")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "(Internal regex catch)" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2f'2f'28'3f'3d'3b'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Multi/inline Comment")+ <|>+ ((pDetectChar False '/' >>= withAttribute OtherTok) >>~ pushContext "(regex caret first check)")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Regular Expression Character Class" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5b'5c'5b'5c'5d'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Pattern Internal Operator"))- <|>- ((pDetectChar False ']' >>= withAttribute "Pattern Character Class") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Regular Expression Character Class" =+ (((pRegExpr regex_'5c'5c'5b'5c'5b'5c'5d'5d >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute FloatTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute BaseNTok) >>~ (popContext >> popContext))) -parseRules "(regex caret first check)" = - do (attr, result) <- (((pDetectChar False '^' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "Regular Expression")- <|>- (pushContext "Regular Expression" >> return ([], "")))- return (attr, result)+parseRules "(regex caret first check)" =+ (((pDetectChar False '^' >>= withAttribute FloatTok) >>~ pushContext "Regular Expression")+ <|>+ (pushContext "Regular Expression" >> currentContext >>= parseRules)) -parseRules "(charclass caret first check)" = - do (attr, result) <- (((pDetectChar False '^' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "Regular Expression Character Class")- <|>- (pushContext "Regular Expression Character Class" >> return ([], "")))- return (attr, result)+parseRules "(charclass caret first check)" =+ (((pDetectChar False '^' >>= withAttribute FloatTok) >>~ pushContext "Regular Expression Character Class")+ <|>+ (pushContext "Regular Expression Character Class" >> currentContext >>= parseRules)) -parseRules "region_marker" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "Region Marker"))- <|>- ((pDetectSpaces >>= withAttribute "Region Marker")))- return (attr, result)+parseRules "region_marker" =+ (((pDetectIdentifier >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetectSpaces >>= withAttribute RegionMarkerTok))) -parseRules "ObjectMember" = - do (attr, result) <- (((pDetectChar False '.' >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Object Member"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((lookAhead (pAnyChar "(){}:!%&+,-/.*<=>?[]|~^;") >> return ([],"") ) >>~ (popContext)))- return (attr, result)+parseRules "ObjectMember" =+ (((pDetectChar False '.' >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute FunctionTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((lookAhead (pAnyChar "(){}:!%&+,-/.*<=>?[]|~^;") >> return (NormalTok,"") ) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Json.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file json.xml, version 1.2,- by Sebastian Pipping (sebastian@pipping.org) -}+{- This module was generated from data in the Kate syntax+ highlighting file json.xml, version 1.2, by Sebastian Pipping (sebastian@pipping.org) -} -module Text.Highlighting.Kate.Syntax.Json ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Json+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "JSON"@@ -19,59 +22,46 @@ syntaxExtensions = "*.json" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "JSON" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("JSON",["Normal"])], synStLanguage = "JSON", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("JSON",["Normal"])], synStLanguage = "JSON", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Pair" -> return () >> pHandleEndLine- "String_Key" -> return () >> pHandleEndLine- "Value" -> return () >> pHandleEndLine- "String_Value" -> return () >> pHandleEndLine- "Array" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Normal" -> return ()+ "Pair" -> return ()+ "String_Key" -> return ()+ "Value" -> return ()+ "String_Value" -> return ()+ "Array" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Style_Decimal","dv"),("Style_Float","fl"),("Style_String_Key","dt"),("Style_String_Value","st"),("Style_String_Key_Char","dt"),("Style_String_Value_Char","st"),("Style_Keyword","dv"),("Style_Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_Constants = Set.fromList $ words $ "null true false" @@ -79,79 +69,73 @@ regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f = compileRegex "-?(?:[0-9]|[1-9][0-9]+)\\.[0-9]+(?:[eE][+-]?[0-9]+)?" regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f = compileRegex "-?(?:[0-9]|[1-9][0-9]+)(?:[eE][+-]?[0-9]+)?" -defaultAttributes = [("Normal","Style_Error"),("Pair","Style_Error"),("String_Key","Style_String_Key"),("Value","Style_Error"),("String_Value","Style_String_Value"),("Array","Style_Error")]+defaultAttributes = [("Normal",ErrorTok),("Pair",ErrorTok),("String_Key",DataTypeTok),("Value",ErrorTok),("String_Value",StringTok),("Array",ErrorTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Style_Seperator_Pair") >>~ pushContext "Pair")- <|>- ((pDetectChar False '[' >>= withAttribute "Style_Seperator_Array") >>~ pushContext "Array")- <|>- ((pDetectSpaces >>= withAttribute "Style_Normal")))- return (attr, result)+parseRules "Normal" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Pair")+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok) >>~ pushContext "Array")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))) -parseRules "Pair" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Style_String_Key") >>~ pushContext "String_Key")- <|>- ((pDetectChar False ':' >>= withAttribute "Style_Seperator_Pair") >>~ pushContext "Value")- <|>- ((pDetectChar False '}' >>= withAttribute "Style_Seperator_Pair") >>~ (popContext))- <|>- ((pDetectChar False ',' >>= withAttribute "Style_Seperator_Pair"))- <|>- ((pDetectSpaces >>= withAttribute "Style_Normal")))- return (attr, result)+parseRules "Pair" =+ (((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "String_Key")+ <|>+ ((pDetectChar False ':' >>= withAttribute NormalTok) >>~ pushContext "Value")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False ',' >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))) -parseRules "String_Key" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Style_String_Key") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'28'3f'3a'5b'22'5c'5c'2fbfnrt'5d'7cu'5b0'2d9a'2dfA'2df'5d'7b4'7d'29 >>= withAttribute "Style_String_Key_Char")))- return (attr, result)+parseRules "String_Key" =+ (((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'28'3f'3a'5b'22'5c'5c'2fbfnrt'5d'7cu'5b0'2d9a'2dfA'2df'5d'7b4'7d'29 >>= withAttribute DataTypeTok))) -parseRules "Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Style_String_Value") >>~ pushContext "String_Value")- <|>- ((pDetectChar False '{' >>= withAttribute "Style_Seperator_Pair") >>~ pushContext "Pair")- <|>- ((pDetectChar False '[' >>= withAttribute "Style_Seperator_Array") >>~ pushContext "Array")- <|>- ((lookAhead (pDetectChar False '}') >> return ([],"") ) >>~ (popContext))- <|>- ((lookAhead (pDetectChar False ',') >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectSpaces >>= withAttribute "Style_Normal"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Constants >>= withAttribute "Style_Keyword"))- <|>- ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute "Style_Float"))- <|>- ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute "Style_Decimal")))- return (attr, result)+parseRules "Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String_Value")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Pair")+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok) >>~ pushContext "Array")+ <|>+ ((lookAhead (pDetectChar False '}') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((lookAhead (pDetectChar False ',') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Constants >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute DecValTok))) -parseRules "String_Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Style_String_Value") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'28'3f'3a'5b'22'5c'5c'2fbfnrt'5d'7cu'5b0'2d9a'2dfA'2df'5d'7b4'7d'29 >>= withAttribute "Style_String_Value_Char")))- return (attr, result)+parseRules "String_Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'28'3f'3a'5b'22'5c'5c'2fbfnrt'5d'7cu'5b0'2d9a'2dfA'2df'5d'7b4'7d'29 >>= withAttribute StringTok))) -parseRules "Array" = - do (attr, result) <- (((pDetectChar False ',' >>= withAttribute "Style_Seperator_Array"))- <|>- ((pDetectChar False ']' >>= withAttribute "Style_Seperator_Array") >>~ (popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Style_Seperator_Pair") >>~ pushContext "Pair")- <|>- ((pDetectChar False '[' >>= withAttribute "Style_Seperator_Array") >>~ pushContext "Array")- <|>- ((pDetectChar False '"' >>= withAttribute "Style_String_Value") >>~ pushContext "String_Value")- <|>- ((pDetectSpaces >>= withAttribute "Style_Normal"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Constants >>= withAttribute "Style_Keyword"))- <|>- ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute "Style_Float"))- <|>- ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute "Style_Decimal")))- return (attr, result)+parseRules "Array" =+ (((pDetectChar False ',' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Pair")+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok) >>~ pushContext "Array")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String_Value")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Constants >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'5c'2e'5b0'2d9'5d'2b'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'2d'3f'28'3f'3a'5b0'2d9'5d'7c'5b1'2d9'5d'5b0'2d9'5d'2b'29'28'3f'3a'5beE'5d'5b'2b'2d'5d'3f'5b0'2d9'5d'2b'29'3f >>= withAttribute DecValTok))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Jsp.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file jsp.xml, version 1.02,- by Rob Martin (rob@gamepimp.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file jsp.xml, version 1.02, by Rob Martin (rob@gamepimp.com) -} -module Text.Highlighting.Kate.Syntax.Jsp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Jsp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "JSP"@@ -19,76 +22,63 @@ syntaxExtensions = "*.jsp;*.JSP" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "JSP" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("JSP",["Normal"])], synStLanguage = "JSP", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("JSP",["Normal"])], synStLanguage = "JSP", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Jsp Standard Directive" -> return () >> pHandleEndLine- "Jsp Xml Directive" -> return () >> pHandleEndLine- "Jsp Comment" -> return () >> pHandleEndLine- "Jsp Custom Tag" -> return () >> pHandleEndLine- "Jsp Standard Directive Value" -> return () >> pHandleEndLine- "Jsp Xml Directive Value" -> return () >> pHandleEndLine- "Jsp Custom Tag Value" -> return () >> pHandleEndLine- "Jsp Double Quoted Param Value" -> return () >> pHandleEndLine- "Jsp Single Quoted Param Value" -> return () >> pHandleEndLine- "Jsp Double Quoted Custom Tag Value" -> return () >> pHandleEndLine- "Jsp Single Quoted Custom Tag Value" -> return () >> pHandleEndLine- "Jsp Scriptlet" -> return () >> pHandleEndLine- "Jsp Expression" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "Jsp Standard Directive" -> return ()+ "Jsp Xml Directive" -> return ()+ "Jsp Comment" -> return ()+ "Jsp Custom Tag" -> return ()+ "Jsp Standard Directive Value" -> return ()+ "Jsp Xml Directive Value" -> return ()+ "Jsp Custom Tag Value" -> return ()+ "Jsp Double Quoted Param Value" -> return ()+ "Jsp Single Quoted Param Value" -> return ()+ "Jsp Double Quoted Custom Tag Value" -> return ()+ "Jsp Single Quoted Custom Tag Value" -> return ()+ "Jsp Scriptlet" -> return ()+ "Jsp Expression" -> return () "Java Single-Line Comment" -> (popContext) >> pEndLine- "Java Multi-Line Comment" -> return () >> pHandleEndLine- "Java String" -> return () >> pHandleEndLine- "Html Attribute" -> return () >> pHandleEndLine- "Html Value" -> return () >> pHandleEndLine- "Html Double Quoted Value" -> return () >> pHandleEndLine- "Html Single Quoted Value" -> return () >> pHandleEndLine- "Html Unquoted Value" -> return () >> pHandleEndLine- "Html Comment" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Java Multi-Line Comment" -> return ()+ "Java String" -> return ()+ "Html Attribute" -> return ()+ "Html Value" -> return ()+ "Html Double Quoted Value" -> return ()+ "Html Single Quoted Value" -> return ()+ "Html Unquoted Value" -> return ()+ "Html Comment" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Identifier","ot"),("Types","dt"),("String","st"),("Comment","co"),("Html Comment","co"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String Char","ch"),("Jsp Comment","co"),("Jsp Param Name","ot"),("Jsp Param Value","st"),("Java Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_java'2d1'2e4'2e2'2dclasses = Set.fromList $ words $ "ARG_IN ARG_INOUT ARG_OUT AWTError AWTEvent AWTEventListener AWTEventListenerProxy AWTEventMulticaster AWTException AWTKeyStroke AWTPermission AbstractAction AbstractBorder AbstractButton AbstractCellEditor AbstractCollection AbstractColorChooserPanel AbstractDocument AbstractFormatter AbstractFormatterFactory AbstractInterruptibleChannel AbstractLayoutCache AbstractList AbstractListModel AbstractMap AbstractMethodError AbstractPreferences AbstractSelectableChannel AbstractSelectionKey AbstractSelector AbstractSequentialList AbstractSet AbstractSpinnerModel AbstractTableModel AbstractUndoableEdit AbstractWriter AccessControlContext AccessControlException AccessController AccessException Accessible AccessibleAction AccessibleBundle AccessibleComponent AccessibleContext AccessibleEditableText AccessibleExtendedComponent AccessibleExtendedTable AccessibleHyperlink AccessibleHypertext AccessibleIcon AccessibleKeyBinding AccessibleObject AccessibleRelation AccessibleRelationSet AccessibleResourceBundle AccessibleRole AccessibleSelection AccessibleState AccessibleStateSet AccessibleTable AccessibleTableModelChange AccessibleText AccessibleValue AccountExpiredException Acl AclEntry AclNotFoundException Action ActionEvent ActionListener ActionMap ActionMapUIResource Activatable ActivateFailedException ActivationDesc ActivationException ActivationGroup ActivationGroupDesc ActivationGroupID ActivationGroup_Stub ActivationID ActivationInstantiator ActivationMonitor ActivationSystem Activator ActiveEvent ActiveValue AdapterActivator AdapterActivatorOperations AdapterAlreadyExists AdapterAlreadyExistsHelper AdapterInactive AdapterInactiveHelper AdapterNonExistent AdapterNonExistentHelper AddressHelper Adjustable AdjustmentEvent AdjustmentListener Adler32 AffineTransform AffineTransformOp AlgorithmParameterGenerator AlgorithmParameterGeneratorSpi AlgorithmParameterSpec AlgorithmParameters AlgorithmParametersSpi AlignmentAction AllPermission AlphaComposite AlreadyBound AlreadyBoundException AlreadyBoundHelper AlreadyBoundHolder AlreadyConnectedException AncestorEvent AncestorListener Annotation Any AnyHolder AnySeqHelper AnySeqHelper AnySeqHolder AppConfigurationEntry Applet AppletContext AppletInitializer AppletStub ApplicationException Arc2D Area AreaAveragingScaleFilter ArithmeticException Array Array ArrayIndexOutOfBoundsException ArrayList ArrayStoreException Arrays AssertionError AsyncBoxView AsynchronousCloseException Attr Attribute Attribute Attribute Attribute Attribute AttributeContext AttributeException AttributeInUseException AttributeList AttributeList AttributeListImpl AttributeModificationException AttributeSet AttributeSet AttributeSetUtilities AttributeUndoableEdit AttributedCharacterIterator AttributedString Attributes Attributes Attributes AttributesImpl AudioClip AudioFileFormat AudioFileReader AudioFileWriter AudioFormat AudioInputStream AudioPermission AudioSystem AuthPermission AuthenticationException AuthenticationNotSupportedException Authenticator Autoscroll BAD_CONTEXT BAD_INV_ORDER BAD_OPERATION BAD_PARAM BAD_POLICY BAD_POLICY_TYPE BAD_POLICY_VALUE BAD_TYPECODE BCSIterator BCSSServiceProvider BYTE_ARRAY BackingStoreException BadKind BadLocationException BadPaddingException BandCombineOp BandedSampleModel BasicArrowButton BasicAttribute BasicAttributes BasicBorders BasicButtonListener BasicButtonUI BasicCaret BasicCheckBoxMenuItemUI BasicCheckBoxUI BasicColorChooserUI BasicComboBoxEditor BasicComboBoxRenderer BasicComboBoxUI BasicComboPopup BasicDesktopIconUI BasicDesktopPaneUI BasicDirectoryModel BasicEditorPaneUI BasicFileChooserUI BasicFormattedTextFieldUI BasicGraphicsUtils BasicHTML BasicHighlighter BasicIconFactory BasicInternalFrameTitlePane BasicInternalFrameUI BasicLabelUI BasicListUI BasicLookAndFeel BasicMenuBarUI BasicMenuItemUI BasicMenuUI BasicOptionPaneUI BasicPanelUI BasicPasswordFieldUI BasicPermission BasicPopupMenuSeparatorUI BasicPopupMenuUI BasicProgressBarUI BasicRadioButtonMenuItemUI BasicRadioButtonUI BasicRootPaneUI BasicScrollBarUI BasicScrollPaneUI BasicSeparatorUI BasicSliderUI BasicSpinnerUI BasicSplitPaneDivider BasicSplitPaneUI BasicStroke BasicTabbedPaneUI BasicTableHeaderUI BasicTableUI BasicTextAreaUI BasicTextFieldUI BasicTextPaneUI BasicTextUI BasicToggleButtonUI BasicToolBarSeparatorUI BasicToolBarUI BasicToolTipUI BasicTreeUI BasicViewportUI BatchUpdateException BeanContext BeanContextChild BeanContextChildComponentProxy BeanContextChildSupport BeanContextContainerProxy BeanContextEvent BeanContextMembershipEvent BeanContextMembershipListener BeanContextProxy BeanContextServiceAvailableEvent BeanContextServiceProvider BeanContextServiceProviderBeanInfo BeanContextServiceRevokedEvent BeanContextServiceRevokedListener BeanContextServices BeanContextServicesListener BeanContextServicesSupport BeanContextSupport BeanDescriptor BeanInfo Beans BeepAction BevelBorder BevelBorderUIResource Bias Bidi BigDecimal BigInteger BinaryRefAddr BindException Binding Binding BindingHelper BindingHolder BindingIterator BindingIteratorHelper BindingIteratorHolder BindingIteratorOperations BindingIteratorPOA BindingListHelper BindingListHolder BindingType BindingTypeHelper BindingTypeHolder BitSet Blob BlockView BoldAction Book Boolean BooleanControl BooleanHolder BooleanSeqHelper BooleanSeqHolder Border BorderFactory BorderLayout BorderUIResource BoundedRangeModel Bounds Bounds Box BoxLayout BoxPainter BoxView BoxedValueHelper BreakIterator Buffer BufferCapabilities BufferOverflowException BufferStrategy BufferUnderflowException BufferedImage BufferedImageFilter BufferedImageOp BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter Button ButtonAreaLayout ButtonBorder ButtonBorder ButtonGroup ButtonModel ButtonUI Byte ByteArrayInputStream ByteArrayOutputStream ByteBuffer ByteChannel ByteHolder ByteLookupTable ByteOrder CDATASection CHAR_ARRAY CMMException COMM_FAILURE CRC32 CRL CRLException CRLSelector CSS CTX_RESTRICT_SCOPE Calendar CallableStatement Callback CallbackHandler CancelablePrintJob CancelledKeyException CannotProceed CannotProceedException CannotProceedHelper CannotProceedHolder CannotRedoException CannotUndoException Canvas CardLayout Caret CaretEvent CaretListener CaretPolicy CellEditor CellEditorListener CellRendererPane CertPath CertPathBuilder CertPathBuilderException CertPathBuilderResult CertPathBuilderSpi CertPathParameters CertPathRep CertPathValidator CertPathValidatorException CertPathValidatorResult CertPathValidatorSpi CertSelector CertStore CertStoreException CertStoreParameters CertStoreSpi Certificate Certificate Certificate CertificateEncodingException CertificateEncodingException CertificateException CertificateException CertificateExpiredException CertificateExpiredException CertificateFactory CertificateFactorySpi CertificateNotYetValidException CertificateNotYetValidException CertificateParsingException CertificateParsingException CertificateRep ChangeEvent ChangeListener ChangedCharSetException Channel ChannelBinding Channels CharArrayReader CharArrayWriter CharBuffer CharConversionException CharHolder CharSeqHelper CharSeqHolder CharSequence Character CharacterAttribute CharacterCodingException CharacterConstants CharacterData CharacterIterator Charset CharsetDecoder CharsetEncoder CharsetProvider Checkbox CheckboxGroup CheckboxMenuItem CheckedInputStream CheckedOutputStream Checksum Choice ChoiceCallback ChoiceFormat Chromaticity Cipher CipherInputStream CipherOutputStream CipherSpi Class ClassCastException ClassCircularityError ClassDesc ClassFormatError ClassLoader ClassNotFoundException ClientRequestInfo ClientRequestInfoOperations ClientRequestInterceptor ClientRequestInterceptorOperations Clip Clipboard ClipboardOwner Clob CloneNotSupportedException Cloneable ClosedByInterruptException ClosedChannelException ClosedSelectorException CodeSets CodeSource Codec CodecFactory CodecFactoryHelper CodecFactoryOperations CodecOperations CoderMalfunctionError CoderResult CodingErrorAction CollationElementIterator CollationKey Collator Collection CollectionCertStoreParameters Collections Color ColorAttribute ColorChooserComponentFactory ColorChooserUI ColorConstants ColorConvertOp ColorModel ColorSelectionModel ColorSpace ColorSupported ColorType ColorUIResource ComboBoxEditor ComboBoxModel ComboBoxUI ComboPopup CommandEnvironment Comment CommunicationException Comparable Comparator Compiler CompletionStatus CompletionStatusHelper Component ComponentAdapter ComponentColorModel ComponentEvent ComponentIdHelper ComponentInputMap ComponentInputMapUIResource ComponentListener ComponentOrientation ComponentSampleModel ComponentUI ComponentView Composite CompositeContext CompositeName CompositeView CompoundBorder CompoundBorderUIResource CompoundControl CompoundEdit CompoundName Compression ConcurrentModificationException Configuration ConfigurationException ConfirmationCallback ConnectException ConnectException ConnectIOException Connection ConnectionEvent ConnectionEventListener ConnectionPendingException ConnectionPoolDataSource ConsoleHandler Constraints Constructor Container ContainerAdapter ContainerEvent ContainerListener ContainerOrderFocusTraversalPolicy Content ContentHandler ContentHandler ContentHandlerFactory ContentModel Context Context ContextList ContextNotEmptyException ContextualRenderedImageFactory Control Control ControlFactory ControllerEventListener ConvolveOp CookieHolder Copies CopiesSupported CopyAction CredentialExpiredException CropImageFilter CubicCurve2D Currency Current Current Current CurrentHelper CurrentHelper CurrentHelper CurrentHolder CurrentOperations CurrentOperations CurrentOperations Cursor CustomMarshal CustomValue Customizer CutAction DATA_CONVERSION DESKeySpec DESedeKeySpec DGC DHGenParameterSpec DHKey DHParameterSpec DHPrivateKey DHPrivateKeySpec DHPublicKey DHPublicKeySpec DOMException DOMImplementation DOMLocator DOMResult DOMSource DSAKey DSAKeyPairGenerator DSAParameterSpec DSAParams DSAPrivateKey DSAPrivateKeySpec DSAPublicKey DSAPublicKeySpec DTD DTDConstants DTDHandler DataBuffer DataBufferByte DataBufferDouble DataBufferFloat DataBufferInt DataBufferShort DataBufferUShort DataFlavor DataFormatException DataInput DataInputStream DataInputStream DataLine DataOutput DataOutputStream DataOutputStream DataSource DataTruncation DatabaseMetaData DatagramChannel DatagramPacket DatagramSocket DatagramSocketImpl DatagramSocketImplFactory Date Date DateEditor DateFormat DateFormatSymbols DateFormatter DateTimeAtCompleted DateTimeAtCreation DateTimeAtProcessing DateTimeSyntax DebugGraphics DecimalFormat DecimalFormatSymbols DeclHandler DefaultBoundedRangeModel DefaultButtonModel DefaultCaret DefaultCellEditor DefaultColorSelectionModel DefaultComboBoxModel DefaultDesktopManager DefaultEditor DefaultEditorKit DefaultFocusManager DefaultFocusTraversalPolicy DefaultFormatter DefaultFormatterFactory DefaultHandler DefaultHighlightPainter DefaultHighlighter DefaultKeyTypedAction DefaultKeyboardFocusManager DefaultListCellRenderer DefaultListModel DefaultListSelectionModel DefaultMenuLayout DefaultMetalTheme DefaultMutableTreeNode DefaultPersistenceDelegate DefaultSelectionType DefaultSingleSelectionModel DefaultStyledDocument DefaultTableCellRenderer DefaultTableColumnModel DefaultTableModel DefaultTextUI DefaultTreeCellEditor DefaultTreeCellRenderer DefaultTreeModel DefaultTreeSelectionModel DefinitionKind DefinitionKindHelper Deflater DeflaterOutputStream Delegate Delegate Delegate DelegationPermission DesignMode DesktopIconUI DesktopManager DesktopPaneUI Destination DestinationType DestroyFailedException Destroyable Dialog DialogType Dictionary DigestException DigestInputStream DigestOutputStream Dimension Dimension2D DimensionUIResource DirContext DirObjectFactory DirStateFactory DirectColorModel DirectoryManager DisplayMode DnDConstants Doc DocAttribute DocAttributeSet DocFlavor DocPrintJob Document Document DocumentBuilder DocumentBuilderFactory DocumentEvent DocumentFilter DocumentFragment DocumentHandler DocumentListener DocumentName DocumentParser DocumentType DomainCombiner DomainManager DomainManagerOperations Double Double Double Double Double Double Double Double Double DoubleBuffer DoubleHolder DoubleSeqHelper DoubleSeqHolder DragGestureEvent DragGestureListener DragGestureRecognizer DragSource DragSourceAdapter DragSourceContext DragSourceDragEvent DragSourceDropEvent DragSourceEvent DragSourceListener DragSourceMotionListener Driver DriverManager DriverPropertyInfo DropTarget DropTargetAdapter DropTargetAutoScroller DropTargetContext DropTargetDragEvent DropTargetDropEvent DropTargetEvent DropTargetListener DuplicateName DuplicateNameHelper DynAny DynAny DynAnyFactory DynAnyFactoryHelper DynAnyFactoryOperations DynAnyHelper DynAnyOperations DynAnySeqHelper DynArray DynArray DynArrayHelper DynArrayOperations DynEnum DynEnum DynEnumHelper DynEnumOperations DynFixed DynFixed DynFixedHelper DynFixedOperations DynSequence DynSequence DynSequenceHelper DynSequenceOperations DynStruct DynStruct DynStructHelper DynStructOperations DynUnion DynUnion DynUnionHelper DynUnionOperations DynValue DynValue DynValueBox DynValueBoxOperations DynValueCommon DynValueCommonOperations DynValueHelper DynValueOperations DynamicImplementation DynamicImplementation DynamicUtilTreeNode ENCODING_CDR_ENCAPS EOFException EditorKit Element Element Element ElementChange ElementEdit ElementIterator ElementSpec Ellipse2D EmptyBorder EmptyBorderUIResource EmptySelectionModel EmptyStackException EncodedKeySpec Encoder Encoding Encoding EncryptedPrivateKeyInfo Engineering Entity Entity EntityReference EntityResolver Entry EnumControl EnumSyntax Enumeration Environment Error ErrorHandler ErrorListener ErrorManager EtchedBorder EtchedBorderUIResource Event EventContext EventDirContext EventHandler EventListener EventListenerList EventListenerProxy EventObject EventQueue EventSetDescriptor EventType EventType Exception ExceptionInInitializerError ExceptionList ExceptionListener ExemptionMechanism ExemptionMechanismException ExemptionMechanismSpi ExpandVetoException ExportException Expression ExtendedRequest ExtendedResponse Externalizable FREE_MEM FactoryConfigurationError FailedLoginException FeatureDescriptor Fidelity Field Field Field Field Field FieldBorder FieldNameHelper FieldNameHelper FieldPosition FieldView File FileCacheImageInputStream FileCacheImageOutputStream FileChannel FileChooserUI FileDescriptor FileDialog FileFilter FileFilter FileHandler FileIcon16 FileImageInputStream FileImageOutputStream FileInputStream FileLock FileLockInterruptionException FileNameMap FileNotFoundException FileOutputStream FilePermission FileReader FileSystemView FileView FileWriter FilenameFilter Filler Filter Filter FilterBypass FilterBypass FilterInputStream FilterOutputStream FilterReader FilterWriter FilteredImageSource Finishings FixedHeightLayoutCache FixedHolder FlatteningPathIterator FlavorException FlavorMap FlavorTable FlipContents Float Float Float Float Float Float Float Float Float FloatBuffer FloatControl FloatHolder FloatSeqHelper FloatSeqHolder FlowLayout FlowStrategy FlowView Flush3DBorder FocusAdapter FocusEvent FocusListener FocusManager FocusTraversalPolicy FolderIcon16 Font FontAttribute FontConstants FontFamilyAction FontFormatException FontMetrics FontRenderContext FontSizeAction FontUIResource ForegroundAction FormView Format FormatConversionProvider FormatMismatch FormatMismatchHelper Formatter ForwardRequest ForwardRequest ForwardRequestHelper ForwardRequestHelper Frame GSSContext GSSCredential GSSException GSSManager GSSName GZIPInputStream GZIPOutputStream GapContent GatheringByteChannel GeneralPath GeneralSecurityException GetField GlyphJustificationInfo GlyphMetrics GlyphPainter GlyphVector GlyphView GradientPaint GraphicAttribute Graphics Graphics2D GraphicsConfigTemplate GraphicsConfiguration GraphicsDevice GraphicsEnvironment GrayFilter GregorianCalendar GridBagConstraints GridBagLayout GridLayout Group Guard GuardedObject HTML HTMLDocument HTMLEditorKit HTMLEditorKit HTMLEditorKit HTMLFrameHyperlinkEvent HTMLWriter Handler HandlerBase HandshakeCompletedEvent HandshakeCompletedListener HasControls HashAttributeSet HashDocAttributeSet HashMap HashPrintJobAttributeSet HashPrintRequestAttributeSet HashPrintServiceAttributeSet HashSet Hashtable HeadlessException HierarchyBoundsAdapter HierarchyBoundsListener HierarchyEvent HierarchyListener Highlight HighlightPainter Highlighter HostnameVerifier HttpURLConnection HttpsURLConnection HyperlinkEvent HyperlinkListener ICC_ColorSpace ICC_Profile ICC_ProfileGray ICC_ProfileRGB IDLEntity IDLType IDLTypeHelper IDLTypeOperations ID_ASSIGNMENT_POLICY_ID ID_UNIQUENESS_POLICY_ID IIOByteBuffer IIOException IIOImage IIOInvalidTreeException IIOMetadata IIOMetadataController IIOMetadataFormat IIOMetadataFormatImpl IIOMetadataNode IIOParam IIOParamController IIOReadProgressListener IIOReadUpdateListener IIOReadWarningListener IIORegistry IIOServiceProvider IIOWriteProgressListener IIOWriteWarningListener IMPLICIT_ACTIVATION_POLICY_ID IMP_LIMIT INITIALIZE INPUT_STREAM INTERNAL INTF_REPOS INVALID_TRANSACTION INV_FLAG INV_IDENT INV_OBJREF INV_POLICY IOException IOR IORHelper IORHolder IORInfo IORInfoOperations IORInterceptor IORInterceptorOperations IRObject IRObjectOperations ISO Icon IconUIResource IconView IdAssignmentPolicy IdAssignmentPolicyOperations IdAssignmentPolicyValue IdUniquenessPolicy IdUniquenessPolicyOperations IdUniquenessPolicyValue IdentifierHelper Identity IdentityHashMap IdentityScope IllegalAccessError IllegalAccessException IllegalArgumentException IllegalBlockSizeException IllegalBlockingModeException IllegalCharsetNameException IllegalComponentStateException IllegalMonitorStateException IllegalPathStateException IllegalSelectorException IllegalStateException IllegalThreadStateException Image ImageCapabilities ImageConsumer ImageFilter ImageGraphicAttribute ImageIO ImageIcon ImageInputStream ImageInputStreamImpl ImageInputStreamSpi ImageObserver ImageOutputStream ImageOutputStreamImpl ImageOutputStreamSpi ImageProducer ImageReadParam ImageReader ImageReaderSpi ImageReaderWriterSpi ImageTranscoder ImageTranscoderSpi ImageTypeSpecifier ImageView ImageWriteParam ImageWriter ImageWriterSpi ImagingOpException ImplicitActivationPolicy ImplicitActivationPolicyOperations ImplicitActivationPolicyValue IncompatibleClassChangeError InconsistentTypeCode InconsistentTypeCode InconsistentTypeCodeHelper IndexColorModel IndexOutOfBoundsException IndexedPropertyDescriptor IndirectionException Inet4Address Inet6Address InetAddress InetSocketAddress Inflater InflaterInputStream Info Info Info Info Info InheritableThreadLocal InitialContext InitialContextFactory InitialContextFactoryBuilder InitialDirContext InitialLdapContext InlineView InputContext InputEvent InputMap InputMapUIResource InputMethod InputMethodContext InputMethodDescriptor InputMethodEvent InputMethodHighlight InputMethodListener InputMethodRequests InputSource InputStream InputStream InputStream InputStreamReader InputSubset InputVerifier InsertBreakAction InsertContentAction InsertHTMLTextAction InsertTabAction Insets InsetsUIResource InstantiationError InstantiationException Instrument InsufficientResourcesException IntBuffer IntHolder Integer IntegerSyntax Interceptor InterceptorOperations InternalError InternalFrameAdapter InternalFrameBorder InternalFrameEvent InternalFrameFocusTraversalPolicy InternalFrameListener InternalFrameUI InternationalFormatter InterruptedException InterruptedIOException InterruptedNamingException InterruptibleChannel IntrospectionException Introspector Invalid InvalidAddress InvalidAddressHelper InvalidAddressHolder InvalidAlgorithmParameterException InvalidAttributeIdentifierException InvalidAttributeValueException InvalidAttributesException InvalidClassException InvalidDnDOperationException InvalidKeyException InvalidKeySpecException InvalidMarkException InvalidMidiDataException InvalidName InvalidName InvalidName InvalidNameException InvalidNameHelper InvalidNameHelper InvalidNameHolder InvalidObjectException InvalidParameterException InvalidParameterSpecException InvalidPolicy InvalidPolicyHelper InvalidPreferencesFormatException InvalidSearchControlsException InvalidSearchFilterException InvalidSeq InvalidSlot InvalidSlotHelper InvalidTransactionException InvalidTypeForEncoding InvalidTypeForEncodingHelper InvalidValue InvalidValue InvalidValueHelper InvocationEvent InvocationHandler InvocationTargetException InvokeHandler IstringHelper ItalicAction ItemEvent ItemListener ItemSelectable Iterator Iterator IvParameterSpec JApplet JButton JCheckBox JCheckBoxMenuItem JColorChooser JComboBox JComponent JDesktopIcon JDesktopPane JDialog JEditorPane JFileChooser JFormattedTextField JFrame JIS JInternalFrame JLabel JLayeredPane JList JMenu JMenuBar JMenuItem JOptionPane JPEGHuffmanTable JPEGImageReadParam JPEGImageWriteParam JPEGQTable JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JRadioButtonMenuItem JRootPane JScrollBar JScrollPane JSeparator JSlider JSpinner JSplitPane JTabbedPane JTable JTableHeader JTextArea JTextComponent JTextField JTextPane JToggleButton JToolBar JToolTip JTree JViewport JWindow JarEntry JarException JarFile JarInputStream JarOutputStream JarURLConnection JobAttributes JobHoldUntil JobImpressions JobImpressionsCompleted JobImpressionsSupported JobKOctets JobKOctetsProcessed JobKOctetsSupported JobMediaSheets JobMediaSheetsCompleted JobMediaSheetsSupported JobMessageFromOperator JobName JobOriginatingUserName JobPriority JobPrioritySupported JobSheets JobState JobStateReason JobStateReasons KerberosKey KerberosPrincipal KerberosTicket Kernel Key Key KeyAdapter KeyAgreement KeyAgreementSpi KeyBinding KeyEvent KeyEventDispatcher KeyEventPostProcessor KeyException KeyFactory KeyFactorySpi KeyGenerator KeyGeneratorSpi KeyListener KeyManagementException KeyManager KeyManagerFactory KeyManagerFactorySpi KeyPair KeyPairGenerator KeyPairGeneratorSpi KeySelectionManager KeySpec KeyStore KeyStoreException KeyStoreSpi KeyStroke KeyboardFocusManager Keymap LDAPCertStoreParameters LIFESPAN_POLICY_ID LOCATION_FORWARD Label LabelUI LabelView LanguageCallback LastOwnerException LayerPainter LayeredHighlighter LayoutFocusTraversalPolicy LayoutManager LayoutManager2 LayoutQueue LazyInputMap LazyValue LdapContext LdapReferralException Lease Level LexicalHandler LifespanPolicy LifespanPolicyOperations LifespanPolicyValue LimitExceededException Line Line2D LineBorder LineBorderUIResource LineBreakMeasurer LineEvent LineListener LineMetrics LineNumberInputStream LineNumberReader LineUnavailableException LinkController LinkException LinkLoopException LinkRef LinkageError LinkedHashMap LinkedHashSet LinkedList List List ListCellRenderer ListDataEvent ListDataListener ListEditor ListIterator ListModel ListPainter ListResourceBundle ListSelectionEvent ListSelectionListener ListSelectionModel ListUI ListView LoaderHandler LocalObject Locale LocateRegistry Locator LocatorImpl LogManager LogRecord LogStream Logger LoggingPermission LoginContext LoginException LoginModule LoginModuleControlFlag Long LongBuffer LongHolder LongLongSeqHelper LongLongSeqHolder LongSeqHelper LongSeqHolder LookAndFeel LookAndFeelInfo LookupOp LookupTable MARSHAL Mac MacSpi MalformedInputException MalformedLinkException MalformedURLException ManagerFactoryParameters Manifest Map MapMode MappedByteBuffer MarginBorder MarshalException MarshalledObject MaskFormatter Matcher Math MatteBorder MatteBorderUIResource Media MediaName MediaPrintableArea MediaSize MediaSizeName MediaTracker MediaTray MediaType Member MemoryCacheImageInputStream MemoryCacheImageOutputStream MemoryHandler MemoryImageSource Menu MenuBar MenuBarBorder MenuBarBorder MenuBarUI MenuComponent MenuContainer MenuDragMouseEvent MenuDragMouseListener MenuElement MenuEvent MenuItem MenuItemBorder MenuItemUI MenuKeyEvent MenuKeyListener MenuListener MenuSelectionManager MenuShortcut MessageDigest MessageDigestSpi MessageFormat MessageProp MetaEventListener MetaMessage MetalBorders MetalButtonUI MetalCheckBoxIcon MetalCheckBoxUI MetalComboBoxButton MetalComboBoxEditor MetalComboBoxIcon MetalComboBoxUI MetalDesktopIconUI MetalFileChooserUI MetalIconFactory MetalInternalFrameTitlePane MetalInternalFrameUI MetalLabelUI MetalLookAndFeel MetalPopupMenuSeparatorUI MetalProgressBarUI MetalRadioButtonUI MetalRootPaneUI MetalScrollBarUI MetalScrollButton MetalScrollPaneUI MetalSeparatorUI MetalSliderUI MetalSplitPaneUI MetalTabbedPaneUI MetalTextFieldUI MetalTheme MetalToggleButtonUI MetalToolBarUI MetalToolTipUI MetalTreeUI Method MethodDescriptor MidiChannel MidiDevice MidiDeviceProvider MidiEvent MidiFileFormat MidiFileReader MidiFileWriter MidiMessage MidiSystem MidiUnavailableException MimeTypeParseException MinimalHTMLWriter MissingResourceException Mixer MixerProvider ModificationItem Modifier MouseAdapter MouseDragGestureRecognizer MouseEvent MouseInputAdapter MouseInputListener MouseListener MouseMotionAdapter MouseMotionListener MouseWheelEvent MouseWheelListener MultiButtonUI MultiColorChooserUI MultiComboBoxUI MultiDesktopIconUI MultiDesktopPaneUI MultiDoc MultiDocPrintJob MultiDocPrintService MultiFileChooserUI MultiInternalFrameUI MultiLabelUI MultiListUI MultiLookAndFeel MultiMenuBarUI MultiMenuItemUI MultiOptionPaneUI MultiPanelUI MultiPixelPackedSampleModel MultiPopupMenuUI MultiProgressBarUI MultiRootPaneUI MultiScrollBarUI MultiScrollPaneUI MultiSeparatorUI MultiSliderUI MultiSpinnerUI MultiSplitPaneUI MultiTabbedPaneUI MultiTableHeaderUI MultiTableUI MultiTextUI MultiToolBarUI MultiToolTipUI MultiTreeUI MultiViewportUI MulticastSocket MultipleComponentProfileHelper MultipleComponentProfileHolder MultipleDocumentHandling MultipleDocumentHandlingType MultipleMaster MutableAttributeSet MutableComboBoxModel MutableTreeNode NA NO_IMPLEMENT NO_MEMORY NO_PERMISSION NO_RESOURCES NO_RESPONSE NVList Name Name NameAlreadyBoundException NameCallback NameClassPair NameComponent NameComponentHelper NameComponentHolder NameDynAnyPair NameDynAnyPairHelper NameDynAnyPairSeqHelper NameHelper NameHolder NameNotFoundException NameParser NameValuePair NameValuePair NameValuePairHelper NameValuePairHelper NameValuePairSeqHelper NamedNodeMap NamedValue NamespaceChangeListener NamespaceSupport Naming NamingContext NamingContextExt NamingContextExtHelper NamingContextExtHolder NamingContextExtOperations NamingContextExtPOA NamingContextHelper NamingContextHolder NamingContextOperations NamingContextPOA NamingEnumeration NamingEvent NamingException NamingExceptionEvent NamingListener NamingManager NamingSecurityException NavigationFilter NegativeArraySizeException NetPermission NetworkInterface NoClassDefFoundError NoConnectionPendingException NoContext NoContextHelper NoInitialContextException NoPermissionException NoRouteToHostException NoServant NoServantHelper NoSuchAlgorithmException NoSuchAttributeException NoSuchElementException NoSuchFieldError NoSuchFieldException NoSuchMethodError NoSuchMethodException NoSuchObjectException NoSuchPaddingException NoSuchProviderException Node NodeChangeEvent NodeChangeListener NodeDimensions NodeList NonReadableChannelException NonWritableChannelException NoninvertibleTransformException NotActiveException NotBoundException NotContextException NotEmpty NotEmptyHelper NotEmptyHolder NotFound NotFoundHelper NotFoundHolder NotFoundReason NotFoundReasonHelper NotFoundReasonHolder NotOwnerException NotSerializableException NotYetBoundException NotYetConnectedException Notation NullCipher NullPointerException Number NumberEditor NumberFormat NumberFormatException NumberFormatter NumberOfDocuments NumberOfInterveningJobs NumberUp NumberUpSupported NumericShaper OBJECT_NOT_EXIST OBJ_ADAPTER OMGVMCID ORB ORB ORBInitInfo ORBInitInfoOperations ORBInitializer ORBInitializerOperations ObjID Object Object ObjectAlreadyActive ObjectAlreadyActiveHelper ObjectChangeListener ObjectFactory ObjectFactoryBuilder ObjectHelper ObjectHolder ObjectIdHelper ObjectImpl ObjectImpl ObjectInput ObjectInputStream ObjectInputValidation ObjectNotActive ObjectNotActiveHelper ObjectOutput ObjectOutputStream ObjectStreamClass ObjectStreamConstants ObjectStreamException ObjectStreamField ObjectView Observable Observer OctetSeqHelper OctetSeqHolder Oid OpenType Operation OperationNotSupportedException Option OptionDialogBorder OptionPaneUI OptionalDataException OrientationRequested OrientationRequestedType OriginType Other OutOfMemoryError OutputDeviceAssigned OutputKeys OutputStream OutputStream OutputStream OutputStreamWriter OverlappingFileLockException OverlayLayout Owner PBEKey PBEKeySpec PBEParameterSpec PDLOverrideSupported PERSIST_STORE PKCS8EncodedKeySpec PKIXBuilderParameters PKIXCertPathBuilderResult PKIXCertPathChecker PKIXCertPathValidatorResult PKIXParameters POA POAHelper POAManager POAManagerOperations POAOperations PRIVATE_MEMBER PSSParameterSpec PUBLIC_MEMBER Package PackedColorModel PageAttributes PageFormat PageRanges Pageable PagesPerMinute PagesPerMinuteColor Paint PaintContext PaintEvent PaletteBorder PaletteCloseIcon Panel PanelUI Paper ParagraphAttribute ParagraphConstants ParagraphView ParagraphView Parameter ParameterBlock ParameterDescriptor ParameterMetaData ParameterMode ParameterModeHelper ParameterModeHolder ParseException ParsePosition Parser Parser Parser ParserAdapter ParserCallback ParserConfigurationException ParserDelegator ParserFactory PartialResultException PasswordAuthentication PasswordCallback PasswordView PasteAction Patch PathIterator Pattern PatternSyntaxException Permission Permission PermissionCollection Permissions PersistenceDelegate PhantomReference Pipe PipedInputStream PipedOutputStream PipedReader PipedWriter PixelGrabber PixelInterleavedSampleModel PlainDocument PlainView Point Point2D Policy Policy Policy PolicyError PolicyErrorCodeHelper PolicyErrorHelper PolicyErrorHolder PolicyFactory PolicyFactoryOperations PolicyHelper PolicyHolder PolicyListHelper PolicyListHolder PolicyNode PolicyOperations PolicyQualifierInfo PolicyTypeHelper Polygon PooledConnection Popup PopupFactory PopupMenu PopupMenuBorder PopupMenuEvent PopupMenuListener PopupMenuUI Port PortUnreachableException PortableRemoteObject PortableRemoteObjectDelegate Position PreferenceChangeEvent PreferenceChangeListener Preferences PreferencesFactory PreparedStatement PresentationDirection Principal Principal PrincipalHolder PrintEvent PrintException PrintGraphics PrintJob PrintJobAdapter PrintJobAttribute PrintJobAttributeEvent PrintJobAttributeListener PrintJobAttributeSet PrintJobEvent PrintJobListener PrintQuality PrintQualityType PrintRequestAttribute PrintRequestAttributeSet PrintService PrintServiceAttribute PrintServiceAttributeEvent PrintServiceAttributeListener PrintServiceAttributeSet PrintServiceLookup PrintStream PrintWriter Printable PrinterAbortException PrinterException PrinterGraphics PrinterIOException PrinterInfo PrinterIsAcceptingJobs PrinterJob PrinterLocation PrinterMakeAndModel PrinterMessageFromOperator PrinterMoreInfo PrinterMoreInfoManufacturer PrinterName PrinterResolution PrinterState PrinterStateReason PrinterStateReasons PrinterURI PrivateCredentialPermission PrivateKey PrivilegedAction PrivilegedActionException PrivilegedExceptionAction Process ProcessingInstruction ProfileDataException ProfileIdHelper ProgressBarUI ProgressMonitor ProgressMonitorInputStream Properties PropertyChangeEvent PropertyChangeListener PropertyChangeListenerProxy PropertyChangeSupport PropertyDescriptor PropertyEditor PropertyEditorManager PropertyEditorSupport PropertyPermission PropertyResourceBundle PropertyVetoException ProtectionDomain ProtocolException Provider ProviderException Proxy ProxyLazyValue PublicKey PushbackInputStream PushbackReader PutField QuadCurve2D QueuedJobCount RC2ParameterSpec RC5ParameterSpec READER REQUEST_PROCESSING_POLICY_ID RGBImageFilter RMIClassLoader RMIClassLoaderSpi RMIClientSocketFactory RMIFailureHandler RMISecurityException RMISecurityManager RMIServerSocketFactory RMISocketFactory RSAKey RSAKeyGenParameterSpec RSAMultiPrimePrivateCrtKey RSAMultiPrimePrivateCrtKeySpec RSAOtherPrimeInfo RSAPrivateCrtKey RSAPrivateCrtKeySpec RSAPrivateKey RSAPrivateKeySpec RSAPublicKey RSAPublicKeySpec RTFEditorKit RadioButtonBorder Random RandomAccess RandomAccessFile Raster RasterFormatException RasterOp ReadOnlyBufferException ReadableByteChannel Reader Receiver Rectangle Rectangle2D RectangularShape Ref RefAddr Reference Reference ReferenceQueue ReferenceUriSchemesSupported Referenceable ReferralException ReflectPermission RefreshFailedException Refreshable RegisterableService Registry RegistryHandler RemarshalException Remote RemoteCall RemoteException RemoteObject RemoteRef RemoteServer RemoteStub RenderContext RenderableImage RenderableImageOp RenderableImageProducer RenderedImage RenderedImageFactory Renderer RenderingHints RepaintManager ReplicateScaleFilter RepositoryIdHelper Request RequestInfo RequestInfoOperations RequestProcessingPolicy RequestProcessingPolicyOperations RequestProcessingPolicyValue RequestingUserName RescaleOp ResolutionSyntax ResolveResult Resolver ResourceBundle ResponseHandler Result Result ResultSet ResultSetMetaData ReverbType Robot RolloverButtonBorder RolloverButtonBorder RootPaneContainer RootPaneUI RoundRectangle2D RowMapper RowSet RowSetEvent RowSetInternal RowSetListener RowSetMetaData RowSetReader RowSetWriter RuleBasedCollator RunTime RunTimeOperations Runnable Runtime RuntimeException RuntimePermission SAXException SAXNotRecognizedException SAXNotSupportedException SAXParseException SAXParser SAXParserFactory SAXResult SAXSource SAXTransformerFactory SERVANT_RETENTION_POLICY_ID SERVICE_FORMATTED SQLData SQLException SQLInput SQLOutput SQLPermission SQLWarning SSLContext SSLContextSpi SSLException SSLHandshakeException SSLKeyException SSLPeerUnverifiedException SSLPermission SSLProtocolException SSLServerSocket SSLServerSocketFactory SSLSession SSLSessionBindingEvent SSLSessionBindingListener SSLSessionContext SSLSocket SSLSocketFactory STRING SUCCESSFUL SYNC_WITH_TRANSPORT SYSTEM_EXCEPTION SampleModel Savepoint ScatteringByteChannel SchemaViolationException ScrollBarUI ScrollPane ScrollPaneAdjustable ScrollPaneBorder ScrollPaneConstants ScrollPaneLayout ScrollPaneUI Scrollable Scrollbar SealedObject SearchControls SearchResult SecretKey SecretKeyFactory SecretKeyFactorySpi SecretKeySpec SecureClassLoader SecureRandom SecureRandomSpi Security SecurityException SecurityManager SecurityPermission Segment SelectableChannel SelectionKey Selector SelectorProvider Separator Separator SeparatorUI Sequence SequenceInputStream Sequencer Serializable SerializablePermission Servant ServantActivator ServantActivatorHelper ServantActivatorOperations ServantActivatorPOA ServantAlreadyActive ServantAlreadyActiveHelper ServantLocator ServantLocatorHelper ServantLocatorOperations ServantLocatorPOA ServantManager ServantManagerOperations ServantNotActive ServantNotActiveHelper ServantObject ServantRetentionPolicy ServantRetentionPolicyOperations ServantRetentionPolicyValue ServerCloneException ServerError ServerException ServerNotActiveException ServerRef ServerRequest ServerRequestInfo ServerRequestInfoOperations ServerRequestInterceptor ServerRequestInterceptorOperations ServerRuntimeException ServerSocket ServerSocketChannel ServerSocketFactory ServiceContext ServiceContextHelper ServiceContextHolder ServiceContextListHelper ServiceContextListHolder ServiceDetail ServiceDetailHelper ServiceIdHelper ServiceInformation ServiceInformationHelper ServiceInformationHolder ServicePermission ServiceRegistry ServiceUI ServiceUIFactory ServiceUnavailableException Set SetOfIntegerSyntax SetOverrideType SetOverrideTypeHelper Severity Shape ShapeGraphicAttribute SheetCollate Short ShortBuffer ShortBufferException ShortHolder ShortLookupTable ShortMessage ShortSeqHelper ShortSeqHolder Sides SidesType Signature SignatureException SignatureSpi SignedObject Signer SimpleAttributeSet SimpleBeanInfo SimpleDateFormat SimpleDoc SimpleFormatter SimpleTimeZone SinglePixelPackedSampleModel SingleSelectionModel SinkChannel Size2DSyntax SizeLimitExceededException SizeRequirements SizeSequence Skeleton SkeletonMismatchException SkeletonNotFoundException SliderUI Socket SocketAddress SocketChannel SocketException SocketFactory SocketHandler SocketImpl SocketImplFactory SocketOptions SocketPermission SocketSecurityException SocketTimeoutException SoftBevelBorder SoftReference SortedMap SortedSet SortingFocusTraversalPolicy Soundbank SoundbankReader SoundbankResource Source SourceChannel SourceDataLine SourceLocator SpinnerDateModel SpinnerListModel SpinnerModel SpinnerNumberModel SpinnerUI SplitPaneBorder SplitPaneUI Spring SpringLayout Stack StackOverflowError StackTraceElement StartTlsRequest StartTlsResponse State StateEdit StateEditable StateFactory Statement Statement StreamCorruptedException StreamHandler StreamPrintService StreamPrintServiceFactory StreamResult StreamSource StreamTokenizer Streamable StreamableValue StrictMath String StringBuffer StringBufferInputStream StringCharacterIterator StringContent StringHolder StringIndexOutOfBoundsException StringNameHelper StringReader StringRefAddr StringSelection StringSeqHelper StringSeqHolder StringTokenizer StringValueHelper StringWriter Stroke Struct StructMember StructMemberHelper Stub StubDelegate StubNotFoundException Style StyleConstants StyleContext StyleSheet StyledDocument StyledEditorKit StyledTextAction Subject SubjectDomainCombiner Subset SupportedValuesAttribute SwingConstants SwingPropertyChangeSupport SwingUtilities SyncFailedException SyncMode SyncScopeHelper Synthesizer SysexMessage System SystemColor SystemException SystemFlavorMap TAG_ALTERNATE_IIOP_ADDRESS TAG_CODE_SETS TAG_INTERNET_IOP TAG_JAVA_CODEBASE TAG_MULTIPLE_COMPONENTS TAG_ORB_TYPE TAG_POLICIES TCKind THREAD_POLICY_ID TRANSACTION_REQUIRED TRANSACTION_ROLLEDBACK TRANSIENT TRANSPORT_RETRY TabExpander TabSet TabStop TabableView TabbedPaneUI TableCellEditor TableCellRenderer TableColumn TableColumnModel TableColumnModelEvent TableColumnModelListener TableHeaderBorder TableHeaderUI TableModel TableModelEvent TableModelListener TableUI TableView Tag TagElement TaggedComponent TaggedComponentHelper TaggedComponentHolder TaggedProfile TaggedProfileHelper TaggedProfileHolder TargetDataLine Templates TemplatesHandler Text TextAction TextArea TextAttribute TextComponent TextEvent TextField TextFieldBorder TextHitInfo TextInputCallback TextLayout TextListener TextMeasurer TextOutputCallback TextSyntax TextUI TexturePaint Thread ThreadDeath ThreadGroup ThreadLocal ThreadPolicy ThreadPolicyOperations ThreadPolicyValue Throwable Tie TileObserver Time TimeLimitExceededException TimeZone Timer Timer TimerTask Timestamp TitledBorder TitledBorderUIResource ToggleButtonBorder ToggleButtonBorder ToggleButtonModel TooManyListenersException ToolBarBorder ToolBarUI ToolTipManager ToolTipUI Toolkit Track TransactionRequiredException TransactionRolledbackException TransactionService TransferHandler Transferable TransformAttribute Transformer TransformerConfigurationException TransformerException TransformerFactory TransformerFactoryConfigurationError TransformerHandler Transmitter Transparency TreeCellEditor TreeCellRenderer TreeControlIcon TreeExpansionEvent TreeExpansionListener TreeFolderIcon TreeLeafIcon TreeMap TreeModel TreeModelEvent TreeModelListener TreeNode TreePath TreeSelectionEvent TreeSelectionListener TreeSelectionModel TreeSet TreeUI TreeWillExpandListener TrustAnchor TrustManager TrustManagerFactory TrustManagerFactorySpi Type Type Type Type Type Type Type TypeCode TypeCodeHolder TypeMismatch TypeMismatch TypeMismatch TypeMismatchHelper TypeMismatchHelper Types UID UIDefaults UIManager UIResource UIResource UIResource UIResource UIResource UIResource UIResource ULongLongSeqHelper ULongLongSeqHolder ULongSeqHelper ULongSeqHolder UNKNOWN UNSUPPORTED_POLICY UNSUPPORTED_POLICY_VALUE URI URIException URIResolver URISyntax URISyntaxException URL URL URLClassLoader URLConnection URLDecoder URLEncoder URLStreamHandler URLStreamHandlerFactory URLStringHelper USER_EXCEPTION UShortSeqHelper UShortSeqHolder UTFDataFormatException UndeclaredThrowableException UnderlineAction UndoManager UndoableEdit UndoableEditEvent UndoableEditListener UndoableEditSupport UnexpectedException UnicastRemoteObject UnicodeBlock UnionMember UnionMemberHelper UnknownEncoding UnknownEncodingHelper UnknownError UnknownException UnknownGroupException UnknownHostException UnknownHostException UnknownObjectException UnknownServiceException UnknownTag UnknownUserException UnknownUserExceptionHelper UnknownUserExceptionHolder UnmappableCharacterException UnmarshalException UnmodifiableSetException UnrecoverableKeyException Unreferenced UnresolvedAddressException UnresolvedPermission UnsatisfiedLinkError UnsolicitedNotification UnsolicitedNotificationEvent UnsolicitedNotificationListener UnsupportedAddressTypeException UnsupportedAudioFileException UnsupportedCallbackException UnsupportedCharsetException UnsupportedClassVersionError UnsupportedEncodingException UnsupportedFlavorException UnsupportedLookAndFeelException UnsupportedOperationException UserException Util UtilDelegate Utilities VMID VM_ABSTRACT VM_CUSTOM VM_NONE VM_TRUNCATABLE ValueBase ValueBaseHelper ValueBaseHolder ValueFactory ValueHandler ValueMember ValueMemberHelper VariableHeightLayoutCache Vector VerifyError VersionSpecHelper VetoableChangeListener VetoableChangeListenerProxy VetoableChangeSupport View ViewFactory ViewportLayout ViewportUI VirtualMachineError Visibility VisibilityHelper VoiceStatus Void VolatileImage WCharSeqHelper WCharSeqHolder WStringSeqHelper WStringSeqHolder WStringValueHelper WeakHashMap WeakReference Window WindowAdapter WindowConstants WindowEvent WindowFocusListener WindowListener WindowStateListener WrappedPlainView WritableByteChannel WritableRaster WritableRenderedImage WriteAbortedException Writer WrongAdapter WrongAdapterHelper WrongPolicy WrongPolicyHelper WrongTransaction WrongTransactionHelper WrongTransactionHolder X500Principal X500PrivateCredential X509CRL X509CRLEntry X509CRLSelector X509CertSelector X509Certificate X509Certificate X509EncodedKeySpec X509Extension X509KeyManager X509TrustManager XAConnection XADataSource XAException XAResource XMLDecoder XMLEncoder XMLFilter XMLFilterImpl XMLFormatter XMLReader XMLReaderAdapter XMLReaderFactory Xid ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream ZoneView _BindingIteratorImplBase _BindingIteratorStub _DynAnyFactoryStub _DynAnyStub _DynArrayStub _DynEnumStub _DynFixedStub _DynSequenceStub _DynStructStub _DynUnionStub _DynValueStub _IDLTypeStub _NamingContextExtStub _NamingContextImplBase _NamingContextStub _PolicyStub _Remote_Stub _ServantActivatorStub _ServantLocatorStub" list_java'2d1'2e4'2e2'2dkeywords = Set.fromList $ words $ "abstract assert break case catch class continue default do else extends false finally for goto if implements import instanceof interface native new null package private protected public return super strictfp switch synchronized this throws throw transient true try volatile while"@@ -113,342 +103,320 @@ regex_'5cs'2b = compileRegex "\\s+" regex_'5c'2f'2a'2d'2d'3e = compileRegex "\\/*-->" -defaultAttributes = [("Normal","Normal Text"),("Jsp Standard Directive","Jsp Param Name"),("Jsp Xml Directive","Jsp Param Name"),("Jsp Comment","Jsp Comment"),("Jsp Custom Tag","Identifier"),("Jsp Standard Directive Value","Jsp Param Value"),("Jsp Xml Directive Value","Jsp Param Value"),("Jsp Custom Tag Value","Normal Text"),("Jsp Double Quoted Param Value","Jsp Param Value"),("Jsp Single Quoted Param Value","Jsp Param Value"),("Jsp Double Quoted Custom Tag Value","Types"),("Jsp Single Quoted Custom Tag Value","Types"),("Jsp Scriptlet","Normal Text"),("Jsp Expression","Normal Text"),("Java Single-Line Comment","Java Comment"),("Java Multi-Line Comment","Java Comment"),("Java String","String"),("Html Attribute","Identifier"),("Html Value","Types"),("Html Double Quoted Value","Types"),("Html Single Quoted Value","Types"),("Html Unquoted Value","Types"),("Html Comment","Html Comment")]+defaultAttributes = [("Normal",NormalTok),("Jsp Standard Directive",OtherTok),("Jsp Xml Directive",OtherTok),("Jsp Comment",CommentTok),("Jsp Custom Tag",OtherTok),("Jsp Standard Directive Value",StringTok),("Jsp Xml Directive Value",StringTok),("Jsp Custom Tag Value",NormalTok),("Jsp Double Quoted Param Value",StringTok),("Jsp Single Quoted Param Value",StringTok),("Jsp Double Quoted Custom Tag Value",DataTypeTok),("Jsp Single Quoted Custom Tag Value",DataTypeTok),("Jsp Scriptlet",NormalTok),("Jsp Expression",NormalTok),("Java Single-Line Comment",CommentTok),("Java Multi-Line Comment",CommentTok),("Java String",StringTok),("Html Attribute",OtherTok),("Html Value",DataTypeTok),("Html Double Quoted Value",DataTypeTok),("Html Single Quoted Value",DataTypeTok),("Html Unquoted Value",DataTypeTok),("Html Comment",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'3c'25'40'5cs'2a'5ba'2dzA'2dZ0'2d9'5f'5c'2e'5d'2a >>= withAttribute "Jsp Directive") >>~ pushContext "Jsp Standard Directive")- <|>- ((pRegExpr regex_'3c'5cs'2ajsp'3a'28declaration'7cexpression'7cscriptlet'29'5cs'2a'3e >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3fs'2ajsp'3a'5ba'2dzA'2dZ0'2d9'5f'5c'2e'5d'2a >>= withAttribute "Jsp Directive") >>~ pushContext "Jsp Xml Directive")- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pString False "<!--" >>= withAttribute "Html Comment") >>~ pushContext "Html Comment")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2a'3a'5c'24'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag")- <|>- ((pString False "<![CDATA[" >>= withAttribute "Normal Text"))- <|>- ((pString False "]]>" >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute "Normal Text") >>~ pushContext "Html Attribute"))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'3c'25'40'5cs'2a'5ba'2dzA'2dZ0'2d9'5f'5c'2e'5d'2a >>= withAttribute NormalTok) >>~ pushContext "Jsp Standard Directive")+ <|>+ ((pRegExpr regex_'3c'5cs'2ajsp'3a'28declaration'7cexpression'7cscriptlet'29'5cs'2a'3e >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3fs'2ajsp'3a'5ba'2dzA'2dZ0'2d9'5f'5c'2e'5d'2a >>= withAttribute NormalTok) >>~ pushContext "Jsp Xml Directive")+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Html Comment")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2a'3a'5c'24'3f'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute NormalTok) >>~ pushContext "Html Attribute")) -parseRules "Jsp Standard Directive" = - do (attr, result) <- (((pDetect2Chars False '%' '>' >>= withAttribute "Jsp Directive") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Jsp Standard Directive Value")- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag"))- return (attr, result)+parseRules "Jsp Standard Directive" =+ (((pDetect2Chars False '%' '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Jsp Standard Directive Value")+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")) -parseRules "Jsp Xml Directive" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'2f'3f'5cs'2a'3e >>= withAttribute "Jsp Directive") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Jsp Xml Directive Value")- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Xml Directive" =+ (((pRegExpr regex_'5cs'2a'5c'2f'3f'5cs'2a'3e >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Jsp Xml Directive Value")+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Comment" = - do (attr, result) <- ((pString False "--%>" >>= withAttribute "Jsp Comment") >>~ (popContext))- return (attr, result)+parseRules "Jsp Comment" =+ ((pString False "--%>" >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Jsp Custom Tag" = - do (attr, result) <- (((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Jsp Custom Tag Value")- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Custom Tag" =+ (((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Jsp Custom Tag Value")+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Standard Directive Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pDetectChar False '"' >>= withAttribute "Jsp Param Value") >>~ pushContext "Jsp Double Quoted Param Value")- <|>- ((pDetectChar False '\'' >>= withAttribute "Jsp Param Value") >>~ pushContext "Jsp Single Quoted Param Value")- <|>- ((pDetect2Chars False '%' '>' >>= withAttribute "Jsp Directive") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Jsp Standard Directive Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Jsp Double Quoted Param Value")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Jsp Single Quoted Param Value")+ <|>+ ((pDetect2Chars False '%' '>' >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "Jsp Xml Directive Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pDetectChar False '"' >>= withAttribute "Jsp Param Value") >>~ pushContext "Jsp Double Quoted Param Value")- <|>- ((pDetectChar False '\'' >>= withAttribute "Jsp Param Value") >>~ pushContext "Jsp Single Quoted Param Value")- <|>- ((pRegExpr regex_'5cs'2a'5c'2f'3f'5cs'2a'3e >>= withAttribute "Jsp Directive") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Jsp Xml Directive Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Jsp Double Quoted Param Value")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Jsp Single Quoted Param Value")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'2f'3f'5cs'2a'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "Jsp Custom Tag Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pDetectChar False '"' >>= withAttribute "Types") >>~ pushContext "Jsp Double Quoted Custom Tag Value")- <|>- ((pDetectChar False '\'' >>= withAttribute "Types") >>~ pushContext "Jsp Single Quoted Custom Tag Value")- <|>- ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute "Normal Text") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Jsp Custom Tag Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "Jsp Double Quoted Custom Tag Value")+ <|>+ ((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ pushContext "Jsp Single Quoted Custom Tag Value")+ <|>+ ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "Jsp Double Quoted Param Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Jsp Param Value") >>~ (popContext >> popContext))- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Double Quoted Param Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Single Quoted Param Value" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Jsp Param Value") >>~ (popContext >> popContext))- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Single Quoted Param Value" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Double Quoted Custom Tag Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Types") >>~ (popContext >> popContext))- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Double Quoted Custom Tag Value" =+ (((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Single Quoted Custom Tag Value" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Types") >>~ (popContext >> popContext))- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Jsp Single Quoted Custom Tag Value" =+ (((pDetectChar False '\'' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Jsp Scriptlet" = - do (attr, result) <- (((pDetect2Chars False '%' '>' >>= withAttribute "Jsp Scriptlet") >>~ (popContext))- <|>- ((pRegExpr regex_'3c'5cs'2ajsp'3a'28declaration'7cexpression'7cscriptlet'29'5cs'2a'3e >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dkeywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_jsp'2dreserved'2dwords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dtypes >>= withAttribute "Types"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dclasses >>= withAttribute "Java 1.4.2 Classes"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Java String")- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text"))- <|>- ((pAnyChar "!%&()+,-<=>?[]^{|}~" >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Java Comment") >>~ pushContext "Java Single-Line Comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Java Comment") >>~ pushContext "Java Multi-Line Comment"))- return (attr, result)+parseRules "Jsp Scriptlet" =+ (((pDetect2Chars False '%' '>' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'3c'5cs'2ajsp'3a'28declaration'7cexpression'7cscriptlet'29'5cs'2a'3e >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dkeywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_jsp'2dreserved'2dwords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dtypes >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dclasses >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Java String")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "!%&()+,-<=>?[]^{|}~" >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Java Single-Line Comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Java Multi-Line Comment")) -parseRules "Jsp Expression" = - do (attr, result) <- (((pString False "'${'" >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Jsp Scriptlet") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dkeywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_jsp'2dreserved'2dwords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dtypes >>= withAttribute "Types"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dclasses >>= withAttribute "Java 1.4.2 Classes"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Java String")- <|>- ((pAnyChar "!%&()+,-<=>?[]^{|}~" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Jsp Expression" =+ (((pString False "'${'" >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dkeywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_jsp'2dreserved'2dwords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dtypes >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java'2d1'2e4'2e2'2dclasses >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Java String")+ <|>+ ((pAnyChar "!%&()+,-<=>?[]^{|}~" >>= withAttribute NormalTok))) -parseRules "Java Single-Line Comment" = +parseRules "Java Single-Line Comment" = pzero -parseRules "Java Multi-Line Comment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Java Comment") >>~ (popContext))- return (attr, result)+parseRules "Java Multi-Line Comment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Java String" = - do (attr, result) <- (((pDetect2Chars False '\\' '"' >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Java String" =+ (((pDetect2Chars False '\\' '"' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Html Attribute" = - do (attr, result) <- (((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Html Value")- <|>- ((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression"))- return (attr, result)+parseRules "Html Attribute" =+ (((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Html Value")+ <|>+ ((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")) -parseRules "Html Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag")- <|>- ((pRegExpr regex_'28'22'7c'26quot'3b'7c'26'2334'3b'29 >>= withAttribute "Types") >>~ pushContext "Html Double Quoted Value")- <|>- ((pRegExpr regex_'28'27'7c'26'2339'3b'29 >>= withAttribute "Types") >>~ pushContext "Html Single Quoted Value")- <|>- ((pRegExpr regex_'5cs'2a'23'3f'2d'3f'5f'3f'5c'2e'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "Types") >>~ pushContext "Html Unquoted Value")- <|>- ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute "Normal Text") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Html Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")+ <|>+ ((pRegExpr regex_'28'22'7c'26quot'3b'7c'26'2334'3b'29 >>= withAttribute DataTypeTok) >>~ pushContext "Html Double Quoted Value")+ <|>+ ((pRegExpr regex_'28'27'7c'26'2339'3b'29 >>= withAttribute DataTypeTok) >>~ pushContext "Html Single Quoted Value")+ <|>+ ((pRegExpr regex_'5cs'2a'23'3f'2d'3f'5f'3f'5c'2e'3f'5ba'2dzA'2dZ0'2d9'5d'2a >>= withAttribute DataTypeTok) >>~ pushContext "Html Unquoted Value")+ <|>+ ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext))) -parseRules "Html Double Quoted Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag")- <|>- ((pRegExpr regex_'28'22'7c'26quot'3b'7c'26'2334'3b'29 >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Html Double Quoted Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")+ <|>+ ((pRegExpr regex_'28'22'7c'26quot'3b'7c'26'2334'3b'29 >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "Html Single Quoted Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag")- <|>- ((pRegExpr regex_'28'27'7c'26'2339'3b'29 >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Html Single Quoted Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")+ <|>+ ((pRegExpr regex_'28'27'7c'26'2339'3b'29 >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "Html Unquoted Value" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute "Keyword") >>~ pushContext "Jsp Custom Tag")- <|>- ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Types") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Html Unquoted Value" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5c'24'3f'5cw'2a'3a'5c'24'3f'5cw'2a >>= withAttribute KeywordTok) >>~ pushContext "Jsp Custom Tag")+ <|>+ ((pRegExpr regex_'5c'2f'3f'3e >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute DataTypeTok) >>~ (popContext >> popContext))) -parseRules "Html Comment" = - do (attr, result) <- (((pString False "<%--" >>= withAttribute "Jsp Comment") >>~ pushContext "Jsp Comment")- <|>- ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute "Jsp Scriptlet") >>~ pushContext "Jsp Scriptlet")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Jsp Expression") >>~ pushContext "Jsp Expression")- <|>- ((pRegExpr regex_'5c'2f'2a'2d'2d'3e >>= withAttribute "Html Comment") >>~ (popContext)))- return (attr, result)+parseRules "Html Comment" =+ (((pString False "<%--" >>= withAttribute CommentTok) >>~ pushContext "Jsp Comment")+ <|>+ ((pRegExpr regex_'3c'25'28'21'7c'3d'29'3f >>= withAttribute NormalTok) >>~ pushContext "Jsp Scriptlet")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute NormalTok) >>~ pushContext "Jsp Expression")+ <|>+ ((pRegExpr regex_'5c'2f'2a'2d'2d'3e >>= withAttribute CommentTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Latex.hs view
@@ -1,805 +1,739 @@-{- This module was generated from data in the Kate syntax highlighting file latex.xml, version 1.47,- by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)+Holger Danielsson (holger.danielsson@versanet.de)+Michel Ludwig (michel.ludwig@kdemail.net)+Thomas Braun (thomas.braun@virtuell-zuhause.de) -}--module Text.Highlighting.Kate.Syntax.Latex ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions-import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)---- | Full name of language.-syntaxName :: String-syntaxName = "LaTeX"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.tex;*.ltx;*.dtx;*.sty;*.cls;*.bbx;*.cbx;*.lbx;"---- | 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 = "LaTeX" }- context <- currentContext <|> (pushContext "Normal Text" >> 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 [("LaTeX",["Normal Text"])], synStLanguage = "LaTeX", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Normal Text" -> return () >> pHandleEndLine- "NoWeb" -> return () >> pHandleEndLine- "Sectioning" -> return () >> pHandleEndLine- "SectioningInside" -> return () >> pHandleEndLine- "SectioningContrSeq" -> (popContext) >> pEndLine- "SectioningMathMode" -> return () >> pHandleEndLine- "SectioningMathContrSeq" -> (popContext) >> pEndLine- "Footnoting" -> return () >> pHandleEndLine- "FootnotingInside" -> return () >> pHandleEndLine- "FootnotingMathMode" -> return () >> pHandleEndLine- "NewCommand" -> return () >> pHandleEndLine- "DefCommand" -> return () >> pHandleEndLine- "CommandParameterStart" -> return () >> pHandleEndLine- "CommandParameter" -> return () >> pHandleEndLine- "ContrSeq" -> (popContext) >> pEndLine- "ToEndOfLine" -> (popContext) >> pEndLine- "Verb" -> (popContext >> popContext) >> pEndLine- "VerbEnd" -> (popContext >> popContext >> popContext) >> pEndLine- "Label" -> return () >> pHandleEndLine- "LabelOption" -> return () >> pHandleEndLine- "LabelParameter" -> return () >> pHandleEndLine- "FancyLabel" -> return () >> pHandleEndLine- "FancyLabelParameter" -> return () >> pHandleEndLine- "FancyLabelRoundBrackets" -> return () >> pHandleEndLine- "FindEndEnvironment" -> return () >> pHandleEndLine- "EndEnvironment" -> return () >> pHandleEndLine- "EndLatexEnv" -> return () >> pHandleEndLine- "FindBeginEnvironment" -> return () >> pHandleEndLine- "BeginEnvironment" -> return () >> pHandleEndLine- "LatexEnv" -> return () >> pHandleEndLine- "VerbatimEnv" -> return () >> pHandleEndLine- "VerbatimEnvParam" -> return () >> pHandleEndLine- "Verbatim" -> return () >> pHandleEndLine- "VerbFindEnd" -> (popContext) >> pEndLine- "CommentEnv" -> return () >> pHandleEndLine- "BlockComment" -> return () >> pHandleEndLine- "CommFindEnd" -> (popContext) >> pEndLine- "MathEnv" -> return () >> pHandleEndLine- "MathEnvParam" -> return () >> pHandleEndLine- "EnvCommon" -> return () >> pHandleEndLine- "MathModeEnv" -> return () >> pHandleEndLine- "MathFindEnd" -> (popContext) >> pEndLine- "TabEnv" -> return () >> pHandleEndLine- "Tab" -> return () >> pHandleEndLine- "Column Separator" -> return () >> pHandleEndLine- "TabFindEnd" -> (popContext) >> pEndLine- "MathMode" -> return () >> pHandleEndLine- "MathModeDisplay" -> return () >> pHandleEndLine- "MathModeEquation" -> return () >> pHandleEndLine- "MathModeEnsure" -> return () >> pHandleEndLine- "MathModeCommon" -> return () >> pHandleEndLine- "MathContrSeq" -> (popContext) >> pEndLine- "MathModeText" -> return () >> pHandleEndLine- "MathModeTextParameterStart" -> return () >> pHandleEndLine- "MathModeTextParameter" -> return () >> pHandleEndLine- "Multiline Comment" -> return () >> pHandleEndLine- "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Error","al"),("Region Marker","re"),("Alert","al")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))---regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\begin(?=[^a-zA-Z])"-regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\end(?=[^a-zA-Z])"-regex_'5c'5c'28cite'7cparencite'7cautocite'7cAutocite'7ccitetitle'29'5c'2a'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cite|parencite|autocite|Autocite|citetitle)\\*(?=[^a-zA-Z])"-regex_'5c'5c'28cites'7cCites'7cparencites'7cParencites'7cautocites'7cAutocites'7csupercites'7cfootcites'7cFootcites'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cites|Cites|parencites|Parencites|autocites|Autocites|supercites|footcites|Footcites)(?=[^a-zA-Z])"-regex_'5c'5c'28cite'7cnocite'7cCite'7cparencite'7cParencite'7cfootcite'7cFootcite'7ctextcite'7cTextcite'7csupercite'7cautocite'7cAutocite'7cciteauthor'7cCiteauthor'7ccitetitle'7cciteyear'7cciteurl'7cnocite'7cfullcite'7cfootfullcite'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cite|nocite|Cite|parencite|Parencite|footcite|Footcite|textcite|Textcite|supercite|autocite|Autocite|citeauthor|Citeauthor|citetitle|citeyear|citeurl|nocite|fullcite|footfullcite)(?=[^a-zA-Z])"-regex_'5c'5c'28subref'5c'2a'3f'7ccref'5c'2a'3f'7clabel'7cpageref'7cautoref'7cref'7cvpageref'7cvref'7cpagecite'7ceqref'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(subref\\*?|cref\\*?|label|pageref|autoref|ref|vpageref|vref|pagecite|eqref)(?=[^a-zA-Z])"-regex_'5c'5c'28part'7cchapter'7csection'7csubsection'7csubsubsection'7cparagraph'7csubparagraph'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 = compileRegex "\\\\(part|chapter|section|subsection|subsubsection|paragraph|subparagraph)\\*?\\s*(?=[\\{\\[])"-regex_'5c'5c'28footnote'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 = compileRegex "\\\\(footnote)\\*?\\s*(?=[\\{\\[])"-regex_'5c'5c'28renewcommand'7cprovidenewcommand'7cnewcommand'29'5c'2a'3f'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(renewcommand|providenewcommand|newcommand)\\*?(?=[^a-zA-Z])"-regex_'5c'5c'28e'7cg'7cx'29'3fdef'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(e|g|x)?def(?=[^a-zA-Z])"-regex_'3c'3c'2e'2a'3e'3e'3d = compileRegex "<<.*>>="-regex_'25'5cs'2aBEGIN'2e'2a'24 = compileRegex "%\\s*BEGIN.*$"-regex_'25'5cs'2aEND'2e'2a'24 = compileRegex "%\\s*END.*$"-regex_'5cs'2a'40'5cs'2a = compileRegex "\\s*@\\s*"-regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d = compileRegex "\\[[^\\]]*\\]"-regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 = compileRegex "[a-zA-Z]+(\\+?|\\*{0,3})"-regex_'5b'5ea'2dzA'2dZ'5d = compileRegex "[^a-zA-Z]"-regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f = compileRegex "[a-zA-Z]+\\*?"-regex_'5cs'2a'5c'7b'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5cs'2a'5c'7d'28'5c'5b'5cd'5c'5d'28'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d'29'3f'29'3f'5c'7b = compileRegex "\\s*\\{\\s*\\\\[a-zA-Z]+\\s*\\}(\\[\\d\\](\\[[^\\]]*\\])?)?\\{"-regex_'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5b'5e'5c'7b'5d'2a'5c'7b = compileRegex "\\s*\\\\[a-zA-Z]+[^\\{]*\\{"-regex_'5c'5c'2e = compileRegex "\\\\."-regex_'28Verb'7cverb'7clstinline'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "(Verb|verb|lstinline)(?=[^a-zA-Z])"-regex_'5ba'2dzA'2dZ'40'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 = compileRegex "[a-zA-Z@]+(\\+?|\\*{0,3})"-regex_'5cs'2a'5c'7b'5cs'2a = compileRegex "\\s*\\{\\s*"-regex_'5cs'2a'5c'5b'5cs'2a = compileRegex "\\s*\\[\\s*"-regex_'5b'5e'5c'5b'5c'7b'5d'2b = compileRegex "[^\\[\\{]+"-regex_'5cs'2a'5c'5d'5cs'2a = compileRegex "\\s*\\]\\s*"-regex_'5cs'2a'5c'7d'5cs'2a = compileRegex "\\s*\\}\\s*"-regex_'5cs'2a'5c'28'5cs'2a = compileRegex "\\s*\\(\\s*"-regex_'5cs'2a'5c'29'5cs'2a = compileRegex "\\s*\\)\\s*"-regex_'5cS = compileRegex "\\S"-regex_'5ba'2dzA'2dZ'5d = compileRegex "[a-zA-Z]"-regex_'5cs'2b = compileRegex "\\s+"-regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2a'29'3f = compileRegex "[a-zA-Z]+(\\*)?"-regex_'28lstlisting'7c'28B'7cL'29'3fVerbatim'29 = compileRegex "(lstlisting|(B|L)?Verbatim)"-regex_'28verbatim'7cboxedverbatim'29 = compileRegex "(verbatim|boxedverbatim)"-regex_comment = compileRegex "comment"-regex_'28alignat'7cxalignat'7cxxalignat'29 = compileRegex "(alignat|xalignat|xxalignat)"-regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29 = compileRegex "(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)"-regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29 = compileRegex "(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)"-regex_'5b'5ea'2dzA'2dZ'5cxd7'5d = compileRegex "[^a-zA-Z\\xd7]"-regex_'5ba'2dzA'2dZ'5d'2b = compileRegex "[a-zA-Z]+"-regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{(verbatim|lstlisting|boxedverbatim|(B|L)?Verbatim)\\*?\\})"-regex_'5cs'2a'5c'7b = compileRegex "\\s*\\{"-regex_'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f = compileRegex "(verbatim|lstlisting|boxedverbatim|(B|L)?Verbatim)\\*?"-regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7bcomment'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{comment\\*?\\})"-regex_comment'5c'2a'3f = compileRegex "comment\\*?"-regex_'5c'7d'5c'7b'5b'5e'5c'7d'5d'2a'5c'7d = compileRegex "\\}\\{[^\\}]*\\}"-regex_'5c'2a'28'3f'3d'5c'7d'29 = compileRegex "\\*(?=\\})"-regex_'5c'2a'5b'5e'5c'7d'5d'2a = compileRegex "\\*[^\\}]*"-regex_'5b'5ea'2dzA'2dZ'5cxd7'5d'5b'5e'5c'7d'5d'2a = compileRegex "[^a-zA-Z\\xd7][^\\}]*"-regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 = compileRegex "\\\\(text|intertext|mbox)\\s*(?=\\{)"-regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29'5c'2a'3f = compileRegex "(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|alignat|xalignat|xxalignat|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)\\*?"-regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)\\*?\\})"-regex_'2e = compileRegex "."-regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f = compileRegex "(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)\\*?"-regex_'5c'5c'28begin'7cend'29'5cs'2a'5c'7b'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'29'5c'2a'3f'5c'7d = compileRegex "\\\\(begin|end)\\s*\\{(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|alignat|xalignat|xxalignat|IEEEeqnarray)\\*?\\}"-regex_'5c'24'2e'2a'5c'24 = compileRegex "\\$.*\\$"-regex_'28FIXME'7cTODO'29'3a'3f = compileRegex "(FIXME|TODO):?"--defaultAttributes = [("Normal Text","Normal Text"),("NoWeb","Normal Text"),("Sectioning","Normal Text"),("SectioningInside","Structure Text"),("SectioningContrSeq","Keyword"),("SectioningMathMode","Structure Math"),("SectioningMathContrSeq","Structure Keyword Mathmode"),("Footnoting","Normal Text"),("FootnotingInside","Normal Text"),("FootnotingMathMode","Math"),("NewCommand","Normal Text"),("DefCommand","Normal Text"),("CommandParameterStart","Normal Text"),("CommandParameter","Normal Text"),("ContrSeq","Keyword"),("ToEndOfLine","Normal Text"),("Verb","Verbatim"),("VerbEnd","Verbatim"),("Label","Normal Text"),("LabelOption","Normal Text"),("LabelParameter","Environment"),("FancyLabel","Normal Text"),("FancyLabelParameter","Environment"),("FancyLabelRoundBrackets","Normal Text"),("FindEndEnvironment","Normal Text"),("EndEnvironment","Environment"),("EndLatexEnv","Environment"),("FindBeginEnvironment","Normal Text"),("BeginEnvironment","Environment"),("LatexEnv","Environment"),("VerbatimEnv","Environment"),("VerbatimEnvParam","Normal Text"),("Verbatim","Verbatim"),("VerbFindEnd","Normal Text"),("CommentEnv","Environment"),("BlockComment","Comment"),("CommFindEnd","Normal Text"),("MathEnv","Environment"),("MathEnvParam","Normal Text"),("EnvCommon","Environment"),("MathModeEnv","Math"),("MathFindEnd","Normal Text"),("TabEnv","Environment"),("Tab","Tab"),("Column Separator","Column Separator"),("TabFindEnd","Normal Text"),("MathMode","Math"),("MathModeDisplay","Math"),("MathModeEquation","Math"),("MathModeEnsure","Math"),("MathModeCommon","Math"),("MathContrSeq","Keyword Mathmode"),("MathModeText","Normal Text"),("MathModeTextParameterStart","Normal Text"),("MathModeTextParameter","Normal Text"),("Multiline Comment","Comment"),("Comment","Comment")]--parseRules "Normal Text" = - do (attr, result) <- (((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "FindBeginEnvironment")- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "FindEndEnvironment")- <|>- ((pRegExpr regex_'5c'5c'28cite'7cparencite'7cautocite'7cAutocite'7ccitetitle'29'5c'2a'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "Label")- <|>- ((pRegExpr regex_'5c'5c'28cites'7cCites'7cparencites'7cParencites'7cautocites'7cAutocites'7csupercites'7cfootcites'7cFootcites'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "FancyLabel")- <|>- ((pRegExpr regex_'5c'5c'28cite'7cnocite'7cCite'7cparencite'7cParencite'7cfootcite'7cFootcite'7ctextcite'7cTextcite'7csupercite'7cautocite'7cAutocite'7cciteauthor'7cCiteauthor'7ccitetitle'7cciteyear'7cciteurl'7cnocite'7cfullcite'7cfootfullcite'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "Label")- <|>- ((pRegExpr regex_'5c'5c'28subref'5c'2a'3f'7ccref'5c'2a'3f'7clabel'7cpageref'7cautoref'7cref'7cvpageref'7cvref'7cpagecite'7ceqref'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "Label")- <|>- ((pRegExpr regex_'5c'5c'28part'7cchapter'7csection'7csubsection'7csubsubsection'7cparagraph'7csubparagraph'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 >>= withAttribute "Structure") >>~ pushContext "Sectioning")- <|>- ((pRegExpr regex_'5c'5c'28footnote'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 >>= withAttribute "Keyword") >>~ pushContext "Footnoting")- <|>- ((pRegExpr regex_'5c'5c'28renewcommand'7cprovidenewcommand'7cnewcommand'29'5c'2a'3f'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword") >>~ pushContext "NewCommand")- <|>- ((pRegExpr regex_'5c'5c'28e'7cg'7cx'29'3fdef'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword") >>~ pushContext "DefCommand")- <|>- ((pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d >>= withAttribute "Normal Text") >>~ pushContext "NoWeb")- <|>- ((pString False "\\(" >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pString False "\\[" >>= withAttribute "Math") >>~ pushContext "MathModeEquation")- <|>- ((pString False "\\iffalse" >>= withAttribute "Comment") >>~ pushContext "Multiline Comment")- <|>- ((pString False "\\ensuremath{" >>= withAttribute "Math") >>~ pushContext "MathModeEnsure")- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword") >>~ pushContext "ContrSeq")- <|>- ((pString False "$$" >>= withAttribute "Math") >>~ pushContext "MathModeDisplay")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet")))- return (attr, result)--parseRules "NoWeb" = - do (attr, result) <- ((pColumn 0 >> pRegExpr regex_'5cs'2a'40'5cs'2a >>= withAttribute "Normal Text") >>~ (popContext))- return (attr, result)--parseRules "Sectioning" = - do (attr, result) <- (((pRegExpr regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ' ' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "SectioningInside")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "SectioningInside" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "SectioningInside")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pString False "\\(" >>= withAttribute "Structure Math") >>~ pushContext "SectioningMathMode")- <|>- ((pDetectChar False '\\' >>= withAttribute "Structure Keyword") >>~ pushContext "SectioningContrSeq")- <|>- ((pDetectChar False '$' >>= withAttribute "Structure Math") >>~ pushContext "SectioningMathMode")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet")))- return (attr, result)--parseRules "SectioningContrSeq" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute "Structure Keyword") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Structure Keyword") >>~ (popContext)))- return (attr, result)--parseRules "SectioningMathMode" = - do (attr, result) <- (((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '$' >>= withAttribute "Structure Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Structure Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Error"))- <|>- ((pDetectChar False '\\' >>= withAttribute "Structure Keyword Mathmode") >>~ pushContext "SectioningMathContrSeq")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet")))- return (attr, result)--parseRules "SectioningMathContrSeq" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute "Structure Keyword Mathmode") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Structure Keyword Mathmode") >>~ (popContext)))- return (attr, result)--parseRules "Footnoting" = - do (attr, result) <- (((pRegExpr regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ' ' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "FootnotingInside")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "FootnotingInside" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "FootnotingInside")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pString False "\\(" >>= withAttribute "Math") >>~ pushContext "FootnotingMathMode")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ pushContext "FootnotingMathMode")- <|>- ((parseRules "Normal Text")))- return (attr, result)--parseRules "FootnotingMathMode" = - do (attr, result) <- (((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Error"))- <|>- ((parseRules "MathMode")))- return (attr, result)--parseRules "NewCommand" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5cs'2a'5c'7d'28'5c'5b'5cd'5c'5d'28'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d'29'3f'29'3f'5c'7b >>= withAttribute "Normal Text") >>~ pushContext "CommandParameterStart")- <|>- ((pDetectChar False '}' >>= withAttribute "Error") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "DefCommand" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5b'5e'5c'7b'5d'2a'5c'7b >>= withAttribute "Normal Text") >>~ pushContext "CommandParameterStart")- <|>- ((pDetectChar False '}' >>= withAttribute "Error") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "CommandParameterStart" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CommandParameter")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)--parseRules "CommandParameter" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "CommandParameter")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)--parseRules "ContrSeq" = - do (attr, result) <- (((pString False "verb*" >>= withAttribute "Keyword") >>~ pushContext "Verb")- <|>- ((pRegExpr regex_'28Verb'7cverb'7clstinline'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword") >>~ pushContext "Verb")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'40'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)--parseRules "ToEndOfLine" = - pzero--parseRules "Verb" = - do (attr, result) <- ((pRegExprDynamic "(.)" >>= withAttribute "Normal Text") >>~ pushContext "VerbEnd")- return (attr, result)--parseRules "VerbEnd" = - do (attr, result) <- (((pString True "%1" >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExprDynamic "[^%1\\xd7]*" >>= withAttribute "Verbatim")))- return (attr, result)--parseRules "Label" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "LabelParameter")- <|>- ((pRegExpr regex_'5cs'2a'5c'5b'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "LabelOption")- <|>- ((pRegExpr regex_'5b'5e'5c'5b'5c'7b'5d'2b >>= withAttribute "Error")))- return (attr, result)--parseRules "LabelOption" = - do (attr, result) <- (((pString False "\\(" >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword") >>~ pushContext "ContrSeq")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5cs'2a'5c'5d'5cs'2a >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "LabelParameter" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a >>= withAttribute "Normal Text") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "FancyLabel" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "FancyLabelParameter")- <|>- ((pRegExpr regex_'5cs'2a'5c'5b'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "LabelOption")- <|>- ((pRegExpr regex_'5cs'2a'5c'28'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "FancyLabelRoundBrackets")- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "FancyLabelParameter" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "FancyLabelRoundBrackets" = - do (attr, result) <- (((pString False "\\(" >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword") >>~ pushContext "ContrSeq")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5cs'2a'5c'29'5cs'2a >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "FindEndEnvironment" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "EndEnvironment")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "EndEnvironment" = - do (attr, result) <- (((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute "Environment") >>~ pushContext "EndLatexEnv")- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Error") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Error") >>~ (popContext)))- return (attr, result)--parseRules "EndLatexEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2a'29'3f >>= withAttribute "Environment"))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute "Error") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "FindBeginEnvironment" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "BeginEnvironment")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Normal Text") >>~ (popContext)))- return (attr, result)--parseRules "BeginEnvironment" = - do (attr, result) <- (((pRegExpr regex_'28lstlisting'7c'28B'7cL'29'3fVerbatim'29 >>= withAttribute "Environment") >>~ pushContext "VerbatimEnvParam")- <|>- ((pRegExpr regex_'28verbatim'7cboxedverbatim'29 >>= withAttribute "Environment") >>~ pushContext "VerbatimEnv")- <|>- ((pRegExpr regex_comment >>= withAttribute "Environment") >>~ pushContext "CommentEnv")- <|>- ((pRegExpr regex_'28alignat'7cxalignat'7cxxalignat'29 >>= withAttribute "Environment") >>~ pushContext "MathEnvParam")- <|>- ((pRegExpr regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29 >>= withAttribute "Environment") >>~ pushContext "MathEnv")- <|>- ((pRegExpr regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29 >>= withAttribute "Environment") >>~ pushContext "TabEnv")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute "Environment") >>~ pushContext "LatexEnv")- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Error") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5cxd7'5d >>= withAttribute "Error") >>~ (popContext)))- return (attr, result)--parseRules "LatexEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b >>= withAttribute "Environment"))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Error"))- <|>- ((parseRules "EnvCommon")))- return (attr, result)--parseRules "VerbatimEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "Verbatim")- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "EnvCommon"))- <|>- ((popContext >> popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "VerbatimEnvParam" = - do (attr, result) <- (((pDetect2Chars False '}' '[' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "Verbatim")- <|>- ((pDetectChar False ']' >>= withAttribute "Normal Text") >>~ pushContext "Verbatim"))- return (attr, result)--parseRules "Verbatim" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f'5c'7d'29 >>= withAttribute "Structure") >>~ pushContext "VerbFindEnd"))- return (attr, result)--parseRules "VerbFindEnd" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f >>= withAttribute "Environment"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext >> popContext >> popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "CommentEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "BlockComment")- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "EnvCommon"))- <|>- ((popContext >> popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "BlockComment" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7bcomment'5c'2a'3f'5c'7d'29 >>= withAttribute "Structure") >>~ pushContext "CommFindEnd"))- return (attr, result)--parseRules "CommFindEnd" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_comment'5c'2a'3f >>= withAttribute "Environment"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext >> popContext >> popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "MathEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "MathModeEnv")- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "EnvCommon")))- return (attr, result)--parseRules "MathEnvParam" = - do (attr, result) <- (((pRegExpr regex_'5c'7d'5c'7b'5b'5e'5c'7d'5d'2a'5c'7d >>= withAttribute "Normal Text") >>~ pushContext "MathModeEnv")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "MathModeEnv")- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "EnvCommon")))- return (attr, result)--parseRules "EnvCommon" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5c'2a'28'3f'3d'5c'7d'29 >>= withAttribute "Environment"))- <|>- ((pRegExpr regex_'5c'2a'5b'5e'5c'7d'5d'2a >>= withAttribute "Error") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5cxd7'5d'5b'5e'5c'7d'5d'2a >>= withAttribute "Error") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "MathModeEnv" = - do (attr, result) <- (((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "FindBeginEnvironment")- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Structure") >>~ pushContext "MathFindEnd")- <|>- ((pString False "\\(" >>= withAttribute "Error"))- <|>- ((pString False "\\[" >>= withAttribute "Error"))- <|>- ((pString False "\\)" >>= withAttribute "Error"))- <|>- ((pString False "\\]" >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute "Keyword Mathmode") >>~ pushContext "MathModeText")- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword Mathmode") >>~ pushContext "MathContrSeq")- <|>- ((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '$' >>= withAttribute "Error"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker")))- return (attr, result)--parseRules "MathFindEnd" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29'5c'2a'3f >>= withAttribute "Environment"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext >> popContext >> popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "TabEnv" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ pushContext "Tab")- <|>- ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "EnvCommon"))- <|>- ((popContext >> popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "Tab" = - do (attr, result) <- (((pDetectChar False '&' >>= withAttribute "Ampersand"))- <|>- ((pString False "@{" >>= withAttribute "Column Separator") >>~ pushContext "Column Separator")- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f'5c'7d'29 >>= withAttribute "Structure") >>~ pushContext "TabFindEnd")- <|>- ((parseRules "Normal Text")))- return (attr, result)--parseRules "Column Separator" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Column Separator") >>~ pushContext "Column Separator")- <|>- ((pDetectChar False '}' >>= withAttribute "Column Separator") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "Column Separator")))- return (attr, result)--parseRules "TabFindEnd" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f >>= withAttribute "Environment"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext >> popContext >> popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "MathMode" = - do (attr, result) <- (((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Error"))- <|>- ((parseRules "MathModeCommon")))- return (attr, result)--parseRules "MathModeDisplay" = - do (attr, result) <- (((pString False "$$" >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetectChar False '$' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Error"))- <|>- ((parseRules "MathModeCommon")))- return (attr, result)--parseRules "MathModeEquation" = - do (attr, result) <- (((pDetect2Chars False '\\' ']' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '$' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Error"))- <|>- ((parseRules "MathModeCommon")))- return (attr, result)--parseRules "MathModeEnsure" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Math") >>~ pushContext "MathModeEnsure")- <|>- ((pDetectChar False '}' >>= withAttribute "Math") >>~ (popContext))- <|>- ((parseRules "MathModeCommon")))- return (attr, result)--parseRules "MathModeCommon" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'28begin'7cend'29'5cs'2a'5c'7b'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'29'5c'2a'3f'5c'7d >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword Mathmode"))- <|>- ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword Mathmode"))- <|>- ((pRegExpr regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute "Keyword Mathmode") >>~ pushContext "MathModeText")- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword Mathmode") >>~ pushContext "MathContrSeq")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet")))- return (attr, result)--parseRules "MathContrSeq" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute "Keyword Mathmode") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Keyword Mathmode") >>~ (popContext)))- return (attr, result)--parseRules "MathModeText" = - do (attr, result) <- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "MathModeTextParameterStart")- return (attr, result)--parseRules "MathModeTextParameterStart" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5c'24'2e'2a'5c'24 >>= withAttribute "Math"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "MathModeTextParameter")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)--parseRules "MathModeTextParameter" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "MathModeTextParameter")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment"))- return (attr, result)--parseRules "Multiline Comment" = - do (attr, result) <- (((pString False "\\fi" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pString False "\\else" >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)--parseRules "Comment" = - do (attr, result) <- (((pRegExpr regex_'28FIXME'7cTODO'29'3a'3f >>= withAttribute "Alert"))- <|>- ((pString False "\\KileResetHL" >>= withAttribute "Comment") >>~ pushContext "Normal Text")- <|>- ((pString False "\\KateResetHL" >>= withAttribute "Comment") >>~ pushContext "Normal Text"))- return (attr, result)+{- This module was generated from data in the Kate syntax+ highlighting file latex.xml, version 1.47, by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)+Holger Danielsson (holger.danielsson@versanet.de)+Michel Ludwig (michel.ludwig@kdemail.net)+Thomas Braun (thomas.braun@virtuell-zuhause.de) -}++module Text.Highlighting.Kate.Syntax.Latex+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Common+import Text.ParserCombinators.Parsec hiding (State)+import Data.Map (fromList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe)++-- | Full name of language.+syntaxName :: String+syntaxName = "LaTeX"++-- | Filename extensions for this language.+syntaxExtensions :: String+syntaxExtensions = "*.tex;*.ltx;*.dtx;*.sty;*.cls;*.bbx;*.cbx;*.lbx;"++-- | Highlight source code using this syntax definition.+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState++parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine++-- | Parse an expression using appropriate local context.+parseExpression :: KateParser Token+parseExpression = do+ st <- getState+ let oldLang = synStLanguage st+ setState $ st { synStLanguage = "LaTeX" }+ context <- currentContext <|> (pushContext "Normal Text" >> currentContext)+ result <- parseRules context+ optional $ eof >> pEndLine+ updateState $ \st -> st { synStLanguage = oldLang }+ return result++startingState = SyntaxState {synStContexts = fromList [("LaTeX",["Normal Text"])], synStLanguage = "LaTeX", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}++pEndLine = do+ context <- currentContext+ case context of+ "Normal Text" -> return ()+ "NoWeb" -> return ()+ "Sectioning" -> return ()+ "SectioningInside" -> return ()+ "SectioningContrSeq" -> (popContext) >> pEndLine+ "SectioningMathMode" -> return ()+ "SectioningMathContrSeq" -> (popContext) >> pEndLine+ "Footnoting" -> return ()+ "FootnotingInside" -> return ()+ "FootnotingMathMode" -> return ()+ "NewCommand" -> return ()+ "DefCommand" -> return ()+ "CommandParameterStart" -> return ()+ "CommandParameter" -> return ()+ "ContrSeq" -> (popContext) >> pEndLine+ "ToEndOfLine" -> (popContext) >> pEndLine+ "Verb" -> (popContext >> popContext) >> pEndLine+ "VerbEnd" -> (popContext >> popContext >> popContext) >> pEndLine+ "Label" -> return ()+ "LabelOption" -> return ()+ "LabelParameter" -> return ()+ "FancyLabel" -> return ()+ "FancyLabelParameter" -> return ()+ "FancyLabelRoundBrackets" -> return ()+ "FindEndEnvironment" -> return ()+ "EndEnvironment" -> return ()+ "EndLatexEnv" -> return ()+ "FindBeginEnvironment" -> return ()+ "BeginEnvironment" -> return ()+ "LatexEnv" -> return ()+ "VerbatimEnv" -> return ()+ "VerbatimEnvParam" -> return ()+ "Verbatim" -> return ()+ "VerbFindEnd" -> (popContext) >> pEndLine+ "CommentEnv" -> return ()+ "BlockComment" -> return ()+ "CommFindEnd" -> (popContext) >> pEndLine+ "MathEnv" -> return ()+ "MathEnvParam" -> return ()+ "EnvCommon" -> return ()+ "MathModeEnv" -> return ()+ "MathFindEnd" -> (popContext) >> pEndLine+ "TabEnv" -> return ()+ "Tab" -> return ()+ "Column Separator" -> return ()+ "TabFindEnd" -> (popContext) >> pEndLine+ "MathMode" -> return ()+ "MathModeDisplay" -> return ()+ "MathModeEquation" -> return ()+ "MathModeEnsure" -> return ()+ "MathModeCommon" -> return ()+ "MathContrSeq" -> (popContext) >> pEndLine+ "MathModeText" -> return ()+ "MathModeTextParameterStart" -> return ()+ "MathModeTextParameter" -> return ()+ "Multiline Comment" -> return ()+ "Comment" -> (popContext) >> pEndLine+ _ -> return ()++withAttribute attr txt = do+ when (null txt) $ fail "Parser matched no text"+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt)++parseExpressionInternal = do+ context <- currentContext+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))+++regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\begin(?=[^a-zA-Z])"+regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\end(?=[^a-zA-Z])"+regex_'5c'5c'28cite'7cparencite'7cautocite'7cAutocite'7ccitetitle'29'5c'2a'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cite|parencite|autocite|Autocite|citetitle)\\*(?=[^a-zA-Z])"+regex_'5c'5c'28cites'7cCites'7cparencites'7cParencites'7cautocites'7cAutocites'7csupercites'7cfootcites'7cFootcites'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cites|Cites|parencites|Parencites|autocites|Autocites|supercites|footcites|Footcites)(?=[^a-zA-Z])"+regex_'5c'5c'28cite'7cnocite'7cCite'7cparencite'7cParencite'7cfootcite'7cFootcite'7ctextcite'7cTextcite'7csupercite'7cautocite'7cAutocite'7cciteauthor'7cCiteauthor'7ccitetitle'7cciteyear'7cciteurl'7cnocite'7cfullcite'7cfootfullcite'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(cite|nocite|Cite|parencite|Parencite|footcite|Footcite|textcite|Textcite|supercite|autocite|Autocite|citeauthor|Citeauthor|citetitle|citeyear|citeurl|nocite|fullcite|footfullcite)(?=[^a-zA-Z])"+regex_'5c'5c'28subref'5c'2a'3f'7ccref'5c'2a'3f'7clabel'7cpageref'7cautoref'7cref'7cvpageref'7cvref'7cpagecite'7ceqref'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(subref\\*?|cref\\*?|label|pageref|autoref|ref|vpageref|vref|pagecite|eqref)(?=[^a-zA-Z])"+regex_'5c'5c'28part'7cchapter'7csection'7csubsection'7csubsubsection'7cparagraph'7csubparagraph'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 = compileRegex "\\\\(part|chapter|section|subsection|subsubsection|paragraph|subparagraph)\\*?\\s*(?=[\\{\\[])"+regex_'5c'5c'28footnote'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 = compileRegex "\\\\(footnote)\\*?\\s*(?=[\\{\\[])"+regex_'5c'5c'28renewcommand'7cprovidenewcommand'7cnewcommand'29'5c'2a'3f'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(renewcommand|providenewcommand|newcommand)\\*?(?=[^a-zA-Z])"+regex_'5c'5c'28e'7cg'7cx'29'3fdef'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "\\\\(e|g|x)?def(?=[^a-zA-Z])"+regex_'3c'3c'2e'2a'3e'3e'3d = compileRegex "<<.*>>="+regex_'25'5cs'2aBEGIN'2e'2a'24 = compileRegex "%\\s*BEGIN.*$"+regex_'25'5cs'2aEND'2e'2a'24 = compileRegex "%\\s*END.*$"+regex_'5cs'2a'40'5cs'2a = compileRegex "\\s*@\\s*"+regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d = compileRegex "\\[[^\\]]*\\]"+regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 = compileRegex "[a-zA-Z]+(\\+?|\\*{0,3})"+regex_'5b'5ea'2dzA'2dZ'5d = compileRegex "[^a-zA-Z]"+regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f = compileRegex "[a-zA-Z]+\\*?"+regex_'5cs'2a'5c'7b'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5cs'2a'5c'7d'28'5c'5b'5cd'5c'5d'28'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d'29'3f'29'3f'5c'7b = compileRegex "\\s*\\{\\s*\\\\[a-zA-Z]+\\s*\\}(\\[\\d\\](\\[[^\\]]*\\])?)?\\{"+regex_'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5b'5e'5c'7b'5d'2a'5c'7b = compileRegex "\\s*\\\\[a-zA-Z]+[^\\{]*\\{"+regex_'5c'5c'2e = compileRegex "\\\\."+regex_'28Verb'7cverb'7clstinline'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 = compileRegex "(Verb|verb|lstinline)(?=[^a-zA-Z])"+regex_'5ba'2dzA'2dZ'40'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 = compileRegex "[a-zA-Z@]+(\\+?|\\*{0,3})"+regex_'5cs'2a'5c'7b'5cs'2a = compileRegex "\\s*\\{\\s*"+regex_'5cs'2a'5c'5b'5cs'2a = compileRegex "\\s*\\[\\s*"+regex_'5b'5e'5c'5b'5c'7b'5d'2b = compileRegex "[^\\[\\{]+"+regex_'5cs'2a'5c'5d'5cs'2a = compileRegex "\\s*\\]\\s*"+regex_'5cs'2a'5c'7d'5cs'2a = compileRegex "\\s*\\}\\s*"+regex_'5cs'2a'5c'28'5cs'2a = compileRegex "\\s*\\(\\s*"+regex_'5cs'2a'5c'29'5cs'2a = compileRegex "\\s*\\)\\s*"+regex_'5cS = compileRegex "\\S"+regex_'5ba'2dzA'2dZ'5d = compileRegex "[a-zA-Z]"+regex_'5cs'2b = compileRegex "\\s+"+regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2a'29'3f = compileRegex "[a-zA-Z]+(\\*)?"+regex_'28lstlisting'7c'28B'7cL'29'3fVerbatim'29 = compileRegex "(lstlisting|(B|L)?Verbatim)"+regex_'28verbatim'7cboxedverbatim'29 = compileRegex "(verbatim|boxedverbatim)"+regex_comment = compileRegex "comment"+regex_'28alignat'7cxalignat'7cxxalignat'29 = compileRegex "(alignat|xalignat|xxalignat)"+regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29 = compileRegex "(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)"+regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29 = compileRegex "(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)"+regex_'5b'5ea'2dzA'2dZ'5cxd7'5d = compileRegex "[^a-zA-Z\\xd7]"+regex_'5ba'2dzA'2dZ'5d'2b = compileRegex "[a-zA-Z]+"+regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{(verbatim|lstlisting|boxedverbatim|(B|L)?Verbatim)\\*?\\})"+regex_'5cs'2a'5c'7b = compileRegex "\\s*\\{"+regex_'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f = compileRegex "(verbatim|lstlisting|boxedverbatim|(B|L)?Verbatim)\\*?"+regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7bcomment'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{comment\\*?\\})"+regex_comment'5c'2a'3f = compileRegex "comment\\*?"+regex_'5c'7d'5c'7b'5b'5e'5c'7d'5d'2a'5c'7d = compileRegex "\\}\\{[^\\}]*\\}"+regex_'5c'2a'28'3f'3d'5c'7d'29 = compileRegex "\\*(?=\\})"+regex_'5c'2a'5b'5e'5c'7d'5d'2a = compileRegex "\\*[^\\}]*"+regex_'5b'5ea'2dzA'2dZ'5cxd7'5d'5b'5e'5c'7d'5d'2a = compileRegex "[^a-zA-Z\\xd7][^\\}]*"+regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 = compileRegex "\\\\(text|intertext|mbox)\\s*(?=\\{)"+regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29'5c'2a'3f = compileRegex "(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|alignat|xalignat|xxalignat|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)\\*?"+regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f'5c'7d'29 = compileRegex "\\\\end(?=\\s*\\{(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)\\*?\\})"+regex_'2e = compileRegex "."+regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f = compileRegex "(tabularx|tabular|supertabular|mpsupertabular|xtabular|mpxtabular|longtable)\\*?"+regex_'5c'5c'28begin'7cend'29'5cs'2a'5c'7b'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'29'5c'2a'3f'5c'7d = compileRegex "\\\\(begin|end)\\s*\\{(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|alignat|xalignat|xxalignat|IEEEeqnarray)\\*?\\}"+regex_'5c'24'2e'2a'5c'24 = compileRegex "\\$.*\\$"+regex_'28FIXME'7cTODO'29'3a'3f = compileRegex "(FIXME|TODO):?"++defaultAttributes = [("Normal Text",NormalTok),("NoWeb",NormalTok),("Sectioning",NormalTok),("SectioningInside",NormalTok),("SectioningContrSeq",NormalTok),("SectioningMathMode",NormalTok),("SectioningMathContrSeq",NormalTok),("Footnoting",NormalTok),("FootnotingInside",NormalTok),("FootnotingMathMode",NormalTok),("NewCommand",NormalTok),("DefCommand",NormalTok),("CommandParameterStart",NormalTok),("CommandParameter",NormalTok),("ContrSeq",NormalTok),("ToEndOfLine",NormalTok),("Verb",NormalTok),("VerbEnd",NormalTok),("Label",NormalTok),("LabelOption",NormalTok),("LabelParameter",NormalTok),("FancyLabel",NormalTok),("FancyLabelParameter",NormalTok),("FancyLabelRoundBrackets",NormalTok),("FindEndEnvironment",NormalTok),("EndEnvironment",NormalTok),("EndLatexEnv",NormalTok),("FindBeginEnvironment",NormalTok),("BeginEnvironment",NormalTok),("LatexEnv",NormalTok),("VerbatimEnv",NormalTok),("VerbatimEnvParam",NormalTok),("Verbatim",NormalTok),("VerbFindEnd",NormalTok),("CommentEnv",NormalTok),("BlockComment",CommentTok),("CommFindEnd",NormalTok),("MathEnv",NormalTok),("MathEnvParam",NormalTok),("EnvCommon",NormalTok),("MathModeEnv",NormalTok),("MathFindEnd",NormalTok),("TabEnv",NormalTok),("Tab",NormalTok),("Column Separator",NormalTok),("TabFindEnd",NormalTok),("MathMode",NormalTok),("MathModeDisplay",NormalTok),("MathModeEquation",NormalTok),("MathModeEnsure",NormalTok),("MathModeCommon",NormalTok),("MathContrSeq",NormalTok),("MathModeText",NormalTok),("MathModeTextParameterStart",NormalTok),("MathModeTextParameter",NormalTok),("Multiline Comment",CommentTok),("Comment",CommentTok)]++parseRules "Normal Text" =+ (((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "FindBeginEnvironment")+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "FindEndEnvironment")+ <|>+ ((pRegExpr regex_'5c'5c'28cite'7cparencite'7cautocite'7cAutocite'7ccitetitle'29'5c'2a'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Label")+ <|>+ ((pRegExpr regex_'5c'5c'28cites'7cCites'7cparencites'7cParencites'7cautocites'7cAutocites'7csupercites'7cfootcites'7cFootcites'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "FancyLabel")+ <|>+ ((pRegExpr regex_'5c'5c'28cite'7cnocite'7cCite'7cparencite'7cParencite'7cfootcite'7cFootcite'7ctextcite'7cTextcite'7csupercite'7cautocite'7cAutocite'7cciteauthor'7cCiteauthor'7ccitetitle'7cciteyear'7cciteurl'7cnocite'7cfullcite'7cfootfullcite'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Label")+ <|>+ ((pRegExpr regex_'5c'5c'28subref'5c'2a'3f'7ccref'5c'2a'3f'7clabel'7cpageref'7cautoref'7cref'7cvpageref'7cvref'7cpagecite'7ceqref'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Label")+ <|>+ ((pRegExpr regex_'5c'5c'28part'7cchapter'7csection'7csubsection'7csubsubsection'7cparagraph'7csubparagraph'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Sectioning")+ <|>+ ((pRegExpr regex_'5c'5c'28footnote'29'5c'2a'3f'5cs'2a'28'3f'3d'5b'5c'7b'5c'5b'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Footnoting")+ <|>+ ((pRegExpr regex_'5c'5c'28renewcommand'7cprovidenewcommand'7cnewcommand'29'5c'2a'3f'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "NewCommand")+ <|>+ ((pRegExpr regex_'5c'5c'28e'7cg'7cx'29'3fdef'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "DefCommand")+ <|>+ ((pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d >>= withAttribute NormalTok) >>~ pushContext "NoWeb")+ <|>+ ((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pString False "\\[" >>= withAttribute NormalTok) >>~ pushContext "MathModeEquation")+ <|>+ ((pString False "\\iffalse" >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")+ <|>+ ((pString False "\\ensuremath{" >>= withAttribute NormalTok) >>~ pushContext "MathModeEnsure")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "ContrSeq")+ <|>+ ((pString False "$$" >>= withAttribute NormalTok) >>~ pushContext "MathModeDisplay")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok)))++parseRules "NoWeb" =+ ((pColumn 0 >> pRegExpr regex_'5cs'2a'40'5cs'2a >>= withAttribute NormalTok) >>~ (popContext))++parseRules "Sectioning" =+ (((pRegExpr regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ' ' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "SectioningInside")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "SectioningInside" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "SectioningInside")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "SectioningMathMode")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "SectioningContrSeq")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "SectioningMathMode")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok)))++parseRules "SectioningContrSeq" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "SectioningMathMode" =+ (((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "SectioningMathContrSeq")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok)))++parseRules "SectioningMathContrSeq" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "Footnoting" =+ (((pRegExpr regex_'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ' ' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "FootnotingInside")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "FootnotingInside" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "FootnotingInside")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "FootnotingMathMode")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "FootnotingMathMode")+ <|>+ ((parseRules "Normal Text")))++parseRules "FootnotingMathMode" =+ (((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute AlertTok))+ <|>+ ((parseRules "MathMode")))++parseRules "NewCommand" =+ (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5cs'2a'5c'7d'28'5c'5b'5cd'5c'5d'28'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d'29'3f'29'3f'5c'7b >>= withAttribute NormalTok) >>~ pushContext "CommandParameterStart")+ <|>+ ((pDetectChar False '}' >>= withAttribute AlertTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "DefCommand" =+ (((pRegExpr regex_'5cs'2a'5c'5c'5ba'2dzA'2dZ'5d'2b'5b'5e'5c'7b'5d'2a'5c'7b >>= withAttribute NormalTok) >>~ pushContext "CommandParameterStart")+ <|>+ ((pDetectChar False '}' >>= withAttribute AlertTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "CommandParameterStart" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CommandParameter")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment"))++parseRules "CommandParameter" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "CommandParameter")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment"))++parseRules "ContrSeq" =+ (((pString False "verb*" >>= withAttribute NormalTok) >>~ pushContext "Verb")+ <|>+ ((pRegExpr regex_'28Verb'7cverb'7clstinline'29'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Verb")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'40'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "ToEndOfLine" =+ pzero++parseRules "Verb" =+ ((pRegExprDynamic "(.)" >>= withAttribute NormalTok) >>~ pushContext "VerbEnd")++parseRules "VerbEnd" =+ (((pString True "%1" >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExprDynamic "[^%1\\xd7]*" >>= withAttribute NormalTok)))++parseRules "Label" =+ (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "LabelParameter")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'5b'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "LabelOption")+ <|>+ ((pRegExpr regex_'5b'5e'5c'5b'5c'7b'5d'2b >>= withAttribute AlertTok)))++parseRules "LabelOption" =+ (((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "ContrSeq")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5c'5d'5cs'2a >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "LabelParameter" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a >>= withAttribute NormalTok) >>~ (popContext >> popContext)))++parseRules "FancyLabel" =+ (((pRegExpr regex_'5cs'2a'5c'7b'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "FancyLabelParameter")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'5b'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "LabelOption")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'28'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "FancyLabelRoundBrackets")+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "FancyLabelParameter" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "FancyLabelRoundBrackets" =+ (((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "ContrSeq")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5c'29'5cs'2a >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "FindEndEnvironment" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "EndEnvironment")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "EndEnvironment" =+ (((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ pushContext "EndLatexEnv")+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute AlertTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute AlertTok) >>~ (popContext)))++parseRules "EndLatexEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2a'29'3f >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute AlertTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute AlertTok) >>~ (popContext >> popContext >> popContext)))++parseRules "FindBeginEnvironment" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "BeginEnvironment")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "BeginEnvironment" =+ (((pRegExpr regex_'28lstlisting'7c'28B'7cL'29'3fVerbatim'29 >>= withAttribute NormalTok) >>~ pushContext "VerbatimEnvParam")+ <|>+ ((pRegExpr regex_'28verbatim'7cboxedverbatim'29 >>= withAttribute NormalTok) >>~ pushContext "VerbatimEnv")+ <|>+ ((pRegExpr regex_comment >>= withAttribute NormalTok) >>~ pushContext "CommentEnv")+ <|>+ ((pRegExpr regex_'28alignat'7cxalignat'7cxxalignat'29 >>= withAttribute NormalTok) >>~ pushContext "MathEnvParam")+ <|>+ ((pRegExpr regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29 >>= withAttribute NormalTok) >>~ pushContext "MathEnv")+ <|>+ ((pRegExpr regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29 >>= withAttribute NormalTok) >>~ pushContext "TabEnv")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ pushContext "LatexEnv")+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute AlertTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5cxd7'5d >>= withAttribute AlertTok) >>~ (popContext)))++parseRules "LatexEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute AlertTok))+ <|>+ ((parseRules "EnvCommon")))++parseRules "VerbatimEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "Verbatim")+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "EnvCommon"))+ <|>+ ((popContext >> popContext >> popContext) >> currentContext >>= parseRules))++parseRules "VerbatimEnvParam" =+ (((pDetect2Chars False '}' '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "Verbatim")+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok) >>~ pushContext "Verbatim"))++parseRules "Verbatim" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f'5c'7d'29 >>= withAttribute NormalTok) >>~ pushContext "VerbFindEnd"))++parseRules "VerbFindEnd" =+ (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28verbatim'7clstlisting'7cboxedverbatim'7c'28B'7cL'29'3fVerbatim'29'5c'2a'3f >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext >> popContext >> popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "CommentEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "BlockComment")+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "EnvCommon"))+ <|>+ ((popContext >> popContext >> popContext) >> currentContext >>= parseRules))++parseRules "BlockComment" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7bcomment'5c'2a'3f'5c'7d'29 >>= withAttribute NormalTok) >>~ pushContext "CommFindEnd"))++parseRules "CommFindEnd" =+ (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_comment'5c'2a'3f >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext >> popContext >> popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "MathEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "MathModeEnv")+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "EnvCommon")))++parseRules "MathEnvParam" =+ (((pRegExpr regex_'5c'7d'5c'7b'5b'5e'5c'7d'5d'2a'5c'7d >>= withAttribute NormalTok) >>~ pushContext "MathModeEnv")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "MathModeEnv")+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "EnvCommon")))++parseRules "EnvCommon" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2a'28'3f'3d'5c'7d'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2a'5b'5e'5c'7d'5d'2a >>= withAttribute AlertTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5cxd7'5d'5b'5e'5c'7d'5d'2a >>= withAttribute AlertTok) >>~ (popContext >> popContext >> popContext)))++parseRules "MathModeEnv" =+ (((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "FindBeginEnvironment")+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "MathFindEnd")+ <|>+ ((pString False "\\(" >>= withAttribute AlertTok))+ <|>+ ((pString False "\\[" >>= withAttribute AlertTok))+ <|>+ ((pString False "\\)" >>= withAttribute AlertTok))+ <|>+ ((pString False "\\]" >>= withAttribute AlertTok))+ <|>+ ((pRegExpr regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute NormalTok) >>~ pushContext "MathModeText")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "MathContrSeq")+ <|>+ ((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok)))++parseRules "MathFindEnd" =+ (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'7cIEEEeqnarraybox'7csmallmatrix'7cpmatrix'7cbmatrix'7cBmatrix'7cvmatrix'7cVmatrix'29'5c'2a'3f >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext >> popContext >> popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "TabEnv" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "Tab")+ <|>+ ((lookAhead (pRegExpr regex_'5ba'2dzA'2dZ'5d) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "EnvCommon"))+ <|>+ ((popContext >> popContext >> popContext) >> currentContext >>= parseRules))++parseRules "Tab" =+ (((pDetectChar False '&' >>= withAttribute NormalTok))+ <|>+ ((pString False "@{" >>= withAttribute NormalTok) >>~ pushContext "Column Separator")+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5cs'2a'5c'7b'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f'5c'7d'29 >>= withAttribute NormalTok) >>~ pushContext "TabFindEnd")+ <|>+ ((parseRules "Normal Text")))++parseRules "Column Separator" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Column Separator")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute NormalTok)))++parseRules "TabFindEnd" =+ (((pRegExpr regex_'5cs'2a'5c'7b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28tabularx'7ctabular'7csupertabular'7cmpsupertabular'7cxtabular'7cmpxtabular'7clongtable'29'5c'2a'3f >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext >> popContext >> popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "MathMode" =+ (((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute AlertTok))+ <|>+ ((parseRules "MathModeCommon")))++parseRules "MathModeDisplay" =+ (((pString False "$$" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '$' >>= withAttribute AlertTok))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute AlertTok))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute AlertTok))+ <|>+ ((parseRules "MathModeCommon")))++parseRules "MathModeEquation" =+ (((pDetect2Chars False '\\' ']' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute AlertTok))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute AlertTok))+ <|>+ ((parseRules "MathModeCommon")))++parseRules "MathModeEnsure" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "MathModeEnsure")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "MathModeCommon")))++parseRules "MathModeCommon" =+ (((pRegExpr regex_'5c'5c'28begin'7cend'29'5cs'2a'5c'7b'28equation'7cdisplaymath'7ceqnarray'7csubeqnarray'7cmath'7cmultline'7cgather'7calign'7cflalign'7calignat'7cxalignat'7cxxalignat'7cIEEEeqnarray'29'5c'2a'3f'5c'7d >>= withAttribute AlertTok))+ <|>+ ((pRegExpr regex_'5c'5cbegin'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'5cend'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'5c'28text'7cintertext'7cmbox'29'5cs'2a'28'3f'3d'5c'7b'29 >>= withAttribute NormalTok) >>~ pushContext "MathModeText")+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "MathContrSeq")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'25'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok)))++parseRules "MathContrSeq" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "MathModeText" =+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "MathModeTextParameterStart")++parseRules "MathModeTextParameterStart" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'24'2e'2a'5c'24 >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "MathModeTextParameter")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment"))++parseRules "MathModeTextParameter" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "MathModeTextParameter")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment"))++parseRules "Multiline Comment" =+ (((pString False "\\fi" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pString False "\\else" >>= withAttribute CommentTok) >>~ (popContext)))++parseRules "Comment" =+ (((pRegExpr regex_'28FIXME'7cTODO'29'3a'3f >>= withAttribute AlertTok))+ <|>+ ((pString False "\\KileResetHL" >>= withAttribute CommentTok) >>~ pushContext "Normal Text")+ <|>+ ((pString False "\\KateResetHL" >>= withAttribute CommentTok) >>~ pushContext "Normal Text")) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Lex.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file lex.xml, version 1.01,- by Jan Villat (jan.villat@net2000.ch) -}+{- This module was generated from data in the Kate syntax+ highlighting file lex.xml, version 1.01, by Jan Villat (jan.villat@net2000.ch) -} -module Text.Highlighting.Kate.Syntax.Lex ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Lex+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Cpp-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,74 +22,61 @@ syntaxExtensions = "*.l;*.lex;*.flex" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Lex/Flex" } context <- currentContext <|> (pushContext "Pre Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Lex/Flex",["Pre Start"])], synStLanguage = "Lex/Flex", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Lex/Flex",["Pre Start"])], synStLanguage = "Lex/Flex", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Pre Start" -> return () >> pHandleEndLine- "Definitions" -> return () >> pHandleEndLine- "Rules" -> return () >> pHandleEndLine- "User Code" -> return () >> pHandleEndLine+ "Pre Start" -> return ()+ "Definitions" -> return ()+ "Rules" -> return ()+ "User Code" -> return () "Percent Command" -> (popContext) >> pEndLine- "Comment" -> return () >> pHandleEndLine+ "Comment" -> return () "Definition RegExpr" -> (popContext) >> pEndLine "Rule RegExpr" -> (popContext) >> pEndLine- "RegExpr (" -> return () >> pHandleEndLine- "RegExpr [" -> return () >> pHandleEndLine- "RegExpr {" -> return () >> pHandleEndLine- "RegExpr Q" -> return () >> pHandleEndLine- "RegExpr Base" -> return () >> pHandleEndLine- "Start Conditions Scope" -> return () >> pHandleEndLine+ "RegExpr (" -> return ()+ "RegExpr [" -> return ()+ "RegExpr {" -> return ()+ "RegExpr Q" -> return ()+ "RegExpr Base" -> return ()+ "Start Conditions Scope" -> return () "Action" -> (popContext) >> pEndLine- "Detect C" -> return () >> pHandleEndLine+ "Detect C" -> return () "Indented C" -> (popContext) >> pEndLine- "Lex C Bloc" -> return () >> pHandleEndLine- "Lex Rule C Bloc" -> return () >> pHandleEndLine- "Normal C Bloc" -> return () >> pHandleEndLine+ "Lex C Bloc" -> return ()+ "Lex Rule C Bloc" -> return ()+ "Normal C Bloc" -> return () "Action C" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Definition","dt"),("Comment","co"),("Content-Type Delimiter","bn"),("Directive","kw"),("RegExpr","st"),("Backslash Code","st"),("Alert","al")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'2e = compileRegex "."@@ -101,158 +91,138 @@ regex_'5c'7c'5cs'2a'24 = compileRegex "\\|\\s*$" regex_'5cs = compileRegex "\\s" -defaultAttributes = [("Pre Start","Normal Text"),("Definitions","Normal Text"),("Rules","Normal Text"),("User Code","Normal Text"),("Percent Command","Directive"),("Comment","Comment"),("Definition RegExpr","RegExpr"),("Rule RegExpr","RegExpr"),("RegExpr (","RegExpr"),("RegExpr [","RegExpr"),("RegExpr {","RegExpr"),("RegExpr Q","RegExpr"),("RegExpr Base","RegExpr"),("Start Conditions Scope","Normal Text"),("Action","Normal Text"),("Detect C","Normal Text"),("Indented C","Normal Text"),("Lex C Bloc","Normal Text"),("Lex Rule C Bloc","Normal Text"),("Normal C Bloc","Normal Text"),("Action C","Normal Text")]+defaultAttributes = [("Pre Start",NormalTok),("Definitions",NormalTok),("Rules",NormalTok),("User Code",NormalTok),("Percent Command",KeywordTok),("Comment",CommentTok),("Definition RegExpr",StringTok),("Rule RegExpr",StringTok),("RegExpr (",StringTok),("RegExpr [",StringTok),("RegExpr {",StringTok),("RegExpr Q",StringTok),("RegExpr Base",StringTok),("Start Conditions Scope",NormalTok),("Action",NormalTok),("Detect C",NormalTok),("Indented C",NormalTok),("Lex C Bloc",NormalTok),("Lex Rule C Bloc",NormalTok),("Normal C Bloc",NormalTok),("Action C",NormalTok)] -parseRules "Pre Start" = - do (attr, result) <- ((lookAhead (pRegExpr regex_'2e) >> return ([],"") ) >>~ pushContext "Definitions")- return (attr, result)+parseRules "Pre Start" =+ ((lookAhead (pRegExpr regex_'2e) >> return (NormalTok,"") ) >>~ pushContext "Definitions") -parseRules "Definitions" = - do (attr, result) <- (((parseRules "Detect C"))- <|>- ((pDetect2Chars False '%' '%' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "Rules")- <|>- ((pDetectChar False '%' >>= withAttribute "Directive") >>~ pushContext "Percent Command")- <|>- ((pColumn 0 >> pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5cw'2a'5cs'2b >>= withAttribute "Definition") >>~ pushContext "Definition RegExpr"))- return (attr, result)+parseRules "Definitions" =+ (((parseRules "Detect C"))+ <|>+ ((pDetect2Chars False '%' '%' >>= withAttribute BaseNTok) >>~ pushContext "Rules")+ <|>+ ((pDetectChar False '%' >>= withAttribute KeywordTok) >>~ pushContext "Percent Command")+ <|>+ ((pColumn 0 >> pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'5d'5cw'2a'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Definition RegExpr")) -parseRules "Rules" = - do (attr, result) <- (((parseRules "Detect C"))- <|>- ((pDetect2Chars False '%' '%' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "User Code")- <|>- (pushContext "Rule RegExpr" >> return ([], "")))- return (attr, result)+parseRules "Rules" =+ (((parseRules "Detect C"))+ <|>+ ((pDetect2Chars False '%' '%' >>= withAttribute BaseNTok) >>~ pushContext "User Code")+ <|>+ (pushContext "Rule RegExpr" >> currentContext >>= parseRules)) -parseRules "User Code" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))- return (attr, result)+parseRules "User Code" =+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)) -parseRules "Percent Command" = +parseRules "Percent Command" = pzero -parseRules "Comment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Comment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Definition RegExpr" = - do (attr, result) <- (((parseRules "RegExpr Base"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "RegExpr"))- <|>- ((pRegExpr regex_'2e'2a >>= withAttribute "Alert")))- return (attr, result)+parseRules "Definition RegExpr" =+ (((parseRules "RegExpr Base"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'2e'2a >>= withAttribute AlertTok))) -parseRules "Rule RegExpr" = - do (attr, result) <- (((pRegExpr regex_'5c'7b'24 >>= withAttribute "Content-Type Delimiter") >>~ pushContext "Start Conditions Scope")- <|>- ((parseRules "RegExpr Base"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "RegExpr"))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Normal Text") >>~ pushContext "Action"))- return (attr, result)+parseRules "Rule RegExpr" =+ (((pRegExpr regex_'5c'7b'24 >>= withAttribute BaseNTok) >>~ pushContext "Start Conditions Scope")+ <|>+ ((parseRules "RegExpr Base"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute NormalTok) >>~ pushContext "Action")) -parseRules "RegExpr (" = - do (attr, result) <- (((parseRules "RegExpr Base"))- <|>- ((pDetectChar False ')' >>= withAttribute "RegExpr") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "RegExpr")))- return (attr, result)+parseRules "RegExpr (" =+ (((parseRules "RegExpr Base"))+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "RegExpr [" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False ']' >>= withAttribute "RegExpr") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "RegExpr")))- return (attr, result)+parseRules "RegExpr [" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "RegExpr {" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '}' >>= withAttribute "RegExpr") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "RegExpr")))- return (attr, result)+parseRules "RegExpr {" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "RegExpr Q" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '"' >>= withAttribute "RegExpr") >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "RegExpr")))- return (attr, result)+parseRules "RegExpr Q" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute StringTok))) -parseRules "RegExpr Base" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '(' >>= withAttribute "RegExpr") >>~ pushContext "RegExpr (")- <|>- ((pDetectChar False '[' >>= withAttribute "RegExpr") >>~ pushContext "RegExpr [")- <|>- ((pDetectChar False '{' >>= withAttribute "RegExpr") >>~ pushContext "RegExpr {")- <|>- ((pDetectChar False '"' >>= withAttribute "RegExpr") >>~ pushContext "RegExpr Q"))- return (attr, result)+parseRules "RegExpr Base" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "RegExpr (")+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "RegExpr [")+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "RegExpr {")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "RegExpr Q")) -parseRules "Start Conditions Scope" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7d >>= withAttribute "Content-Type Delimiter") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Rule RegExpr")- <|>- (pushContext "Rule RegExpr" >> return ([], "")))- return (attr, result)+parseRules "Start Conditions Scope" =+ (((pRegExpr regex_'5cs'2a'5c'7d >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Rule RegExpr")+ <|>+ (pushContext "Rule RegExpr" >> currentContext >>= parseRules)) -parseRules "Action" = - do (attr, result) <- (((pRegExpr regex_'5c'7c'5cs'2a'24 >>= withAttribute "Directive"))- <|>- ((pDetect2Chars False '%' '{' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "Lex Rule C Bloc")- <|>- (pushContext "Action C" >> return ([], "")))- return (attr, result)+parseRules "Action" =+ (((pRegExpr regex_'5c'7c'5cs'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '%' '{' >>= withAttribute BaseNTok) >>~ pushContext "Lex Rule C Bloc")+ <|>+ (pushContext "Action C" >> currentContext >>= parseRules)) -parseRules "Detect C" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5cs >>= withAttribute "Normal Text") >>~ pushContext "Indented C")- <|>- ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "Lex C Bloc"))- return (attr, result)+parseRules "Detect C" =+ (((pColumn 0 >> pRegExpr regex_'5cs >>= withAttribute NormalTok) >>~ pushContext "Indented C")+ <|>+ ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute BaseNTok) >>~ pushContext "Lex C Bloc")) -parseRules "Indented C" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))- return (attr, result)+parseRules "Indented C" =+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)) -parseRules "Lex C Bloc" = - do (attr, result) <- (((pColumn 0 >> pDetect2Chars False '%' '}' >>= withAttribute "Content-Type Delimiter") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Lex C Bloc" =+ (((pColumn 0 >> pDetect2Chars False '%' '}' >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Lex Rule C Bloc" = - do (attr, result) <- (((pDetect2Chars False '%' '}' >>= withAttribute "Content-Type Delimiter") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Lex Rule C Bloc" =+ (((pDetect2Chars False '%' '}' >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Normal C Bloc" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Normal C Bloc")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Normal C Bloc" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Normal C Bloc")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Action C" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Normal C Bloc")- <|>- ((pDetectChar False '}' >>= withAttribute "Alert"))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Action C" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Normal C Bloc")+ <|>+ ((pDetectChar False '}' >>= withAttribute AlertTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) parseRules "" = parseRules "Pre Start"
Text/Highlighting/Kate/Syntax/LiterateHaskell.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file literate-haskell.xml, version 2.0.2,- by Nicolas Wu (zenzike@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file literate-haskell.xml, version 2.0.2, by Nicolas Wu (zenzike@gmail.com) -} -module Text.Highlighting.Kate.Syntax.LiterateHaskell ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.LiterateHaskell+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Haskell-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,102 +22,83 @@ syntaxExtensions = "*.lhs" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Literate Haskell" } context <- currentContext <|> (pushContext "text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Literate Haskell",["text"])], synStLanguage = "Literate Haskell", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Literate Haskell",["text"])], synStLanguage = "Literate Haskell", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "text" -> return () >> pHandleEndLine+ "text" -> return () "normal" -> (popContext) >> pEndLine- "normals" -> return () >> pHandleEndLine- "comments'" -> pushContext "uncomments" >> pHandleEndLine- "uncomments" -> return () >> pHandleEndLine+ "normals" -> return ()+ "comments'" -> pushContext "uncomments" >> return ()+ "uncomments" -> return () "recomments" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("BirdTrack","ot"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'5c'7b'2d'5b'5e'23'5d = compileRegex "\\{-[^#]" -defaultAttributes = [("text","Text"),("normal","Normal"),("normals","Normal"),("comments'","Comment"),("uncomments","Text"),("recomments","Comment")]+defaultAttributes = [("text",NormalTok),("normal",NormalTok),("normals",NormalTok),("comments'",CommentTok),("uncomments",NormalTok),("recomments",CommentTok)] -parseRules "text" = - do (attr, result) <- (((pColumn 0 >> pDetectChar False '>' >>= withAttribute "BirdTrack") >>~ pushContext "normal")- <|>- ((pColumn 0 >> pDetectChar False '<' >>= withAttribute "BirdTrack") >>~ pushContext "normal")- <|>- ((pString False "\\begin{code}" >>= withAttribute "Text") >>~ pushContext "normals")- <|>- ((pString False "\\begin{spec}" >>= withAttribute "Text") >>~ pushContext "normals"))- return (attr, result)+parseRules "text" =+ (((pColumn 0 >> pDetectChar False '>' >>= withAttribute OtherTok) >>~ pushContext "normal")+ <|>+ ((pColumn 0 >> pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "normal")+ <|>+ ((pString False "\\begin{code}" >>= withAttribute NormalTok) >>~ pushContext "normals")+ <|>+ ((pString False "\\begin{spec}" >>= withAttribute NormalTok) >>~ pushContext "normals")) -parseRules "normal" = - do (attr, result) <- (((pRegExpr regex_'5c'7b'2d'5b'5e'23'5d >>= withAttribute "Comment") >>~ pushContext "comments'")- <|>- ((Text.Highlighting.Kate.Syntax.Haskell.parseExpression)))- return (attr, result)+parseRules "normal" =+ (((pRegExpr regex_'5c'7b'2d'5b'5e'23'5d >>= withAttribute CommentTok) >>~ pushContext "comments'")+ <|>+ ((Text.Highlighting.Kate.Syntax.Haskell.parseExpression))) -parseRules "normals" = - do (attr, result) <- (((pString False "\\end{code}" >>= withAttribute "Normal") >>~ (popContext))- <|>- ((pString False "\\end{spec}" >>= withAttribute "Normal") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Haskell.parseExpression)))- return (attr, result)+parseRules "normals" =+ (((pString False "\\end{code}" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pString False "\\end{spec}" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Haskell.parseExpression))) -parseRules "comments'" = - do (attr, result) <- ((pDetect2Chars False '-' '}' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "comments'" =+ ((pDetect2Chars False '-' '}' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "uncomments" = - do (attr, result) <- (((pColumn 0 >> pDetectChar False '>' >>= withAttribute "BirdTrack") >>~ pushContext "recomments")- <|>- ((pColumn 0 >> pDetectChar False '<' >>= withAttribute "BirdTrack") >>~ pushContext "recomments"))- return (attr, result)+parseRules "uncomments" =+ (((pColumn 0 >> pDetectChar False '>' >>= withAttribute OtherTok) >>~ pushContext "recomments")+ <|>+ ((pColumn 0 >> pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "recomments")) -parseRules "recomments" = - do (attr, result) <- ((pDetect2Chars False '-' '}' >>= withAttribute "Comment") >>~ (popContext >> popContext >> popContext))- return (attr, result)+parseRules "recomments" =+ ((pDetect2Chars False '-' '}' >>= withAttribute CommentTok) >>~ (popContext >> popContext >> popContext)) parseRules "" = parseRules "text"
Text/Highlighting/Kate/Syntax/Lua.hs view
@@ -1,16 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file lua.xml, version 1.04,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file lua.xml, version 1.04, by -} -module Text.Highlighting.Kate.Syntax.Lua ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Lua+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import qualified Text.Highlighting.Kate.Syntax.Doxygenlua-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Lua"@@ -20,61 +22,48 @@ syntaxExtensions = "*.lua" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Lua" } context <- currentContext <|> (pushContext "Base" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Lua",["Base"])], synStLanguage = "Lua", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Lua",["Base"])], synStLanguage = "Lua", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Base" -> pushContext "Normal" >> pHandleEndLine- "Normal" -> return () >> pHandleEndLine+ "Base" -> pushContext "Normal" >> return ()+ "Normal" -> return () "Comment" -> (popContext) >> pEndLine- "Block Comment" -> return () >> pHandleEndLine- "String_single" -> pushContext "Error" >> pHandleEndLine- "String_double" -> pushContext "Error" >> pHandleEndLine- "String_block" -> return () >> pHandleEndLine- "Error" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Block Comment" -> return ()+ "String_single" -> pushContext "Error" >> return ()+ "String_double" -> pushContext "Error" >> return ()+ "String_block" -> return ()+ "Error" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Alerts","al"),("BFunc","fu"),("Comment","co"),("Constant","kw"),("Control","kw"),("Error","er"),("Keyword","kw"),("Numbers","dv"),("Strings","st"),("Symbols","ot"),("Variable","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "and function in local not or" list_control = Set.fromList $ words $ "break do else elseif end for if repeat return then until while"@@ -84,7 +73,6 @@ list_deprecated = Set.fromList $ words $ "table.foreach table.foreachi foreach foreachi" regex_'23'21'2e'2a'24 = compileRegex "#!.*$"-regex_'2e'2a'24 = compileRegex ".*$" regex_'5cbfunction'5cb = compileRegex "\\bfunction\\b" regex_'5cbelse'5cb = compileRegex "\\belse\\b" regex_'5cbelseif'5cb = compileRegex "\\belseif\\b"@@ -99,111 +87,102 @@ regex_'5c'5c'28a'7cb'7cf'7cn'7cr'7ct'7cv'7c'5c'5c'7c'22'7c'5c'27'7c'5b'7c'5d'29 = compileRegex "\\\\(a|b|f|n|r|t|v|\\\\|\"|\\'|[|])" regex_'5c'5c'5babfnrtv'27'22'5c'5c'5c'5b'5c'5d'5d = compileRegex "\\\\[abfnrtv'\"\\\\\\[\\]]" -defaultAttributes = [("Base","Comment"),("Normal","Normal Text"),("Comment","Comment"),("Block Comment","Comment"),("String_single","Strings"),("String_double","Strings"),("String_block","Strings"),("Error","Error")]+defaultAttributes = [("Base",CommentTok),("Normal",NormalTok),("Comment",CommentTok),("Block Comment",CommentTok),("String_single",StringTok),("String_double",StringTok),("String_block",StringTok),("Error",ErrorTok)] -parseRules "Base" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'23'21'2e'2a'24 >>= withAttribute "Comment") >>~ pushContext "Normal")- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'2e'2a'24) >> return ([],"") ) >>~ pushContext "Normal"))- return (attr, result)+parseRules "Base" =+ (((pColumn 0 >> pRegExpr regex_'23'21'2e'2a'24 >>= withAttribute CommentTok) >>~ pushContext "Normal")+ <|>+ (pushContext "Normal" >> currentContext >>= parseRules)) -parseRules "Normal" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Doxygenlua.parseExpression))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_deprecated >>= withAttribute "Error"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pRegExprDynamic "--\\[(=*)\\[" >>= withAttribute "Comment") >>~ pushContext "Block Comment")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExprDynamic "\\[(=*)\\[" >>= withAttribute "Strings") >>~ pushContext "String_block")- <|>- ((pDetectChar False '\'' >>= withAttribute "Strings") >>~ pushContext "String_single")- <|>- ((pDetectChar False '"' >>= withAttribute "Strings") >>~ pushContext "String_double")- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_basefunc >>= withAttribute "BFunc"))- <|>- ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_pseudo'2dvariables >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbelse'5cb >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'5cbelseif'5cb >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'5cbdo'5cb >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'5cbif'5cb >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'5cbend'5cb >>= withAttribute "Control"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_control >>= withAttribute "Control"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbols"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbols"))- <|>- ((pRegExpr regex_'5cb'5cd'2a'5c'2e'3f'5cd'2a'28e'7ce'5c'2d'7ce'5c'2b'29'3f'5cd'2b'5cb >>= withAttribute "Numbers"))- <|>- ((pRegExpr regex_'5cb'2d'3f0'5bxX'5d'5b0'2d9a'2dfA'2dF'5d'2b'5cb >>= withAttribute "Numbers"))- <|>- ((pRegExpr regex_'5cb'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'28'3f'3d'5cs'2a'28'5b'28'7b'27'22'5d'7c'5c'5b'5c'5b'29'29'5cb >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5cb'5bA'2dZ'5f'5d'5bA'2dZ0'2d9'5f'5d'2a'5cb >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5cb'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5cb >>= withAttribute "Variable"))- <|>- ((pDetect2Chars False '!' '=' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '-' '=' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '+' '=' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '+' '+' >>= withAttribute "Error"))- <|>- ((pDetect2Chars False '.' '=' >>= withAttribute "Error"))- <|>- ((pAnyChar "[]().=~+-*/^><#;" >>= withAttribute "Symbols")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_deprecated >>= withAttribute ErrorTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExprDynamic "--\\[(=*)\\[" >>= withAttribute CommentTok) >>~ pushContext "Block Comment")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExprDynamic "\\[(=*)\\[" >>= withAttribute StringTok) >>~ pushContext "String_block")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String_single")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String_double")+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_basefunc >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5cbfunction'5cb >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_pseudo'2dvariables >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbelse'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbelseif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdo'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cb >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_control >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cb'5cd'2a'5c'2e'3f'5cd'2a'28e'7ce'5c'2d'7ce'5c'2b'29'3f'5cd'2b'5cb >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'2d'3f0'5bxX'5d'5b0'2d9a'2dfA'2dF'5d'2b'5cb >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'28'3f'3d'5cs'2a'28'5b'28'7b'27'22'5d'7c'5c'5b'5c'5b'29'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZ'5f'5d'5bA'2dZ0'2d9'5f'5d'2a'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5cb >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '!' '=' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '-' '=' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '+' '=' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '+' '+' >>= withAttribute ErrorTok))+ <|>+ ((pDetect2Chars False '.' '=' >>= withAttribute ErrorTok))+ <|>+ ((pAnyChar "[]().=~+-*/^><#;" >>= withAttribute OtherTok))) -parseRules "Comment" = - do (attr, result) <- (((pDetect2Chars False '-' '-' >>= withAttribute "Alerts"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_attention >>= withAttribute "Alerts")))- return (attr, result)+parseRules "Comment" =+ (((pDetect2Chars False '-' '-' >>= withAttribute AlertTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_attention >>= withAttribute AlertTok))) -parseRules "Block Comment" = - do (attr, result) <- (((pRegExprDynamic "\\]%1\\]" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Alerts"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_attention >>= withAttribute "Alerts")))- return (attr, result)+parseRules "Block Comment" =+ (((pRegExprDynamic "\\]%1\\]" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute AlertTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\\"" list_attention >>= withAttribute AlertTok))) -parseRules "String_single" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'28a'7cb'7cf'7cn'7cr'7ct'7cv'7c'5c'5c'7c'22'7c'5c'27'7c'5b'7c'5d'29 >>= withAttribute "Symbols"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Strings") >>~ (popContext)))- return (attr, result)+parseRules "String_single" =+ (((pRegExpr regex_'5c'5c'28a'7cb'7cf'7cn'7cr'7ct'7cv'7c'5c'5c'7c'22'7c'5c'27'7c'5b'7c'5d'29 >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "String_double" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5babfnrtv'27'22'5c'5c'5c'5b'5c'5d'5d >>= withAttribute "Symbols"))- <|>- ((pDetectChar False '"' >>= withAttribute "Strings") >>~ (popContext)))- return (attr, result)+parseRules "String_double" =+ (((pRegExpr regex_'5c'5c'5babfnrtv'27'22'5c'5c'5c'5b'5c'5d'5d >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "String_block" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'28a'7cb'7cf'7cn'7cr'7ct'7cv'7c'5c'5c'7c'22'7c'5c'27'7c'5b'7c'5d'29 >>= withAttribute "Symbols"))- <|>- ((pRegExprDynamic "\\]%1\\]" >>= withAttribute "Strings") >>~ (popContext)))- return (attr, result)+parseRules "String_block" =+ (((pRegExpr regex_'5c'5c'28a'7cb'7cf'7cn'7cr'7ct'7cv'7c'5c'5c'7c'22'7c'5c'27'7c'5b'7c'5d'29 >>= withAttribute OtherTok))+ <|>+ ((pRegExprDynamic "\\]%1\\]" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Error" = +parseRules "Error" = pzero parseRules "" = parseRules "Base"
Text/Highlighting/Kate/Syntax/Makefile.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file makefile.xml, version 1.12,- by Per Wigren (wigren@home.se) -}+{- This module was generated from data in the Kate syntax+ highlighting file makefile.xml, version 1.12, by Per Wigren (wigren@home.se) -} -module Text.Highlighting.Kate.Syntax.Makefile ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Makefile+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Makefile"@@ -19,63 +22,50 @@ syntaxExtensions = "GNUmakefile;Makefile;makefile;GNUmakefile.*;Makefile.*;makefile.*" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Makefile" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Makefile",["Normal"])], synStLanguage = "Makefile", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Makefile",["Normal"])], synStLanguage = "Makefile", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Value" -> (popContext) >> pEndLine- "VarFromValue(" -> return () >> pHandleEndLine- "VarFromValue{" -> return () >> pHandleEndLine- "VarFromNormal(" -> return () >> pHandleEndLine- "VarFromNormal{" -> return () >> pHandleEndLine- "FunctionCall(" -> return () >> pHandleEndLine- "FunctionCall{" -> return () >> pHandleEndLine+ "VarFromValue(" -> return ()+ "VarFromValue{" -> return ()+ "VarFromNormal(" -> return ()+ "VarFromNormal{" -> return ()+ "FunctionCall(" -> return ()+ "FunctionCall{" -> return () "Commands" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Comment","co"),("String","st"),("Variable","dt"),("Target","dv"),("Section","ot"),("Operator","ch"),("Commands","bn"),("Special","fl")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "include define else endef endif ifdef ifeq ifndef ifneq" list_functions = Set.fromList $ words $ "call subst patsubst strip findstring filter filter-out sort word wordlist words firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath if or and foreach value eval origin flavor shell error warning info"@@ -87,95 +77,85 @@ regex_'40'5b'2d'5f'5cd'5cw'5d'2a'40 = compileRegex "@[-_\\d\\w]*@" regex_'5b'5f'5cw'2d'5d'2a'5cb = compileRegex "[_\\w-]*\\b" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Value","String"),("VarFromValue(","Variable"),("VarFromValue{","Variable"),("VarFromNormal(","Variable"),("VarFromNormal{","Variable"),("FunctionCall(","String"),("FunctionCall{","String"),("Commands","Normal Text")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Value",StringTok),("VarFromValue(",DataTypeTok),("VarFromValue{",DataTypeTok),("VarFromNormal(",DataTypeTok),("VarFromNormal{",DataTypeTok),("FunctionCall(",StringTok),("FunctionCall{",StringTok),("Commands",NormalTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5b'5f'5cw'5cd'5d'2a'5cs'2a'28'3f'3d'3a'3d'7c'3d'7c'5c'2b'3d'7c'5c'3f'3d'29 >>= withAttribute "Variable") >>~ pushContext "Value")- <|>- ((pFirstNonSpace >> pRegExpr regex_'5b'5f'5cw'5cd'2d'5d'2a'5cs'2a'3a >>= withAttribute "Target"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'2e'5d'2e'2a'3a >>= withAttribute "Section"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal{")- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal(")- <|>- ((pDetect2Chars False '\\' '#' >>= withAttribute "Special"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Special"))- <|>- ((pAnyChar "+*=%$():\\;" >>= withAttribute "Operator"))- <|>- ((pFirstNonSpace >> pAnyChar "@-" >>= withAttribute "Operator") >>~ pushContext "Commands")- <|>- ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5b'5f'5cw'5cd'5d'2a'5cs'2a'28'3f'3d'3a'3d'7c'3d'7c'5c'2b'3d'7c'5c'3f'3d'29 >>= withAttribute DataTypeTok) >>~ pushContext "Value")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5b'5f'5cw'5cd'2d'5d'2a'5cs'2a'3a >>= withAttribute DecValTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5b'2e'5d'2e'2a'3a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal{")+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal(")+ <|>+ ((pDetect2Chars False '\\' '#' >>= withAttribute FloatTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute FloatTok))+ <|>+ ((pAnyChar "+*=%$():\\;" >>= withAttribute CharTok))+ <|>+ ((pFirstNonSpace >> pAnyChar "@-" >>= withAttribute CharTok) >>~ pushContext "Commands")+ <|>+ ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Value" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '$' '{' >>= withAttribute "Operator") >>~ pushContext "VarFromValue{")- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Operator") >>~ pushContext "VarFromValue(")- <|>- ((pRegExpr regex_'40'5b'2d'5f'5cd'5cw'5d'2a'40 >>= withAttribute "Special") >>~ (popContext))- <|>- ((pDetectChar False ';' >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)+parseRules "Value" =+ (((pLineContinue >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '$' '{' >>= withAttribute CharTok) >>~ pushContext "VarFromValue{")+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute CharTok) >>~ pushContext "VarFromValue(")+ <|>+ ((pRegExpr regex_'40'5b'2d'5f'5cd'5cw'5d'2a'40 >>= withAttribute FloatTok) >>~ (popContext))+ <|>+ ((pDetectChar False ';' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "VarFromValue(" = - do (attr, result) <- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)+parseRules "VarFromValue(" =+ ((pDetectChar False ')' >>= withAttribute CharTok) >>~ (popContext)) -parseRules "VarFromValue{" = - do (attr, result) <- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)+parseRules "VarFromValue{" =+ ((pDetectChar False '}' >>= withAttribute CharTok) >>~ (popContext)) -parseRules "VarFromNormal(" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Keyword") >>~ pushContext "FunctionCall(")- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)+parseRules "VarFromNormal(" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute KeywordTok) >>~ pushContext "FunctionCall(")+ <|>+ ((pDetectChar False ')' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "VarFromNormal{" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Keyword") >>~ pushContext "FunctionCall{")- <|>- ((pDetectChar False '}' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "VarFromNormal{" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute KeywordTok) >>~ pushContext "FunctionCall{")+ <|>+ ((pDetectChar False '}' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "FunctionCall(" = - do (attr, result) <- (((pDetect2Chars False '$' '{' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal{")- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal(")- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "FunctionCall(" =+ (((pDetect2Chars False '$' '{' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal{")+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal(")+ <|>+ ((pDetectChar False ')' >>= withAttribute CharTok) >>~ (popContext >> popContext))) -parseRules "FunctionCall{" = - do (attr, result) <- (((pDetect2Chars False '$' '{' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal{")- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal(")- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "FunctionCall{" =+ (((pDetect2Chars False '$' '{' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal{")+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal(")+ <|>+ ((pDetectChar False '}' >>= withAttribute CharTok) >>~ (popContext >> popContext))) -parseRules "Commands" = - do (attr, result) <- (((pDetect2Chars False '$' '{' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal{")- <|>- ((pDetect2Chars False '$' '(' >>= withAttribute "Operator") >>~ pushContext "VarFromNormal(")- <|>- ((pRegExpr regex_'5b'5f'5cw'2d'5d'2a'5cb >>= withAttribute "Commands") >>~ (popContext)))- return (attr, result)+parseRules "Commands" =+ (((pDetect2Chars False '$' '{' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal{")+ <|>+ ((pDetect2Chars False '$' '(' >>= withAttribute CharTok) >>~ pushContext "VarFromNormal(")+ <|>+ ((pRegExpr regex_'5b'5f'5cw'2d'5d'2a'5cb >>= withAttribute BaseNTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Mandoc.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file mandoc.xml, version 0.11,- by Matthew Woehlke (mw_triad@users.sourceforge.net) -}+{- This module was generated from data in the Kate syntax+ highlighting file mandoc.xml, version 0.11, by Matthew Woehlke (mw_triad@users.sourceforge.net) -} -module Text.Highlighting.Kate.Syntax.Mandoc ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Mandoc+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Troff Mandoc"@@ -19,56 +22,43 @@ syntaxExtensions = "*.1;*.2;*.3;*.4;*.5;*.6;*.7;*.8;*.1m;*.3x;*.tmac" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Troff Mandoc" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Troff Mandoc",["Normal"])], synStLanguage = "Troff Mandoc", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Troff Mandoc",["Normal"])], synStLanguage = "Troff Mandoc", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "DetectDirective" -> (popContext) >> pEndLine "Directive" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Macros","fu"),("Headings","kw"),("Paragraphs","dt"),("Formatting","kw"),("Other Macros","fu"),("Identifier","st")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_headings = Set.fromList $ words $ "SH SS TH" list_paragraph = Set.fromList $ words $ "HP IP LP P PD PP RE RS TP"@@ -76,31 +66,28 @@ list_others = Set.fromList $ words $ "DT" -defaultAttributes = [("Normal","Normal Text"),("DetectDirective","Macros"),("Directive","Identifier")]+defaultAttributes = [("Normal",NormalTok),("DetectDirective",FunctionTok),("Directive",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((parseRules "DetectComments##Roff"))- <|>- ((pColumn 0 >> pDetectChar False '.' >>= withAttribute "Macros") >>~ pushContext "DetectDirective")- <|>- ((parseRules "DetectOthers##Roff")))- return (attr, result)+parseRules "Normal" =+ (((parseRules "DetectComments##Roff"))+ <|>+ ((pColumn 0 >> pDetectChar False '.' >>= withAttribute FunctionTok) >>~ pushContext "DetectDirective")+ <|>+ ((parseRules "DetectOthers##Roff"))) -parseRules "DetectDirective" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_headings >>= withAttribute "Headings") >>~ pushContext "Directive")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_paragraph >>= withAttribute "Paragraphs") >>~ pushContext "Directive")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_formatting >>= withAttribute "Formatting") >>~ pushContext "Directive")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_others >>= withAttribute "Other Macros") >>~ pushContext "Directive")- <|>- ((parseRules "DetectDirective##Roff")))- return (attr, result)+parseRules "DetectDirective" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_headings >>= withAttribute KeywordTok) >>~ pushContext "Directive")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_paragraph >>= withAttribute DataTypeTok) >>~ pushContext "Directive")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_formatting >>= withAttribute KeywordTok) >>~ pushContext "Directive")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_others >>= withAttribute FunctionTok) >>~ pushContext "Directive")+ <|>+ ((parseRules "DetectDirective##Roff"))) -parseRules "Directive" = - do (attr, result) <- ((parseRules "Directive##Roff"))- return (attr, result)+parseRules "Directive" =+ ((parseRules "Directive##Roff")) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Matlab.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file matlab.xml, version 1.30,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file matlab.xml, version 1.30, by -} -module Text.Highlighting.Kate.Syntax.Matlab ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Matlab+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Matlab"@@ -19,55 +22,42 @@ syntaxExtensions = "*.m;*.M" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Matlab" } context <- currentContext <|> (pushContext "_normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Matlab",["_normal"])], synStLanguage = "Matlab", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Matlab",["_normal"])], synStLanguage = "Matlab", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of "_normal" -> (popContext) >> pEndLine "_adjoint" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Number","fl"),("String","st"),("System","bn"),("Incomplete String","ch"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_KeywordsList = Set.fromList $ words $ "break case catch classdef continue else elseif end for function global if otherwise parfor persistent return spmd switch try while methods properties events" @@ -83,61 +73,59 @@ regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f = compileRegex "(\\d+(\\.\\d+)?|\\.\\d+)([eE][+-]?\\d+)?[ij]?" regex_'27'2b = compileRegex "'+" -defaultAttributes = [("_normal","Normal Text"),("_adjoint","Operator")]+defaultAttributes = [("_normal",NormalTok),("_adjoint",NormalTok)] -parseRules "_normal" = - do (attr, result) <- (((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a'28'3f'3d'27'29 >>= withAttribute "Variable") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f'28'3f'3d'27'29 >>= withAttribute "Number") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'5b'5c'29'5c'5d'7d'5d'28'3f'3d'27'29 >>= withAttribute "Delimiter") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'5c'2e'27'28'3f'3d'27'29 >>= withAttribute "Operator") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'28'27'27'5b'5e'27'5d'2a'29'2a'27'28'3f'3d'5b'5e'27'5d'7c'24'29 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'27'5b'5e'27'5d'2a'28'27'27'5b'5e'27'5d'2a'29'2a >>= withAttribute "Incomplete String"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_KeywordsList >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'25'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'21'2e'2a'24 >>= withAttribute "System"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f >>= withAttribute "Number"))- <|>- ((pAnyChar "()[]{}" >>= withAttribute "Delimiter"))- <|>- ((pString False "..." >>= withAttribute "Operator"))- <|>- ((pString False "==" >>= withAttribute "Operator"))- <|>- ((pString False "~=" >>= withAttribute "Operator"))- <|>- ((pString False "<=" >>= withAttribute "Operator"))- <|>- ((pString False ">=" >>= withAttribute "Operator"))- <|>- ((pString False "&&" >>= withAttribute "Operator"))- <|>- ((pString False "||" >>= withAttribute "Operator"))- <|>- ((pString False ".*" >>= withAttribute "Operator"))- <|>- ((pString False ".^" >>= withAttribute "Operator"))- <|>- ((pString False "./" >>= withAttribute "Operator"))- <|>- ((pString False ".'" >>= withAttribute "Operator"))- <|>- ((pAnyChar "*+-/\\&|<>~^=,;:@" >>= withAttribute "Operator")))- return (attr, result)+parseRules "_normal" =+ (((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f'28'3f'3d'27'29 >>= withAttribute FloatTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'5b'5c'29'5c'5d'7d'5d'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'5c'2e'27'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'28'27'27'5b'5e'27'5d'2a'29'2a'27'28'3f'3d'5b'5e'27'5d'7c'24'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'27'5b'5e'27'5d'2a'28'27'27'5b'5e'27'5d'2a'29'2a >>= withAttribute CharTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_KeywordsList >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'21'2e'2a'24 >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f >>= withAttribute FloatTok))+ <|>+ ((pAnyChar "()[]{}" >>= withAttribute NormalTok))+ <|>+ ((pString False "..." >>= withAttribute NormalTok))+ <|>+ ((pString False "==" >>= withAttribute NormalTok))+ <|>+ ((pString False "~=" >>= withAttribute NormalTok))+ <|>+ ((pString False "<=" >>= withAttribute NormalTok))+ <|>+ ((pString False ">=" >>= withAttribute NormalTok))+ <|>+ ((pString False "&&" >>= withAttribute NormalTok))+ <|>+ ((pString False "||" >>= withAttribute NormalTok))+ <|>+ ((pString False ".*" >>= withAttribute NormalTok))+ <|>+ ((pString False ".^" >>= withAttribute NormalTok))+ <|>+ ((pString False "./" >>= withAttribute NormalTok))+ <|>+ ((pString False ".'" >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "*+-/\\&|<>~^=,;:@" >>= withAttribute NormalTok))) -parseRules "_adjoint" = - do (attr, result) <- ((pRegExpr regex_'27'2b >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)+parseRules "_adjoint" =+ ((pRegExpr regex_'27'2b >>= withAttribute NormalTok) >>~ (popContext)) parseRules "" = parseRules "_normal"
Text/Highlighting/Kate/Syntax/Maxima.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file maxima.xml, version 0.16,- by Alexey Beshenov <al@beshenov.ru> -}+{- This module was generated from data in the Kate syntax+ highlighting file maxima.xml, version 0.16, by Alexey Beshenov <al@beshenov.ru> -} -module Text.Highlighting.Kate.Syntax.Maxima ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Maxima+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Maxima"@@ -19,56 +22,43 @@ syntaxExtensions = "*.mac;*.MAC;*.dem;*.DEM" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Maxima" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Maxima",["Normal Text"])], synStLanguage = "Maxima", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Maxima",["Normal Text"])], synStLanguage = "Maxima", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of "Normal Text" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ "Comment" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("String","st"),("Function","fu"),("Integer","dv"),("Float","fl")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_MaximaKeyword = Set.fromList $ words $ "and do else elseif false for if in not or step then thru true while" list_SpecialComment = Set.fromList $ words $ "FIXME TODO"@@ -81,43 +71,40 @@ regex_'5b'2d'2b'5d'3f'5cd'2b'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b = compileRegex "[-+]?\\d+[BbDdEeSs][-+]?\\d+" regex_'5b'2d'2b'5d'3f'5cd'2b = compileRegex "[-+]?\\d+" -defaultAttributes = [("Normal Text","Normal Text"),("String","String"),("Comment","Comment")]+defaultAttributes = [("Normal Text",NormalTok),("String",StringTok),("Comment",NormalTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaFunction >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaVariable >>= withAttribute "Variable"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaKeyword >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'25'5f'5d'2a >>= withAttribute "Label"))- <|>- ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b'5c'2e'5cd'2a'28'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5b'2d'2b'5d'3f'5c'2e'5cd'2b'28'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b >>= withAttribute "Integer"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Quote")))- return (attr, result)+parseRules "Normal Text" =+ (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaFunction >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaVariable >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_MaximaKeyword >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute NormalTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'25'5f'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b'5c'2e'5cd'2a'28'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5b'2d'2b'5d'3f'5c'2e'5cd'2b'28'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b'5bBbDdEeSs'5d'5b'2d'2b'5d'3f'5cd'2b >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5b'2d'2b'5d'3f'5cd'2b >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Comment" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_SpecialComment >>= withAttribute "Special"))- <|>- ((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Comment" =+ (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\@#" list_SpecialComment >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute NormalTok) >>~ (popContext))) parseRules "" = parseRules "Normal Text"
− Text/Highlighting/Kate/Syntax/Mediawiki.hs
@@ -1,221 +0,0 @@-{- This module was generated from data in the Kate syntax highlighting file mediawiki.xml, version 1.02,- by -}--module Text.Highlighting.Kate.Syntax.Mediawiki ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions-import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)---- | Full name of language.-syntaxName :: String-syntaxName = "MediaWiki"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = ""---- | 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 = "MediaWiki" }- 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 [("MediaWiki",["normal"])], synStLanguage = "MediaWiki", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "normal" -> return () >> pHandleEndLine- "Table" -> return () >> pHandleEndLine- "comment" -> return () >> pHandleEndLine- "URL" -> return () >> pHandleEndLine- "WikiLink" -> return () >> pHandleEndLine- "WikiLinkDescription" -> return () >> pHandleEndLine- "Link" -> return () >> pHandleEndLine- "Error" -> (popContext) >> pEndLine- "Template" -> return () >> pHandleEndLine- "NoWiki" -> return () >> pHandleEndLine- "Unformatted" -> (popContext) >> pEndLine- "Pre" -> return () >> pHandleEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Link","ot"),("URL","ot"),("Comment","co"),("Section","kw"),("HTML-Entity","dv"),("HTML-Tag","kw"),("Wiki-Tag","dv"),("Error","er")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))---regex_'28'5b'3d'5d'7b2'2c2'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b2'2c2'7d'7c'5b'3d'5d'7b3'2c3'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b3'2c3'7d'7c'5b'3d'5d'7b4'2c4'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b4'2c4'7d'7c'5b'3d'5d'7b5'2c5'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b5'2c5'7d'29 = compileRegex "([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})"-regex_'5b'7e'5d'7b3'2c4'7d = compileRegex "[~]{3,4}"-regex_'5b'2a'23'3b'3a'5cs'5d'2a'5b'2a'23'3a'5d'2b = compileRegex "[*#;:\\s]*[*#:]+"-regex_'5b'5b'5d'28'3f'21'5b'5b'5d'29 = compileRegex "[[](?![[])"-regex_'28http'3a'7cftp'3a'7cmailto'3a'29'5b'5cS'5d'2a'28'24'7c'5b'5cs'5d'29 = compileRegex "(http:|ftp:|mailto:)[\\S]*($|[\\s])"-regex_'5b'27'5d'7b2'2c'7d = compileRegex "[']{2,}"-regex_'5b'3c'5d'5b'5e'3e'5d'2b'5b'3e'5d = compileRegex "[<][^>]+[>]"-regex_'5b'5cs'5d = compileRegex "[\\s]"-regex_'5b'2d'5d'7b4'2c'7d = compileRegex "[-]{4,}"-regex_'3c'21'2d'2d'5b'5e'2d'5d'2a'2d'2d'3e = compileRegex "<!--[^-]*-->"--defaultAttributes = [("normal","Normal"),("Table","Normal"),("comment","Comment"),("URL","Link"),("WikiLink","Link"),("WikiLinkDescription","Link"),("Link","Template"),("Error","Error"),("Template","Link"),("NoWiki","NoWiki"),("Unformatted","Unformatted"),("Pre","NoWiki")]--parseRules "normal" = - do (attr, result) <- (((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pColumn 0 >> pRegExpr regex_'28'5b'3d'5d'7b2'2c2'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b2'2c2'7d'7c'5b'3d'5d'7b3'2c3'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b3'2c3'7d'7c'5b'3d'5d'7b4'2c4'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b4'2c4'7d'7c'5b'3d'5d'7b5'2c5'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b5'2c5'7d'29 >>= withAttribute "Section"))- <|>- ((pRegExpr regex_'5b'7e'5d'7b3'2c4'7d >>= withAttribute "Wiki-Tag"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'2a'23'3b'3a'5cs'5d'2a'5b'2a'23'3a'5d'2b >>= withAttribute "Wiki-Tag"))- <|>- ((pRegExpr regex_'5b'5b'5d'28'3f'21'5b'5b'5d'29 >>= withAttribute "Wiki-Tag") >>~ pushContext "URL")- <|>- ((pRegExpr regex_'28http'3a'7cftp'3a'7cmailto'3a'29'5b'5cS'5d'2a'28'24'7c'5b'5cs'5d'29 >>= withAttribute "URL"))- <|>- ((pRegExpr regex_'5b'27'5d'7b2'2c'7d >>= withAttribute "Wiki-Tag"))- <|>- ((pColumn 0 >> pDetect2Chars False '{' '|' >>= withAttribute "Wiki-Tag") >>~ pushContext "Table")- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Wiki-Tag") >>~ pushContext "Template")- <|>- ((pDetect2Chars False '[' '[' >>= withAttribute "Wiki-Tag") >>~ pushContext "WikiLink")- <|>- ((pRangeDetect '&' ';' >>= withAttribute "HTML-Entity"))- <|>- ((pString False "<nowiki>" >>= withAttribute "Wiki-Tag") >>~ pushContext "NoWiki")- <|>- ((pString False "<pre>" >>= withAttribute "HTML-Tag") >>~ pushContext "Pre")- <|>- ((pRegExpr regex_'5b'3c'5d'5b'5e'3e'5d'2b'5b'3e'5d >>= withAttribute "HTML-Tag"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'5cs'5d >>= withAttribute "Normal") >>~ pushContext "Unformatted"))- return (attr, result)--parseRules "Table" = - do (attr, result) <- (((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pColumn 0 >> pRegExpr regex_'28'5b'3d'5d'7b2'2c2'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b2'2c2'7d'7c'5b'3d'5d'7b3'2c3'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b3'2c3'7d'7c'5b'3d'5d'7b4'2c4'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b4'2c4'7d'7c'5b'3d'5d'7b5'2c5'7d'5b'5e'3d'5d'2b'5b'3d'5d'7b5'2c5'7d'29 >>= withAttribute "Section"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'2a'23'3b'3a'5cs'5d'2a'5b'2a'23'3a'5d'2b >>= withAttribute "Wiki-Tag"))- <|>- ((pRegExpr regex_'5b'5b'5d'28'3f'21'5b'5b'5d'29 >>= withAttribute "Wiki-Tag") >>~ pushContext "URL")- <|>- ((pRegExpr regex_'28http'3a'7cftp'3a'7cmailto'3a'29'5b'5cS'5d'2a'28'24'7c'5b'5cs'5d'29 >>= withAttribute "URL"))- <|>- ((pRegExpr regex_'5b'27'5d'7b2'2c'7d >>= withAttribute "Wiki-Tag"))- <|>- ((pColumn 0 >> pDetect2Chars False '|' '}' >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pDetectChar False '|' >>= withAttribute "Wiki-Tag"))- <|>- ((pDetect2Chars False '{' '{' >>= withAttribute "Wiki-Tag") >>~ pushContext "Template")- <|>- ((pDetect2Chars False '[' '[' >>= withAttribute "Wiki-Tag") >>~ pushContext "WikiLink")- <|>- ((pRangeDetect '&' ';' >>= withAttribute "HTML-Entity"))- <|>- ((pString False "<nowiki>" >>= withAttribute "Wiki-Tag") >>~ pushContext "NoWiki")- <|>- ((pString False "<pre>" >>= withAttribute "HTML-Tag") >>~ pushContext "Pre")- <|>- ((pRegExpr regex_'5b'3c'5d'5b'5e'3e'5d'2b'5b'3e'5d >>= withAttribute "HTML-Tag"))- <|>- ((pColumn 0 >> pRegExpr regex_'5b'5cs'5d >>= withAttribute "Normal") >>~ pushContext "Unformatted")- <|>- ((pRegExpr regex_'5b'7e'5d'7b3'2c4'7d >>= withAttribute "Wiki-Tag"))- <|>- ((pRegExpr regex_'5b'2d'5d'7b4'2c'7d >>= withAttribute "Wiki-Tag"))- <|>- ((pColumn 0 >> pDetectChar False '!' >>= withAttribute "Wiki-Tag")))- return (attr, result)--parseRules "comment" = - do (attr, result) <- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)--parseRules "URL" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)--parseRules "WikiLink" = - do (attr, result) <- (((pDetectChar False '|' >>= withAttribute "Wiki-Tag") >>~ pushContext "WikiLinkDescription")- <|>- ((pDetect2Chars False ']' ']' >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)--parseRules "WikiLinkDescription" = - do (attr, result) <- ((lookAhead (pDetect2Chars False ']' ']') >> return ([],"") ) >>~ (popContext))- return (attr, result)--parseRules "Link" = - do (attr, result) <- (((pDetect2Chars False '}' '}' >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pAnyChar "'[]" >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)--parseRules "Error" = - pzero--parseRules "Template" = - do (attr, result) <- (((pDetect2Chars False '}' '}' >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)--parseRules "NoWiki" = - do (attr, result) <- (((pRegExpr regex_'3c'21'2d'2d'5b'5e'2d'5d'2a'2d'2d'3e >>= withAttribute "NoWiki"))- <|>- ((pString False "</nowiki>" >>= withAttribute "Wiki-Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'3c'5d'5b'5e'3e'5d'2b'5b'3e'5d >>= withAttribute "HTML-Tag"))- <|>- ((pString False "<pre>" >>= withAttribute "HTML-Tag") >>~ pushContext "Pre"))- return (attr, result)--parseRules "Unformatted" = - pzero--parseRules "Pre" = - do (attr, result) <- ((pString False "</pre>" >>= withAttribute "Wiki-Tag") >>~ (popContext))- return (attr, result)--parseRules "" = parseRules "normal"--parseRules x = fail $ "Unknown context" ++ x
Text/Highlighting/Kate/Syntax/Metafont.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file metafont.xml, version 0.9,- by Yedvilun (yedvilun@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file metafont.xml, version 0.9, by Yedvilun (yedvilun@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Metafont ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Metafont+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Metapost/Metafont"@@ -19,63 +22,50 @@ syntaxExtensions = "*.mp;*.mps;*.mpost;*.mf" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Metapost/Metafont" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Metapost/Metafont",["Normal Text"])], synStLanguage = "Metapost/Metafont", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Metapost/Metafont",["Normal Text"])], synStLanguage = "Metapost/Metafont", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine- "string" -> return () >> pHandleEndLine- "TeXMode" -> return () >> pHandleEndLine+ "Normal Text" -> return ()+ "string" -> return ()+ "TeXMode" -> return () "ContrSeq" -> (popContext) >> pEndLine "ToEndOfLine" -> (popContext) >> pEndLine "Verb" -> (popContext >> popContext) >> pEndLine "VerbEnd" -> (popContext >> popContext >> popContext) >> pEndLine- "MathMode" -> return () >> pHandleEndLine+ "MathMode" -> return () "MathContrSeq" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Error","al"),("String","st"),("Alert","al"),("Macro","kw"),("Operator","kw"),("Special","kw"),("Conditional","kw"),("BoolExp","kw"),("NumExp","fu"),("Variable","kw"),("Identifier","kw"),("Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_mfBoolExp = Set.fromList $ words $ "true false known unknown odd charexists not and or" list_mfNumExp = Set.fromList $ words $ "normaldeviate length ascii oct hex angle turningnumber totalweight directiontime xpart ypart xxpart xypart yxpart yypart sqrt sind cosd mlog mexp floor uniformdeviate abs div dotprod max min mod ceiling"@@ -122,170 +112,161 @@ regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f = compileRegex "[a-zA-Z]+\\*?" regex_'28FIXME'7cTODO'29'3a'3f = compileRegex "(FIXME|TODO):?" -defaultAttributes = [("Normal Text","Normal Text"),("string","String"),("TeXMode","Tex"),("ContrSeq","Keyword"),("ToEndOfLine","Normal Text"),("Verb","Verbatim"),("VerbEnd","Verbatim"),("MathMode","Math"),("MathContrSeq","Keyword Mathmode"),("Comment","Comment")]+defaultAttributes = [("Normal Text",NormalTok),("string",StringTok),("TeXMode",NormalTok),("ContrSeq",NormalTok),("ToEndOfLine",NormalTok),("Verb",NormalTok),("VerbEnd",NormalTok),("MathMode",NormalTok),("MathContrSeq",NormalTok),("Comment",CommentTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfBoolExp >>= withAttribute "BoolExp"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfNumExp >>= withAttribute "NumExp"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfInternal >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPairExp >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPathExp >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPenExp >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPicExp >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfStringExp >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfCommand >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfType >>= withAttribute "Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfDefinition >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfCondition >>= withAttribute "Conditional"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPrimitive >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfMacro >>= withAttribute "Macro"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mpInternal >>= withAttribute "Statement"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mpMacro >>= withAttribute "Macro"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'5c'2f'7c'5c'3d'7c'5c'3a'5c'3d'29 >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "Operator"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5cb'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'5cb >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'2d'3f'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'2d'3f'5c'2e'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'2d'3f'5cd'2b'5c'2e'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'5bxy'5d'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5cbz'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5cbp'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute "Variable"))- <|>- ((pDetectChar False '$' >>= withAttribute "Special"))- <|>- ((pRegExpr regex_'5cb'28verbatimtex'7cbtex'29'5cb >>= withAttribute "Identifier") >>~ pushContext "TeXMode")- <|>- ((pRegExpr regex_'5cbbegin'28group'7cfig'7cchar'29'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cbend'28group'7cfig'7cchar'29'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cbextra'5fbegin'28group'7cfig'7cchar'29'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cbextra'5fend'28group'7cfig'7cchar'29'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cb'28def'7cvardef'29'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cbenddef'5cb >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'5cbif'5cb >>= withAttribute "Conditional"))- <|>- ((pRegExpr regex_'5cbfi'5cb >>= withAttribute "Conditional"))- <|>- ((pRegExpr regex_'5cb'28for'7cforsuffixes'7cforever'29'5cb >>= withAttribute "Conditional"))- <|>- ((pRegExpr regex_'5cbendfor'5cb >>= withAttribute "Conditional")))- return (attr, result)+parseRules "Normal Text" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfBoolExp >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfNumExp >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfInternal >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPairExp >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPathExp >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPenExp >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPicExp >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfStringExp >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfCommand >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfType >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" Set.empty >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfDefinition >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfCondition >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfPrimitive >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mfMacro >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mpInternal >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_mpMacro >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'5c'2f'7c'5c'3d'7c'5c'3a'5c'3d'29 >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute KeywordTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5cb'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'5cb >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'2d'3f'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'2d'3f'5c'2e'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'2d'3f'5cd'2b'5c'2e'5cd'2b'28bp'7ccc'7ccm'7cdd'7cin'7cmm'7cpc'7cpt'29'23'3f'5cb >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'5bxy'5d'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbz'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbp'5cd'28'5cw'7c'5c'27'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28verbatimtex'7cbtex'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "TeXMode")+ <|>+ ((pRegExpr regex_'5cbbegin'28group'7cfig'7cchar'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'28group'7cfig'7cchar'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbextra'5fbegin'28group'7cfig'7cchar'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbextra'5fend'28group'7cfig'7cchar'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28def'7cvardef'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbenddef'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbif'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfi'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28for'7cforsuffixes'7cforever'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbendfor'5cb >>= withAttribute KeywordTok))) -parseRules "string" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '"' >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "string" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '"' >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "TeXMode" = - do (attr, result) <- (((pDetectChar False '\\' >>= withAttribute "Keyword") >>~ pushContext "ContrSeq")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pString False "\\(" >>= withAttribute "Math") >>~ pushContext "MathMode")- <|>- ((pRegExpr regex_'5cbetex'5cb >>= withAttribute "Identifier") >>~ (popContext)))- return (attr, result)+parseRules "TeXMode" =+ (((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "ContrSeq")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pString False "\\(" >>= withAttribute NormalTok) >>~ pushContext "MathMode")+ <|>+ ((pRegExpr regex_'5cbetex'5cb >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "ContrSeq" = - do (attr, result) <- (((pString False "verb*" >>= withAttribute "Keyword") >>~ pushContext "Verb")- <|>- ((pRegExpr regex_verb'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute "Keyword") >>~ pushContext "Verb")- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)+parseRules "ContrSeq" =+ (((pString False "verb*" >>= withAttribute NormalTok) >>~ pushContext "Verb")+ <|>+ ((pRegExpr regex_verb'28'3f'3d'5b'5ea'2dzA'2dZ'5d'29 >>= withAttribute NormalTok) >>~ pushContext "Verb")+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'28'5c'2b'3f'7c'5c'2a'7b0'2c3'7d'29 >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "ToEndOfLine" = +parseRules "ToEndOfLine" = pzero -parseRules "Verb" = - do (attr, result) <- ((pRegExprDynamic "(.)" >>= withAttribute "Normal Text") >>~ pushContext "VerbEnd")- return (attr, result)+parseRules "Verb" =+ ((pRegExprDynamic "(.)" >>= withAttribute NormalTok) >>~ pushContext "VerbEnd") -parseRules "VerbEnd" = - do (attr, result) <- (((pString True "%1" >>= withAttribute "Normal Text") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExprDynamic "[^%1\\xd7]*" >>= withAttribute "Verbatim")))- return (attr, result)+parseRules "VerbEnd" =+ (((pString True "%1" >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExprDynamic "[^%1\\xd7]*" >>= withAttribute NormalTok))) -parseRules "MathMode" = - do (attr, result) <- (((pString False "$$" >>= withAttribute "Error"))- <|>- ((pDetectChar False '\\' >>= withAttribute "Keyword Mathmode") >>~ pushContext "MathContrSeq")- <|>- ((pDetectChar False '$' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Math") >>~ (popContext))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Error")))- return (attr, result)+parseRules "MathMode" =+ (((pString False "$$" >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '\\' >>= withAttribute NormalTok) >>~ pushContext "MathContrSeq")+ <|>+ ((pDetectChar False '$' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute AlertTok))) -parseRules "MathContrSeq" = - do (attr, result) <- (((pDetectChar False '\215' >>= withAttribute "Bullet"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute "Keyword Mathmode") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute "Keyword Mathmode") >>~ (popContext)))- return (attr, result)+parseRules "MathContrSeq" =+ (((pDetectChar False '\215' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'2b'5c'2a'3f >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5ea'2dzA'2dZ'5d >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "Comment" = - do (attr, result) <- (((pRegExpr regex_'28FIXME'7cTODO'29'3a'3f >>= withAttribute "Alert"))- <|>- ((pDetectChar False '\215' >>= withAttribute "Bullet")))- return (attr, result)+parseRules "Comment" =+ (((pRegExpr regex_'28FIXME'7cTODO'29'3a'3f >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '\215' >>= withAttribute NormalTok))) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Mips.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file mips.xml, version 1.03,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file mips.xml, version 1.03, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Mips ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Mips+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "MIPS Assembler"@@ -19,55 +22,42 @@ syntaxExtensions = "*.s;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "MIPS Assembler" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("MIPS Assembler",["normal"])], synStLanguage = "MIPS Assembler", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("MIPS Assembler",["normal"])], synStLanguage = "MIPS Assembler", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine- "string" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "normal" -> return ()+ "string" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Hardware Instruction","kw"),("Pseudo Instruction","fu"),("Other Register","dt"),("Main Register","dt"),("Floating Point Register","fl"),("Section","dt"),("Type","kw"),("Comment","co"),("Char","ch"),("String","st"),("Label","ot"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_type = Set.fromList $ words $ ".align .ascii .asciiz .byte .double .extern .float .globl .half .sdata .set .space .word" list_section = Set.fromList $ words $ ".data .kdata .ktext .text"@@ -83,47 +73,45 @@ regex_'5b'5cw'5f'5c'2e'5d'2b'3a = compileRegex "[\\w_\\.]+:" regex_'5c'5c'2e = compileRegex "\\\\." -defaultAttributes = [("normal","Normal Text"),("string","String")]+defaultAttributes = [("normal",NormalTok),("string",StringTok)] -parseRules "normal" = - do (attr, result) <- (((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_hardware >>= withAttribute "Hardware Instruction"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_pseudo >>= withAttribute "Pseudo Instruction"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_register1 >>= withAttribute "Other Register"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_register2 >>= withAttribute "Main Register"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_fp >>= withAttribute "Floating Point Register"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_section >>= withAttribute "Type"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_type >>= withAttribute "Section"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'5b'5cw'5f'5c'2e'5d'2b'3a >>= withAttribute "Label"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pInt >>= withAttribute "Decimal")))- return (attr, result)+parseRules "normal" =+ (((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_hardware >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_pseudo >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_register1 >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_register2 >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_fp >>= withAttribute FloatTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_section >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_type >>= withAttribute DataTypeTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5b'5cw'5f'5c'2e'5d'2b'3a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pInt >>= withAttribute DecValTok))) -parseRules "string" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "string" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Modula2.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file modula-2.xml, version 1.03,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file modula-2.xml, version 1.03, by -} -module Text.Highlighting.Kate.Syntax.Modula2 ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Modula2+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Modula-2"@@ -19,105 +22,87 @@ syntaxExtensions = "*.mod;*.def;*.mi;*.md" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Modula-2" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Modula-2",["Normal"])], synStLanguage = "Modula-2", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Modula-2",["Normal"])], synStLanguage = "Modula-2", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String1" -> (popContext) >> pEndLine "String2" -> (popContext) >> pEndLine- "Comment2" -> return () >> pHandleEndLine+ "Comment2" -> return () "Comment3" -> (popContext) >> pEndLine- "Prep1" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Prep1" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Type","dt"),("Number","dv"),("String","st"),("Directive","ot"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_directives = Set.fromList $ words $ "ASSEMBLER ALLOCATE DEALLOCATE SIZE Write WriteString WriteCard WriteLn WriteBf WriteInt WriteReal WriteLongReal Read ReadString ReadCard ReadInt ReadReal ReadLongReal Open Close OpenInput OpenOutput Accessible Erase EOF Done EmptyString Assign Append Length StrEq Copy Concat pos Delete Insert compare CAPS PutBf GetArgs GetEnv ResetClock UserTime SystemTime GetChar GetInt GetCard GetString GetReal GetLongReal PutChar PutInt PutCard PutString PutReal PutLongReal PutLn" list_keywords = Set.fromList $ words $ "AND ARRAY ASM BEGIN CASE CONST DIV DO ELSE ELSIF END FOR IF IMPLEMENTATION IN SET INCL EXCL ABS BITSET CAP CHR DEC HALT HIGH INC MAX MIN ODD ORD PROC TRUNC VAL MOD NIL NOT OF OR PROCEDURE MODULE DEFINITION RECORD REPEAT THEN TO TYPE UNTIL LOOP VAR WHILE WITH EXIT FALSE TRUE BY FROM IMPORT EXPORT QUALIFIED RETURN NEWPROCESS TRANSFER IOTRANSFER FOREIGN" list_types = Set.fromList $ words $ "INTEGER CARDINAL SHORTINT SHORTCARD LONGINT LONGREAL CHAR BOOLEAN POINTER ADDRESS ADR REAL File" -defaultAttributes = [("Normal","Normal Text"),("String1","String"),("String2","String"),("Comment2","Comment"),("Comment3","Comment"),("Prep1","Directive")]+defaultAttributes = [("Normal",NormalTok),("String1",StringTok),("String2",StringTok),("Comment2",CommentTok),("Comment3",CommentTok),("Prep1",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_directives >>= withAttribute "Directive"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pFloat >>= withAttribute "Number"))- <|>- ((pInt >>= withAttribute "Number"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String1")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String2")- <|>- ((pString False "(*$" >>= withAttribute "Directive") >>~ pushContext "Prep1")- <|>- ((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Comment2"))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_directives >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pFloat >>= withAttribute DecValTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String1")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String2")+ <|>+ ((pString False "(*$" >>= withAttribute OtherTok) >>~ pushContext "Prep1")+ <|>+ ((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment2")) -parseRules "String1" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String1" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "String2" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String2" =+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Comment2" = - do (attr, result) <- ((pDetect2Chars False '*' ')' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Comment2" =+ ((pDetect2Chars False '*' ')' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Comment3" = +parseRules "Comment3" = pzero -parseRules "Prep1" = - do (attr, result) <- ((pString False "$*)" >>= withAttribute "Directive") >>~ pushContext "Prep1")- return (attr, result)+parseRules "Prep1" =+ ((pString False "$*)" >>= withAttribute OtherTok) >>~ pushContext "Prep1") parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Modula3.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file modula-3.xml, version 1.01,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file modula-3.xml, version 1.01, by -} -module Text.Highlighting.Kate.Syntax.Modula3 ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Modula3+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Modula-3"@@ -19,57 +22,44 @@ syntaxExtensions = "*.m3;*.i3;*.ig;*.mg;" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Modula-3" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Modula-3",["Normal"])], synStLanguage = "Modula-3", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Modula-3",["Normal"])], synStLanguage = "Modula-3", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String1" -> (popContext) >> pEndLine- "Comment2" -> return () >> pHandleEndLine- "Prep1" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Comment2" -> return ()+ "Prep1" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Operator","kw"),("Type","dt"),("Integer","bn"),("Real","fl"),("Constant","dv"),("String","st"),("Char","ch"),("Pervasive","fu"),("StdLib","fu"),("Comment","co"),("Pragma","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "ANY ARRAY AS BEGIN BITS BRANDED BY CASE CONST DO ELSE ELSIF END EVAL EXCEPT EXCEPTION EXIT EXPORTS FINALLY FOR FROM GENERIC IF IMPORT INTERFACE LOCK LOOP METHODS MODULE OBJECT OF OVERRIDES PROCEDURE RAISE RAISES READONLY RECORD REF REPEAT RETURN REVEAL ROOT SET THEN TO TRY TYPE TYPECASE UNSAFE UNTIL UNTRACED VALUE VAR WHILE WITH" list_operators = Set.fromList $ words $ "AND DIV IN MOD NOT OR + < # = ; .. : - > { } | := <: * <= ( ) ^ , => / >= [ ] . &"@@ -86,55 +76,51 @@ regex_'5cb'28'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'7c'28'5b2'2d9'5d'7c1'5b0'2d6'5d'29'5c'5f'5b0'2d9A'2dFa'2df'5d'7b1'2c'7d'29'5cb = compileRegex "\\b([\\+|\\-]{0,1}[0-9]{1,}|([2-9]|1[0-6])\\_[0-9A-Fa-f]{1,})\\b" regex_'5c'27'28'2e'7c'5c'5c'5bntrf'5c'5c'27'22'5d'7c'5c'5c'5b0'2d7'5d'7b3'7d'29'5c'27 = compileRegex "\\'(.|\\\\[ntrf\\\\'\"]|\\\\[0-7]{3})\\'" -defaultAttributes = [("Normal","Normal Text"),("String1","String"),("Comment2","Comment"),("Prep1","Pragma")]+defaultAttributes = [("Normal",NormalTok),("String1",StringTok),("Comment2",CommentTok),("Prep1",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_PROCEDURE'5b'5cs'5d'2e'2a'5c'28 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_END'5cs'2a'5bA'2dZa'2dz'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'3b >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28RECORD'7cOBJECT'7cTRY'7cWHILE'7cFOR'7cREPEAT'7cLOOP'7cIF'7cCASE'7cWITH'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28END'3b'7cEND'29'5cb >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_constants >>= withAttribute "Constant"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_pervasives >>= withAttribute "Pervasive"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_stdlibs >>= withAttribute "StdLib"))- <|>- ((pRegExpr regex_'5cb'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'5c'2e'5b0'2d9'5d'7b1'2c'7d'28'5bE'7ce'7cD'7cd'7cX'7cx'5d'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'29'7b0'2c1'7d'5cb >>= withAttribute "Real"))- <|>- ((pRegExpr regex_'5cb'28'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'7c'28'5b2'2d9'5d'7c1'5b0'2d6'5d'29'5c'5f'5b0'2d9A'2dFa'2df'5d'7b1'2c'7d'29'5cb >>= withAttribute "Integer"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String1")- <|>- ((pRegExpr regex_'5c'27'28'2e'7c'5c'5c'5bntrf'5c'5c'27'22'5d'7c'5c'5c'5b0'2d7'5d'7b3'7d'29'5c'27 >>= withAttribute "Char"))- <|>- ((pDetect2Chars False '<' '*' >>= withAttribute "Pragma") >>~ pushContext "Prep1")- <|>- ((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Comment2"))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_PROCEDURE'5b'5cs'5d'2e'2a'5c'28 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_END'5cs'2a'5bA'2dZa'2dz'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'5c'3b >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28RECORD'7cOBJECT'7cTRY'7cWHILE'7cFOR'7cREPEAT'7cLOOP'7cIF'7cCASE'7cWITH'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28END'3b'7cEND'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_constants >>= withAttribute DecValTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_pervasives >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\" list_stdlibs >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'5c'2e'5b0'2d9'5d'7b1'2c'7d'28'5bE'7ce'7cD'7cd'7cX'7cx'5d'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'29'7b0'2c1'7d'5cb >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'28'5b'5c'2b'7c'5c'2d'5d'7b0'2c1'7d'5b0'2d9'5d'7b1'2c'7d'7c'28'5b2'2d9'5d'7c1'5b0'2d6'5d'29'5c'5f'5b0'2d9A'2dFa'2df'5d'7b1'2c'7d'29'5cb >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String1")+ <|>+ ((pRegExpr regex_'5c'27'28'2e'7c'5c'5c'5bntrf'5c'5c'27'22'5d'7c'5c'5c'5b0'2d7'5d'7b3'7d'29'5c'27 >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '<' '*' >>= withAttribute OtherTok) >>~ pushContext "Prep1")+ <|>+ ((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment2")) -parseRules "String1" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String1" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Comment2" = - do (attr, result) <- (((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Comment2")- <|>- ((pDetect2Chars False '*' ')' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Comment2" =+ (((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment2")+ <|>+ ((pDetect2Chars False '*' ')' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Prep1" = - do (attr, result) <- ((pDetect2Chars False '*' '>' >>= withAttribute "Pragma") >>~ (popContext))- return (attr, result)+parseRules "Prep1" =+ ((pDetect2Chars False '*' '>' >>= withAttribute OtherTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Monobasic.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file monobasic.xml, version 1.01,- by Davide Bettio (davide.bettio@kdemail.net) -}+{- This module was generated from data in the Kate syntax+ highlighting file monobasic.xml, version 1.01, by Davide Bettio (davide.bettio@kdemail.net) -} -module Text.Highlighting.Kate.Syntax.Monobasic ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Monobasic+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "MonoBasic"@@ -19,56 +22,43 @@ syntaxExtensions = "*.vb" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "MonoBasic" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("MonoBasic",["Normal"])], synStLanguage = "MonoBasic", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("MonoBasic",["Normal"])], synStLanguage = "MonoBasic", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Type","dt"),("String","st"),("Preprocessor","ot"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "option explicit strict imports inherits as new dim redim private friend public const readonly writeonly default shared shadows protected overloads overrides notoverridable notinheritable mustinherit mustoverride mybase myclass me delegate catch finaly when throw to step then else true false nothing call byval byref optional paramarray return declare withevents event raiseevent addhandler and or not xor andalso orelse goto on error resume" list_types = Set.fromList $ words $ "boolean char string integer long double object exception date datetime int16 int32 int64 paramarray timespan byte decimal intptr single guid"@@ -115,109 +105,107 @@ regex_'23If'2e'2a'24 = compileRegex "#If.*$" regex_'23End'2eIf'2e'2a'24 = compileRegex "#End.If.*$" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Comment","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Comment",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '\'' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'5cb'28Namespace'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eNamespace'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Module'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eModule'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Class'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eClass'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Interface'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eInterface'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Structure'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eStructure'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Enum'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eEnum'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Property'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eProperty'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Get'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eGet'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Set'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eSet'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Sub'29'28'5b'2e'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eSub'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_Exit'2eSub'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Function'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eFunction'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_Exit'2eFunction'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Try'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eTry'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28If'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eIf'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_Select'2eCase'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eSelect'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28For'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Next'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Do'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28Loop'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28While'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_End'2eWhile'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_Exit'2eWhile'2e'2a'24 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'23Region'2e'2a'24 >>= withAttribute "Preprocessor"))- <|>- ((pRegExpr regex_'23End'2eRegion'2e'2a'24 >>= withAttribute "Preprocessor"))- <|>- ((pRegExpr regex_'23If'2e'2a'24 >>= withAttribute "Preprocessor"))- <|>- ((pRegExpr regex_'23End'2eIf'2e'2a'24 >>= withAttribute "Preprocessor")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'5cb'28Namespace'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eNamespace'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Module'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eModule'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Class'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eClass'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Interface'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eInterface'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Structure'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eStructure'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Enum'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eEnum'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Property'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eProperty'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Get'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eGet'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Set'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eSet'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Sub'29'28'5b'2e'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eSub'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_Exit'2eSub'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Function'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eFunction'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_Exit'2eFunction'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Try'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eTry'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28If'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eIf'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_Select'2eCase'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eSelect'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28For'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Next'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Do'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28Loop'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28While'29'28'5b'5cs'5d'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_End'2eWhile'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_Exit'2eWhile'2e'2a'24 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'23Region'2e'2a'24 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23End'2eRegion'2e'2a'24 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23If'2e'2a'24 >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23End'2eIf'2e'2a'24 >>= withAttribute OtherTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Comment" = +parseRules "Comment" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Nasm.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file nasm.xml, version 1.40,- by Nicola Gigante (nicola.gigante@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file nasm.xml, version 1.40, by Nicola Gigante (nicola.gigante@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Nasm ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Nasm+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Intel x86 (NASM)"@@ -19,57 +22,44 @@ syntaxExtensions = "*.asm" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Intel x86 (NASM)" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Intel x86 (NASM)",["Normal"])], synStLanguage = "Intel x86 (NASM)", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Intel x86 (NASM)",["Normal"])], synStLanguage = "Intel x86 (NASM)", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "Comment" -> (popContext) >> pEndLine "Preprocessor" -> (popContext) >> pEndLine "String" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Registers","kw"),("Instructions","kw"),("NASM Keywords","kw"),("Comment","co"),("Label","fu"),("Data","dt"),("BaseN","bn"),("Float","fl"),("Number","dv"),("Char","ch"),("String","st"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_registers = Set.fromList $ words $ "eax ax ah al ebx bx bh bl ecx cx ch cl edx dx dh dl ebp bp esi si edi di esp sp cs ds es fs gs ss cr0 cr2 cr3 cr4 dr0 dr1 dr2 dr3 dr6 dr7 st mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7" list_instructions = Set.fromList $ words $ "aaa aad aam aas adc add addpd addps addsd addss addsubpd addsubps and andnpd andnps andpd andps arpl bound bsf bsr bswap bt btc btr bts call cbw cwde cwd cdq cdqe cqo clc cld clgi cli clts clflush cmc cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle cmovna cmovnae cmovnb cmovnbe cmovnc cmovne cmovng cmovnge cmovnl cmovnle cmovno cmovnp cmovns cmovnz cmovo cmovp cmovpe cmovpo cmovs cmovz cmp cmpeqpd cmpeqps cmpeqsd cmpeqss cmplepd cmpleps cmplesd cmpless cmpltpd cmpltps cmpltsd cmpltss cmpneqpd cmpneqps cmpneqsd cmpneqss cmpnlepd cmpnleps cmpnlesd cmpnless cmpnltpd cmpnltps cmpnltsd cmpnltss cmpordpd cmpordps cmpordsd cmpordss cmppd cmpps cmps cmpsb cmpsd cmpss cmpsw cmpunordpd cmpunordps cmpunordsd cmpunordss cmpxchg cmpxchg486 cmpxchg8b cmpxchg16b comisd comiss cpuid cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvtss2sd cvtss2si cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi cvttsd2si cvttss2si daa das dec div divpd divps divsd divss emms enter f2xm1 fabs fadd faddp fbld fbstp fchs fclex fnclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne fcmovnu fcmovu fcom fcomp fcompp fcomi fcomip fcos fdecstp fdisi feni fdiv fdivr fdivp fdivrp femms ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisttp fisub fisubr fld fld1 fldl2e fldl2t fldlg2 fldln2 fldcw fldenv fldpi fldz fmul fmulp fndisi fneni fninit fnop fnsave fnstcw fnstenv fnstsw fnwait fpatan fptan fprem fprem1 frndint frstor fsave fscale fsetpm fsin fsincos fsqrt fst fstp fstcw fstenv fstsw fsub fsubr fsubp fsubrp ftst fucom fucomp fucompp fucomi fucomip fwait fxam fxch fxrstor fxsave fxtract fyl2x fyl2xp1 haddpd haddps hlt hsubpd hsubps ibts idiv imul in inc ins insb insd insw int int1 int3 into invd invlpg invlpga iret iretd iretq iretw ja jae jb jbe jc je jg jge jl jle jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz jo jp jpe jpo js jz jcxz jecxz jrcxz jmp lahf lar lddqu ldmxcsr lds les lea leave lfence lfs lgdt lgs lidt lldt lmsw loadall loadall286 lods lodsb lodsd lodsq lodsw loop loope loopne loopnz loopz lsl lss ltr maskmovdqu maskmovq maxpd maxps maxsd maxss mfence minpd minps minsd minss monitor mov movapd movaps movd movddup movdq2q movdqa movdqu movhlps movhpd movhps movlhps movlpd movlps movmskpd movmskps movntdq movnti movntpd movntps movntq movq movq2dq movs movsb movsd movshdup movsldup movsq movss movsx movsxd movsw movupd movups movzx mul mulpd mulps mulsd mulss mwait neg nop not or orpd orps out outs outsb outsw outsd packssdw packsswb packuswb paddb paddd paddq paddsb paddsw paddusb paddusw paddw pand pandn pause pavgb pavgusb pavgw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw pcmpgtd pdistib pextrw pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pfnacc pfpnacc pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pi2fw pinsrw pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub pmovmskb pmulhrw pmulhuw pmulhw pmullw pmuludq pmvgezb pmvlzb pmvnzb pmvzb pop popa popaw popad popf popfw popfd popfq por prefetch prefetchnta prefetcht0 prefetcht1 prefetcht2 prefetchw psadbw pshufd pshufhw pshuflw pshufw pslld pslldq psllq psllw psrad psraw psrld psrldq psrlq psrlw psubb psubd psubq psubsb psubsiw psubsw psubusb psubusw psubw pswapd punpckhbw punpckhdq punpckhqdq punpckhwd punpcklbw punpckldq punpcklqdq punpcklwd push pusha pushad pushaw pushf pushfd pushfq pushfw pxor rcl rcr rcpps rcpss rdmsr rdpmc rdshr rdtsc rdtscp ret retf retn rol ror rsdc rsldt rsm rsqrtps rsqrtss rsts sahf sal sar salc sbb scas scasb scasd scasq scasw seta setae setb setbe setc sete setg setge setl setle setna setnae setnb setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets setz sfence sgdt shl shld shr shrd shufpd shufps sidt skinit sldt smi smint smintold smsw sqrtpd sqrtps sqrtsd sqrtss stc std stgi sti stmxcsr stos stosb stosd stosq stosw str sub subpd subps subsd subss svdc svldt svts swapgs syscall sysenter sysexit sysret test ucomisd ucomiss ud0 ud1 ud2 umov unpckhpd unpckhps unpcklpd unpcklps verr verw vmload vmmcall vmrun vmsave wait wbinvd wrmsr wrshr xadd xbts xchg xlat xlatb xor xorpd xorps"@@ -82,55 +72,53 @@ regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'28'5c'24'7c0x'29'7b1'7d'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2a'7c'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2ah'29'28'5b_'5ct'2c'5d'2b'7c'24'29 = compileRegex "(^|[ \\t,]+)((\\$|0x){1}[0-9]+[a-f0-9]*|[0-9]+[a-f0-9]*h)([ \\t,]+|$)" regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'5b0'2d7'5d'2b'28q'7co'29'7c'5b01'5d'2bb'29'28'5b_'5ct'2c'5d'2b'7c'24'29 = compileRegex "(^|[ \\t,]+)([0-7]+(q|o)|[01]+b)([ \\t,]+|$)" -defaultAttributes = [("Normal","Normal Text"),("Comment","Comment"),("Preprocessor","Preprocessor"),("String","String")]+defaultAttributes = [("Normal",NormalTok),("Comment",CommentTok),("Preprocessor",OtherTok),("String",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_registers >>= withAttribute "Registers"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Data >>= withAttribute "Data"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_instructions >>= withAttribute "Instructions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_NASM_Keywords >>= withAttribute "NASM Keywords"))- <|>- ((pDetectChar False ';' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '%' >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pAnyChar "\"'" >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pColumn 0 >> pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'5f'2e'24'5d'2b'3a >>= withAttribute "Label"))- <|>- ((pRegExpr regex_'28cmov'7cfcmov'7cj'7cloop'7cset'29'28a'7cae'7cb'7cbe'7cc'7ce'7cg'7cge'7cl'7cle'7cna'7cnae'7cnb'7cnbe'7cnc'7cne'7cng'7cnge'7cnl'7cnle'7cno'7cnp'7cns'7cnz'7co'7cp'7cpe'7cpo'7cs'7cz'29 >>= withAttribute "Instructions"))- <|>- ((pRegExpr regex_cpu_'28pentium'7cppro'7cp2'7cp3'7ckatmai'7cp4'7cwillamette'7cprescott'7cia64'29'2a >>= withAttribute "NASM Keywords"))- <|>- ((pRegExpr regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'28'5c'24'7c0x'29'7b1'7d'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2a'7c'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2ah'29'28'5b_'5ct'2c'5d'2b'7c'24'29 >>= withAttribute "BaseN"))- <|>- ((pRegExpr regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'5b0'2d7'5d'2b'28q'7co'29'7c'5b01'5d'2bb'29'28'5b_'5ct'2c'5d'2b'7c'24'29 >>= withAttribute "BaseN"))- <|>- ((pDetectChar False '$' >>= withAttribute "Number"))- <|>- ((pHlCOct >>= withAttribute "BaseN"))- <|>- ((pHlCHex >>= withAttribute "BaseN"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Number"))- <|>- ((pHlCChar >>= withAttribute "Char")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_registers >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_Data >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_instructions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_NASM_Keywords >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False ';' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '%' >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pAnyChar "\"'" >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'5f'2e'24'5d'2b'3a >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'28cmov'7cfcmov'7cj'7cloop'7cset'29'28a'7cae'7cb'7cbe'7cc'7ce'7cg'7cge'7cl'7cle'7cna'7cnae'7cnb'7cnbe'7cnc'7cne'7cng'7cnge'7cnl'7cnle'7cno'7cnp'7cns'7cnz'7co'7cp'7cpe'7cpo'7cs'7cz'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_cpu_'28pentium'7cppro'7cp2'7cp3'7ckatmai'7cp4'7cwillamette'7cprescott'7cia64'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'28'5c'24'7c0x'29'7b1'7d'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2a'7c'5b0'2d9'5d'2b'5ba'2df0'2d9'5d'2ah'29'28'5b_'5ct'2c'5d'2b'7c'24'29 >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'28'5e'7c'5b_'5ct'2c'5d'2b'29'28'5b0'2d7'5d'2b'28q'7co'29'7c'5b01'5d'2bb'29'28'5b_'5ct'2c'5d'2b'7c'24'29 >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute DecValTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))) -parseRules "Comment" = +parseRules "Comment" = pzero -parseRules "Preprocessor" = +parseRules "Preprocessor" = pzero -parseRules "String" = - do (attr, result) <- ((pAnyChar "\"'" >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pAnyChar "\"'" >>= withAttribute StringTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Noweb.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file noweb.xml, version 1.0,- by Scott Collins (scc@scottcollins.net) -}+{- This module was generated from data in the Kate syntax+ highlighting file noweb.xml, version 1.0, by Scott Collins (scc@scottcollins.net) -} -module Text.Highlighting.Kate.Syntax.Noweb ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Noweb+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Html import qualified Text.Highlighting.Kate.Syntax.Cpp-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -20,57 +23,44 @@ syntaxExtensions = "*.w;*.nw" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "noweb" } context <- currentContext <|> (pushContext "RawDocumentation" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("noweb",["RawDocumentation"])], synStLanguage = "noweb", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("noweb",["RawDocumentation"])], synStLanguage = "noweb", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "RawDocumentation" -> return () >> pHandleEndLine- "CodeQuote" -> return () >> pHandleEndLine- "CodeSection" -> return () >> pHandleEndLine- "SectionNames" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "RawDocumentation" -> return ()+ "CodeQuote" -> return ()+ "CodeSection" -> return ()+ "SectionNames" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Punctuation","re"),("SectionName","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'3c'3c'2e'2a'3e'3e'3d'24 = compileRegex "<<.*>>=$"@@ -80,45 +70,41 @@ regex_'40'3c'3c = compileRegex "@<<" regex_'3c'3c'2e'2a'5b'5e'40'5d'3e'3e'28'3f'21'3d'29 = compileRegex "<<.*[^@]>>(?!=)" -defaultAttributes = [("RawDocumentation","Prose"),("CodeQuote","Code"),("CodeSection","Code"),("SectionNames","Prose")]+defaultAttributes = [("RawDocumentation",NormalTok),("CodeQuote",NormalTok),("CodeSection",NormalTok),("SectionNames",NormalTok)] -parseRules "RawDocumentation" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d'24 >>= withAttribute "SectionName") >>~ pushContext "CodeSection")- <|>- ((pDetect2Chars False '@' '[' >>= withAttribute "Prose"))- <|>- ((pDetect2Chars False '[' '[' >>= withAttribute "Punctuation") >>~ pushContext "CodeQuote")- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "RawDocumentation" =+ (((pColumn 0 >> pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d'24 >>= withAttribute RegionMarkerTok) >>~ pushContext "CodeSection")+ <|>+ ((pDetect2Chars False '@' '[' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '[' '[' >>= withAttribute RegionMarkerTok) >>~ pushContext "CodeQuote")+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression))) -parseRules "CodeQuote" = - do (attr, result) <- (((pDetect2Chars False '@' ']' >>= withAttribute "Code"))- <|>- ((pRegExpr regex_'5c'5d'5c'5d'28'3f'21'5c'5d'29 >>= withAttribute "Punctuation") >>~ (popContext))- <|>- ((parseRules "SectionNames"))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "CodeQuote" =+ (((pDetect2Chars False '@' ']' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'5d'5c'5d'28'3f'21'5c'5d'29 >>= withAttribute RegionMarkerTok) >>~ (popContext))+ <|>+ ((parseRules "SectionNames"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "CodeSection" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'40'24 >>= withAttribute "Punctuation") >>~ pushContext "RawDocumentation")- <|>- ((pColumn 0 >> pRegExpr regex_'40'28'3f'3d'5b'5cs'25'5d'29 >>= withAttribute "Punctuation") >>~ pushContext "RawDocumentation")- <|>- ((pColumn 0 >> lookAhead (pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d'24) >> return ([],"") ) >>~ pushContext "RawDocumentation")- <|>- ((parseRules "SectionNames"))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "CodeSection" =+ (((pColumn 0 >> pRegExpr regex_'40'24 >>= withAttribute RegionMarkerTok) >>~ pushContext "RawDocumentation")+ <|>+ ((pColumn 0 >> pRegExpr regex_'40'28'3f'3d'5b'5cs'25'5d'29 >>= withAttribute RegionMarkerTok) >>~ pushContext "RawDocumentation")+ <|>+ ((pColumn 0 >> lookAhead (pRegExpr regex_'3c'3c'2e'2a'3e'3e'3d'24) >> return (NormalTok,"") ) >>~ pushContext "RawDocumentation")+ <|>+ ((parseRules "SectionNames"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "SectionNames" = - do (attr, result) <- (((pRegExpr regex_'40'3c'3c >>= withAttribute "Prose"))- <|>- ((pRegExpr regex_'3c'3c'2e'2a'5b'5e'40'5d'3e'3e'28'3f'21'3d'29 >>= withAttribute "SectionName")))- return (attr, result)+parseRules "SectionNames" =+ (((pRegExpr regex_'40'3c'3c >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'3c'3c'2e'2a'5b'5e'40'5d'3e'3e'28'3f'21'3d'29 >>= withAttribute RegionMarkerTok))) parseRules "" = parseRules "RawDocumentation"
Text/Highlighting/Kate/Syntax/Objectivec.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file objectivec.xml, version 1.07,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file objectivec.xml, version 1.07, by -} -module Text.Highlighting.Kate.Syntax.Objectivec ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Objectivec+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Objective-C"@@ -20,145 +23,127 @@ syntaxExtensions = "*.m;*.h" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Objective-C" } context <- currentContext <|> (pushContext "Default" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Objective-C",["Default"])], synStLanguage = "Objective-C", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Objective-C",["Default"])], synStLanguage = "Objective-C", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Default" -> return () >> pHandleEndLine+ "Default" -> return () "String" -> (popContext) >> pEndLine "SingleLineComment" -> (popContext) >> pEndLine- "MultiLineComment" -> return () >> pHandleEndLine- "Preprocessor" -> pushContext "Default" >> pHandleEndLine- "MultiLineCommentPrep" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "MultiLineComment" -> return ()+ "Preprocessor" -> pushContext "Default" >> return ()+ "MultiLineCommentPrep" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Preprocessor","ot"),("Prep. Lib","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case continue default do else enum extern for goto if return sizeof struct switch typedef union while @class @defs @encode @end @implementation @interface @private @protected @protocol @public @selector self super" list_types = Set.fromList $ words $ "auto char const double float int long register short signed static unsigned void volatile" regex_'23 = compileRegex "#" -defaultAttributes = [("Default","Normal Text"),("String","String"),("SingleLineComment","Comment"),("MultiLineComment","Comment"),("Preprocessor","Preprocessor"),("MultiLineCommentPrep","Comment")]+defaultAttributes = [("Default",NormalTok),("String",StringTok),("SingleLineComment",CommentTok),("MultiLineComment",CommentTok),("Preprocessor",OtherTok),("MultiLineCommentPrep",CommentTok)] -parseRules "Default" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'23 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pDetect2Chars False '@' '"' >>= withAttribute "String") >>~ pushContext "String"))- return (attr, result)+parseRules "Default" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'23 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pDetect2Chars False '@' '"' >>= withAttribute StringTok) >>~ pushContext "String")) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "SingleLineComment" = +parseRules "SingleLineComment" = pzero -parseRules "MultiLineComment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "MultiLineComment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineCommentPrep"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute OtherTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute OtherTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineCommentPrep")) -parseRules "MultiLineCommentPrep" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext >> popContext))- return (attr, result)+parseRules "MultiLineCommentPrep" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext)) parseRules "" = parseRules "Default"
Text/Highlighting/Kate/Syntax/Objectivecpp.hs view
@@ -1,17 +1,20 @@-{- This module was generated from data in the Kate syntax highlighting file objectivecpp.xml, version 1.01,- by Gennady Telegin (gepo@lvk.cs.msu.su -}+{- This module was generated from data in the Kate syntax+ highlighting file objectivecpp.xml, version 1.01, by Gennady Telegin (gepo@lvk.cs.msu.su -} -module Text.Highlighting.Kate.Syntax.Objectivecpp ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Objectivecpp+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Objective-C++"@@ -21,66 +24,53 @@ syntaxExtensions = "*.mm;*.M;*.h" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Objective-C++" } context <- currentContext <|> (pushContext "Default" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Objective-C++",["Default"])], synStLanguage = "Objective-C++", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Objective-C++",["Default"])], synStLanguage = "Objective-C++", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Default" -> return () >> pHandleEndLine+ "Default" -> return () "String" -> (popContext) >> pEndLine "SingleLineComment" -> (popContext) >> pEndLine- "MultiLineComment" -> return () >> pHandleEndLine- "Preprocessor" -> pushContext "Default" >> pHandleEndLine- "MultiLineCommentPrep" -> return () >> pHandleEndLine+ "MultiLineComment" -> return ()+ "Preprocessor" -> pushContext "Default" >> return ()+ "MultiLineCommentPrep" -> return () "Region Marker" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine+ "Commentar 2" -> return () "Preprocessor" -> (popContext) >> pEndLine "Define" -> (popContext) >> pEndLine- "Outscoped" -> return () >> pHandleEndLine- "Outscoped intern" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Outscoped" -> return ()+ "Outscoped intern" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Extensions","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Preprocessor","ot"),("Prep. Lib","ot"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case continue default do else enum extern for goto if return sizeof struct switch typedef union while @class @defs @encode @end @implementation @interface @private @protected @protocol @public @selector self super asm catch class const_cast delete dynamic_cast explicit export false friend inline namespace new operator private protected public qobject_cast reinterpret_cast static_cast template this throw true try typeid type_info typename using virtual and and_eq bad_cast bad_typeid bitand bitor compl not not_eq or or_eq xor xor_eq" list_extensions = Set.fromList $ words $ "K_DCOP SLOT SIGNAL Q_CLASSINFO Q_ENUMS Q_EXPORT Q_OBJECT Q_OVERRIDE Q_PROPERTY Q_SETS Q_SIGNALS Q_SLOTS Q_FOREACH Q_DECLARE_FLAGS Q_INIT_RESOURCE Q_CLEANUP_RESOURCE Q_GLOBAL_STATIC Q_GLOBAL_STATIC_WITH_ARGS Q_DECLARE_INTERFACE Q_DECLARE_TYPEINFO Q_DECLARE_SHARED Q_DECLARE_FLAGS Q_DECLARE_OPERATORS_FOR_FLAGS Q_FOREVER Q_DECLARE_PRIVATE Q_DECLARE_PUBLIC Q_D Q_Q Q_DISABLE_COPY Q_INTERFACES Q_FLAGS Q_SCRIPTABLE Q_INVOKABLE Q_GADGET Q_ARG Q_RETURN_ARG Q_ASSERT Q_ASSERT_X TRUE FALSE connect disconnect emit signals slots foreach forever"@@ -94,197 +84,186 @@ regex_'23'5cs'2a'28endif'7celse'7celif'29 = compileRegex "#\\s*(endif|else|elif)" regex_'23'5cs'2aendif = compileRegex "#\\s*endif" -defaultAttributes = [("Default","Normal Text"),("String","String"),("SingleLineComment","Comment"),("MultiLineComment","Comment"),("Preprocessor","Preprocessor"),("MultiLineCommentPrep","Comment"),("Region Marker","Region Marker"),("Commentar 1","Comment"),("Commentar 2","Comment"),("Preprocessor","Preprocessor"),("Define","Preprocessor"),("Outscoped","Comment"),("Outscoped intern","Comment")]+defaultAttributes = [("Default",NormalTok),("String",StringTok),("SingleLineComment",CommentTok),("MultiLineComment",CommentTok),("Preprocessor",OtherTok),("MultiLineCommentPrep",CommentTok),("Region Marker",RegionMarkerTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("Preprocessor",OtherTok),("Define",OtherTok),("Outscoped",CommentTok),("Outscoped intern",CommentTok)] -parseRules "Default" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0 >>= withAttribute "Preprocessor") >>~ pushContext "Outscoped")- <|>- ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pFirstNonSpace >> pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "Region Marker")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pColumn 0 >> pRegExpr regex_'23 >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pDetect2Chars False '@' '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extensions >>= withAttribute "Extensions"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]{|}~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Default" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0 >>= withAttribute OtherTok) >>~ pushContext "Outscoped")+ <|>+ ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pFirstNonSpace >> pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pFirstNonSpace >> pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "Region Marker")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pColumn 0 >> pRegExpr regex_'23 >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pDetect2Chars False '@' '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_extensions >>= withAttribute KeywordTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]{|}~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "SingleLineComment" = +parseRules "SingleLineComment" = pzero -parseRules "MultiLineComment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "MultiLineComment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineCommentPrep"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute OtherTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute OtherTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineCommentPrep")) -parseRules "MultiLineCommentPrep" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext >> popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "MultiLineCommentPrep" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Region Marker" = +parseRules "Region Marker" = pzero -parseRules "Commentar 1" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 1" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Commentar 2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Commentar 2" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor"))- <|>- ((pRegExpr regex_define'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute "Preprocessor") >>~ pushContext "Define")- <|>- ((pRegExpr regex_define'2e'2a >>= withAttribute "Preprocessor"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineCommentPrep"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_define'2e'2a'28'28'3f'3d'5c'5c'29'29 >>= withAttribute OtherTok) >>~ pushContext "Define")+ <|>+ ((pRegExpr regex_define'2e'2a >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute OtherTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute OtherTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute OtherTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineCommentPrep")) -parseRules "Define" = - do (attr, result) <- ((pLineContinue >>= withAttribute "Preprocessor"))- return (attr, result)+parseRules "Define" =+ ((pLineContinue >>= withAttribute OtherTok)) -parseRules "Outscoped" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28endif'7celse'7celif'29 >>= withAttribute "Preprocessor") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28endif'7celse'7celif'29 >>= withAttribute OtherTok) >>~ (popContext))) -parseRules "Outscoped intern" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped intern" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute CommentTok) >>~ (popContext))) parseRules "" = parseRules "Default"
Text/Highlighting/Kate/Syntax/Ocaml.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file ocaml.xml, version 1.05,- by Glyn Webster (glyn@wave.co.nz) -}+{- This module was generated from data in the Kate syntax+ highlighting file ocaml.xml, version 1.05, by Glyn Webster (glyn@wave.co.nz) -} -module Text.Highlighting.Kate.Syntax.Ocaml ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Ocaml+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Objective Caml"@@ -19,63 +22,50 @@ syntaxExtensions = "*.ml;*.mli" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Objective Caml" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Objective Caml",["Normal"])], synStLanguage = "Objective Caml", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Objective Caml",["Normal"])], synStLanguage = "Objective Caml", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "Multiline Comment" -> return () >> pHandleEndLine- "String Constant" -> return () >> pHandleEndLine- "Block" -> return () >> pHandleEndLine- "Sig" -> return () >> pHandleEndLine- "Struct" -> return () >> pHandleEndLine- "Object" -> return () >> pHandleEndLine- "ModuleEnv" -> return () >> pHandleEndLine- "ModuleEnv2" -> return () >> pHandleEndLine- "Camlp4 Quotation Constant" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Normal" -> return ()+ "Multiline Comment" -> return ()+ "String Constant" -> return ()+ "Block" -> return ()+ "Sig" -> return ()+ "Struct" -> return ()+ "Object" -> return ()+ "ModuleEnv" -> return ()+ "ModuleEnv2" -> return ()+ "Camlp4 Quotation Constant" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Core Data Type","dt"),("Decimal","dv"),("Hexadecimal","bn"),("Octal","bn"),("Binary","bn"),("Float","fl"),("Character","ch"),("String","st"),("Escaped characters","ch"),("Comment","co"),("Camlp4 Quotation","st"),("Directive","ot"),("Constructor","dt"),("Region Marker","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_revised_syntax_keywords = Set.fromList $ words $ "declare value where" list_keywords = Set.fromList $ words $ "and as assert asr class closed constraint downto else exception external false for fun function functor if in inherit initializer land lazy let lor lsl lsr lxor match method mod mutable new of or parser private rec then to true try type val virtual when while with"@@ -107,143 +97,133 @@ regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 = compileRegex "\\\\(\\\\|>>|<<)" regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c = compileRegex "\\\\<:[A-Za-z\\0300-\\0326\\0330-\\0366\\0370-\\0377_][A-Za-z\\0300-\\0326\\0330-\\0366\\0370-\\03770-9_']*<" -defaultAttributes = [("Normal","Normal Text"),("Multiline Comment","Comment"),("String Constant","String"),("Block","Normal text"),("Sig","Normal text"),("Struct","Normal text"),("Object","Normal text"),("ModuleEnv","Normal text"),("ModuleEnv2","Normal text"),("Camlp4 Quotation Constant","Camlp4 Quotation")]+defaultAttributes = [("Normal",NormalTok),("Multiline Comment",CommentTok),("String Constant",StringTok),("Block",NormalTok),("Sig",NormalTok),("Struct",NormalTok),("Object",NormalTok),("ModuleEnv",NormalTok),("ModuleEnv2",NormalTok),("Camlp4 Quotation Constant",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Multiline Comment")- <|>- ((pDetectChar False '(' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False ')' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '[' '|' >>= withAttribute "Symbol"))- <|>- ((pDetect2Chars False '|' ']' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '[' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False ']' >>= withAttribute "Symbol"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_do >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_done >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_module'5fenvironment >>= withAttribute "Directive") >>~ pushContext "ModuleEnv")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_begin >>= withAttribute "Region Marker") >>~ pushContext "Block")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_object >>= withAttribute "Region Marker") >>~ pushContext "Object")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_sig >>= withAttribute "Region Marker") >>~ pushContext "Sig")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_struct >>= withAttribute "Region Marker") >>~ pushContext "Struct")- <|>- ((pRegExpr regex_'60'5cs'2a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Constructor"))- <|>- ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return ([],"") ) >>~ pushContext "ModuleEnv2")- <|>- ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Constructor"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'2e'2a'24 >>= withAttribute "Directive"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String Constant")- <|>- ((pRegExpr regex_'27'28'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29'7c'5b'5e'27'5d'29'27 >>= withAttribute "Character"))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_revised_syntax_keywords >>= withAttribute "Revised Syntax Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_core_types >>= withAttribute "Core Data Type"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Identifier"))- <|>- ((pRegExpr regex_'2d'3f0'5bxX'5d'5b0'2d9A'2dFa'2df'5f'5d'2b >>= withAttribute "Hexadecimal"))- <|>- ((pRegExpr regex_'2d'3f0'5boO'5d'5b0'2d7'5f'5d'2b >>= withAttribute "Octal"))- <|>- ((pRegExpr regex_'2d'3f0'5bbB'5d'5b01'5f'5d'2b >>= withAttribute "Binary"))- <|>- ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'28'5c'2e'28'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'29'7c'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'29 >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a >>= withAttribute "Decimal")))- return (attr, result)+parseRules "Normal" =+ (((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '[' '|' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '|' ']' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_do >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_done >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_module'5fenvironment >>= withAttribute OtherTok) >>~ pushContext "ModuleEnv")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_begin >>= withAttribute KeywordTok) >>~ pushContext "Block")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_object >>= withAttribute KeywordTok) >>~ pushContext "Object")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_sig >>= withAttribute KeywordTok) >>~ pushContext "Sig")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_struct >>= withAttribute KeywordTok) >>~ pushContext "Struct")+ <|>+ ((pRegExpr regex_'60'5cs'2a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute DataTypeTok))+ <|>+ ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return (NormalTok,"") ) >>~ pushContext "ModuleEnv2")+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute DataTypeTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'2e'2a'24 >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String Constant")+ <|>+ ((pRegExpr regex_'27'28'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29'7c'5b'5e'27'5d'29'27 >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_revised_syntax_keywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_core_types >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5bxX'5d'5b0'2d9A'2dFa'2df'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5boO'5d'5b0'2d7'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f0'5bbB'5d'5b01'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'28'5c'2e'28'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'3f'29'7c'28'5beE'5d'5b'2d'2b'5d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'29'29 >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a >>= withAttribute DecValTok))) -parseRules "Multiline Comment" = - do (attr, result) <- (((pDetect2Chars False '*' ')' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Multiline Comment"))- return (attr, result)+parseRules "Multiline Comment" =+ (((pDetect2Chars False '*' ')' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Multiline Comment")) -parseRules "String Constant" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29 >>= withAttribute "Escaped characters"))- <|>- ((pRegExpr regex_'5c'5c'24 >>= withAttribute "Escaped characters")))- return (attr, result)+parseRules "String Constant" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'28'5c'5c'5bntbr'27'22'5c'5c'5d'7c'5c'5c'5b0'2d9'5d'7b3'7d'7c'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b2'7d'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'24 >>= withAttribute CharTok))) -parseRules "Block" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Block" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Sig" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Sig" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Struct" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Struct" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "Object" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute "Region Marker") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "Object" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_end >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "ModuleEnv" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal text"))- <|>- ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return ([],"") ) >>~ pushContext "ModuleEnv2")- <|>- ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Module") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "ModuleEnv" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'5cs'2a'5c'2e) >> return (NormalTok,"") ) >>~ pushContext "ModuleEnv2")+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "ModuleEnv2" = - do (attr, result) <- (((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute "Module"))- <|>- ((pDetectSpaces >>= withAttribute "Normal text"))- <|>- ((pString False "." >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)+parseRules "ModuleEnv2" =+ (((pRegExpr regex_'5bA'2dZ'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "." >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "Camlp4 Quotation Constant" = - do (attr, result) <- (((pDetect2Chars False '>' '>' >>= withAttribute "Camlp4 Quotation") >>~ (popContext))- <|>- ((pDetect2Chars False '<' '<' >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Camlp4 Quotation") >>~ pushContext "Camlp4 Quotation Constant")- <|>- ((pRegExpr regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 >>= withAttribute "Escaped characters"))- <|>- ((pRegExpr regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute "Escaped characters")))- return (attr, result)+parseRules "Camlp4 Quotation Constant" =+ (((pDetect2Chars False '>' '>' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '<' '<' >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute StringTok) >>~ pushContext "Camlp4 Quotation Constant")+ <|>+ ((pRegExpr regex_'5c'5c'28'5c'5c'7c'3e'3e'7c'3c'3c'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'3c'3a'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c0377'5f'5d'5bA'2dZa'2dz'5c0300'2d'5c0326'5c0330'2d'5c0366'5c0370'2d'5c03770'2d9'5f'27'5d'2a'3c >>= withAttribute CharTok))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Octave.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file octave.xml, version 1.01,- by Luis Silvestre and Federico Zenith -}+{- This module was generated from data in the Kate syntax+ highlighting file octave.xml, version 1.01, by Luis Silvestre and Federico Zenith -} -module Text.Highlighting.Kate.Syntax.Octave ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Octave+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Octave"@@ -19,55 +22,42 @@ syntaxExtensions = "*.octave;*.m;*.M" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Octave" } context <- currentContext <|> (pushContext "_normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Octave",["_normal"])], synStLanguage = "Octave", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Octave",["_normal"])], synStLanguage = "Octave", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "_normal" -> return () >> pHandleEndLine+ "_normal" -> return () "_adjoint" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Number","fl"),("String","st"),("String Char","ch"),("Incomplete String","ch"),("Comment","co"),("Functions","fu"),("Forge","fu"),("Builtin","bn"),("Commands","fu")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "all_va_args break case continue else elseif end_unwind_protect global gplot gsplot otherwise persistent replot return static until unwind_protect unwind_protect_cleanup varargin varargout" list_builtin = Set.fromList $ words $ "argv e eps false F_DUPFD F_GETFD F_GETFL filesep F_SETFD F_SETFL i I inf Inf j J NA nan NaN O_APPEND O_ASYNC O_CREAT OCTAVE_HOME OCTAVE_VERSION O_EXCL O_NONBLOCK O_RDONLY O_RDWR O_SYNC O_TRUNC O_WRONLY pi program_invocation_name program_name P_tmpdir realmax realmin SEEK_CUR SEEK_END SEEK_SET SIG stderr stdin stdout true ans automatic_replot beep_on_error completion_append_char crash_dumps_octave_core current_script_file_name debug_on_error debug_on_interrupt debug_on_warning debug_symtab_lookups DEFAULT_EXEC_PATH DEFAULT_LOADPATH default_save_format echo_executing_commands EDITOR EXEC_PATH FFTW_WISDOM_PROGRAM fixed_point_format gnuplot_binary gnuplot_command_axes gnuplot_command_end gnuplot_command_plot gnuplot_command_replot gnuplot_command_splot gnuplot_command_title gnuplot_command_using gnuplot_command_with gnuplot_has_frames history_file history_size ignore_function_time_stamp IMAGEPATH INFO_FILE INFO_PROGRAM __kluge_procbuf_delay__ LOADPATH MAKEINFO_PROGRAM max_recursion_depth octave_core_file_format octave_core_file_limit octave_core_file_name output_max_field_width output_precision page_output_immediately PAGER page_screen_output print_answer_id_name print_empty_dimensions print_rhs_assign_val PS1 PS2 PS4 save_header_format_string save_precision saving_history sighup_dumps_octave_core sigterm_dumps_octave_core silent_functions split_long_rows string_fill_char struct_levels_to_print suppress_verbose_help_message variables_can_hide_functions warn_assign_as_truth_value warn_divide_by_zero warn_empty_list_elements warn_fortran_indexing warn_function_name_clash warn_future_time_stamp warn_imag_to_real warn_matlab_incompatible warn_missing_semicolon warn_neg_dim_as_zero warn_num_to_str warn_precedence_change warn_reload_forces_clear warn_resize_on_range_error warn_separator_insert warn_single_quote_string warn_str_to_num warn_undefined_return_values warn_variable_switch_label whos_line_format"@@ -103,113 +93,111 @@ regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f = compileRegex "(\\d+(\\.\\d+)?|\\.\\d+)([eE][+-]?\\d+)?[ij]?" regex_'27'2b = compileRegex "'+" -defaultAttributes = [("_normal","Normal Text"),("_adjoint","Operator")]+defaultAttributes = [("_normal",NormalTok),("_adjoint",NormalTok)] -parseRules "_normal" = - do (attr, result) <- (((pRegExpr regex_'5cb'28for'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28endfor'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28if'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28endif'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28do'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28until'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28while'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28endwhile'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28function'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28endfunction'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28switch'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28endswitch'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28try'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28end'5ftry'5fcatch'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28end'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a'28'3f'3d'27'29 >>= withAttribute "Variable") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f'28'3f'3d'27'29 >>= withAttribute "Number") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'5b'5c'29'5c'5d'7d'5d'28'3f'3d'27'29 >>= withAttribute "Delimiter") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'5c'2e'27'28'3f'3d'27'29 >>= withAttribute "Operator") >>~ pushContext "_adjoint")- <|>- ((pRegExpr regex_'27'28'5b'5e'27'5c'5c'5d'7c'27'27'7c'5c'5c'27'7c'5c'5c'5b'5e'27'5d'29'2a'27'28'3f'3d'5b'5e'27'5d'7c'24'29 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'27'28'5b'5e'27'5d'7c'27'27'7c'5c'5c'27'29'2a >>= withAttribute "Incomplete String"))- <|>- ((pRegExpr regex_'22'28'5b'5e'22'5c'5c'5d'7c'22'22'7c'5c'5c'22'7c'5c'5c'5b'5e'22'5d'29'2a'22'28'3f'3d'5b'5e'22'5d'7c'24'29 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'22'28'5b'5e'22'5d'7c'22'22'7c'5c'5c'22'29'2a >>= withAttribute "Incomplete String"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_commands >>= withAttribute "Commands"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Functions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtin >>= withAttribute "Builtin"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_forge >>= withAttribute "Forge"))- <|>- ((pRegExpr regex_'5b'25'23'5d'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f >>= withAttribute "Number"))- <|>- ((pAnyChar "()[]{}" >>= withAttribute "Delimiter"))- <|>- ((pString False "..." >>= withAttribute "Operator"))- <|>- ((pString False "==" >>= withAttribute "Operator"))- <|>- ((pString False "~=" >>= withAttribute "Operator"))- <|>- ((pString False "!=" >>= withAttribute "Operator"))- <|>- ((pString False "<=" >>= withAttribute "Operator"))- <|>- ((pString False ">=" >>= withAttribute "Operator"))- <|>- ((pString False "<>" >>= withAttribute "Operator"))- <|>- ((pString False "&&" >>= withAttribute "Operator"))- <|>- ((pString False "||" >>= withAttribute "Operator"))- <|>- ((pString False "++" >>= withAttribute "Operator"))- <|>- ((pString False "--" >>= withAttribute "Operator"))- <|>- ((pString False "**" >>= withAttribute "Operator"))- <|>- ((pString False ".*" >>= withAttribute "Operator"))- <|>- ((pString False ".**" >>= withAttribute "Operator"))- <|>- ((pString False ".^" >>= withAttribute "Operator"))- <|>- ((pString False "./" >>= withAttribute "Operator"))- <|>- ((pString False ".'" >>= withAttribute "Operator"))- <|>- ((pAnyChar "!\"%(*+,/;=>[]|~#&)-:<>\\^" >>= withAttribute "Operator")))- return (attr, result)+parseRules "_normal" =+ (((pRegExpr regex_'5cb'28for'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28endfor'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28if'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28endif'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28do'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28until'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28while'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28endwhile'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28function'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28endfunction'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28switch'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28endswitch'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28try'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28end'5ftry'5fcatch'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'28end'29'5cb >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f'28'3f'3d'27'29 >>= withAttribute FloatTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'5b'5c'29'5c'5d'7d'5d'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'5c'2e'27'28'3f'3d'27'29 >>= withAttribute NormalTok) >>~ pushContext "_adjoint")+ <|>+ ((pRegExpr regex_'27'28'5b'5e'27'5c'5c'5d'7c'27'27'7c'5c'5c'27'7c'5c'5c'5b'5e'27'5d'29'2a'27'28'3f'3d'5b'5e'27'5d'7c'24'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'27'28'5b'5e'27'5d'7c'27'27'7c'5c'5c'27'29'2a >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'22'28'5b'5e'22'5c'5c'5d'7c'22'22'7c'5c'5c'22'7c'5c'5c'5b'5e'22'5d'29'2a'22'28'3f'3d'5b'5e'22'5d'7c'24'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'22'28'5b'5e'22'5d'7c'22'22'7c'5c'5c'22'29'2a >>= withAttribute CharTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_commands >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtin >>= withAttribute BaseNTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_forge >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'25'23'5d'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5d'5cw'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5cd'2b'28'5c'2e'5cd'2b'29'3f'7c'5c'2e'5cd'2b'29'28'5beE'5d'5b'2b'2d'5d'3f'5cd'2b'29'3f'5bij'5d'3f >>= withAttribute FloatTok))+ <|>+ ((pAnyChar "()[]{}" >>= withAttribute NormalTok))+ <|>+ ((pString False "..." >>= withAttribute NormalTok))+ <|>+ ((pString False "==" >>= withAttribute NormalTok))+ <|>+ ((pString False "~=" >>= withAttribute NormalTok))+ <|>+ ((pString False "!=" >>= withAttribute NormalTok))+ <|>+ ((pString False "<=" >>= withAttribute NormalTok))+ <|>+ ((pString False ">=" >>= withAttribute NormalTok))+ <|>+ ((pString False "<>" >>= withAttribute NormalTok))+ <|>+ ((pString False "&&" >>= withAttribute NormalTok))+ <|>+ ((pString False "||" >>= withAttribute NormalTok))+ <|>+ ((pString False "++" >>= withAttribute NormalTok))+ <|>+ ((pString False "--" >>= withAttribute NormalTok))+ <|>+ ((pString False "**" >>= withAttribute NormalTok))+ <|>+ ((pString False ".*" >>= withAttribute NormalTok))+ <|>+ ((pString False ".**" >>= withAttribute NormalTok))+ <|>+ ((pString False ".^" >>= withAttribute NormalTok))+ <|>+ ((pString False "./" >>= withAttribute NormalTok))+ <|>+ ((pString False ".'" >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "!\"%(*+,/;=>[]|~#&)-:<>\\^" >>= withAttribute NormalTok))) -parseRules "_adjoint" = - do (attr, result) <- ((pRegExpr regex_'27'2b >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)+parseRules "_adjoint" =+ ((pRegExpr regex_'27'2b >>= withAttribute NormalTok) >>~ (popContext)) parseRules "" = parseRules "_normal"
Text/Highlighting/Kate/Syntax/Pascal.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file pascal.xml, version 1.22,- by Unnamed people and Liu Sizhuang(oldherl@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file pascal.xml, version 1.22, by Unnamed people and Liu Sizhuang(oldherl@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Pascal ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Pascal+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Pascal"@@ -19,63 +22,50 @@ syntaxExtensions = "*.pp;*.pas;*.p" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Pascal" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Pascal",["Normal"])], synStLanguage = "Pascal", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Pascal",["Normal"])], synStLanguage = "Pascal", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "CharNum" -> (popContext) >> pEndLine "HexCharNum" -> (popContext) >> pEndLine "Hex" -> (popContext) >> pEndLine "String" -> (popContext) >> pEndLine "Prep1" -> (popContext) >> pEndLine "Prep2" -> (popContext) >> pEndLine- "Comment1" -> return () >> pHandleEndLine- "Comment2" -> return () >> pHandleEndLine+ "Comment1" -> return ()+ "Comment2" -> return () "Comment3" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Hex","bn"),("Keyword","kw"),("ISO/Delphi Extended","kw"),("Type","dt"),("Number","dv"),("String","st"),("Directive","ot"),("Comment","co"),("Alert","al")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "and array asm case const div do downto else file for function goto if in label mod nil not of operator or packed procedure program record repeat set then to type unit until uses var while with xor at automated break continue dispinterface dispose exit false finalization initialization library new published resourcestring self true" list_ISO'2fDelphi_Extended = Set.fromList $ words $ "abstract as bindable constructor destructor except export finally import implementation inherited inline interface is module on only otherwise override private property protected public read qualified raise restricted shl shr threadvar try virtual write"@@ -88,83 +78,73 @@ regex_'5b'5e0'2d9'5d = compileRegex "[^0-9]" regex_'5b'5ea'2dfA'2dF0'2d9'5d = compileRegex "[^a-fA-F0-9]" -defaultAttributes = [("Normal","Normal Text"),("CharNum","String"),("HexCharNum","Hex"),("Hex","Hex"),("String","String"),("Prep1","Directive"),("Prep2","Directive"),("Comment1","Comment"),("Comment2","Comment"),("Comment3","Comment")]+defaultAttributes = [("Normal",NormalTok),("CharNum",StringTok),("HexCharNum",BaseNTok),("Hex",BaseNTok),("String",StringTok),("Prep1",OtherTok),("Prep2",OtherTok),("Comment1",CommentTok),("Comment2",CommentTok),("Comment3",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pRegExpr regex_'5cb'28begin'7ccase'7crecord'29'28'3f'3d'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28'28object'7cclass'29'28'3f'3d'28'5c'28'2e'2a'5c'29'29'3f'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'3b'3f'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29'7ctry'28'3f'3d'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29'29 >>= withAttribute "ISO/Delphi Extended"))- <|>- ((pRegExpr regex_'5cbend'28'3f'3d'28'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'29'28'5b'2e'3b'5cs'5d'7c'24'29'7c'2f'2f'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ISO'2fDelphi_Extended >>= withAttribute "ISO/Delphi Extended"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Type"))- <|>- ((pFloat >>= withAttribute "Number"))- <|>- ((pInt >>= withAttribute "Number"))- <|>- ((pDetectChar False '$' >>= withAttribute "Hex") >>~ pushContext "Hex")- <|>- ((pDetectChar False '#' >>= withAttribute "String") >>~ pushContext "CharNum")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pString False "(*$" >>= withAttribute "Directive") >>~ pushContext "Prep1")- <|>- ((pDetect2Chars False '{' '$' >>= withAttribute "Directive") >>~ pushContext "Prep2")- <|>- ((pDetectChar False '{' >>= withAttribute "Comment") >>~ pushContext "Comment1")- <|>- ((pDetect2Chars False '(' '*' >>= withAttribute "Comment") >>~ pushContext "Comment2")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Comment3"))- return (attr, result)+parseRules "Normal" =+ (((pRegExpr regex_'5cb'28begin'7ccase'7crecord'29'28'3f'3d'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28'28object'7cclass'29'28'3f'3d'28'5c'28'2e'2a'5c'29'29'3f'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'3b'3f'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29'7ctry'28'3f'3d'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'28'5b'5cs'5d'7c'24'7c'2f'2f'29'29'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'28'3f'3d'28'28'5c'7b'5b'5e'7d'5d'2a'28'5c'7d'7c'24'29'7c'5c'28'5c'2a'2e'2a'28'5c'2a'5c'29'7c'24'29'29'2a'29'28'5b'2e'3b'5cs'5d'7c'24'29'7c'2f'2f'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_ISO'2fDelphi_Extended >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pFloat >>= withAttribute DecValTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute BaseNTok) >>~ pushContext "Hex")+ <|>+ ((pDetectChar False '#' >>= withAttribute StringTok) >>~ pushContext "CharNum")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pString False "(*$" >>= withAttribute OtherTok) >>~ pushContext "Prep1")+ <|>+ ((pDetect2Chars False '{' '$' >>= withAttribute OtherTok) >>~ pushContext "Prep2")+ <|>+ ((pDetectChar False '{' >>= withAttribute CommentTok) >>~ pushContext "Comment1")+ <|>+ ((pDetect2Chars False '(' '*' >>= withAttribute CommentTok) >>~ pushContext "Comment2")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Comment3")) -parseRules "CharNum" = - do (attr, result) <- (((pDetectChar False '$' >>= withAttribute "Hex") >>~ pushContext "HexCharNum")- <|>- ((pRegExpr regex_'5b'5e0'2d9'5d >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "CharNum" =+ (((pDetectChar False '$' >>= withAttribute BaseNTok) >>~ pushContext "HexCharNum")+ <|>+ ((pRegExpr regex_'5b'5e0'2d9'5d >>= withAttribute StringTok) >>~ (popContext))) -parseRules "HexCharNum" = - do (attr, result) <- ((pRegExpr regex_'5b'5ea'2dfA'2dF0'2d9'5d >>= withAttribute "Hex") >>~ (popContext >> popContext))- return (attr, result)+parseRules "HexCharNum" =+ ((pRegExpr regex_'5b'5ea'2dfA'2dF0'2d9'5d >>= withAttribute BaseNTok) >>~ (popContext >> popContext)) -parseRules "Hex" = - do (attr, result) <- ((pRegExpr regex_'5b'5ea'2dfA'2dF0'2d9'5d >>= withAttribute "Hex") >>~ (popContext))- return (attr, result)+parseRules "Hex" =+ ((pRegExpr regex_'5b'5ea'2dfA'2dF0'2d9'5d >>= withAttribute BaseNTok) >>~ (popContext)) -parseRules "String" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Prep1" = - do (attr, result) <- ((pDetect2Chars False '*' ')' >>= withAttribute "Directive") >>~ (popContext))- return (attr, result)+parseRules "Prep1" =+ ((pDetect2Chars False '*' ')' >>= withAttribute OtherTok) >>~ (popContext)) -parseRules "Prep2" = - do (attr, result) <- ((pDetectChar False '}' >>= withAttribute "Directive") >>~ (popContext))- return (attr, result)+parseRules "Prep2" =+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext)) -parseRules "Comment1" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute "Alert"))- <|>- ((pDetectChar False '}' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Comment1" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute AlertTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Comment2" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute "Alert"))- <|>- ((pDetect2Chars False '*' ')' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Comment2" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute AlertTok))+ <|>+ ((pDetect2Chars False '*' ')' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Comment3" = - do (attr, result) <- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute "Alert"))- return (attr, result)+parseRules "Comment3" =+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_attention >>= withAttribute AlertTok)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Perl.hs view
@@ -1,922 +1,847 @@-{- This module was generated from data in the Kate syntax highlighting file perl.xml, version 1.25,- by Anders Lund (anders@alweb.dk) -}--module Text.Highlighting.Kate.Syntax.Perl ( 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 Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "Perl"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.pl;*.pm"---- | 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 = "Perl" }- 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 [("Perl",["normal"])], synStLanguage = "Perl", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "normal" -> return () >> pHandleEndLine- "find_quoted" -> return () >> pHandleEndLine- "find_qqx" -> return () >> pHandleEndLine- "find_qw" -> return () >> pHandleEndLine- "ipstring_internal" -> return () >> pHandleEndLine- "ip_string" -> return () >> pHandleEndLine- "ip_string_2" -> return () >> pHandleEndLine- "ip_string_3" -> return () >> pHandleEndLine- "ip_string_4" -> return () >> pHandleEndLine- "ip_string_5" -> return () >> pHandleEndLine- "ip_string_6" -> return () >> pHandleEndLine- "string" -> return () >> pHandleEndLine- "string_2" -> return () >> pHandleEndLine- "string_3" -> return () >> pHandleEndLine- "string_4" -> return () >> pHandleEndLine- "string_5" -> return () >> pHandleEndLine- "string_6" -> return () >> pHandleEndLine- "find_subst" -> return () >> pHandleEndLine- "subst_curlybrace_pattern" -> return () >> pHandleEndLine- "subst_curlybrace_middle" -> return () >> pHandleEndLine- "subst_curlybrace_replace" -> return () >> pHandleEndLine- "subst_curlybrace_replace_recursive" -> return () >> pHandleEndLine- "subst_paren_pattern" -> return () >> pHandleEndLine- "subst_paren_replace" -> return () >> pHandleEndLine- "subst_bracket_pattern" -> return () >> pHandleEndLine- "subst_bracket_replace" -> return () >> pHandleEndLine- "subst_slash_pattern" -> return () >> pHandleEndLine- "subst_slash_replace" -> return () >> pHandleEndLine- "subst_sq_pattern" -> return () >> pHandleEndLine- "subst_sq_replace" -> return () >> pHandleEndLine- "tr" -> (popContext) >> pEndLine- "find_pattern" -> return () >> pHandleEndLine- "pattern_slash" -> return () >> pHandleEndLine- "pattern" -> return () >> pHandleEndLine- "pattern_brace" -> return () >> pHandleEndLine- "pattern_bracket" -> return () >> pHandleEndLine- "pattern_paren" -> return () >> pHandleEndLine- "pattern_sq" -> return () >> pHandleEndLine- "regex_pattern_internal_rules_1" -> return () >> pHandleEndLine- "regex_pattern_internal_rules_2" -> return () >> pHandleEndLine- "regex_pattern_internal" -> return () >> pHandleEndLine- "regex_pattern_internal_ip" -> return () >> pHandleEndLine- "pat_ext" -> return () >> pHandleEndLine- "pat_char_class" -> return () >> pHandleEndLine- "find_variable" -> (popContext) >> pEndLine- "find_variable_unsafe" -> (popContext) >> pEndLine- "var_detect" -> (popContext >> popContext) >> pEndLine- "var_detect_unsafe" -> (popContext >> popContext) >> pEndLine- "var_detect_rules" -> (popContext >> popContext) >> pEndLine- "quote_word" -> return () >> pHandleEndLine- "quote_word_paren" -> return () >> pHandleEndLine- "quote_word_brace" -> return () >> pHandleEndLine- "quote_word_bracket" -> return () >> pHandleEndLine- "find_here_document" -> (popContext) >> pEndLine- "here_document" -> return () >> pHandleEndLine- "here_document_dumb" -> return () >> pHandleEndLine- "data_handle" -> return () >> pHandleEndLine- "end_handle" -> return () >> pHandleEndLine- "Backticked" -> return () >> pHandleEndLine- "slash_safe_escape" -> (popContext) >> pEndLine- "package_qualified_blank" -> return () >> pHandleEndLine- "sub_name_def" -> (popContext) >> pEndLine- "sub_arg_definition" -> return () >> pHandleEndLine- "pod" -> return () >> pHandleEndLine- "comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Pragma","kw"),("Function","fu"),("Operator","kw"),("Data Type","dt"),("Special Variable","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("String","st"),("String (interpolated)","st"),("String Special Character","ch"),("Pattern","ot"),("Pattern Internal Operator","ch"),("Pattern Character Class","bn"),("Comment","co"),("Pod","co"),("Nothing","co")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_keywords = Set.fromList $ words $ "if unless else elsif while until for each foreach next last break continue return use no require my our local BEGIN END require package sub do __END__ __DATA__ __FILE__ __LINE__ __PACKAGE__"-list_operators = Set.fromList $ words $ "= != ~= += -= *= /= **= |= ||= //= &= &&= ?= + - * % || // && | & < << > >> ^ -> => . , ; :: \\ and or not eq ne lt gt le ge cmp"-list_functions = Set.fromList $ words $ "abs accept alarm atan2 bind binmode bless caller chdir chmod chomp chop chown chr chroot close closedir connect cos crypt dbmclose dbmopen defined delete die dump endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt glob gmtime goto grep hex import index int ioctl join keys kill last lc lcfirst length link listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd oct open opendir ord pack package pipe pop pos print printf prototype push quotemeta rand read readdir readline readlink recv redo ref rename reset return reverse rewinddir rindex rmdir scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat study sub substr symlink syscall sysread sysseek system syswrite tell telldir tie time times truncate uc ucfirst umask undef unlink unpack unshift untie utime values vec wait waitpid wantarray warn write"-list_pragmas = Set.fromList $ words $ "strict english warnings vars subs utf8 sigtrap locale open less integer filetest constant bytes diagnostics"--regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"-regex_'5cbsub'5cs'2b = compileRegex "\\bsub\\s+"-regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'28'5cs'7c'24'29 = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)(\\s|$)"-regex_'5c'5c'28'5b'22'27'5d'29'5b'5e'5c1'5d = compileRegex "\\\\([\"'])[^\\1]"-regex_'28'3f'3a'5b'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'7c'5c'2a'5b'5e'5cd'5c'2a'7b'5c'24'40'25'3d'28'5d'29 = compileRegex "(?:[$@]\\S|%[\\w{]|\\*[^\\d\\*{\\$@%=(])"-regex_'3c'5bA'2dZ0'2d9'5f'5d'2b'3e = compileRegex "<[A-Z0-9_]+>"-regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5cs'2a'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|\\s*[\"'])"-regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*\\}\\s*/{1,2}"-regex_'5cs'2a'5b'29'5c'5d'5d'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*[)\\]]\\s*/{1,2}"-regex_'5cw'2b'3a'3a = compileRegex "\\w+::"-regex_'5cw'2b'5b'3d'5d = compileRegex "\\w+[=]"-regex_'5cbq'28'3f'3d'5bqwx'5d'3f'5cs'2a'5b'5e'5cw'5cs'5d'29 = compileRegex "\\bq(?=[qwx]?\\s*[^\\w\\s])"-regex_'5cbs'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\bs(?=\\s*[^\\w\\s\\]})])"-regex_'5cb'28'3f'3atr'7cy'29'5cs'2a'28'3f'3d'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\b(?:tr|y)\\s*(?=[^\\w\\s\\]})])"-regex_'5cb'28'3f'3am'7cqr'29'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\b(?:m|qr)(?=\\s*[^\\w\\s\\]})])"-regex_'5b'5cw'5f'5d'2b'5cs'2a'2f = compileRegex "[\\w_]+\\s*/"-regex_'5b'3c'3e'22'27'3a'5d'2f = compileRegex "[<>\"':]/"-regex_'2d'5brwxoRWXOeszfdlpSbctugkTBMAC'5d = compileRegex "-[rwxoRWXOeszfdlpSbctugkTBMAC]"-regex_x'5cs'2a'28'27'29 = compileRegex "x\\s*(')"-regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 = compileRegex "([^a-zA-Z0-9_\\s[\\]{}()])"-regex_'5cs'2b'23'2e'2a = compileRegex "\\s+#.*"-regex_'5c'5c'5bUuLlEtnaefr'5d = compileRegex "\\\\[UuLlEtnaefr]"-regex_'5c'5c'2e = compileRegex "\\\\."-regex_'28'3f'3a'5b'5c'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'29 = compileRegex "(?:[\\$@]\\S|%[\\w{])"-regex_'28'5b'5e'5cw'5cs'5b'5c'5d'7b'7d'28'29'5d'29 = compileRegex "([^\\w\\s[\\]{}()])"-regex_'5cs'2b'23'2e'2a'24 = compileRegex "\\s+#.*$"-regex_'23'2e'2a'24 = compileRegex "#.*$"-regex_'5c'7d'5bcegimosx'5d'2a = compileRegex "\\}[cegimosx]*"-regex_'5c'29'5bcegimosx'5d'2a = compileRegex "\\)[cegimosx]*"-regex_'5c'5d'5bcegimosx'5d'2a = compileRegex "\\][cegimosx]*"-regex_'27'5bcegimosx'5d'2a = compileRegex "'[cegimosx]*"-regex_'5c'28'5b'5e'29'5d'2a'5c'29'5cs'2a'5c'28'3f'3a'5b'5e'29'5d'2a'5c'29 = compileRegex "\\([^)]*\\)\\s*\\(?:[^)]*\\)"-regex_'7b'5b'5e'7d'5d'2a'5c'7d'5cs'2a'5c'7b'5b'5e'7d'5d'2a'5c'7d = compileRegex "{[^}]*\\}\\s*\\{[^}]*\\}"-regex_'5c'5b'5b'5e'7d'5d'2a'5c'5d'5cs'2a'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d = compileRegex "\\[[^}]*\\]\\s*\\[[^\\]]*\\]"-regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29'2e'2a'5c1'2e'2a'5c1 = compileRegex "([^a-zA-Z0-9_\\s[\\]{}()]).*\\1.*\\1"-regex_'28'5b'5e'5cw'5cs'5d'29 = compileRegex "([^\\w\\s])"-regex_'5c'24'28'3f'3d'2f'29 = compileRegex "\\$(?=/)"-regex_'2f'5bcgimosx'5d'2a = compileRegex "/[cgimosx]*"-regex_'5c'7d'5bcgimosx'5d'2a = compileRegex "\\}[cgimosx]*"-regex_'5c'5d'5bcgimosx'5d'2a = compileRegex "\\][cgimosx]*"-regex_'5c'29'5bcgimosx'5d'2a = compileRegex "\\)[cgimosx]*"-regex_'27'5bcgimosx'5d'2a = compileRegex "'[cgimosx]*"-regex_'5c'5c'5banDdSsWw'5d = compileRegex "\\\\[anDdSsWw]"-regex_'5c'5c'5bABbEGLlNUuQdQZz'5d = compileRegex "\\\\[ABbEGLlNUuQdQZz]"-regex_'5c'5c'5b'5cd'5d'2b = compileRegex "\\\\[\\d]+"-regex_'5b'28'29'3f'5c'5e'2a'2b'7c'5d = compileRegex "[()?\\^*+|]"-regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d = compileRegex "\\{[\\d, ]+\\}"-regex_'5cs'7b3'2c'7d'23'2e'2a'24 = compileRegex "\\s{3,}#.*$"-regex_'5b'24'40'5d'5b'5e'5c'5d'5cs'7b'7d'28'29'7c'3e'27'5d = compileRegex "[$@][^\\]\\s{}()|>']"-regex_'5c'23'5b'5e'29'5d'2a = compileRegex "\\#[^)]*"-regex_'5b'3a'3d'21'3e'3c'5d'2b = compileRegex "[:=!><]+"-regex_'5c'5b'3a'5c'5e'3f'5ba'2dz'5d'2b'3a'5c'5d = compileRegex "\\[:\\^?[a-z]+:\\]"-regex_'5c'24'5b0'2d9'5d'2b = compileRegex "\\$[0-9]+"-regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 = compileRegex "[@\\$](?:[\\+\\-_]\\B|ARGV\\b|INC\\b)"-regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 = compileRegex "[%\\$](?:INC\\b|ENV\\b|SIG\\b)"-regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d = compileRegex "\\$\\$[\\$\\w_]"-regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d = compileRegex "\\$[#_][\\w_]"-regex_'5c'24'2b'3a'3a = compileRegex "\\$+::"-regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f = compileRegex "\\$[^a-zA-Z0-9\\s{][A-Z]?"-regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d = compileRegex "[\\$@%]\\{[\\w_]+\\}"-regex_'5c'2a'5ba'2dzA'2dZ'5f'5d'2b = compileRegex "\\*[a-zA-Z_]+"-regex_'5c'2a'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f = compileRegex "\\*[^a-zA-Z0-9\\s{][A-Z]?"-regex_'5b'5c'24'40'25'5d = compileRegex "[\\$@%]"-regex_'5c'2a'5cw'2b = compileRegex "\\*\\w+"-regex_'5b'5cw'5f'5d'2b = compileRegex "[\\w_]+"-regex_'28'5cw'2b'29'5cs'2a'3b'3f = compileRegex "(\\w+)\\s*;?"-regex_'5cs'2a'22'28'5b'5e'22'5d'2b'29'22'5cs'2a'3b'3f = compileRegex "\\s*\"([^\"]+)\"\\s*;?"-regex_'5cs'2a'60'28'5b'5e'60'5d'2b'29'60'5cs'2a'3b'3f = compileRegex "\\s*`([^`]+)`\\s*;?"-regex_'5cs'2a'27'28'5b'5e'27'5d'2b'29'27'5cs'2a'3b'3f = compileRegex "\\s*'([^']+)'\\s*;?"-regex_'5c'3d'5cs'2a'3c'3c'5cs'2a'5b'22'27'5d'3f'28'5bA'2dZ0'2d9'5f'5c'2d'5d'2b'29'5b'22'27'5d'3f = compileRegex "\\=\\s*<<\\s*[\"']?([A-Z0-9_\\-]+)[\"']?"-regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2b'2e'2a = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)\\s+.*"-regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)\\s*.*"-regex_'5cs'2a'5b'29'5c'5d'5d'3f'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*[)\\]]?\\s*/{1,2}"-regex_'5cw'2b = compileRegex "\\w+"-regex_'5c'24'5cS = compileRegex "\\$\\S"-regex_'5cs'2a'5c'28 = compileRegex "\\s*\\("-regex_'5c'3dcut'2e'2a'24 = compileRegex "\\=cut.*$"--defaultAttributes = [("normal","Normal Text"),("find_quoted","Normal Text"),("find_qqx","Normal Text"),("find_qw","Normal Text"),("ipstring_internal","String (interpolated)"),("ip_string","String (interpolated)"),("ip_string_2","String (interpolated)"),("ip_string_3","String (interpolated)"),("ip_string_4","String (interpolated)"),("ip_string_5","String (interpolated)"),("ip_string_6","String (interpolated)"),("string","String"),("string_2","String"),("string_3","String"),("string_4","String"),("string_5","String"),("string_6","String"),("find_subst","Normal Text"),("subst_curlybrace_pattern","Pattern"),("subst_curlybrace_middle","Normal Text"),("subst_curlybrace_replace","String (interpolated)"),("subst_curlybrace_replace_recursive","String (interpolated)"),("subst_paren_pattern","Pattern"),("subst_paren_replace","String (interpolated)"),("subst_bracket_pattern","Pattern"),("subst_bracket_replace","String (interpolated)"),("subst_slash_pattern","Pattern"),("subst_slash_replace","String (interpolated)"),("subst_sq_pattern","Pattern"),("subst_sq_replace","String"),("tr","Pattern"),("find_pattern","Pattern"),("pattern_slash","Pattern"),("pattern","Pattern"),("pattern_brace","Pattern"),("pattern_bracket","Pattern"),("pattern_paren","Pattern"),("pattern_sq","Pattern"),("regex_pattern_internal_rules_1",""),("regex_pattern_internal_rules_2",""),("regex_pattern_internal","Pattern"),("regex_pattern_internal_ip","Pattern"),("pat_ext","Pattern Internal Operator"),("pat_char_class","Pattern Character Class"),("find_variable","Data Type"),("find_variable_unsafe","Data Type"),("var_detect","Data Type"),("var_detect_unsafe","Data Type"),("var_detect_rules","Data Type"),("quote_word","Normal Text"),("quote_word_paren","Normal Text"),("quote_word_brace","Normal Text"),("quote_word_bracket","Normal Text"),("find_here_document","Normal Text"),("here_document","String (interpolated)"),("here_document_dumb","Normal Text"),("data_handle","Data"),("end_handle","Nothing"),("Backticked","String (interpolated)"),("slash_safe_escape","Normal Text"),("package_qualified_blank","Normal Text"),("sub_name_def","Normal Text"),("sub_arg_definition","Normal Text"),("pod","Pod"),("comment","Comment")]--parseRules "normal" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pString False "__DATA__" >>= withAttribute "Keyword") >>~ pushContext "data_handle")- <|>- ((pFirstNonSpace >> pString False "__END__" >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbsub'5cs'2b >>= withAttribute "Keyword") >>~ pushContext "sub_name_def")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragmas >>= withAttribute "Pragma"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'28'5cs'7c'24'29 >>= withAttribute "Pod") >>~ pushContext "pod")- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pHlCOct >>= withAttribute "Octal") >>~ pushContext "slash_safe_escape")- <|>- ((pHlCHex >>= withAttribute "Hex") >>~ pushContext "slash_safe_escape")- <|>- ((pFloat >>= withAttribute "Float") >>~ pushContext "slash_safe_escape")- <|>- ((pInt >>= withAttribute "Decimal") >>~ pushContext "slash_safe_escape")- <|>- ((pRegExpr regex_'5c'5c'28'5b'22'27'5d'29'5b'5e'5c1'5d >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '&' '\'' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '"' >>= withAttribute "Operator") >>~ pushContext "ip_string")- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator") >>~ pushContext "string")- <|>- ((pDetectChar False '`' >>= withAttribute "Operator") >>~ pushContext "Backticked")- <|>- ((lookAhead (pRegExpr regex_'28'3f'3a'5b'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'7c'5c'2a'5b'5e'5cd'5c'2a'7b'5c'24'40'25'3d'28'5d'29) >> return ([],"") ) >>~ pushContext "find_variable")- <|>- ((pRegExpr regex_'3c'5bA'2dZ0'2d9'5f'5d'2b'3e >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5cs'2a'5b'22'27'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_here_document")- <|>- ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5cs'2a'5b'29'5c'5d'5d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5cw'2b'3a'3a >>= withAttribute "Function") >>~ pushContext "sub_name_def")- <|>- ((pRegExpr regex_'5cw'2b'5b'3d'5d >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5cbq'28'3f'3d'5bqwx'5d'3f'5cs'2a'5b'5e'5cw'5cs'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_quoted")- <|>- ((pRegExpr regex_'5cbs'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_subst")- <|>- ((pRegExpr regex_'5cb'28'3f'3atr'7cy'29'5cs'2a'28'3f'3d'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "tr")- <|>- ((pRegExpr regex_'5cb'28'3f'3am'7cqr'29'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_pattern")- <|>- ((pRegExpr regex_'5b'5cw'5f'5d'2b'5cs'2a'2f >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'5b'3c'3e'22'27'3a'5d'2f >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '/' >>= withAttribute "Operator") >>~ pushContext "pattern_slash")- <|>- ((pRegExpr regex_'2d'5brwxoRWXOeszfdlpSbctugkTBMAC'5d >>= withAttribute "Operator"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text")))- return (attr, result)--parseRules "find_quoted" = - do (attr, result) <- (((pRegExpr regex_x'5cs'2a'28'27'29 >>= withAttribute "Operator") >>~ pushContext "string_6")- <|>- ((pAnyChar "qx" >>= withAttribute "Operator") >>~ pushContext "find_qqx")- <|>- ((pDetectChar False 'w' >>= withAttribute "Operator") >>~ pushContext "find_qw")- <|>- ((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "string_2")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "string_3")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "string_4")- <|>- ((pDetectChar False '<' >>= withAttribute "Operator") >>~ pushContext "string_5")- <|>- ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "string_6")- <|>- ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute "Comment")))- return (attr, result)--parseRules "find_qqx" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "ip_string_2")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "ip_string_3")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "ip_string_4")- <|>- ((pDetectChar False '<' >>= withAttribute "Operator") >>~ pushContext "ip_string_5")- <|>- ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "ip_string_6")- <|>- ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute "Comment")))- return (attr, result)--parseRules "find_qw" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "quote_word_paren")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "quote_word_brace")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "quote_word_bracket")- <|>- ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "quote_word")- <|>- ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute "Comment")))- return (attr, result)--parseRules "ipstring_internal" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String (interpolated)"))- <|>- ((pRegExpr regex_'5c'5c'5bUuLlEtnaefr'5d >>= withAttribute "String Special Character"))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "String (interpolated)"))- <|>- ((lookAhead (pRegExpr regex_'28'3f'3a'5b'5c'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'29) >> return ([],"") ) >>~ pushContext "find_variable_unsafe"))- return (attr, result)--parseRules "ip_string" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Operator") >>~ (popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "ip_string_2" = - do (attr, result) <- (((pRangeDetect '(' ')' >>= withAttribute "String (interpolated)"))- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "ip_string_3" = - do (attr, result) <- (((pRangeDetect '{' '}' >>= withAttribute "String (interpolated)"))- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "ip_string_4" = - do (attr, result) <- (((pRangeDetect '[' ']' >>= withAttribute "String (interpolated)"))- <|>- ((pDetectChar False ']' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "ip_string_5" = - do (attr, result) <- (((pRangeDetect '<' '>' >>= withAttribute "String (interpolated)"))- <|>- ((pDetectChar False '>' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "ip_string_6" = - do (attr, result) <- (((pRegExprDynamic "\\%1" >>= withAttribute "String (interpolated)"))- <|>- ((pDetectChar True '1' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "string" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '\'' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)--parseRules "string_2" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pRangeDetect '(' ')' >>= withAttribute "String"))- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "string_3" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pRangeDetect '{' '}' >>= withAttribute "String"))- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "string_4" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pRangeDetect '[' ']' >>= withAttribute "String"))- <|>- ((pDetectChar False ']' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "string_5" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '<' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "String"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "String"))- <|>- ((pDetectChar False '>' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "string_6" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "String Special Character"))- <|>- ((pRegExprDynamic "\\%1" >>= withAttribute "String Special Character"))- <|>- ((pDetectChar True '1' >>= withAttribute "Operator") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "find_subst" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute "Comment"))- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "subst_curlybrace_pattern")- <|>- ((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "subst_paren_pattern")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "subst_bracket_pattern")- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator") >>~ pushContext "subst_sq_pattern")- <|>- ((pRegExpr regex_'28'5b'5e'5cw'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute "Operator") >>~ pushContext "subst_slash_pattern"))- return (attr, result)--parseRules "subst_curlybrace_pattern" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((parseRules "regex_pattern_internal_ip"))- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ pushContext "subst_curlybrace_middle"))- return (attr, result)--parseRules "subst_curlybrace_middle" = - do (attr, result) <- (((pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "subst_curlybrace_replace"))- return (attr, result)--parseRules "subst_curlybrace_replace" = - do (attr, result) <- (((parseRules "ipstring_internal"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "subst_curlybrace_replace_recursive")- <|>- ((pRegExpr regex_'5c'7d'5bcegimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext >> popContext)))- return (attr, result)--parseRules "subst_curlybrace_replace_recursive" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "String (interpolated)") >>~ pushContext "subst_curlybrace_replace_recursive")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "subst_paren_pattern" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((parseRules "regex_pattern_internal_ip"))- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ pushContext "subst_paren_replace"))- return (attr, result)--parseRules "subst_paren_replace" = - do (attr, result) <- (((parseRules "ipstring_internal"))- <|>- ((pDetectChar False '(' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5c'29'5bcegimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "subst_bracket_pattern" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((parseRules "regex_pattern_internal_ip"))- <|>- ((pDetectChar False ']' >>= withAttribute "Operator") >>~ pushContext "subst_bracket_replace"))- return (attr, result)--parseRules "subst_bracket_replace" = - do (attr, result) <- (((parseRules "ipstring_internal"))- <|>- ((pDetectChar False '[' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5c'5d'5bcegimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "subst_slash_pattern" = - do (attr, result) <- (((pRegExprDynamic "\\$(?=%1)" >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExprDynamic "(%1)" >>= withAttribute "Operator") >>~ pushContext "subst_slash_replace")- <|>- ((parseRules "regex_pattern_internal_ip")))- return (attr, result)--parseRules "subst_slash_replace" = - do (attr, result) <- (((pRegExprDynamic "%1[cegimosx]*" >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "subst_sq_pattern" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((parseRules "regex_pattern_internal"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator") >>~ pushContext "subst_sq_replace"))- return (attr, result)--parseRules "subst_sq_replace" = - do (attr, result) <- ((pRegExpr regex_'27'5bcegimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- return (attr, result)--parseRules "tr" = - do (attr, result) <- (((pRegExpr regex_'5c'28'5b'5e'29'5d'2a'5c'29'5cs'2a'5c'28'3f'3a'5b'5e'29'5d'2a'5c'29 >>= withAttribute "Pattern") >>~ (popContext))- <|>- ((pRegExpr regex_'7b'5b'5e'7d'5d'2a'5c'7d'5cs'2a'5c'7b'5b'5e'7d'5d'2a'5c'7d >>= withAttribute "Pattern") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'5b'5b'5e'7d'5d'2a'5c'5d'5cs'2a'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute "Pattern") >>~ (popContext))- <|>- ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29'2e'2a'5c1'2e'2a'5c1 >>= withAttribute "Pattern") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "find_pattern" = - do (attr, result) <- (((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute "Comment"))- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "pattern_brace")- <|>- ((pDetectChar False '(' >>= withAttribute "Operator") >>~ pushContext "pattern_paren")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "pattern_bracket")- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator") >>~ pushContext "pattern_sq")- <|>- ((pRegExpr regex_'28'5b'5e'5cw'5cs'5d'29 >>= withAttribute "Operator") >>~ pushContext "pattern"))- return (attr, result)--parseRules "pattern_slash" = - do (attr, result) <- (((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute "Pattern Internal Operator"))- <|>- ((parseRules "regex_pattern_internal_ip"))- <|>- ((pRegExpr regex_'2f'5bcgimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)--parseRules "pattern" = - do (attr, result) <- (((pRegExprDynamic "\\$(?=%1)" >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExprDynamic "%1[cgimosx]*" >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((parseRules "regex_pattern_internal_ip"))- <|>- ((pRegExprDynamic "\\$(?=\\%1)" >>= withAttribute "Pattern Internal Operator")))- return (attr, result)--parseRules "pattern_brace" = - do (attr, result) <- (((pRegExpr regex_'5c'7d'5bcgimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((parseRules "regex_pattern_internal_ip")))- return (attr, result)--parseRules "pattern_bracket" = - do (attr, result) <- (((pRegExpr regex_'5c'5d'5bcgimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((parseRules "regex_pattern_internal_ip")))- return (attr, result)--parseRules "pattern_paren" = - do (attr, result) <- (((pRegExpr regex_'5c'29'5bcgimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((parseRules "regex_pattern_internal_ip")))- return (attr, result)--parseRules "pattern_sq" = - do (attr, result) <- (((pRegExpr regex_'27'5bcgimosx'5d'2a >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((parseRules "regex_pattern_internal")))- return (attr, result)--parseRules "regex_pattern_internal_rules_1" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'23'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pRegExpr regex_'5c'5c'5banDdSsWw'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pRegExpr regex_'5c'5c'5bABbEGLlNUuQdQZz'5d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'5c'5b'5cd'5d'2b >>= withAttribute "Special Variable"))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Pattern")))- return (attr, result)--parseRules "regex_pattern_internal_rules_2" = - do (attr, result) <- (((pDetect2Chars False '(' '?' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "pat_ext")- <|>- ((pDetectChar False '[' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "pat_char_class")- <|>- ((pRegExpr regex_'5b'28'29'3f'5c'5e'2a'2b'7c'5d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pDetectChar False '$' >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5cs'7b3'2c'7d'23'2e'2a'24 >>= withAttribute "Comment")))- return (attr, result)--parseRules "regex_pattern_internal" = - do (attr, result) <- (((parseRules "regex_pattern_internal_rules_1"))- <|>- ((parseRules "regex_pattern_internal_rules_2")))- return (attr, result)--parseRules "regex_pattern_internal_ip" = - do (attr, result) <- (((parseRules "regex_pattern_internal_rules_1"))- <|>- ((lookAhead (pRegExpr regex_'5b'24'40'5d'5b'5e'5c'5d'5cs'7b'7d'28'29'7c'3e'27'5d) >> return ([],"") ) >>~ pushContext "find_variable_unsafe")- <|>- ((parseRules "regex_pattern_internal_rules_2")))- return (attr, result)--parseRules "pat_ext" = - do (attr, result) <- (((pRegExpr regex_'5c'23'5b'5e'29'5d'2a >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'3a'3d'21'3e'3c'5d'2b >>= withAttribute "Pattern Internal Operator") >>~ (popContext))- <|>- ((pDetectChar False ')' >>= withAttribute "Pattern Internal Operator") >>~ (popContext)))- return (attr, result)--parseRules "pat_char_class" = - do (attr, result) <- (((pDetectChar False '^' >>= withAttribute "Pattern Internal Operator"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Pattern Character Class"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Pattern Character Class"))- <|>- ((pRegExpr regex_'5c'5b'3a'5c'5e'3f'5ba'2dz'5d'2b'3a'5c'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pDetectChar False ']' >>= withAttribute "Pattern Internal Operator") >>~ (popContext)))- return (attr, result)--parseRules "find_variable" = - do (attr, result) <- (((pRegExpr regex_'5c'24'5b0'2d9'5d'2b >>= withAttribute "Special Variable") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 >>= withAttribute "Special Variable") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 >>= withAttribute "Special Variable") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'24'2b'3a'3a >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute "Special Variable") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pAnyChar "$@%" >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'2a'5ba'2dzA'2dZ'5f'5d'2b >>= withAttribute "Data Type") >>~ pushContext "var_detect")- <|>- ((pRegExpr regex_'5c'2a'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute "Special Variable"))- <|>- ((pAnyChar "$@%*" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "find_variable_unsafe" = - do (attr, result) <- (((pRegExpr regex_'5c'24'5b0'2d9'5d'2b >>= withAttribute "Special Variable") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 >>= withAttribute "Special Variable") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 >>= withAttribute "Special Variable") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5c'24'2b'3a'3a >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute "Special Variable"))- <|>- ((pRegExpr regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5b'5c'24'40'25'5d >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pRegExpr regex_'5c'2a'5cw'2b >>= withAttribute "Data Type") >>~ pushContext "var_detect_unsafe")- <|>- ((pAnyChar "$@%*" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "var_detect" = - do (attr, result) <- (((parseRules "var_detect_rules"))- <|>- ((parseRules "slash_safe_escape"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "var_detect_unsafe" = - do (attr, result) <- (((parseRules "var_detect_rules"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "var_detect_rules" = - do (attr, result) <- (((pRegExpr regex_'5b'5cw'5f'5d'2b >>= withAttribute "Data Type"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '-' '>' >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '+' '+' >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Normal Text")))- return (attr, result)--parseRules "quote_word" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Normal Text"))- <|>- ((pDetectChar True '1' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "quote_word_paren" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ')' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "quote_word_brace" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "quote_word_bracket" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ']' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)--parseRules "find_here_document" = - do (attr, result) <- (((pRegExpr regex_'28'5cw'2b'29'5cs'2a'3b'3f >>= withAttribute "Keyword") >>~ pushContext "here_document")- <|>- ((pRegExpr regex_'5cs'2a'22'28'5b'5e'22'5d'2b'29'22'5cs'2a'3b'3f >>= withAttribute "Keyword") >>~ pushContext "here_document")- <|>- ((pRegExpr regex_'5cs'2a'60'28'5b'5e'60'5d'2b'29'60'5cs'2a'3b'3f >>= withAttribute "Keyword") >>~ pushContext "here_document")- <|>- ((pRegExpr regex_'5cs'2a'27'28'5b'5e'27'5d'2b'29'27'5cs'2a'3b'3f >>= withAttribute "Keyword") >>~ pushContext "here_document_dumb"))- return (attr, result)--parseRules "here_document" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "String (interpolated)"))- <|>- ((pColumn 0 >> pRegExprDynamic "%1" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5c'3d'5cs'2a'3c'3c'5cs'2a'5b'22'27'5d'3f'28'5bA'2dZ0'2d9'5f'5c'2d'5d'2b'29'5b'22'27'5d'3f >>= withAttribute "Keyword") >>~ pushContext "here_document")- <|>- ((parseRules "ipstring_internal")))- return (attr, result)--parseRules "here_document_dumb" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pColumn 0 >> pRegExprDynamic "%1" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text")))- return (attr, result)--parseRules "data_handle" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2b'2e'2a >>= withAttribute "Pod") >>~ pushContext "pod")- <|>- ((pFirstNonSpace >> pString False "__END__" >>= withAttribute "Keyword") >>~ pushContext "normal"))- return (attr, result)--parseRules "end_handle" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a >>= withAttribute "Pod") >>~ pushContext "pod")- <|>- ((pFirstNonSpace >> pString False "__DATA__" >>= withAttribute "Keyword") >>~ pushContext "data_handle"))- return (attr, result)--parseRules "Backticked" = - do (attr, result) <- (((parseRules "ipstring_internal"))- <|>- ((pDetectChar False '`' >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)--parseRules "slash_safe_escape" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'5b'29'5c'5d'5d'3f'5cs'2a'2f'7b1'2c2'7d >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "package_qualified_blank" = - do (attr, result) <- ((pRegExpr regex_'5b'5cw'5f'5d'2b >>= withAttribute "Normal Text") >>~ (popContext))- return (attr, result)--parseRules "sub_name_def" = - do (attr, result) <- (((pRegExpr regex_'5cw'2b >>= withAttribute "Function"))- <|>- ((lookAhead (pRegExpr regex_'5c'24'5cS) >> return ([],"") ) >>~ pushContext "find_variable")- <|>- ((pRegExpr regex_'5cs'2a'5c'28 >>= withAttribute "Normal Text") >>~ pushContext "sub_arg_definition")- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Normal Text"))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "sub_arg_definition" = - do (attr, result) <- (((pAnyChar "*$@%" >>= withAttribute "Data Type"))- <|>- ((pAnyChar "&\\[];" >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ pushContext "slash_safe_escape")- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "pod" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Pod"))- <|>- ((pDetectIdentifier >>= withAttribute "Pod"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a >>= withAttribute "Pod"))- <|>- ((pColumn 0 >> pRegExpr regex_'5c'3dcut'2e'2a'24 >>= withAttribute "Pod") >>~ (popContext)))- return (attr, result)--parseRules "comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+{- This module was generated from data in the Kate syntax+ highlighting file perl.xml, version 1.25, by Anders Lund (anders@alweb.dk) -}++module Text.Highlighting.Kate.Syntax.Perl+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Common+import qualified Text.Highlighting.Kate.Syntax.Alert+import Text.ParserCombinators.Parsec hiding (State)+import Data.Map (fromList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe)+import qualified Data.Set as Set++-- | Full name of language.+syntaxName :: String+syntaxName = "Perl"++-- | Filename extensions for this language.+syntaxExtensions :: String+syntaxExtensions = "*.pl;*.pm"++-- | Highlight source code using this syntax definition.+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState++parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine++-- | Parse an expression using appropriate local context.+parseExpression :: KateParser Token+parseExpression = do+ st <- getState+ let oldLang = synStLanguage st+ setState $ st { synStLanguage = "Perl" }+ context <- currentContext <|> (pushContext "normal" >> currentContext)+ result <- parseRules context+ optional $ eof >> pEndLine+ updateState $ \st -> st { synStLanguage = oldLang }+ return result++startingState = SyntaxState {synStContexts = fromList [("Perl",["normal"])], synStLanguage = "Perl", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}++pEndLine = do+ context <- currentContext+ case context of+ "normal" -> return ()+ "find_quoted" -> return ()+ "find_qqx" -> return ()+ "find_qw" -> return ()+ "ipstring_internal" -> return ()+ "ip_string" -> return ()+ "ip_string_2" -> return ()+ "ip_string_3" -> return ()+ "ip_string_4" -> return ()+ "ip_string_5" -> return ()+ "ip_string_6" -> return ()+ "string" -> return ()+ "string_2" -> return ()+ "string_3" -> return ()+ "string_4" -> return ()+ "string_5" -> return ()+ "string_6" -> return ()+ "find_subst" -> return ()+ "subst_curlybrace_pattern" -> return ()+ "subst_curlybrace_middle" -> return ()+ "subst_curlybrace_replace" -> return ()+ "subst_curlybrace_replace_recursive" -> return ()+ "subst_paren_pattern" -> return ()+ "subst_paren_replace" -> return ()+ "subst_bracket_pattern" -> return ()+ "subst_bracket_replace" -> return ()+ "subst_slash_pattern" -> return ()+ "subst_slash_replace" -> return ()+ "subst_sq_pattern" -> return ()+ "subst_sq_replace" -> return ()+ "tr" -> (popContext) >> pEndLine+ "find_pattern" -> return ()+ "pattern_slash" -> return ()+ "pattern" -> return ()+ "pattern_brace" -> return ()+ "pattern_bracket" -> return ()+ "pattern_paren" -> return ()+ "pattern_sq" -> return ()+ "regex_pattern_internal_rules_1" -> return ()+ "regex_pattern_internal_rules_2" -> return ()+ "regex_pattern_internal" -> return ()+ "regex_pattern_internal_ip" -> return ()+ "pat_ext" -> return ()+ "pat_char_class" -> return ()+ "find_variable" -> (popContext) >> pEndLine+ "find_variable_unsafe" -> (popContext) >> pEndLine+ "var_detect" -> (popContext >> popContext) >> pEndLine+ "var_detect_unsafe" -> (popContext >> popContext) >> pEndLine+ "var_detect_rules" -> (popContext >> popContext) >> pEndLine+ "quote_word" -> return ()+ "quote_word_paren" -> return ()+ "quote_word_brace" -> return ()+ "quote_word_bracket" -> return ()+ "find_here_document" -> (popContext) >> pEndLine+ "here_document" -> return ()+ "here_document_dumb" -> return ()+ "data_handle" -> return ()+ "end_handle" -> return ()+ "Backticked" -> return ()+ "slash_safe_escape" -> (popContext) >> pEndLine+ "package_qualified_blank" -> return ()+ "sub_name_def" -> (popContext) >> pEndLine+ "sub_arg_definition" -> return ()+ "pod" -> return ()+ "comment" -> (popContext) >> pEndLine+ _ -> return ()++withAttribute attr txt = do+ when (null txt) $ fail "Parser matched no text"+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt)++parseExpressionInternal = do+ context <- currentContext+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))++list_keywords = Set.fromList $ words $ "if unless else elsif while until for each foreach next last break continue return use no require my our local BEGIN END require package sub do __END__ __DATA__ __FILE__ __LINE__ __PACKAGE__"+list_operators = Set.fromList $ words $ "= != ~= += -= *= /= **= |= ||= //= &= &&= ?= + - * % || // && | & < << > >> ^ -> => . , ; :: \\ and or not eq ne lt gt le ge cmp"+list_functions = Set.fromList $ words $ "abs accept alarm atan2 bind binmode bless caller chdir chmod chomp chop chown chr chroot close closedir connect cos crypt dbmclose dbmopen defined delete die dump endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt glob gmtime goto grep hex import index int ioctl join keys kill last lc lcfirst length link listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd oct open opendir ord pack package pipe pop pos print printf prototype push quotemeta rand read readdir readline readlink recv redo ref rename reset return reverse rewinddir rindex rmdir scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat study sub substr symlink syscall sysread sysseek system syswrite tell telldir tie time times truncate uc ucfirst umask undef unlink unpack unshift untie utime values vec wait waitpid wantarray warn write"+list_pragmas = Set.fromList $ words $ "strict english warnings vars subs utf8 sigtrap locale open less integer filetest constant bytes diagnostics"++regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"+regex_'5cbsub'5cs'2b = compileRegex "\\bsub\\s+"+regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'28'5cs'7c'24'29 = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)(\\s|$)"+regex_'5c'5c'28'5b'22'27'5d'29'5b'5e'5c1'5d = compileRegex "\\\\([\"'])[^\\1]"+regex_'28'3f'3a'5b'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'7c'5c'2a'5b'5e'5cd'5c'2a'7b'5c'24'40'25'3d'28'5d'29 = compileRegex "(?:[$@]\\S|%[\\w{]|\\*[^\\d\\*{\\$@%=(])"+regex_'3c'5bA'2dZ0'2d9'5f'5d'2b'3e = compileRegex "<[A-Z0-9_]+>"+regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5cs'2a'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|\\s*[\"'])"+regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*\\}\\s*/{1,2}"+regex_'5cs'2a'5b'29'5c'5d'5d'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*[)\\]]\\s*/{1,2}"+regex_'5cw'2b'3a'3a = compileRegex "\\w+::"+regex_'5cw'2b'5b'3d'5d = compileRegex "\\w+[=]"+regex_'5cbq'28'3f'3d'5bqwx'5d'3f'5cs'2a'5b'5e'5cw'5cs'5d'29 = compileRegex "\\bq(?=[qwx]?\\s*[^\\w\\s])"+regex_'5cbs'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\bs(?=\\s*[^\\w\\s\\]})])"+regex_'5cb'28'3f'3atr'7cy'29'5cs'2a'28'3f'3d'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\b(?:tr|y)\\s*(?=[^\\w\\s\\]})])"+regex_'5cb'28'3f'3am'7cqr'29'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 = compileRegex "\\b(?:m|qr)(?=\\s*[^\\w\\s\\]})])"+regex_'5b'5cw'5f'5d'2b'5cs'2a'2f = compileRegex "[\\w_]+\\s*/"+regex_'5b'3c'3e'22'27'3a'5d'2f = compileRegex "[<>\"':]/"+regex_'2d'5brwxoRWXOeszfdlpSbctugkTBMAC'5d = compileRegex "-[rwxoRWXOeszfdlpSbctugkTBMAC]"+regex_x'5cs'2a'28'27'29 = compileRegex "x\\s*(')"+regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 = compileRegex "([^a-zA-Z0-9_\\s[\\]{}()])"+regex_'5cs'2b'23'2e'2a = compileRegex "\\s+#.*"+regex_'5c'5c'5bUuLlEtnaefr'5d = compileRegex "\\\\[UuLlEtnaefr]"+regex_'5c'5c'2e = compileRegex "\\\\."+regex_'28'3f'3a'5b'5c'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'29 = compileRegex "(?:[\\$@]\\S|%[\\w{])"+regex_'28'5b'5e'5cw'5cs'5b'5c'5d'7b'7d'28'29'5d'29 = compileRegex "([^\\w\\s[\\]{}()])"+regex_'5cs'2b'23'2e'2a'24 = compileRegex "\\s+#.*$"+regex_'23'2e'2a'24 = compileRegex "#.*$"+regex_'5c'7d'5bcegimosx'5d'2a = compileRegex "\\}[cegimosx]*"+regex_'5c'29'5bcegimosx'5d'2a = compileRegex "\\)[cegimosx]*"+regex_'5c'5d'5bcegimosx'5d'2a = compileRegex "\\][cegimosx]*"+regex_'27'5bcegimosx'5d'2a = compileRegex "'[cegimosx]*"+regex_'5c'28'5b'5e'29'5d'2a'5c'29'5cs'2a'5c'28'3f'3a'5b'5e'29'5d'2a'5c'29 = compileRegex "\\([^)]*\\)\\s*\\(?:[^)]*\\)"+regex_'7b'5b'5e'7d'5d'2a'5c'7d'5cs'2a'5c'7b'5b'5e'7d'5d'2a'5c'7d = compileRegex "{[^}]*\\}\\s*\\{[^}]*\\}"+regex_'5c'5b'5b'5e'7d'5d'2a'5c'5d'5cs'2a'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d = compileRegex "\\[[^}]*\\]\\s*\\[[^\\]]*\\]"+regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29'2e'2a'5c1'2e'2a'5c1 = compileRegex "([^a-zA-Z0-9_\\s[\\]{}()]).*\\1.*\\1"+regex_'28'5b'5e'5cw'5cs'5d'29 = compileRegex "([^\\w\\s])"+regex_'5c'24'28'3f'3d'2f'29 = compileRegex "\\$(?=/)"+regex_'2f'5bcgimosx'5d'2a = compileRegex "/[cgimosx]*"+regex_'5c'7d'5bcgimosx'5d'2a = compileRegex "\\}[cgimosx]*"+regex_'5c'5d'5bcgimosx'5d'2a = compileRegex "\\][cgimosx]*"+regex_'5c'29'5bcgimosx'5d'2a = compileRegex "\\)[cgimosx]*"+regex_'27'5bcgimosx'5d'2a = compileRegex "'[cgimosx]*"+regex_'5c'5c'5banDdSsWw'5d = compileRegex "\\\\[anDdSsWw]"+regex_'5c'5c'5bABbEGLlNUuQdQZz'5d = compileRegex "\\\\[ABbEGLlNUuQdQZz]"+regex_'5c'5c'5b'5cd'5d'2b = compileRegex "\\\\[\\d]+"+regex_'5b'28'29'3f'5c'5e'2a'2b'7c'5d = compileRegex "[()?\\^*+|]"+regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d = compileRegex "\\{[\\d, ]+\\}"+regex_'5cs'7b3'2c'7d'23'2e'2a'24 = compileRegex "\\s{3,}#.*$"+regex_'5b'24'40'5d'5b'5e'5c'5d'5cs'7b'7d'28'29'7c'3e'27'5d = compileRegex "[$@][^\\]\\s{}()|>']"+regex_'5c'23'5b'5e'29'5d'2a = compileRegex "\\#[^)]*"+regex_'5b'3a'3d'21'3e'3c'5d'2b = compileRegex "[:=!><]+"+regex_'5c'5b'3a'5c'5e'3f'5ba'2dz'5d'2b'3a'5c'5d = compileRegex "\\[:\\^?[a-z]+:\\]"+regex_'5c'24'5b0'2d9'5d'2b = compileRegex "\\$[0-9]+"+regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 = compileRegex "[@\\$](?:[\\+\\-_]\\B|ARGV\\b|INC\\b)"+regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 = compileRegex "[%\\$](?:INC\\b|ENV\\b|SIG\\b)"+regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d = compileRegex "\\$\\$[\\$\\w_]"+regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d = compileRegex "\\$[#_][\\w_]"+regex_'5c'24'2b'3a'3a = compileRegex "\\$+::"+regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f = compileRegex "\\$[^a-zA-Z0-9\\s{][A-Z]?"+regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d = compileRegex "[\\$@%]\\{[\\w_]+\\}"+regex_'5c'2a'5ba'2dzA'2dZ'5f'5d'2b = compileRegex "\\*[a-zA-Z_]+"+regex_'5c'2a'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f = compileRegex "\\*[^a-zA-Z0-9\\s{][A-Z]?"+regex_'5b'5c'24'40'25'5d = compileRegex "[\\$@%]"+regex_'5c'2a'5cw'2b = compileRegex "\\*\\w+"+regex_'5b'5cw'5f'5d'2b = compileRegex "[\\w_]+"+regex_'28'5cw'2b'29'5cs'2a'3b'3f = compileRegex "(\\w+)\\s*;?"+regex_'5cs'2a'22'28'5b'5e'22'5d'2b'29'22'5cs'2a'3b'3f = compileRegex "\\s*\"([^\"]+)\"\\s*;?"+regex_'5cs'2a'60'28'5b'5e'60'5d'2b'29'60'5cs'2a'3b'3f = compileRegex "\\s*`([^`]+)`\\s*;?"+regex_'5cs'2a'27'28'5b'5e'27'5d'2b'29'27'5cs'2a'3b'3f = compileRegex "\\s*'([^']+)'\\s*;?"+regex_'5c'3d'5cs'2a'3c'3c'5cs'2a'5b'22'27'5d'3f'28'5bA'2dZ0'2d9'5f'5c'2d'5d'2b'29'5b'22'27'5d'3f = compileRegex "\\=\\s*<<\\s*[\"']?([A-Z0-9_\\-]+)[\"']?"+regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2b'2e'2a = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)\\s+.*"+regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a = compileRegex "\\=(?:head[1-6]|over|back|item|for|begin|end|pod)\\s*.*"+regex_'5cs'2a'5b'29'5c'5d'5d'3f'5cs'2a'2f'7b1'2c2'7d = compileRegex "\\s*[)\\]]?\\s*/{1,2}"+regex_'5cw'2b = compileRegex "\\w+"+regex_'5c'24'5cS = compileRegex "\\$\\S"+regex_'5cs'2a'5c'28 = compileRegex "\\s*\\("+regex_'5c'3dcut'2e'2a'24 = compileRegex "\\=cut.*$"++defaultAttributes = [("normal",NormalTok),("find_quoted",NormalTok),("find_qqx",NormalTok),("find_qw",NormalTok),("ipstring_internal",StringTok),("ip_string",StringTok),("ip_string_2",StringTok),("ip_string_3",StringTok),("ip_string_4",StringTok),("ip_string_5",StringTok),("ip_string_6",StringTok),("string",StringTok),("string_2",StringTok),("string_3",StringTok),("string_4",StringTok),("string_5",StringTok),("string_6",StringTok),("find_subst",NormalTok),("subst_curlybrace_pattern",OtherTok),("subst_curlybrace_middle",NormalTok),("subst_curlybrace_replace",StringTok),("subst_curlybrace_replace_recursive",StringTok),("subst_paren_pattern",OtherTok),("subst_paren_replace",StringTok),("subst_bracket_pattern",OtherTok),("subst_bracket_replace",StringTok),("subst_slash_pattern",OtherTok),("subst_slash_replace",StringTok),("subst_sq_pattern",OtherTok),("subst_sq_replace",StringTok),("tr",OtherTok),("find_pattern",OtherTok),("pattern_slash",OtherTok),("pattern",OtherTok),("pattern_brace",OtherTok),("pattern_bracket",OtherTok),("pattern_paren",OtherTok),("pattern_sq",OtherTok),("regex_pattern_internal_rules_1",NormalTok),("regex_pattern_internal_rules_2",NormalTok),("regex_pattern_internal",OtherTok),("regex_pattern_internal_ip",OtherTok),("pat_ext",CharTok),("pat_char_class",BaseNTok),("find_variable",DataTypeTok),("find_variable_unsafe",DataTypeTok),("var_detect",DataTypeTok),("var_detect_unsafe",DataTypeTok),("var_detect_rules",DataTypeTok),("quote_word",NormalTok),("quote_word_paren",NormalTok),("quote_word_brace",NormalTok),("quote_word_bracket",NormalTok),("find_here_document",NormalTok),("here_document",StringTok),("here_document_dumb",NormalTok),("data_handle",NormalTok),("end_handle",CommentTok),("Backticked",StringTok),("slash_safe_escape",NormalTok),("package_qualified_blank",NormalTok),("sub_name_def",NormalTok),("sub_arg_definition",NormalTok),("pod",CommentTok),("comment",CommentTok)]++parseRules "normal" =+ (((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pString False "__DATA__" >>= withAttribute KeywordTok) >>~ pushContext "data_handle")+ <|>+ ((pFirstNonSpace >> pString False "__END__" >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbsub'5cs'2b >>= withAttribute KeywordTok) >>~ pushContext "sub_name_def")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_operators >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragmas >>= withAttribute KeywordTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'28'5cs'7c'24'29 >>= withAttribute CommentTok) >>~ pushContext "pod")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pHlCOct >>= withAttribute BaseNTok) >>~ pushContext "slash_safe_escape")+ <|>+ ((pHlCHex >>= withAttribute BaseNTok) >>~ pushContext "slash_safe_escape")+ <|>+ ((pFloat >>= withAttribute FloatTok) >>~ pushContext "slash_safe_escape")+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "slash_safe_escape")+ <|>+ ((pRegExpr regex_'5c'5c'28'5b'22'27'5d'29'5b'5e'5c1'5d >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '&' '\'' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute KeywordTok) >>~ pushContext "ip_string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '`' >>= withAttribute KeywordTok) >>~ pushContext "Backticked")+ <|>+ ((lookAhead (pRegExpr regex_'28'3f'3a'5b'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'7c'5c'2a'5b'5e'5cd'5c'2a'7b'5c'24'40'25'3d'28'5d'29) >> return (NormalTok,"") ) >>~ pushContext "find_variable")+ <|>+ ((pRegExpr regex_'3c'5bA'2dZ0'2d9'5f'5d'2b'3e >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5cs'2a'5b'22'27'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "find_here_document")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'2a'5b'29'5c'5d'5d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cw'2b'3a'3a >>= withAttribute FunctionTok) >>~ pushContext "sub_name_def")+ <|>+ ((pRegExpr regex_'5cw'2b'5b'3d'5d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cbq'28'3f'3d'5bqwx'5d'3f'5cs'2a'5b'5e'5cw'5cs'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "find_quoted")+ <|>+ ((pRegExpr regex_'5cbs'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "find_subst")+ <|>+ ((pRegExpr regex_'5cb'28'3f'3atr'7cy'29'5cs'2a'28'3f'3d'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "tr")+ <|>+ ((pRegExpr regex_'5cb'28'3f'3am'7cqr'29'28'3f'3d'5cs'2a'5b'5e'5cw'5cs'5c'5d'7d'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "find_pattern")+ <|>+ ((pRegExpr regex_'5b'5cw'5f'5d'2b'5cs'2a'2f >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b'3c'3e'22'27'3a'5d'2f >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '/' >>= withAttribute KeywordTok) >>~ pushContext "pattern_slash")+ <|>+ ((pRegExpr regex_'2d'5brwxoRWXOeszfdlpSbctugkTBMAC'5d >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok)))++parseRules "find_quoted" =+ (((pRegExpr regex_x'5cs'2a'28'27'29 >>= withAttribute KeywordTok) >>~ pushContext "string_6")+ <|>+ ((pAnyChar "qx" >>= withAttribute KeywordTok) >>~ pushContext "find_qqx")+ <|>+ ((pDetectChar False 'w' >>= withAttribute KeywordTok) >>~ pushContext "find_qw")+ <|>+ ((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "string_2")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "string_3")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "string_4")+ <|>+ ((pDetectChar False '<' >>= withAttribute KeywordTok) >>~ pushContext "string_5")+ <|>+ ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "string_6")+ <|>+ ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute CommentTok)))++parseRules "find_qqx" =+ (((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "ip_string_2")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "ip_string_3")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "ip_string_4")+ <|>+ ((pDetectChar False '<' >>= withAttribute KeywordTok) >>~ pushContext "ip_string_5")+ <|>+ ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "ip_string_6")+ <|>+ ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute CommentTok)))++parseRules "find_qw" =+ (((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "quote_word_paren")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "quote_word_brace")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "quote_word_bracket")+ <|>+ ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "quote_word")+ <|>+ ((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute CommentTok)))++parseRules "ipstring_internal" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bUuLlEtnaefr'5d >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((lookAhead (pRegExpr regex_'28'3f'3a'5b'5c'24'40'5d'5cS'7c'25'5b'5cw'7b'5d'29) >> return (NormalTok,"") ) >>~ pushContext "find_variable_unsafe"))++parseRules "ip_string" =+ (((pDetectChar False '"' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "ip_string_2" =+ (((pRangeDetect '(' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "ip_string_3" =+ (((pRangeDetect '{' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "ip_string_4" =+ (((pRangeDetect '[' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "ip_string_5" =+ (((pRangeDetect '<' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "ip_string_6" =+ (((pRegExprDynamic "\\%1" >>= withAttribute StringTok))+ <|>+ ((pDetectChar True '1' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "string" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '\'' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok) >>~ (popContext)))++parseRules "string_2" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pRangeDetect '(' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "string_3" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pRangeDetect '{' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "string_4" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pRangeDetect '[' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "string_5" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '<' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "string_6" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "\\%1" >>= withAttribute CharTok))+ <|>+ ((pDetectChar True '1' >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "find_subst" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "subst_curlybrace_pattern")+ <|>+ ((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "subst_paren_pattern")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "subst_bracket_pattern")+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok) >>~ pushContext "subst_sq_pattern")+ <|>+ ((pRegExpr regex_'28'5b'5e'5cw'5cs'5b'5c'5d'7b'7d'28'29'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "subst_slash_pattern"))++parseRules "subst_curlybrace_pattern" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((parseRules "regex_pattern_internal_ip"))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ pushContext "subst_curlybrace_middle"))++parseRules "subst_curlybrace_middle" =+ (((pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "subst_curlybrace_replace"))++parseRules "subst_curlybrace_replace" =+ (((parseRules "ipstring_internal"))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "subst_curlybrace_replace_recursive")+ <|>+ ((pRegExpr regex_'5c'7d'5bcegimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext >> popContext)))++parseRules "subst_curlybrace_replace_recursive" =+ (((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "subst_curlybrace_replace_recursive")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "subst_paren_pattern" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((parseRules "regex_pattern_internal_ip"))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ pushContext "subst_paren_replace"))++parseRules "subst_paren_replace" =+ (((parseRules "ipstring_internal"))+ <|>+ ((pDetectChar False '(' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'29'5bcegimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "subst_bracket_pattern" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((parseRules "regex_pattern_internal_ip"))+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok) >>~ pushContext "subst_bracket_replace"))++parseRules "subst_bracket_replace" =+ (((parseRules "ipstring_internal"))+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'5d'5bcegimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "subst_slash_pattern" =+ (((pRegExprDynamic "\\$(?=%1)" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "(%1)" >>= withAttribute KeywordTok) >>~ pushContext "subst_slash_replace")+ <|>+ ((parseRules "regex_pattern_internal_ip")))++parseRules "subst_slash_replace" =+ (((pRegExprDynamic "%1[cegimosx]*" >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "ipstring_internal")))++parseRules "subst_sq_pattern" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((parseRules "regex_pattern_internal"))+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok) >>~ pushContext "subst_sq_replace"))++parseRules "subst_sq_replace" =+ ((pRegExpr regex_'27'5bcegimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))++parseRules "tr" =+ (((pRegExpr regex_'5c'28'5b'5e'29'5d'2a'5c'29'5cs'2a'5c'28'3f'3a'5b'5e'29'5d'2a'5c'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'7b'5b'5e'7d'5d'2a'5c'7d'5cs'2a'5c'7b'5b'5e'7d'5d'2a'5c'7d >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'5b'5b'5e'7d'5d'2a'5c'5d'5cs'2a'5c'5b'5b'5e'5c'5d'5d'2a'5c'5d >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'28'5b'5ea'2dzA'2dZ0'2d9'5f'5cs'5b'5c'5d'7b'7d'28'29'5d'29'2e'2a'5c1'2e'2a'5c1 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "find_pattern" =+ (((pRegExpr regex_'5cs'2b'23'2e'2a >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "pattern_brace")+ <|>+ ((pDetectChar False '(' >>= withAttribute KeywordTok) >>~ pushContext "pattern_paren")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "pattern_bracket")+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok) >>~ pushContext "pattern_sq")+ <|>+ ((pRegExpr regex_'28'5b'5e'5cw'5cs'5d'29 >>= withAttribute KeywordTok) >>~ pushContext "pattern"))++parseRules "pattern_slash" =+ (((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute CharTok))+ <|>+ ((parseRules "regex_pattern_internal_ip"))+ <|>+ ((pRegExpr regex_'2f'5bcgimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext)))++parseRules "pattern" =+ (((pRegExprDynamic "\\$(?=%1)" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "%1[cgimosx]*" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "regex_pattern_internal_ip"))+ <|>+ ((pRegExprDynamic "\\$(?=\\%1)" >>= withAttribute CharTok)))++parseRules "pattern_brace" =+ (((pRegExpr regex_'5c'7d'5bcgimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "regex_pattern_internal_ip")))++parseRules "pattern_bracket" =+ (((pRegExpr regex_'5c'5d'5bcgimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "regex_pattern_internal_ip")))++parseRules "pattern_paren" =+ (((pRegExpr regex_'5c'29'5bcgimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "regex_pattern_internal_ip")))++parseRules "pattern_sq" =+ (((pRegExpr regex_'27'5bcgimosx'5d'2a >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "regex_pattern_internal")))++parseRules "regex_pattern_internal_rules_1" =+ (((pFirstNonSpace >> pRegExpr regex_'23'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pRegExpr regex_'5c'5c'5banDdSsWw'5d >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bABbEGLlNUuQdQZz'5d >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'5c'5b'5cd'5d'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute OtherTok)))++parseRules "regex_pattern_internal_rules_2" =+ (((pDetect2Chars False '(' '?' >>= withAttribute CharTok) >>~ pushContext "pat_ext")+ <|>+ ((pDetectChar False '[' >>= withAttribute CharTok) >>~ pushContext "pat_char_class")+ <|>+ ((pRegExpr regex_'5b'28'29'3f'5c'5e'2a'2b'7c'5d >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5cs'7b3'2c'7d'23'2e'2a'24 >>= withAttribute CommentTok)))++parseRules "regex_pattern_internal" =+ (((parseRules "regex_pattern_internal_rules_1"))+ <|>+ ((parseRules "regex_pattern_internal_rules_2")))++parseRules "regex_pattern_internal_ip" =+ (((parseRules "regex_pattern_internal_rules_1"))+ <|>+ ((lookAhead (pRegExpr regex_'5b'24'40'5d'5b'5e'5c'5d'5cs'7b'7d'28'29'7c'3e'27'5d) >> return (NormalTok,"") ) >>~ pushContext "find_variable_unsafe")+ <|>+ ((parseRules "regex_pattern_internal_rules_2")))++parseRules "pat_ext" =+ (((pRegExpr regex_'5c'23'5b'5e'29'5d'2a >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'3a'3d'21'3e'3c'5d'2b >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((pDetectChar False ')' >>= withAttribute CharTok) >>~ (popContext)))++parseRules "pat_char_class" =+ (((pDetectChar False '^' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute BaseNTok))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5c'5b'3a'5c'5e'3f'5ba'2dz'5d'2b'3a'5c'5d >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute CharTok) >>~ (popContext)))++parseRules "find_variable" =+ (((pRegExpr regex_'5c'24'5b0'2d9'5d'2b >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'24'2b'3a'3a >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pAnyChar "$@%" >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'2a'5ba'2dzA'2dZ'5f'5d'2b >>= withAttribute DataTypeTok) >>~ pushContext "var_detect")+ <|>+ ((pRegExpr regex_'5c'2a'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute DataTypeTok))+ <|>+ ((pAnyChar "$@%*" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "find_variable_unsafe" =+ (((pRegExpr regex_'5c'24'5b0'2d9'5d'2b >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5b'40'5c'24'5d'28'3f'3a'5b'5c'2b'5c'2d'5f'5d'5cB'7cARGV'5cb'7cINC'5cb'29 >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5b'25'5c'24'5d'28'3f'3aINC'5cb'7cENV'5cb'7cSIG'5cb'29 >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5c'24'5c'24'5b'5c'24'5cw'5f'5d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5c'24'5b'23'5f'5d'5b'5cw'5f'5d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5c'24'2b'3a'3a >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5c'24'5b'5ea'2dzA'2dZ0'2d9'5cs'7b'5d'5bA'2dZ'5d'3f >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'5c'24'40'25'5d'5c'7b'5b'5cw'5f'5d'2b'5c'7d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5b'5c'24'40'25'5d >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pRegExpr regex_'5c'2a'5cw'2b >>= withAttribute DataTypeTok) >>~ pushContext "var_detect_unsafe")+ <|>+ ((pAnyChar "$@%*" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "var_detect" =+ (((parseRules "var_detect_rules"))+ <|>+ ((parseRules "slash_safe_escape"))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "var_detect_unsafe" =+ (((parseRules "var_detect_rules"))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "var_detect_rules" =+ (((pRegExpr regex_'5b'5cw'5f'5d'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '-' '>' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '+' '+' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute NormalTok)))++parseRules "quote_word" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute NormalTok))+ <|>+ ((pDetectChar True '1' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "quote_word_paren" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "quote_word_brace" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "quote_word_bracket" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext)))++parseRules "find_here_document" =+ (((pRegExpr regex_'28'5cw'2b'29'5cs'2a'3b'3f >>= withAttribute KeywordTok) >>~ pushContext "here_document")+ <|>+ ((pRegExpr regex_'5cs'2a'22'28'5b'5e'22'5d'2b'29'22'5cs'2a'3b'3f >>= withAttribute KeywordTok) >>~ pushContext "here_document")+ <|>+ ((pRegExpr regex_'5cs'2a'60'28'5b'5e'60'5d'2b'29'60'5cs'2a'3b'3f >>= withAttribute KeywordTok) >>~ pushContext "here_document")+ <|>+ ((pRegExpr regex_'5cs'2a'27'28'5b'5e'27'5d'2b'29'27'5cs'2a'3b'3f >>= withAttribute KeywordTok) >>~ pushContext "here_document_dumb"))++parseRules "here_document" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pColumn 0 >> pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5c'3d'5cs'2a'3c'3c'5cs'2a'5b'22'27'5d'3f'28'5bA'2dZ0'2d9'5f'5c'2d'5d'2b'29'5b'22'27'5d'3f >>= withAttribute KeywordTok) >>~ pushContext "here_document")+ <|>+ ((parseRules "ipstring_internal")))++parseRules "here_document_dumb" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExprDynamic "%1" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok)))++parseRules "data_handle" =+ (((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2b'2e'2a >>= withAttribute CommentTok) >>~ pushContext "pod")+ <|>+ ((pFirstNonSpace >> pString False "__END__" >>= withAttribute KeywordTok) >>~ pushContext "normal"))++parseRules "end_handle" =+ (((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a >>= withAttribute CommentTok) >>~ pushContext "pod")+ <|>+ ((pFirstNonSpace >> pString False "__DATA__" >>= withAttribute KeywordTok) >>~ pushContext "data_handle"))++parseRules "Backticked" =+ (((parseRules "ipstring_internal"))+ <|>+ ((pDetectChar False '`' >>= withAttribute KeywordTok) >>~ (popContext)))++parseRules "slash_safe_escape" =+ (((pRegExpr regex_'5cs'2a'5c'7d'5cs'2a'2f'7b1'2c2'7d >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'5b'29'5c'5d'5d'3f'5cs'2a'2f'7b1'2c2'7d >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "package_qualified_blank" =+ ((pRegExpr regex_'5b'5cw'5f'5d'2b >>= withAttribute NormalTok) >>~ (popContext))++parseRules "sub_name_def" =+ (((pRegExpr regex_'5cw'2b >>= withAttribute FunctionTok))+ <|>+ ((lookAhead (pRegExpr regex_'5c'24'5cS) >> return (NormalTok,"") ) >>~ pushContext "find_variable")+ <|>+ ((pRegExpr regex_'5cs'2a'5c'28 >>= withAttribute NormalTok) >>~ pushContext "sub_arg_definition")+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute NormalTok))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "sub_arg_definition" =+ (((pAnyChar "*$@%" >>= withAttribute DataTypeTok))+ <|>+ ((pAnyChar "&\\[];" >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ pushContext "slash_safe_escape")+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "pod" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'3d'28'3f'3ahead'5b1'2d6'5d'7cover'7cback'7citem'7cfor'7cbegin'7cend'7cpod'29'5cs'2a'2e'2a >>= withAttribute CommentTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'3dcut'2e'2a'24 >>= withAttribute CommentTok) >>~ (popContext)))++parseRules "comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Php.hs view
@@ -1,8 +1,10 @@-{- This module was generated from data in the Kate syntax highlighting file php.xml, version 1.42,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file php.xml, version 1.42, by -} -module Text.Highlighting.Kate.Syntax.Php ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Php+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Doxygen import qualified Text.Highlighting.Kate.Syntax.Alert@@ -10,12 +12,13 @@ import qualified Text.Highlighting.Kate.Syntax.Css import qualified Text.Highlighting.Kate.Syntax.SqlMysql import qualified Text.Highlighting.Kate.Syntax.Javascript-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "PHP/PHP"@@ -25,69 +28,56 @@ syntaxExtensions = "" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "PHP/PHP" } context <- currentContext <|> (pushContext "start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("PHP/PHP",["start"])], synStLanguage = "PHP/PHP", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("PHP/PHP",["start"])], synStLanguage = "PHP/PHP", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "start" -> return () >> pHandleEndLine- "phpsource" -> return () >> pHandleEndLine- "ternary" -> return () >> pHandleEndLine- "case" -> return () >> pHandleEndLine+ "start" -> return ()+ "phpsource" -> return ()+ "ternary" -> return ()+ "case" -> return () "onelinecomment" -> (popContext) >> pEndLine- "twolinecomment" -> return () >> pHandleEndLine- "doublebackquotestringcommon" -> return () >> pHandleEndLine- "backquotestring" -> return () >> pHandleEndLine- "doublequotestring" -> return () >> pHandleEndLine- "singlequotestring" -> return () >> pHandleEndLine- "htmlheredoc" -> return () >> pHandleEndLine- "cssheredoc" -> return () >> pHandleEndLine- "mysqlheredoc" -> return () >> pHandleEndLine- "javascriptheredoc" -> return () >> pHandleEndLine- "heredoc" -> return () >> pHandleEndLine- "commonheredoc" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "twolinecomment" -> return ()+ "doublebackquotestringcommon" -> return ()+ "backquotestring" -> return ()+ "doublequotestring" -> return ()+ "singlequotestring" -> return ()+ "htmlheredoc" -> return ()+ "cssheredoc" -> return ()+ "mysqlheredoc" -> return ()+ "javascriptheredoc" -> return ()+ "heredoc" -> return ()+ "commonheredoc" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Classes","kw"),("Function","fu"),("Special method","fu"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("String","st"),("Comment","co"),("Special Variable","kw"),("Variable","kw"),("Library Constant","kw"),("Constant","kw"),("Control Structures","kw"),("Backslash Code","kw"),("Other","ot"),("HTML Tag","kw"),("HTML Comment","co"),("Identifier","ot"),("Types","dt"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_control_structures = Set.fromList $ words $ "as case default if else elseif while do for foreach break continue switch declare return require include require_once include_once endif endwhile endfor endforeach endswitch" list_keywords = Set.fromList $ words $ "abstract catch class clone const exception extends final function global implements instanceof interface new self static parent private protected public throw try and or xor var namespace use"@@ -117,215 +107,199 @@ regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5b'5e'22'5d'2a'22'7c'5c'24'5ba'2dzA'2dZ'5d'2a'29'7c'27'5b'5e'27'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d = compileRegex "\\{\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\[([0-9]*|\"[^\"]*\"|\\$[a-zA-Z]*)|'[^']*'|\\])*(->[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\[[a-zA-Z0-9_]*\\])*(\\[([0-9]*|\"[a-zA-Z_]*\")|'[a-zA-Z_]*'|\\])*)*\\}" regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d = compileRegex "\\{\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\[([0-9]*|\"[a-zA-Z_]*\")|'[a-zA-Z_]*'|\\])*(->[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\[[a-zA-Z0-9_]*\\])*(\\[([0-9]*|\"[a-zA-Z_]*\")|'[a-zA-Z_]*'|\\])*)*\\}" -defaultAttributes = [("start","Normal Text"),("phpsource","PHP Text"),("ternary","PHP Text"),("case","PHP Text"),("onelinecomment","Comment"),("twolinecomment","Comment"),("doublebackquotestringcommon","String"),("backquotestring","String"),("doublequotestring","String"),("singlequotestring","String"),("htmlheredoc","Normal Text"),("cssheredoc","Normal Text"),("mysqlheredoc","Normal Text"),("javascriptheredoc","Normal Text"),("heredoc","String"),("commonheredoc","String")]+defaultAttributes = [("start",NormalTok),("phpsource",NormalTok),("ternary",NormalTok),("case",NormalTok),("onelinecomment",CommentTok),("twolinecomment",CommentTok),("doublebackquotestringcommon",StringTok),("backquotestring",StringTok),("doublequotestring",StringTok),("singlequotestring",StringTok),("htmlheredoc",NormalTok),("cssheredoc",NormalTok),("mysqlheredoc",NormalTok),("javascriptheredoc",NormalTok),("heredoc",StringTok),("commonheredoc",StringTok)] -parseRules "start" = - do (attr, result) <- (((pRegExpr regex_'3c'5c'3f'28'3f'3a'3d'7cphp'29'3f >>= withAttribute "Keyword") >>~ pushContext "phpsource")- <|>- ((pString False "?>" >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)+parseRules "start" =+ (((pRegExpr regex_'3c'5c'3f'28'3f'3a'3d'7cphp'29'3f >>= withAttribute KeywordTok) >>~ pushContext "phpsource")+ <|>+ ((pString False "?>" >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "phpsource" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "PHP Text"))- <|>- ((lookAhead (pString False "?>") >> return ([],"") ) >>~ (popContext))- <|>- ((pDetectChar False '?' >>= withAttribute "Other") >>~ pushContext "ternary")- <|>- ((pRegExpr regex_'28case'7cdefault'29'28'5cs'7c'3a'7c'24'29 >>= withAttribute "Keyword") >>~ pushContext "case")- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ':' >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_endif'7cendwhile'7cendfor'7cendforeach'7cendswitch >>= withAttribute "Control Structures"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "onelinecomment")- <|>- ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "onelinecomment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "twolinecomment")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_deprecated >>= withAttribute "Error"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_control_structures >>= withAttribute "Control Structures"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_predefined'2dclasses >>= withAttribute "Classes"))- <|>- ((pDetectChar False '@' >>= withAttribute "Error"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_special'5fmethods >>= withAttribute "Special method"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_constants >>= withAttribute "Library Constant"))- <|>- ((pRegExpr regex_'5cb'5bA'2dZ'5f'5d'5bA'2dZ'5f0'2d9'5d'2a'5cb >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5c'28'5cs'2a'28int'7cinteger'7cbool'7cboolean'7cfloat'7cdouble'7creal'7cstring'7carray'7cobject'29'5cs'2a'5c'29 >>= withAttribute "Types"))- <|>- ((pDetectIdentifier >>= withAttribute "PHP Text"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "doublequotestring")- <|>- ((pDetectChar False '`' >>= withAttribute "String") >>~ pushContext "backquotestring")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "singlequotestring")- <|>- ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fHTML'29'5cb >>= withAttribute "Backslash Code") >>~ pushContext "htmlheredoc")- <|>- ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fCSS'29'5cb >>= withAttribute "Backslash Code") >>~ pushContext "cssheredoc")- <|>- ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fJAVASCRIPT'29'5cb >>= withAttribute "Backslash Code") >>~ pushContext "javascriptheredoc")- <|>- ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fMYSQL'29'5cb >>= withAttribute "Backslash Code") >>~ pushContext "mysqlheredoc")- <|>- ((pRegExpr regex_'3c'3c'3c'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29 >>= withAttribute "Backslash Code") >>~ pushContext "heredoc")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_special'2dvariables >>= withAttribute "Special Variable"))- <|>- ((pRegExpr regex_'5c'24'2b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5b0123456789'5d'2a'5c'2e'5c'2e'5c'2e'5b0123456789'5d'2a >>= withAttribute "String"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text"))- <|>- ((pAnyChar ";(),[]" >>= withAttribute "Other")))- return (attr, result)+parseRules "phpsource" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pString False "?>") >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pDetectChar False '?' >>= withAttribute OtherTok) >>~ pushContext "ternary")+ <|>+ ((pRegExpr regex_'28case'7cdefault'29'28'5cs'7c'3a'7c'24'29 >>= withAttribute KeywordTok) >>~ pushContext "case")+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ':' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_endif'7cendwhile'7cendfor'7cendforeach'7cendswitch >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "onelinecomment")+ <|>+ ((Text.Highlighting.Kate.Syntax.Doxygen.parseExpression))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "onelinecomment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "twolinecomment")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_deprecated >>= withAttribute ErrorTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_control_structures >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_predefined'2dclasses >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '@' >>= withAttribute ErrorTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_special'5fmethods >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_constants >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZ'5f'5d'5bA'2dZ'5f0'2d9'5d'2a'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'28'5cs'2a'28int'7cinteger'7cbool'7cboolean'7cfloat'7cdouble'7creal'7cstring'7carray'7cobject'29'5cs'2a'5c'29 >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "doublequotestring")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "backquotestring")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "singlequotestring")+ <|>+ ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fHTML'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "htmlheredoc")+ <|>+ ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fCSS'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "cssheredoc")+ <|>+ ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fJAVASCRIPT'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "javascriptheredoc")+ <|>+ ((pRegExpr regex_'3c'3c'3c'28'28EO'29'3fMYSQL'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "mysqlheredoc")+ <|>+ ((pRegExpr regex_'3c'3c'3c'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29 >>= withAttribute KeywordTok) >>~ pushContext "heredoc")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\@" list_special'2dvariables >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'24'2b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5b0123456789'5d'2a'5c'2e'5c'2e'5c'2e'5b0123456789'5d'2a >>= withAttribute StringTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ";(),[]" >>= withAttribute OtherTok))) -parseRules "ternary" = - do (attr, result) <- (((pDetect2Chars False ':' ':' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False ':' >>= withAttribute "Other") >>~ (popContext))- <|>- ((parseRules "phpsource")))- return (attr, result)+parseRules "ternary" =+ (((pDetect2Chars False ':' ':' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ':' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "phpsource"))) -parseRules "case" = - do (attr, result) <- ((parseRules "ternary"))- return (attr, result)+parseRules "case" =+ ((parseRules "ternary")) -parseRules "onelinecomment" = - do (attr, result) <- (((lookAhead (pString False "?>") >> return ([],"") ) >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "onelinecomment" =+ (((lookAhead (pString False "?>") >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "twolinecomment" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "twolinecomment" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "doublebackquotestringcommon" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' 'n' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' 'r' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' 't' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' 'v' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' 'f' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' '$' >>= withAttribute "Backslash Code"))- <|>- ((pRegExpr regex_'5c'5c'5b0'2d7'5d'7b1'2c3'7d >>= withAttribute "Backslash Code"))- <|>- ((pRegExpr regex_'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b1'2c2'7d >>= withAttribute "Backslash Code"))- <|>- ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5b'5e'22'5d'2a'22'7c'5c'24'5ba'2dzA'2dZ'5d'2a'29'7c'27'5b'5e'27'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d >>= withAttribute "Variable")))- return (attr, result)+parseRules "doublebackquotestringcommon" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' 'n' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' 'r' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' 't' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' 'v' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' 'f' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' '$' >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'5c'5b0'2d7'5d'7b1'2c3'7d >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'5cx'5b0'2d9A'2dFa'2df'5d'7b1'2c2'7d >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'5c'7d >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5b'5e'22'5d'2a'22'7c'5c'24'5ba'2dzA'2dZ'5d'2a'29'7c'27'5b'5e'27'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d >>= withAttribute KeywordTok))) -parseRules "backquotestring" = - do (attr, result) <- (((parseRules "doublebackquotestringcommon"))- <|>- ((pDetect2Chars False '\\' '`' >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '`' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "backquotestring" =+ (((parseRules "doublebackquotestringcommon"))+ <|>+ ((pDetect2Chars False '\\' '`' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "doublequotestring" = - do (attr, result) <- (((parseRules "doublebackquotestringcommon"))- <|>- ((pDetect2Chars False '\\' '"' >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "doublequotestring" =+ (((parseRules "doublebackquotestringcommon"))+ <|>+ ((pDetect2Chars False '\\' '"' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "singlequotestring" = - do (attr, result) <- (((pDetect2Chars False '\\' '\'' >>= withAttribute "Backslash Code"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "singlequotestring" =+ (((pDetect2Chars False '\\' '\'' >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "htmlheredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute "Backslash Code") >>~ (popContext))- <|>- ((parseRules "commonheredoc"))- <|>- ((Text.Highlighting.Kate.Syntax.Html.parseExpression)))- return (attr, result)+parseRules "htmlheredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "commonheredoc"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Html.parseExpression))) -parseRules "cssheredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute "Backslash Code") >>~ (popContext))- <|>- ((parseRules "commonheredoc"))- <|>- ((Text.Highlighting.Kate.Syntax.Css.parseExpression)))- return (attr, result)+parseRules "cssheredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "commonheredoc"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Css.parseExpression))) -parseRules "mysqlheredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute "Backslash Code") >>~ (popContext))- <|>- ((parseRules "commonheredoc"))- <|>- ((Text.Highlighting.Kate.Syntax.SqlMysql.parseExpression)))- return (attr, result)+parseRules "mysqlheredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "commonheredoc"))+ <|>+ ((Text.Highlighting.Kate.Syntax.SqlMysql.parseExpression))) -parseRules "javascriptheredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute "Backslash Code") >>~ (popContext))- <|>- ((parseRules "commonheredoc"))- <|>- ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))- return (attr, result)+parseRules "javascriptheredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "commonheredoc"))+ <|>+ ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression))) -parseRules "heredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute "Backslash Code") >>~ (popContext))- <|>- ((parseRules "commonheredoc")))- return (attr, result)+parseRules "heredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1;?$" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "commonheredoc"))) -parseRules "commonheredoc" = - do (attr, result) <- (((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d >>= withAttribute "Variable")))- return (attr, result)+parseRules "commonheredoc" =+ (((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'5c'7d >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'7b'5c'24'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'28'2d'3e'5ba'2dzA'2dZ'5f'5cx7f'2d'5cxff'5d'5ba'2dzA'2dZ0'2d9'5f'5cx7f'2d'5cxff'5d'2a'28'5c'5b'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5c'5d'29'2a'28'5c'5b'28'5b0'2d9'5d'2a'7c'22'5ba'2dzA'2dZ'5f'5d'2a'22'29'7c'27'5ba'2dzA'2dZ'5f'5d'2a'27'7c'5c'5d'29'2a'29'2a'5c'7d >>= withAttribute KeywordTok))) parseRules "" = parseRules "start"
Text/Highlighting/Kate/Syntax/Pike.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file pike.xml, version 1.07,- by Paul Pogonyshev -}+{- This module was generated from data in the Kate syntax+ highlighting file pike.xml, version 1.07, by Paul Pogonyshev -} -module Text.Highlighting.Kate.Syntax.Pike ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Pike+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Pike"@@ -19,60 +22,47 @@ syntaxExtensions = "*.pike" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Pike" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Pike",["Normal"])], synStLanguage = "Pike", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Pike",["Normal"])], synStLanguage = "Pike", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Line Comment" -> (popContext) >> pEndLine- "Block Comment" -> return () >> pHandleEndLine+ "Block Comment" -> return () "Preprocessor" -> (popContext) >> pEndLine- "Outscoped" -> return () >> pHandleEndLine- "Outscoped intern" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Outscoped" -> return ()+ "Outscoped intern" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Builtin Function","fu"),("Data Type","dt"),("Decimal","dv"),("Hex","bn"),("Octal","bn"),("Binary","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Note","al"),("Preprocessor","ot"),("Preprocessor Lib","st")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "break case class continue default do else for foreach if return switch while" list_types = Set.fromList $ words $ "array float function int mapping mixed multiset> object program static string void"@@ -87,95 +77,88 @@ regex_'23'5cs'2a'28endif'7celif'7celse'29 = compileRegex "#\\s*(endif|elif|else)" regex_'23'5cs'2aendif = compileRegex "#\\s*endif" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Line Comment","Comment"),("Block Comment","Comment"),("Preprocessor","Preprocessor"),("Outscoped","Comment"),("Outscoped intern","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Line Comment",CommentTok),("Block Comment",CommentTok),("Preprocessor",OtherTok),("Outscoped",CommentTok),("Outscoped intern",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute "Builtin Function"))- <|>- ((pRegExpr regex_'60'28'5b'5c'2b'5c'2d'5c'2a'2f'25'7e'26'5c'7c'5e'5d'7c'5b'21'3d'3c'3e'5d'3d'7c'3c'3c'3f'7c'3e'3e'3f'7c'28'5c'5b'5c'5d'7c'2d'3e'29'3d'3f'29 >>= withAttribute "Builtin Function"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pRegExpr regex_0'5bbB'5d'5b01'5d'2b >>= withAttribute "Binary"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Line Comment")- <|>- ((pDetect2Chars False '#' '!' >>= withAttribute "Comment") >>~ pushContext "Line Comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Block Comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0 >>= withAttribute "Preprocessor") >>~ pushContext "Outscoped")- <|>- ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor"))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_builtins >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'60'28'5b'5c'2b'5c'2d'5c'2a'2f'25'7e'26'5c'7c'5e'5d'7c'5b'21'3d'3c'3e'5d'3d'7c'3c'3c'3f'7c'3e'3e'3f'7c'28'5c'5b'5c'5d'7c'2d'3e'29'3d'3f'29 >>= withAttribute FunctionTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_0'5bbB'5d'5b01'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Line Comment")+ <|>+ ((pDetect2Chars False '#' '!' >>= withAttribute CommentTok) >>~ pushContext "Line Comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Block Comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif'5cs'2b0 >>= withAttribute OtherTok) >>~ pushContext "Outscoped")+ <|>+ ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'5c'5cd'5b0'2d9'5d'2b >>= withAttribute "String Char"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pLineContinue >>= withAttribute "String")))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'5c'5cd'5b0'2d9'5d'2b >>= withAttribute CharTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pLineContinue >>= withAttribute StringTok))) -parseRules "Line Comment" = - do (attr, result) <- ((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute "Note"))- return (attr, result)+parseRules "Line Comment" =+ ((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute AlertTok)) -parseRules "Block Comment" = - do (attr, result) <- (((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute "Note")))- return (attr, result)+parseRules "Block Comment" =+ (((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute AlertTok))) -parseRules "Preprocessor" = - do (attr, result) <- (((pRangeDetect '"' '"' >>= withAttribute "Preprocessor Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Preprocessor Lib"))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Line Comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Block Comment")- <|>- ((pLineContinue >>= withAttribute "Preprocessor")))- return (attr, result)+parseRules "Preprocessor" =+ (((pRangeDetect '"' '"' >>= withAttribute StringTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute StringTok))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Line Comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Block Comment")+ <|>+ ((pLineContinue >>= withAttribute OtherTok))) -parseRules "Outscoped" = - do (attr, result) <- (((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute "Note"))- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Block Comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28endif'7celif'7celse'29 >>= withAttribute "Preprocessor") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped" =+ (((pRegExpr regex_'28FIXME'7cTODO'7cNOT'28IC'29'3fE'29'3a'3f >>= withAttribute AlertTok))+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Block Comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2a'28endif'7celif'7celse'29 >>= withAttribute OtherTok) >>~ (popContext))) -parseRules "Outscoped intern" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Block Comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute "Comment") >>~ pushContext "Outscoped intern")- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Outscoped intern" =+ (((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Block Comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aif >>= withAttribute CommentTok) >>~ pushContext "Outscoped intern")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aendif >>= withAttribute CommentTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Postscript.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file postscript.xml, version 1.01,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file postscript.xml, version 1.01, by -} -module Text.Highlighting.Kate.Syntax.Postscript ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Postscript+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "PostScript"@@ -19,89 +22,74 @@ syntaxExtensions = "*.ps;*.ai;*.eps" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "PostScript" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("PostScript",["Normal"])], synStLanguage = "PostScript", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("PostScript",["Normal"])], synStLanguage = "PostScript", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "Comment" -> (popContext) >> pEndLine "Header" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Comment","co"),("Header","ot"),("Float","fl"),("Decimal","dv"),("String","st"),("Data Type","dt")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "abs add aload anchorsearch and arc arcn arct arcto array ashow astore awidthshow begin bind bitshift ceiling charpath clear cleartomark clip clippath closepath concat concatmatrix copy count counttomark currentcmykcolor currentdash currentdict currentfile currentfont currentgray currentgstate currenthsbcolor currentlinecap currentlinejoin currentlinewidth currentmatrix currentpoint currentrgbcolor currentshared curveto cvi cvlit cvn cvr cvrs cvs cvx def defineusername dict div dtransform dup end eoclip eofill eoviewclip eq exch exec exit file fill findfont flattenpath floor flush flushfile for forall ge get getinterval grestore gsave gstate gt identmatrix idiv idtransform if ifelse image imagemask index ineofill infill initviewclip inueofill inufill invertmatrix itransform known le length lineto load loop lt makefont matrix maxlength mod moveto mul ne neg newpath not null or pathbbox pathforall pop print printobject put putinterval rcurveto read readhexstring readline readstring rectclip rectfill rectstroke rectviewclip repeat restore rlineto rmoveto roll rotate round save scale scalefont search selectfont setbbox setcachedevice setcachedevice2 setcharwidth setcmykcolor setdash setfont setgray setgstate sethsbcolor setlinecap setlinejoin setlinewidth setmatrix setrgbcolor setshared shareddict show showpage stop stopped store string stringwidth stroke strokepath sub systemdict token transform translate truncate type uappend ucache ueofill ufill undef upath userdict ustroke viewclip viewclippath where widthshow write writehexstring writeobject writestring wtranslation xor xshow xyshow yshow fontdirectory sharedfontdirectory courier courier-bold courier-boldoblique courier-oblique helvetica helvetica-bold helvetica-boldoblique helvetica-oblique symbol times-bold times-bolditalic times-italic times-roman execuserobject currentcolor currentcolorspace currentglobal execform filter findresource globaldict makepattern setcolor setcolorspace setglobal setpagedevice setpattern isolatin1encoding standardencoding atan banddevice bytesavailable cachestatus closefile colorimage condition copypage cos countdictstack countexecstack cshow currentblackgeneration currentcacheparams currentcolorscreen currentcolortransfer currentcontext currentflat currenthalftone currenthalftonephase currentmiterlimit currentobjectformat currentpacking currentscreen currentstrokeadjust currenttransfer currentundercolorremoval defaultmatrix definefont deletefile detach deviceinfo dictstack echo erasepage errordict execstack executeonly exp false filenameforall fileposition fork framedevice grestoreall handleerror initclip initgraphics initmatrix instroke inustroke join kshow ln lock log mark monitor noaccess notify nulldevice packedarray quit rand rcheck readonly realtime renamefile renderbands resetfile reversepath rootfont rrand run scheck setblackgeneration setcachelimit setcacheparams setcolorscreen setcolortransfer setfileposition setflat sethalftone sethalftonephase setmiterlimit setobjectformat setpacking setscreen setstrokeadjust settransfer setucacheparams setundercolorremoval sin sqrt srand stack status statusdict true ucachestatus undefinefont usertime ustrokepath version vmreclaim vmstatus wait wcheck xcheck yield defineuserobject undefineuserobject userobjects cleardictstack setvmthreshold currentcolorrendering currentdevparams currentoverprint currentpagedevice currentsystemparams currentuserparams defineresource findencoding gcheck glyphshow languagelevel product pstack resourceforall resourcestatus revision serialnumber setcolorrendering setdevparams setoverprint setsystemparams setuserparams startjob undefineresource globalfontdirectory ascii85decode ascii85encode asciihexdecode asciihexencode ccittfaxdecode ccittfaxencode dctdecode dctencode lzwdecode lzwencode nullencode runlengthdecode runlengthencode subfiledecode ciebaseda ciebasedabc devicecmyk devicegray devicergb indexed pattern separation ciebaseddef ciebaseddefg devicen" regex_'5c'2f'7b1'2c2'7d'5b'5e'5cs'5c'28'5c'29'5c'7b'5c'7d'5c'5b'5c'5d'25'2f'5d'2a = compileRegex "\\/{1,2}[^\\s\\(\\)\\{\\}\\[\\]%/]*" -defaultAttributes = [("Normal","Normal Text"),("Comment","Comment"),("Header","Header"),("String","String")]+defaultAttributes = [("Normal",NormalTok),("Comment",CommentTok),("Header",OtherTok),("String",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pDetect2Chars False '%' '!' >>= withAttribute "Header") >>~ pushContext "Header")- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'5c'2f'7b1'2c2'7d'5b'5e'5cs'5c'28'5c'29'5c'7b'5c'7d'5c'5b'5c'5d'25'2f'5d'2a >>= withAttribute "Data Type")))- return (attr, result)+parseRules "Normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False '%' '!' >>= withAttribute OtherTok) >>~ pushContext "Header")+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'5c'2f'7b1'2c2'7d'5b'5e'5cs'5c'28'5c'29'5c'7b'5c'7d'5c'5b'5c'5d'25'2f'5d'2a >>= withAttribute DataTypeTok))) -parseRules "Comment" = +parseRules "Comment" = pzero -parseRules "Header" = +parseRules "Header" = pzero -parseRules "String" = - do (attr, result) <- ((pDetectChar False ')' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Prolog.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file prolog.xml, version 1.04,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file prolog.xml, version 1.04, by -} -module Text.Highlighting.Kate.Syntax.Prolog ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Prolog+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Prolog"@@ -19,58 +22,45 @@ syntaxExtensions = "*.prolog" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Prolog" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Prolog",["normal"])], synStLanguage = "Prolog", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Prolog",["normal"])], synStLanguage = "Prolog", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine+ "normal" -> return () "comment" -> (popContext) >> pEndLine- "string" -> return () >> pHandleEndLine- "string2" -> return () >> pHandleEndLine- "comment region" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "string" -> return ()+ "string2" -> return ()+ "comment region" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Comment","co"),("Integer","dv"),("String","st"),("Variable","ot"),("Arithmetic","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywordl = Set.fromList $ words $ "abstract align as and class clauses constants database determ domains elsedef endclass enddef erroneous facts failure global goal if ifdef ifndef implement include language multi nocopy nondeterm object or procedure protected predicates reference single static struct this" list_keywordu = Set.fromList $ words $ "ABSTRACT ALIGN AS AND CLASS CLAUSES CONSTANTS DATABASE DETERM DOMAINS ELSEDEF ENDCLASS ENDDEF ERRONEOUS FACTS FAILURE GLOBAL GOAL IF IFDEF IFNDEF IMPLEMENT INCLUDE LANGUAGE MULTI NOCOPY NONDETERM OBJECT OR PROCEDURE PROTECTED PREDICATES REFERENCE SINGLE STATIC STRUCT THIS"@@ -83,52 +73,48 @@ regex_'5bA'2dZ'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "[A-Z_][A-Za-z0-9_]*" regex_'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a = compileRegex "[a-z][A-Za-z0-9_]*" -defaultAttributes = [("normal","Symbol"),("comment","Comment"),("string","String"),("string2","String"),("comment region","Comment")]+defaultAttributes = [("normal",NormalTok),("comment",CommentTok),("string",StringTok),("string2",StringTok),("comment region",CommentTok)] -parseRules "normal" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordl >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordu >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_arith >>= withAttribute "Arithmetic"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_compiler >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_basetype >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5bA'2dZ'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute "Identifier"))- <|>- ((pDetectChar False '%' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "comment region")- <|>- ((pInt >>= withAttribute "Integer"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "string2")- <|>- ((pAnyChar "~!^*()-+=[]|\\:;,./?&<>" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "normal" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordl >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordu >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_arith >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_compiler >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_special >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_basetype >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5bA'2dZ'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5ba'2dz'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '%' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "comment region")+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "string2")+ <|>+ ((pAnyChar "~!^*()-+=[]|\\:;,./?&<>" >>= withAttribute NormalTok))) -parseRules "comment" = +parseRules "comment" = pzero -parseRules "string" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "string" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "string2" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "string2" =+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "comment region" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "comment region" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "normal"
Text/Highlighting/Kate/Syntax/Python.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file python.xml, version 2.11,- by Michael Bueker -}+{- This module was generated from data in the Kate syntax+ highlighting file python.xml, version 2.11, by Michael Bueker -} -module Text.Highlighting.Kate.Syntax.Python ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Python+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert_indent-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Python"@@ -20,70 +23,57 @@ syntaxExtensions = "*.py;*.pyw;SConstruct;SConscript" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Python" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Python",["Normal"])], synStLanguage = "Python", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Python",["Normal"])], synStLanguage = "Python", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "CheckForString" -> (popContext) >> pEndLine- "parenthesised" -> return () >> pHandleEndLine+ "parenthesised" -> return () "Hash comment" -> (popContext) >> pEndLine- "Tripple A-comment" -> return () >> pHandleEndLine- "Tripple Q-comment" -> return () >> pHandleEndLine- "Single A-comment" -> return () >> pHandleEndLine- "Single Q-comment" -> return () >> pHandleEndLine- "stringformat" -> return () >> pHandleEndLine- "Tripple A-string" -> return () >> pHandleEndLine- "Raw Tripple A-string" -> return () >> pHandleEndLine- "Tripple Q-string" -> return () >> pHandleEndLine- "Raw Tripple Q-string" -> return () >> pHandleEndLine- "Single A-string" -> return () >> pHandleEndLine- "Single Q-string" -> return () >> pHandleEndLine- "Raw A-string" -> return () >> pHandleEndLine- "Raw Q-string" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Tripple A-comment" -> return ()+ "Tripple Q-comment" -> return ()+ "Single A-comment" -> return ()+ "Single Q-comment" -> return ()+ "stringformat" -> return ()+ "Tripple A-string" -> return ()+ "Raw Tripple A-string" -> return ()+ "Tripple Q-string" -> return ()+ "Raw Tripple Q-string" -> return ()+ "Single A-string" -> return ()+ "Single Q-string" -> return ()+ "Raw A-string" -> return ()+ "Raw Q-string" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Definition Keyword","kw"),("String Substitution","ot"),("Command Keyword","kw"),("Flow Control Keyword","kw"),("Builtin Function","dt"),("Special Variable","ot"),("Extensions","ot"),("Exceptions","ot"),("Overloaders","ot"),("Preprocessor","ch"),("String Char","ch"),("Float","fl"),("Int","dv"),("Hex","bn"),("Octal","bn"),("Complex","ot"),("Comment","co"),("String","st"),("Raw String","st"),("Decorator","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_prep = Set.fromList $ words $ "import from as" list_defs = Set.fromList $ words $ "class def del global lambda nonlocal"@@ -103,201 +93,184 @@ regex_'40'5b'5fa'2dzA'2dZ'5d'5b'5c'2e'5fa'2dzA'2dZ0'2d9'5d'2a = compileRegex "@[_a-zA-Z][\\._a-zA-Z0-9]*" regex_'25'28'28'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'29'3f'5b'230'5c'2d_'2b'5d'3f'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'3f'28'5c'2e'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'29'3f'5bhlL'5d'3f'5bcrsdiouxXeEfFgG'25'5d'7cprog'7cdefault'29 = compileRegex "%((\\([a-zA-Z0-9_]+\\))?[#0\\- +]?([1-9][0-9]*|\\*)?(\\.([1-9][0-9]*|\\*))?[hlL]?[crsdiouxXeEfFgG%]|prog|default)" -defaultAttributes = [("Normal","Normal Text"),("CheckForString","Normal Text"),("parenthesised","Normal Text"),("Hash comment","Comment"),("Tripple A-comment","Comment"),("Tripple Q-comment","Comment"),("Single A-comment","Comment"),("Single Q-comment","Comment"),("stringformat","String Substitution"),("Tripple A-string","String"),("Raw Tripple A-string","Raw String"),("Tripple Q-string","String"),("Raw Tripple Q-string","Raw String"),("Single A-string","String"),("Single Q-string","String"),("Raw A-string","Raw String"),("Raw Q-string","Raw String")]+defaultAttributes = [("Normal",NormalTok),("CheckForString",NormalTok),("parenthesised",NormalTok),("Hash comment",CommentTok),("Tripple A-comment",CommentTok),("Tripple Q-comment",CommentTok),("Single A-comment",CommentTok),("Single Q-comment",CommentTok),("stringformat",OtherTok),("Tripple A-string",StringTok),("Raw Tripple A-string",StringTok),("Tripple Q-string",StringTok),("Raw Tripple Q-string",StringTok),("Single A-string",StringTok),("Single Q-string",StringTok),("Raw A-string",StringTok),("Raw Q-string",StringTok)] -parseRules "Normal" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Normal Text") >>~ pushContext "CheckForString")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_prep >>= withAttribute "Preprocessor"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_defs >>= withAttribute "Definition Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_commands >>= withAttribute "Command Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_flow >>= withAttribute "Flow Control Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_builtinfuncs >>= withAttribute "Builtin Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_specialvars >>= withAttribute "Special Variable"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_bindings >>= withAttribute "Extensions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_exceptions >>= withAttribute "Exceptions"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_overloaders >>= withAttribute "Overloaders"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Normal"))- <|>- ((pRegExpr regex__'28'28'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'7c'28'5b0'2d9'5d'2b'7c'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'29'5beE'5d'28'5c'2b'7c'2d'29'3f'5b0'2d9'5d'2b'29'7c'5b0'2d9'5d'2b'29'5bjJ'5d >>= withAttribute "Complex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- (withChildren (pInt >>= withAttribute "Int") ((pString False "L" >>= withAttribute "Int")))- <|>- ((pString False "r'''" >>= withAttribute "Raw String") >>~ pushContext "Raw Tripple A-string")- <|>- ((pString False "r\"\"\"" >>= withAttribute "Raw String") >>~ pushContext "Raw Tripple Q-string")- <|>- ((pString False "r'" >>= withAttribute "Raw String") >>~ pushContext "Raw A-string")- <|>- ((pString False "r\"" >>= withAttribute "Raw String") >>~ pushContext "Raw Q-string")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Hash comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_u'3f'27'27'27 >>= withAttribute "Comment") >>~ pushContext "Tripple A-comment")- <|>- ((pFirstNonSpace >> pRegExpr regex_u'3f'22'22'22 >>= withAttribute "Comment") >>~ pushContext "Tripple Q-comment")- <|>- ((pString False "'''" >>= withAttribute "String") >>~ pushContext "Tripple A-string")- <|>- ((pString False "u'''" >>= withAttribute "String") >>~ pushContext "Tripple A-string")- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ pushContext "Tripple Q-string")- <|>- ((pString False "u\"\"\"" >>= withAttribute "String") >>~ pushContext "Tripple Q-string")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "Single A-string")- <|>- ((pDetect2Chars False 'u' '\'' >>= withAttribute "String") >>~ pushContext "Single A-string")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Single Q-string")- <|>- ((pDetect2Chars False 'u' '"' >>= withAttribute "String") >>~ pushContext "Single Q-string")- <|>- ((pDetectChar False '(' >>= withAttribute "Normal") >>~ pushContext "parenthesised")- <|>- ((pDetectChar False ')' >>= withAttribute "Normal") >>~ (popContext))- <|>- ((pAnyChar "+*/%\\|=;\\!<>!^&~-" >>= withAttribute "Operator"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'40'5b'5fa'2dzA'2dZ'5d'5b'5c'2e'5fa'2dzA'2dZ0'2d9'5d'2a >>= withAttribute "Decorator")))- return (attr, result)+parseRules "Normal" =+ (((pLineContinue >>= withAttribute NormalTok) >>~ pushContext "CheckForString")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_prep >>= withAttribute CharTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_defs >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_operators >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_commands >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_flow >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_builtinfuncs >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_specialvars >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_bindings >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_exceptions >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\#'" list_overloaders >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex__'28'28'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'7c'28'5b0'2d9'5d'2b'7c'28'5b0'2d9'5d'2a'5c'2e'5b0'2d9'5d'2b'7c'5b0'2d9'5d'2b'5c'2e'29'29'5beE'5d'28'5c'2b'7c'2d'29'3f'5b0'2d9'5d'2b'29'7c'5b0'2d9'5d'2b'29'5bjJ'5d >>= withAttribute OtherTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) ((pString False "L" >>= withAttribute DecValTok)))+ <|>+ ((pString False "r'''" >>= withAttribute StringTok) >>~ pushContext "Raw Tripple A-string")+ <|>+ ((pString False "r\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Raw Tripple Q-string")+ <|>+ ((pString False "r'" >>= withAttribute StringTok) >>~ pushContext "Raw A-string")+ <|>+ ((pString False "r\"" >>= withAttribute StringTok) >>~ pushContext "Raw Q-string")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Hash comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_u'3f'27'27'27 >>= withAttribute CommentTok) >>~ pushContext "Tripple A-comment")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_u'3f'22'22'22 >>= withAttribute CommentTok) >>~ pushContext "Tripple Q-comment")+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ pushContext "Tripple A-string")+ <|>+ ((pString False "u'''" >>= withAttribute StringTok) >>~ pushContext "Tripple A-string")+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Tripple Q-string")+ <|>+ ((pString False "u\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Tripple Q-string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Single A-string")+ <|>+ ((pDetect2Chars False 'u' '\'' >>= withAttribute StringTok) >>~ pushContext "Single A-string")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Single Q-string")+ <|>+ ((pDetect2Chars False 'u' '"' >>= withAttribute StringTok) >>~ pushContext "Single Q-string")+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "parenthesised")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pAnyChar "+*/%\\|=;\\!<>!^&~-" >>= withAttribute NormalTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'40'5b'5fa'2dzA'2dZ'5d'5b'5c'2e'5fa'2dzA'2dZ0'2d9'5d'2a >>= withAttribute OtherTok))) -parseRules "CheckForString" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "'''" >>= withAttribute "String") >>~ pushContext "Tripple A-string")- <|>- ((pString False "u'''" >>= withAttribute "String") >>~ pushContext "Tripple A-string")- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ pushContext "Tripple Q-string")- <|>- ((pString False "u\"\"\"" >>= withAttribute "String") >>~ pushContext "Tripple Q-string")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "CheckForString" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ pushContext "Tripple A-string")+ <|>+ ((pString False "u'''" >>= withAttribute StringTok) >>~ pushContext "Tripple A-string")+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Tripple Q-string")+ <|>+ ((pString False "u\"\"\"" >>= withAttribute StringTok) >>~ pushContext "Tripple Q-string")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "parenthesised" = - do (attr, result) <- ((parseRules "Normal"))- return (attr, result)+parseRules "parenthesised" =+ ((parseRules "Normal")) -parseRules "Hash comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression))- return (attr, result)+parseRules "Hash comment" =+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "Tripple A-comment" = - do (attr, result) <- (((pString False "'''" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression)))- return (attr, result)+parseRules "Tripple A-comment" =+ (((pString False "'''" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Tripple Q-comment" = - do (attr, result) <- (((pHlCChar >>= withAttribute "Comment"))- <|>- ((pString False "\"\"\"" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression)))- return (attr, result)+parseRules "Tripple Q-comment" =+ (((pHlCChar >>= withAttribute CommentTok))+ <|>+ ((pString False "\"\"\"" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Single A-comment" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Comment"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression)))- return (attr, result)+parseRules "Single A-comment" =+ (((pHlCStringChar >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "Single Q-comment" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Comment"))- <|>- ((pDetectChar False '"' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression)))- return (attr, result)+parseRules "Single Q-comment" =+ (((pHlCStringChar >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert_indent.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "stringformat" = - do (attr, result) <- ((pRegExpr regex_'25'28'28'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'29'3f'5b'230'5c'2d_'2b'5d'3f'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'3f'28'5c'2e'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'29'3f'5bhlL'5d'3f'5bcrsdiouxXeEfFgG'25'5d'7cprog'7cdefault'29 >>= withAttribute "String Substitution"))- return (attr, result)+parseRules "stringformat" =+ ((pRegExpr regex_'25'28'28'5c'28'5ba'2dzA'2dZ0'2d9'5f'5d'2b'5c'29'29'3f'5b'230'5c'2d_'2b'5d'3f'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'3f'28'5c'2e'28'5b1'2d9'5d'5b0'2d9'5d'2a'7c'5c'2a'29'29'3f'5bhlL'5d'3f'5bcrsdiouxXeEfFgG'25'5d'7cprog'7cdefault'29 >>= withAttribute OtherTok)) -parseRules "Tripple A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((parseRules "stringformat"))- <|>- ((pString False "'''" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Tripple A-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Tripple A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((parseRules "stringformat"))- <|>- ((pString False "'''" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Tripple A-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pString False "'''" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Tripple Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((parseRules "stringformat"))- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Tripple Q-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Tripple Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((parseRules "stringformat"))- <|>- ((pString False "\"\"\"" >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Tripple Q-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pString False "\"\"\"" >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Single A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((parseRules "stringformat"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Single A-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Single Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((parseRules "stringformat"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "Single Q-string" =+ (((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw A-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((parseRules "stringformat"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)+parseRules "Raw A-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Raw Q-string" = - do (attr, result) <- (((pHlCStringChar >>= withAttribute "Raw String"))- <|>- ((parseRules "stringformat"))- <|>- ((pDetectChar False '"' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)+parseRules "Raw Q-string" =+ (((pHlCStringChar >>= withAttribute StringTok))+ <|>+ ((parseRules "stringformat"))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/R.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file r.xml, version 2.04,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file r.xml, version 2.04, by -} -module Text.Highlighting.Kate.Syntax.R ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.R+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "R Script"@@ -19,62 +22,49 @@ syntaxExtensions = "*.R;*.r;*.S;*.s;*.q" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "R Script" } context <- currentContext <|> (pushContext "level0" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("R Script",["level0"])], synStLanguage = "R Script", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("R Script",["level0"])], synStLanguage = "R Script", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "level0" -> return () >> pHandleEndLine- "ctx0" -> return () >> pHandleEndLine- "parenthesis" -> return () >> pHandleEndLine- "string" -> return () >> pHandleEndLine- "string2" -> return () >> pHandleEndLine- "backquotedsymbol" -> return () >> pHandleEndLine+ "level0" -> return ()+ "ctx0" -> return ()+ "parenthesis" -> return ()+ "string" -> return ()+ "string2" -> return ()+ "backquotedsymbol" -> return () "Headline" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- "CommonRules" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "CommonRules" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Identifier","dt"),("String","st"),("Comment","co"),("Reserved Words","ot"),("Error","er"),("String Char","ch"),("Float","fl"),("Int","dv")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_controls = Set.fromList $ words $ "for in next break while repeat if else switch function" list_words = Set.fromList $ words $ "TRUE FALSE NULL NA NA_integer_ NA_real_ NA_complex_ NA_character_ Inf NaN"@@ -95,113 +85,106 @@ regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7b1'2c2'7d'7c'5c'21'3d'7c'5c'7c'7b1'2c2'7d'7c'26'7b1'2c2'7d'7c'3a'7b1'2c3'7d'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'7b2'2c'7d = compileRegex "(\\+|\\-|\\*|/|<=|>=|={1,2}|\\!=|\\|{1,2}|&{1,2}|:{1,3}|\\^|@|\\$|~){2,}" regex_'25'5b'5e'25'5d'2a'25 = compileRegex "%[^%]*%" -defaultAttributes = [("level0","Normal Text"),("ctx0","Normal Text"),("parenthesis","In Parenthesis"),("string","String"),("string2","String"),("backquotedsymbol","Identifier"),("Headline","Headline"),("Comment","Comment"),("CommonRules","Normal Text")]+defaultAttributes = [("level0",NormalTok),("ctx0",NormalTok),("parenthesis",NormalTok),("string",StringTok),("string2",StringTok),("backquotedsymbol",DataTypeTok),("Headline",NormalTok),("Comment",CommentTok),("CommonRules",NormalTok)] -parseRules "level0" = - do (attr, result) <- (((parseRules "CommonRules"))- <|>- ((pDetectChar False '}' >>= withAttribute "Error"))- <|>- ((pDetectChar False ')' >>= withAttribute "Error")))- return (attr, result)+parseRules "level0" =+ (((parseRules "CommonRules"))+ <|>+ ((pDetectChar False '}' >>= withAttribute ErrorTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute ErrorTok))) -parseRules "ctx0" = - do (attr, result) <- (((parseRules "CommonRules"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol") >>~ (popContext))- <|>- ((pDetectChar False ')' >>= withAttribute "Error")))- return (attr, result)+parseRules "ctx0" =+ (((parseRules "CommonRules"))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False ')' >>= withAttribute ErrorTok))) -parseRules "parenthesis" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Boolean"))- <|>- ((pDetectChar False ')' >>= withAttribute "Symbol") >>~ (popContext))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5c'2e'5d'5b0'2d9a'2dzA'2dZ'5f'5c'2e'5d'2a'5b'5cs'5d'2a'3d'28'3f'3d'28'5b'5e'3d'5d'7c'24'29'29 >>= withAttribute "Identifier"))- <|>- ((parseRules "CommonRules"))- <|>- ((pDetectChar False '}' >>= withAttribute "Error")))- return (attr, result)+parseRules "parenthesis" =+ (((pLineContinue >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5c'2e'5d'5b0'2d9a'2dzA'2dZ'5f'5c'2e'5d'2a'5b'5cs'5d'2a'3d'28'3f'3d'28'5b'5e'3d'5d'7c'24'29'29 >>= withAttribute DataTypeTok))+ <|>+ ((parseRules "CommonRules"))+ <|>+ ((pDetectChar False '}' >>= withAttribute ErrorTok))) -parseRules "string" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char")))- return (attr, result)+parseRules "string" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))) -parseRules "string2" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char")))- return (attr, result)+parseRules "string2" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))) -parseRules "backquotedsymbol" = - do (attr, result) <- (((pDetectChar False '`' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char")))- return (attr, result)+parseRules "backquotedsymbol" =+ (((pDetectChar False '`' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))) -parseRules "Headline" = +parseRules "Headline" = pzero -parseRules "Comment" = +parseRules "Comment" = pzero -parseRules "CommonRules" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "string2")- <|>- ((pDetectChar False '`' >>= withAttribute "String") >>~ pushContext "backquotedsymbol")- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\$" list_controls >>= withAttribute "Control Structure"))- <|>- ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\$" list_words >>= withAttribute "Reserved Words"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Int"))- <|>- ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'2b'5ba'2dzA'2dZ'5f'5c'2e0'2d9'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'2e'5ba'2dzA'2dZ'5f'5c'2e'5d'2b'5ba'2dzA'2dZ'5f'5c'2e0'2d9'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'28 >>= withAttribute "Symbol") >>~ pushContext "parenthesis")- <|>- ((pString False "##" >>= withAttribute "Headline") >>~ pushContext "Headline")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'26'5c'7c'3d'3e'40'5e'5d'29'28'5b'3c'5d'7b1'2c2'7d'5c'2d'7c'5c'2d'5b'3e'5d'7b1'2c2'7d'29 >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'28'5b'3c'5d'7b1'2c2'7d'5c'2d'7c'5c'2d'5b'3e'5d'7b1'2c2'7d'29'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'26'5c'7c'3d'3c'40'5d'29 >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'28'5b'3c'5d'7b3'7d'7c'5b'3e'5d'7b3'7d'29 >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'5b'3c'5d'7b1'2c2'7d'5c'2d >>= withAttribute "Assign"))- <|>- ((pRegExpr regex_'5c'2d'5b'3e'5d'7b1'2c2'7d >>= withAttribute "Assign"))- <|>- ((pRegExpr regex_'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'26'5c'7c'40'5e'5d'29'3d >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'3d'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'3c'3e'26'5c'7c'40'5e'5d'29 >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'3d'28'3f'21'3d'29 >>= withAttribute "Assign"))- <|>- ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7b1'2c2'7d'7c'5c'21'3d'7c'5c'7c'7b1'2c2'7d'7c'26'7b1'2c2'7d'7c'3a'7b1'2c3'7d'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'28'28'3f'21'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7c'5c'21'3d'7c'5c'7c'7c'26'7c'3a'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'29'7c'24'29 >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7b1'2c2'7d'7c'5c'21'3d'7c'5c'7c'7b1'2c2'7d'7c'26'7b1'2c2'7d'7c'3a'7b1'2c3'7d'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'7b2'2c'7d >>= withAttribute "Error"))- <|>- ((pRegExpr regex_'25'5b'5e'25'5d'2a'25 >>= withAttribute "Operator"))- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol") >>~ pushContext "ctx0")- <|>- ((pDetectChar False '[' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False ']' >>= withAttribute "Symbol")))- return (attr, result)+parseRules "CommonRules" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "string2")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "backquotedsymbol")+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\$" list_controls >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t():!+,-<=>%&*/;?[]^{|}~\\$" list_words >>= withAttribute OtherTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5ba'2dzA'2dZ'5f'5d'2b'5ba'2dzA'2dZ'5f'5c'2e0'2d9'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'2e'5ba'2dzA'2dZ'5f'5c'2e'5d'2b'5ba'2dzA'2dZ'5f'5c'2e0'2d9'5d'2a'28'3f'3d'5b'5cs'5d'2a'5b'28'5d'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'28 >>= withAttribute NormalTok) >>~ pushContext "parenthesis")+ <|>+ ((pString False "##" >>= withAttribute NormalTok) >>~ pushContext "Headline")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'26'5c'7c'3d'3e'40'5e'5d'29'28'5b'3c'5d'7b1'2c2'7d'5c'2d'7c'5c'2d'5b'3e'5d'7b1'2c2'7d'29 >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'28'5b'3c'5d'7b1'2c2'7d'5c'2d'7c'5c'2d'5b'3e'5d'7b1'2c2'7d'29'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'26'5c'7c'3d'3c'40'5d'29 >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'28'5b'3c'5d'7b3'7d'7c'5b'3e'5d'7b3'7d'29 >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'5b'3c'5d'7b1'2c2'7d'5c'2d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2d'5b'3e'5d'7b1'2c2'7d >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'26'5c'7c'40'5e'5d'29'3d >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'3d'28'5b'5c'2b'5c'2d'5c'2a'2f'5c'5e'5c'3a'5c'24'7e'21'3c'3e'26'5c'7c'40'5e'5d'29 >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'3d'28'3f'21'3d'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7b1'2c2'7d'7c'5c'21'3d'7c'5c'7c'7b1'2c2'7d'7c'26'7b1'2c2'7d'7c'3a'7b1'2c3'7d'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'28'28'3f'21'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7c'5c'21'3d'7c'5c'7c'7c'26'7c'3a'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'29'7c'24'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5c'2b'7c'5c'2d'7c'5c'2a'7c'2f'7c'3c'3d'7c'3e'3d'7c'3d'7b1'2c2'7d'7c'5c'21'3d'7c'5c'7c'7b1'2c2'7d'7c'26'7b1'2c2'7d'7c'3a'7b1'2c3'7d'7c'5c'5e'7c'40'7c'5c'24'7c'7e'29'7b2'2c'7d >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'25'5b'5e'25'5d'2a'25 >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "ctx0")+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok))) parseRules "" = parseRules "level0"
Text/Highlighting/Kate/Syntax/Relaxngcompact.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file relaxngcompact.xml, version 0.2,- by Rintze Zelle -}+{- This module was generated from data in the Kate syntax+ highlighting file relaxngcompact.xml, version 0.2, by Rintze Zelle -} -module Text.Highlighting.Kate.Syntax.Relaxngcompact ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Relaxngcompact+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "RelaxNG-Compact"@@ -19,58 +22,45 @@ syntaxExtensions = "*.rnc" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "RelaxNG-Compact" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("RelaxNG-Compact",["Normal Text"])], synStLanguage = "RelaxNG-Compact", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("RelaxNG-Compact",["Normal Text"])], synStLanguage = "RelaxNG-Compact", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine+ "Normal Text" -> return () "Comments" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine+ "String" -> return () "Node Names" -> (popContext) >> pEndLine "Definitions" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comments","co"),("String","st"),("Keywords","kw"),("Datatypes","dt"),("Node Names","ot"),("Definitions","fu")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_Keywords = Set.fromList $ words $ "default datatypes div empty external grammar include inherit list mixed namespace notAllowed parent start token" list_Node_Names = Set.fromList $ words $ "attribute element"@@ -78,36 +68,32 @@ regex_'5b'5cw'5c'2e'2d'5d'2b'5b'5cs'5d'2b'3d = compileRegex "[\\w\\.-]+[\\s]+=" -defaultAttributes = [("Normal Text","Normal Text"),("Comments","Comments"),("String","String"),("Node Names","Node Names"),("Definitions","Definitions")]+defaultAttributes = [("Normal Text",NormalTok),("Comments",CommentTok),("String",StringTok),("Node Names",OtherTok),("Definitions",FunctionTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comments") >>~ pushContext "Comments")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Keywords >>= withAttribute "Keywords"))- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Node_Names >>= withAttribute "Keywords") >>~ pushContext "Node Names")- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Datatypes >>= withAttribute "Datatypes"))- <|>- ((lookAhead (pRegExpr regex_'5b'5cw'5c'2e'2d'5d'2b'5b'5cs'5d'2b'3d) >> return ([],"") ) >>~ pushContext "Definitions"))- return (attr, result)+parseRules "Normal Text" =+ (((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comments")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Node_Names >>= withAttribute KeywordTok) >>~ pushContext "Node Names")+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\" list_Datatypes >>= withAttribute DataTypeTok))+ <|>+ ((lookAhead (pRegExpr regex_'5b'5cw'5c'2e'2d'5d'2b'5b'5cs'5d'2b'3d) >> return (NormalTok,"") ) >>~ pushContext "Definitions")) -parseRules "Comments" = +parseRules "Comments" = pzero -parseRules "String" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)+parseRules "String" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "Node Names" = - do (attr, result) <- ((lookAhead (pDetectChar False '{') >> return ([],"") ) >>~ (popContext))- return (attr, result)+parseRules "Node Names" =+ ((lookAhead (pDetectChar False '{') >> return (NormalTok,"") ) >>~ (popContext)) -parseRules "Definitions" = - do (attr, result) <- ((lookAhead (pDetectChar False '=') >> return ([],"") ) >>~ (popContext >> popContext))- return (attr, result)+parseRules "Definitions" =+ ((lookAhead (pDetectChar False '=') >> return (NormalTok,"") ) >>~ (popContext >> popContext)) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Rhtml.hs view
@@ -1,1345 +1,1237 @@-{- This module was generated from data in the Kate syntax highlighting file rhtml.xml, version 1.01,- by Richard Dale rdale@foton.es -}--module Text.Highlighting.Kate.Syntax.Rhtml ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions-import Text.Highlighting.Kate.Common-import qualified Text.Highlighting.Kate.Syntax.Alert-import qualified Text.Highlighting.Kate.Syntax.Css-import qualified Text.Highlighting.Kate.Syntax.Javascript-import Text.ParserCombinators.Parsec-import Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "Ruby/Rails/RHTML"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.rhtml;*.html.erb"---- | 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 = "Ruby/Rails/RHTML" }- context <- currentContext <|> (pushContext "Start" >> 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 [("Ruby/Rails/RHTML",["Start"])], synStLanguage = "Ruby/Rails/RHTML", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Start" -> return () >> pHandleEndLine- "FindHTML" -> return () >> pHandleEndLine- "FindEntityRefs" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "FindAttributes" -> return () >> pHandleEndLine- "FindDTDRules" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "El Open" -> return () >> pHandleEndLine- "El Close" -> return () >> pHandleEndLine- "El Close 2" -> return () >> pHandleEndLine- "El Close 3" -> return () >> pHandleEndLine- "CSS" -> return () >> pHandleEndLine- "CSS content" -> return () >> pHandleEndLine- "JS" -> return () >> pHandleEndLine- "JS content" -> return () >> pHandleEndLine- "JS comment close" -> (popContext) >> pEndLine- "Value" -> return () >> pHandleEndLine- "Value NQ" -> (popContext >> popContext) >> pEndLine- "Value DQ" -> return () >> pHandleEndLine- "Value SQ" -> return () >> pHandleEndLine- "rubysourceline" -> (popContext) >> pEndLine- "rubysource" -> return () >> pHandleEndLine- "Line Continue" -> (popContext) >> pEndLine- "Quoted String" -> return () >> pHandleEndLine- "Apostrophed String" -> return () >> pHandleEndLine- "Command String" -> return () >> pHandleEndLine- "Embedded documentation" -> return () >> pHandleEndLine- "RegEx 1" -> return () >> pHandleEndLine- "Subst" -> return () >> pHandleEndLine- "Short Subst" -> (popContext) >> pEndLine- "Member Access" -> (popContext) >> pEndLine- "Comment Line" -> (popContext) >> pEndLine- "General Comment" -> (popContext) >> pEndLine- "RDoc Label" -> (popContext) >> pEndLine- "find_heredoc" -> (popContext) >> pEndLine- "find_indented_heredoc" -> (popContext) >> pEndLine- "indented_heredoc" -> return () >> pHandleEndLine- "apostrophed_indented_heredoc" -> return () >> pHandleEndLine- "normal_heredoc" -> return () >> pHandleEndLine- "apostrophed_normal_heredoc" -> return () >> pHandleEndLine- "heredoc_rules" -> return () >> pHandleEndLine- "find_gdl_input" -> (popContext) >> pEndLine- "gdl_dq_string_1" -> return () >> pHandleEndLine- "gdl_dq_string_1_nested" -> return () >> pHandleEndLine- "gdl_dq_string_2" -> return () >> pHandleEndLine- "gdl_dq_string_2_nested" -> return () >> pHandleEndLine- "gdl_dq_string_3" -> return () >> pHandleEndLine- "gdl_dq_string_3_nested" -> return () >> pHandleEndLine- "gdl_dq_string_4" -> return () >> pHandleEndLine- "gdl_dq_string_4_nested" -> return () >> pHandleEndLine- "gdl_dq_string_5" -> return () >> pHandleEndLine- "dq_string_rules" -> return () >> pHandleEndLine- "gdl_token_array_1" -> return () >> pHandleEndLine- "gdl_token_array_1_nested" -> return () >> pHandleEndLine- "gdl_token_array_2" -> return () >> pHandleEndLine- "gdl_token_array_2_nested" -> return () >> pHandleEndLine- "gdl_token_array_3" -> return () >> pHandleEndLine- "gdl_token_array_3_nested" -> return () >> pHandleEndLine- "gdl_token_array_4" -> return () >> pHandleEndLine- "gdl_token_array_4_nested" -> return () >> pHandleEndLine- "gdl_token_array_5" -> return () >> pHandleEndLine- "token_array_rules" -> return () >> pHandleEndLine- "gdl_apostrophed_1" -> return () >> pHandleEndLine- "gdl_apostrophed_1_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_2" -> return () >> pHandleEndLine- "gdl_apostrophed_2_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_3" -> return () >> pHandleEndLine- "gdl_apostrophed_3_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_4" -> return () >> pHandleEndLine- "gdl_apostrophed_4_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_5" -> return () >> pHandleEndLine- "apostrophed_rules" -> return () >> pHandleEndLine- "gdl_shell_command_1" -> return () >> pHandleEndLine- "gdl_shell_command_1_nested" -> return () >> pHandleEndLine- "gdl_shell_command_2" -> return () >> pHandleEndLine- "gdl_shell_command_2_nested" -> return () >> pHandleEndLine- "gdl_shell_command_3" -> return () >> pHandleEndLine- "gdl_shell_command_3_nested" -> return () >> pHandleEndLine- "gdl_shell_command_4" -> return () >> pHandleEndLine- "gdl_shell_command_4_nested" -> return () >> pHandleEndLine- "gdl_shell_command_5" -> return () >> pHandleEndLine- "shell_command_rules" -> return () >> pHandleEndLine- "gdl_regexpr_1" -> return () >> pHandleEndLine- "gdl_regexpr_1_nested" -> return () >> pHandleEndLine- "gdl_regexpr_2" -> return () >> pHandleEndLine- "gdl_regexpr_2_nested" -> return () >> pHandleEndLine- "gdl_regexpr_3" -> return () >> pHandleEndLine- "gdl_regexpr_3_nested" -> return () >> pHandleEndLine- "gdl_regexpr_4" -> return () >> pHandleEndLine- "gdl_regexpr_4_nested" -> return () >> pHandleEndLine- "gdl_regexpr_5" -> return () >> pHandleEndLine- "regexpr_rules" -> return () >> pHandleEndLine- "DATA" -> return () >> pHandleEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Attribute Definition","ot"),("Access Control","kw"),("Definition","kw"),("Pseudo variable","dv"),("Dec","dv"),("Float","fl"),("Char","ch"),("Octal","bn"),("Hex","bn"),("Bin","bn"),("Symbol","st"),("String","st"),("Raw String","st"),("Command","st"),("Regular Expression","ot"),("Substitution","ot"),("GDL input","ot"),("Default globals","dt"),("Global Variable","dt"),("Global Constant","dt"),("Constant","dt"),("Constant Value","dt"),("Instance Variable","ot"),("Class Variable","ot"),("Ruby Comment","co"),("Blockcomment","co"),("RDoc Value","ot"),("Error","er"),("Alert","al"),("Delimiter","ch"),("Expression","ot"),("Operator","ch"),("Comment","co"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("Element","kw"),("Attribute","ot"),("Value","st"),("EntityRef","dv"),("PEntityRef","dv"),("Error","er")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_keywords = Set.fromList $ words $ "BEGIN END and begin break case defined? do else elsif end ensure for if in include next not or redo rescue retry return then unless until when while yield"-list_access'2dcontrol = Set.fromList $ words $ "private_class_method private protected public_class_method public"-list_attribute'2ddefinitions = Set.fromList $ words $ "attr_reader attr_writer attr_accessor"-list_definitions = Set.fromList $ words $ "alias module class def undef"-list_pseudo'2dvariables = Set.fromList $ words $ "self super nil false true caller __FILE__ __LINE__"-list_default'2dglobals = Set.fromList $ words $ "$stdout $defout $stderr $deferr $stdin"-list_kernel'2dmethods = Set.fromList $ words $ "abort at_exit autoload autoload? binding block_given? callcc caller catch chomp chomp! chop chop! eval exec exit exit! fail fork format getc gets global_variables gsub gsub! iterator? lambda load local_variables loop method_missing open p print printf proc putc puts raise rand readline readlines require scan select set_trace_func sleep split sprintf srand sub sub! syscall system test throw trace_var trap untrace_var warn auto_complete_field auto_complete_result auto_discovery_link_tag auto_link benchmark button_to cache capture check_box check_box_tag collection_select concat content_for content_tag country_options_for_select country_select current_page? date_select datetime_select debug define_javascript_functions distance_of_time_in_words distance_of_time_in_words_to_now draggable_element drop_receiving_element end_form_tag error_message_on error_messages_for escape_javascript evaluate_remote_response excerpt file_field file_field_tag finish_upload_status form form_remote_tag form_tag form_tag_with_upload_progress h hidden_field hidden_field_tag highlight human_size image_path image_submit_tag image_tag input javascript_include_tag javascript_path javascript_tag link_image_to link_to link_to_function link_to_if link_to_image link_to_remote link_to_unless link_to_unless_current mail_to markdown number_to_currency number_to_human_size number_to_percentage number_to_phone number_with_delimiter number_with_precision observe_field observe_form option_groups_from_collection_for_select options_for_select options_from_collection_for_select pagination_links password_field password_field_tag periodically_call_remote pluralize radio_button radio_button_tag register_template_handler render render_file render_template sanitize select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year simple_format sortable_element start_form_tag strip_links stylesheet_link_tag stylesheet_path submit_tag submit_to_remote tag text_area text_area_tag text_field text_field_tag text_field_with_auto_complete textilize textilize_without_paragraph time_ago_in_words time_zone_options_for_select time_zone_select truncate update_element_function upload_progress_status upload_progress_text upload_progress_update_bar_js upload_status_progress_bar_tag upload_status_tag upload_status_text_tag url_for visual_effect word_wrap"-list_attention = Set.fromList $ words $ "TODO FIXME NOTE"--regex_'3c'25'3d'3f = compileRegex "<%=?"-regex_'3c'21DOCTYPE'5cs'2b = compileRegex "<!DOCTYPE\\s+"-regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a = compileRegex "<\\?[\\w:-]*"-regex_'3cstyle'5cb = compileRegex "<style\\b"-regex_'3cscript'5cb = compileRegex "<script\\b"-regex_'3cpre'5cb = compileRegex "<pre\\b"-regex_'3cdiv'5cb = compileRegex "<div\\b"-regex_'3ctable'5cb = compileRegex "<table\\b"-regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "<[A-Za-z_:][\\w.:_-]*"-regex_'3c'2fpre'5cb = compileRegex "</pre\\b"-regex_'3c'2fdiv'5cb = compileRegex "</div\\b"-regex_'3c'2ftable'5cb = compileRegex "</table\\b"-regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "</[A-Za-z_:][\\w.:_-]*"-regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b = compileRegex "&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\\w.:_-]*);"-regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b = compileRegex "%[A-Za-z_:][\\w.:_-]*;"-regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "[A-Za-z_:][\\w.:_-]*"-regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "\\s+[A-Za-z_:][\\w.:_-]*"-regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb = compileRegex "<!(ELEMENT|ENTITY|ATTLIST|NOTATION)\\b"-regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b = compileRegex "-(-(?!->))+"-regex_'5cS = compileRegex "\\S"-regex_'3c'2fstyle'5cb = compileRegex "</style\\b"-regex_'3c'2fscript'5cb = compileRegex "</script\\b"-regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 = compileRegex "//(?=.*</script\\b)"-regex_'2f'28'3f'21'3e'29 = compileRegex "/(?!>)"-regex_'5b'5e'2f'3e'3c'22'27'5cs'5d = compileRegex "[^/><\"'\\s]"-regex_'2d'3f'25'3e = compileRegex "-?%>"-regex_'5f'5fEND'5f'5f'24 = compileRegex "__END__$"-regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"-regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb = compileRegex "(\\=|\\(|\\[|\\{)\\s*(if|unless|while|until)\\b"-regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "(while|until)\\b(?!.*\\bdo\\b)"-regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\;\\s*(while|until)\\b(?!.*\\bdo\\b)"-regex_'28if'7cunless'29'5cb = compileRegex "(if|unless)\\b"-regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb = compileRegex "\\;\\s*(if|unless)\\b"-regex_'5cbclass'5cb = compileRegex "\\bclass\\b"-regex_'5cbmodule'5cb = compileRegex "\\bmodule\\b"-regex_'5cbbegin'5cb = compileRegex "\\bbegin\\b"-regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\bfor\\b(?!.*\\bdo\\b)"-regex_'5cbcase'5cb = compileRegex "\\bcase\\b"-regex_'5cbdo'5cb = compileRegex "\\bdo\\b"-regex_'5cbdef'5cb = compileRegex "\\bdef\\b"-regex_'5cbend'5cb = compileRegex "\\bend\\b"-regex_'28'5cb'7c'5e'5cs'2a'29'28else'7celsif'7crescue'7censure'29'28'5cs'2b'7c'24'29 = compileRegex "(\\b|^\\s*)(else|elsif|rescue|ensure)(\\s+|$)"-regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 = compileRegex "\\.[_a-z][_a-zA-Z0-9]*(\\?|\\!|\\b)"-regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS = compileRegex "\\s\\?(\\\\M\\-)?(\\\\C\\-)?\\\\?\\S"-regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "\\$[a-zA-Z_0-9]+"-regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb = compileRegex "\\$\\-[a-zA-z_]\\b"-regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'5d = compileRegex "\\$[\\d_*`\\!:?'/\\\\\\-\\&]"-regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb = compileRegex "\\b[_A-Z]+[A-Z_0-9]+\\b"-regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb = compileRegex "\\b[A-Z]+_*([0-9]|[a-z])[_a-zA-Z0-9]*\\b"-regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b = compileRegex "\\b\\-?0[xX][_0-9a-fA-F]+"-regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b = compileRegex "\\b\\-?0[bB][_01]+"-regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a = compileRegex "\\b\\-?0[1-7][_0-7]*"-regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f = compileRegex "\\b\\-?[0-9][0-9_]*\\.[0-9][0-9_]*([eE]\\-?[1-9][0-9]*(\\.[0-9]*)?)?"-regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb = compileRegex "\\b\\-?[1-9][0-9_]*\\b"-regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<-(?=\\w+|[\"'])"-regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|[\"'])"-regex_'5cs'5b'5c'3f'5c'3a'5c'25'2f'5d'5cs = compileRegex "\\s[\\?\\:\\%/]\\s"-regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b = compileRegex "[|&<>\\^\\+*~\\-=]+"-regex_'5cs'21 = compileRegex "\\s!"-regex_'2f'3d'5cs = compileRegex "/=\\s"-regex_'3a'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a = compileRegex ":[a-zA-Z_][a-zA-Z0-9_]*"-regex_'23'5cs'2aBEGIN'2e'2a'24 = compileRegex "#\\s*BEGIN.*$"-regex_'23'5cs'2aEND'2e'2a'24 = compileRegex "#\\s*END.*$"-regex_'23 = compileRegex "#"-regex_'5cs'23 = compileRegex "\\s#"-regex_'5b'5c'5b'5c'5d'5d'2b = compileRegex "[\\[\\]]+"-regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@[a-zA-Z_0-9]+"-regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@@[a-zA-Z_0-9]+"-regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxw'5d'3f'5b'5e'5cs'3e'5d'29 = compileRegex "\\s*[%](?=[Qqxw]?[^\\s>])"-regex_'5c'5c'5c'22 = compileRegex "\\\\\\\""-regex_'23'40'7b1'2c2'7d = compileRegex "#@{1,2}"-regex_'5c'5c'5c'27 = compileRegex "\\\\\\'"-regex_'5c'5c'5c'60 = compileRegex "\\\\\\`"-regex_'5c'5c'5c'2f = compileRegex "\\\\\\/"-regex_'5b'5e'5c'5c'5d'24 = compileRegex "[^\\\\]$"-regex_'2f'5buiomxn'5d'2a = compileRegex "/[uiomxn]*"-regex_'5cw'28'3f'21'5cw'29 = compileRegex "\\w(?!\\w)"-regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?(?=[^\\w\\d\\.\\:])"-regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?"-regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[A-Z]+_*(\\d|[a-z])\\w*(?=[^\\w\\d\\.\\:])"-regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a = compileRegex "[A-Z]+_*([0-9]|[a-z])\\w*"-regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[_A-Z][_A-Z0-9]*(?=[^\\w\\d\\.\\:])"-regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a = compileRegex "[_A-Z][_A-Z0-9]*"-regex_'5cW = compileRegex "\\W"-regex_'5cw'5c'3a'5c'3a'5cs = compileRegex "\\w\\:\\:\\s"-regex_'27'28'5cw'2b'29'27 = compileRegex "'(\\w+)'"-regex_'22'3f'28'5cw'2b'29'22'3f = compileRegex "\"?(\\w+)\"?"-regex_w'5c'28 = compileRegex "w\\("-regex_w'5c'7b = compileRegex "w\\{"-regex_w'5c'5b = compileRegex "w\\["-regex_w'3c = compileRegex "w<"-regex_w'28'5b'5e'5cs'5cw'5d'29 = compileRegex "w([^\\s\\w])"-regex_q'5c'28 = compileRegex "q\\("-regex_q'5c'7b = compileRegex "q\\{"-regex_q'5c'5b = compileRegex "q\\["-regex_q'3c = compileRegex "q<"-regex_q'28'5b'5e'5cs'5cw'5d'29 = compileRegex "q([^\\s\\w])"-regex_x'5c'28 = compileRegex "x\\("-regex_x'5c'7b = compileRegex "x\\{"-regex_x'5c'5b = compileRegex "x\\["-regex_x'3c = compileRegex "x<"-regex_x'28'5b'5e'5cs'5cw'5d'29 = compileRegex "x([^\\s\\w])"-regex_r'5c'28 = compileRegex "r\\("-regex_r'5c'7b = compileRegex "r\\{"-regex_r'5c'5b = compileRegex "r\\["-regex_r'3c = compileRegex "r<"-regex_r'28'5b'5e'5cs'5cw'5d'29 = compileRegex "r([^\\s\\w])"-regex_Q'3f'5c'28 = compileRegex "Q?\\("-regex_Q'3f'5c'7b = compileRegex "Q?\\{"-regex_Q'3f'5c'5b = compileRegex "Q?\\["-regex_Q'3f'3c = compileRegex "Q?<"-regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 = compileRegex "Q?([^\\s\\w])"-regex_'5c'29'5buiomxn'5d'2a = compileRegex "\\)[uiomxn]*"-regex_'5c'7d'5buiomxn'5d'2a = compileRegex "\\}[uiomxn]*"-regex_'5c'5d'5buiomxn'5d'2a = compileRegex "\\][uiomxn]*"-regex_'3e'5buiomxn'5d'2a = compileRegex ">[uiomxn]*"--defaultAttributes = [("Start","Normal Text"),("FindHTML","Normal Text"),("FindEntityRefs","Normal Text"),("FindPEntityRefs","Normal Text"),("FindAttributes","Normal Text"),("FindDTDRules","Normal Text"),("Comment","Comment"),("CDATA","Normal Text"),("PI","Normal Text"),("Doctype","Normal Text"),("Doctype Internal Subset","Normal Text"),("Doctype Markupdecl","Normal Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("El Open","Normal Text"),("El Close","Normal Text"),("El Close 2","Normal Text"),("El Close 3","Normal Text"),("CSS","Normal Text"),("CSS content","Normal Text"),("JS","Normal Text"),("JS content","Normal Text"),("JS comment close","Comment"),("Value","Normal Text"),("Value NQ","Normal Text"),("Value DQ","Value"),("Value SQ","Value"),("rubysourceline","RUBY RAILS ERB Text"),("rubysource","RUBY RAILS ERB Text"),("Line Continue","Ruby Normal Text"),("Quoted String","String"),("Apostrophed String","Raw String"),("Command String","Command"),("Embedded documentation","Ruby Comment"),("RegEx 1","Regular Expression"),("Subst","Ruby Normal Text"),("Short Subst","Substitution"),("Member Access","Member"),("Comment Line","Ruby Comment"),("General Comment","Ruby Comment"),("RDoc Label","RDoc Value"),("find_heredoc","Ruby Normal Text"),("find_indented_heredoc","Ruby Normal Text"),("indented_heredoc","Ruby Normal Text"),("apostrophed_indented_heredoc","Ruby Normal Text"),("normal_heredoc","Ruby Normal Text"),("apostrophed_normal_heredoc","Ruby Normal Text"),("heredoc_rules","Ruby Normal Text"),("find_gdl_input","Ruby Normal Text"),("gdl_dq_string_1","String"),("gdl_dq_string_1_nested","String"),("gdl_dq_string_2","String"),("gdl_dq_string_2_nested","String"),("gdl_dq_string_3","String"),("gdl_dq_string_3_nested","String"),("gdl_dq_string_4","String"),("gdl_dq_string_4_nested","String"),("gdl_dq_string_5","String"),("dq_string_rules","String"),("gdl_token_array_1","String"),("gdl_token_array_1_nested","String"),("gdl_token_array_2","String"),("gdl_token_array_2_nested","String"),("gdl_token_array_3","String"),("gdl_token_array_3_nested","String"),("gdl_token_array_4","String"),("gdl_token_array_4_nested","String"),("gdl_token_array_5","String"),("token_array_rules","String"),("gdl_apostrophed_1","Raw String"),("gdl_apostrophed_1_nested","Raw String"),("gdl_apostrophed_2","Raw String"),("gdl_apostrophed_2_nested","Raw String"),("gdl_apostrophed_3","Raw String"),("gdl_apostrophed_3_nested","Raw String"),("gdl_apostrophed_4","Raw String"),("gdl_apostrophed_4_nested","Raw String"),("gdl_apostrophed_5","Raw String"),("apostrophed_rules","Raw String"),("gdl_shell_command_1","Command"),("gdl_shell_command_1_nested","Command"),("gdl_shell_command_2","Command"),("gdl_shell_command_2_nested","Command"),("gdl_shell_command_3","Command"),("gdl_shell_command_3_nested","Command"),("gdl_shell_command_4","Command"),("gdl_shell_command_4_nested","Command"),("gdl_shell_command_5","Command"),("shell_command_rules","Command"),("gdl_regexpr_1","Regular Expression"),("gdl_regexpr_1_nested","Regular Expression"),("gdl_regexpr_2","Regular Expression"),("gdl_regexpr_2_nested","Regular Expression"),("gdl_regexpr_3","Regular Expression"),("gdl_regexpr_3_nested","Regular Expression"),("gdl_regexpr_4","Regular Expression"),("gdl_regexpr_4_nested","Regular Expression"),("gdl_regexpr_5","Regular Expression"),("regexpr_rules","Regular Expression"),("DATA","Data")]--parseRules "Start" = - do (attr, result) <- ((parseRules "FindHTML"))- return (attr, result)--parseRules "FindHTML" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pString False "%" >>= withAttribute "Keyword") >>~ pushContext "rubysourceline")- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pRegExpr regex_'3cstyle'5cb >>= withAttribute "Element") >>~ pushContext "CSS")- <|>- ((pRegExpr regex_'3cscript'5cb >>= withAttribute "Element") >>~ pushContext "JS")- <|>- ((pRegExpr regex_'3cpre'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3cdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3ctable'5cb >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Open")- <|>- ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El Close")- <|>- ((parseRules "FindDTDRules"))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)--parseRules "FindEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pAnyChar "&<" >>= withAttribute "Error")))- return (attr, result)--parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntityRef"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)--parseRules "FindAttributes" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute"))- <|>- ((pDetectChar False '=' >>= withAttribute "Attribute") >>~ pushContext "Value"))- return (attr, result)--parseRules "FindDTDRules" = - do (attr, result) <- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- return (attr, result)--parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Error")))- return (attr, result)--parseRules "CDATA" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "EntityRef")))- return (attr, result)--parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)--parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)--parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((parseRules "FindDTDRules"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)--parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)--parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)--parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)--parseRules "El Open" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "El Close" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "El Close 2" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "El Close 3" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "CSS" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "CSS content")- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "CSS content" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((Text.Highlighting.Kate.Syntax.Css.parseExpression)))- return (attr, result)--parseRules "JS" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "JS content")- <|>- ((parseRules "FindAttributes"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)--parseRules "JS content" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 2")- <|>- ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute "Comment") >>~ pushContext "JS comment close")- <|>- ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))- return (attr, result)--parseRules "JS comment close" = - do (attr, result) <- (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute "Element") >>~ pushContext "El Close 3")- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)--parseRules "Value" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Value DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Value SQ")- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- (pushContext "Value NQ" >> return ([], "")))- return (attr, result)--parseRules "Value NQ" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((parseRules "FindEntityRefs"))- <|>- ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute "Value"))- <|>- ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute "Value"))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "Value DQ" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)--parseRules "Value SQ" = - do (attr, result) <- (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute "Keyword") >>~ pushContext "rubysource")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)--parseRules "rubysourceline" = - do (attr, result) <- ((parseRules "rubysource"))- return (attr, result)--parseRules "rubysource" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Ruby Normal Text") >>~ pushContext "Line Continue")- <|>- ((pRegExpr regex_'2d'3f'25'3e >>= withAttribute "Keyword") >>~ (popContext))- <|>- ((pColumn 0 >> pRegExpr regex_'5f'5fEND'5f'5f'24 >>= withAttribute "Keyword") >>~ pushContext "DATA")- <|>- ((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbclass'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbmodule'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbcase'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbdo'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbdef'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'28'5cb'7c'5e'5cs'2a'29'28else'7celsif'7crescue'7censure'29'28'5cs'2b'7c'24'29 >>= withAttribute "Keyword"))- <|>- ((pString False "..." >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 >>= withAttribute "Message"))- <|>- ((pRegExpr regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS >>= withAttribute "Dec"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attribute'2ddefinitions >>= withAttribute "Attribute Definition"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_access'2dcontrol >>= withAttribute "Access Control"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_definitions >>= withAttribute "Definition"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_pseudo'2dvariables >>= withAttribute "Pseudo variable"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_default'2dglobals >>= withAttribute "Default globals"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_kernel'2dmethods >>= withAttribute "Kernel methods"))- <|>- ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Global Variable"))- <|>- ((pRegExpr regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb >>= withAttribute "Global Variable"))- <|>- ((pRegExpr regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'5d >>= withAttribute "Default globals"))- <|>- ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb >>= withAttribute "Global Constant"))- <|>- ((pRegExpr regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b >>= withAttribute "Hex"))- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b >>= withAttribute "Bin"))- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a >>= withAttribute "Octal"))- <|>- ((pRegExpr regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f >>= withAttribute "Float"))- <|>- ((pRegExpr regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb >>= withAttribute "Dec"))- <|>- ((pInt >>= withAttribute "Dec"))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pColumn 0 >> pString False "=begin" >>= withAttribute "Blockcomment") >>~ pushContext "Embedded documentation")- <|>- ((pRegExpr regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_indented_heredoc")- <|>- ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_heredoc")- <|>- ((pDetectChar False '.' >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '&' '&' >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '|' '|' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5cs'5b'5c'3f'5c'3a'5c'25'2f'5d'5cs >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5cs'21 >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'2f'3d'5cs >>= withAttribute "Operator"))- <|>- ((pString False "%=" >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Operator") >>~ pushContext "Member Access")- <|>- ((pRegExpr regex_'3a'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Quoted String")- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ pushContext "Apostrophed String")- <|>- ((pDetectChar False '`' >>= withAttribute "Command") >>~ pushContext "Command String")- <|>- ((pString False "?#" >>= withAttribute "Normal Text"))- <|>- ((pColumn 0 >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pColumn 0 >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23 >>= withAttribute "Comment") >>~ pushContext "Comment Line")- <|>- ((pRegExpr regex_'5cs'23 >>= withAttribute "Comment") >>~ pushContext "General Comment")- <|>- ((pRegExpr regex_'5b'5c'5b'5c'5d'5d'2b >>= withAttribute "Delimiter"))- <|>- ((pDetectChar False '{' >>= withAttribute "Delimiter"))- <|>- ((pDetectChar False '}' >>= withAttribute "Delimiter"))- <|>- ((pRegExpr regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Instance Variable"))- <|>- ((pRegExpr regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Class Variable"))- <|>- ((pDetectChar False '/' >>= withAttribute "Regular Expression") >>~ pushContext "RegEx 1")- <|>- ((pRegExpr regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxw'5d'3f'5b'5e'5cs'3e'5d'29 >>= withAttribute "GDL input") >>~ pushContext "find_gdl_input"))- return (attr, result)--parseRules "Line Continue" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((parseRules "rubysource")))- return (attr, result)--parseRules "Quoted String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'22 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "Apostrophed String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'27 >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "Command String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'60 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pHlCChar >>= withAttribute "Char") >>~ (popContext))- <|>- ((pDetectChar False '`' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "Embedded documentation" = - do (attr, result) <- ((pColumn 0 >> pString False "=end" >>= withAttribute "Ruby Comment") >>~ (popContext))- return (attr, result)--parseRules "RegEx 1" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5c'2f >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'5b'5e'5c'5c'5d'24 >>= withAttribute "Regular Expression") >>~ (popContext))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pRegExpr regex_'2f'5buiomxn'5d'2a >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "Subst" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Substitution") >>~ (popContext))- <|>- ((parseRules "rubysource")))- return (attr, result)--parseRules "Short Subst" = - do (attr, result) <- (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution"))- <|>- ((pRegExpr regex_'5cw'28'3f'21'5cw'29 >>= withAttribute "Substitution") >>~ (popContext)))- return (attr, result)--parseRules "Member Access" = - do (attr, result) <- (((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Message") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f >>= withAttribute "Message"))- <|>- ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Constant") >>~ (popContext))- <|>- ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Constant Value") >>~ (popContext))- <|>- ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a >>= withAttribute "Constant Value"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Operator"))- <|>- ((pDetectChar False '.' >>= withAttribute "Member"))- <|>- ((pAnyChar "=+-*/%|&[]{}~" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pDetectChar False '#' >>= withAttribute "Ruby Comment") >>~ (popContext))- <|>- ((pAnyChar "()\\" >>= withAttribute "Ruby Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5cW >>= withAttribute "Member") >>~ (popContext)))- return (attr, result)--parseRules "Comment Line" = - do (attr, result) <- (((pRegExpr regex_'5cw'5c'3a'5c'3a'5cs >>= withAttribute "Ruby Comment") >>~ pushContext "RDoc Label")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attention >>= withAttribute "Alert"))- <|>- ((pRegExpr regex_'2d'3f'25'3e >>= withAttribute "Keyword") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "General Comment" = - do (attr, result) <- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attention >>= withAttribute "Dec"))- return (attr, result)--parseRules "RDoc Label" = - pzero--parseRules "find_heredoc" = - do (attr, result) <- (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute "Keyword") >>~ pushContext "apostrophed_normal_heredoc")- <|>- ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute "Keyword") >>~ pushContext "normal_heredoc"))- return (attr, result)--parseRules "find_indented_heredoc" = - do (attr, result) <- (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute "Keyword") >>~ pushContext "apostrophed_indented_heredoc")- <|>- ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute "Keyword") >>~ pushContext "indented_heredoc"))- return (attr, result)--parseRules "indented_heredoc" = - do (attr, result) <- (((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((parseRules "heredoc_rules")))- return (attr, result)--parseRules "apostrophed_indented_heredoc" = - do (attr, result) <- ((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- return (attr, result)--parseRules "normal_heredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((parseRules "heredoc_rules")))- return (attr, result)--parseRules "apostrophed_normal_heredoc" = - do (attr, result) <- ((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- return (attr, result)--parseRules "heredoc_rules" = - do (attr, result) <- (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "find_gdl_input" = - do (attr, result) <- (((pRegExpr regex_w'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_1")- <|>- ((pRegExpr regex_w'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_2")- <|>- ((pRegExpr regex_w'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_3")- <|>- ((pRegExpr regex_w'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_4")- <|>- ((pRegExpr regex_w'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_5")- <|>- ((pRegExpr regex_q'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_1")- <|>- ((pRegExpr regex_q'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_2")- <|>- ((pRegExpr regex_q'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_3")- <|>- ((pRegExpr regex_q'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_4")- <|>- ((pRegExpr regex_q'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_5")- <|>- ((pRegExpr regex_x'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_1")- <|>- ((pRegExpr regex_x'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_2")- <|>- ((pRegExpr regex_x'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_3")- <|>- ((pRegExpr regex_x'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_4")- <|>- ((pRegExpr regex_x'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_5")- <|>- ((pRegExpr regex_r'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_1")- <|>- ((pRegExpr regex_r'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_2")- <|>- ((pRegExpr regex_r'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_3")- <|>- ((pRegExpr regex_r'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_4")- <|>- ((pRegExpr regex_r'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_5")- <|>- ((pRegExpr regex_Q'3f'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_1")- <|>- ((pRegExpr regex_Q'3f'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_2")- <|>- ((pRegExpr regex_Q'3f'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_3")- <|>- ((pRegExpr regex_Q'3f'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_4")- <|>- ((pRegExpr regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_5"))- return (attr, result)--parseRules "gdl_dq_string_1" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "String"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_1_nested" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_dq_string_2" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_2_nested"))- return (attr, result)--parseRules "gdl_dq_string_2_nested" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_3" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "String"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_3_nested" = - do (attr, result) <- (((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_4" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "String"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_4_nested" = - do (attr, result) <- (((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_5" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "dq_string_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "gdl_token_array_1" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "String"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_token_array_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_1_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_token_array_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_2" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_token_array_2_nested"))- return (attr, result)--parseRules "gdl_token_array_2_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_token_array_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_3" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "String"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_token_array_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_3_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_token_array_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_4" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "String"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_token_array_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_4_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_token_array_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_5" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "token_array_rules" = - do (attr, result) <- ((pString False "\\\\" >>= withAttribute "String"))- return (attr, result)--parseRules "gdl_apostrophed_1" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '(' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_1_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_2" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_2_nested"))- return (attr, result)--parseRules "gdl_apostrophed_2_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_3" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '[' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_3_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_4" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '<' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_4_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_5" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Raw String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "apostrophed_rules" = - do (attr, result) <- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Raw String"))- return (attr, result)--parseRules "gdl_shell_command_1" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Command"))- <|>- ((pDetectChar False '(' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_1_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_2" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Command"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_2_nested"))- return (attr, result)--parseRules "gdl_shell_command_2_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_3" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Command"))- <|>- ((pDetectChar False '[' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_3_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_4" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Command"))- <|>- ((pDetectChar False '<' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_4_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_5" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Command"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "shell_command_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Command"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "gdl_regexpr_1" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '(' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_1_nested")- <|>- ((pRegExpr regex_'5c'29'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_1_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_2" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'5c'7d'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_2_nested"))- return (attr, result)--parseRules "gdl_regexpr_2_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_3" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '[' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_3_nested")- <|>- ((pRegExpr regex_'5c'5d'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_3_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_4" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '<' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_4_nested")- <|>- ((pRegExpr regex_'3e'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_4_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_5" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Regular Expression"))- <|>- ((pRegExprDynamic "\\s*%1[uiomxn]*" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "regexpr_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "DATA" = +{- This module was generated from data in the Kate syntax+ highlighting file rhtml.xml, version 1.01, by Richard Dale rdale@foton.es -}++module Text.Highlighting.Kate.Syntax.Rhtml+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Common+import qualified Text.Highlighting.Kate.Syntax.Alert+import qualified Text.Highlighting.Kate.Syntax.Css+import qualified Text.Highlighting.Kate.Syntax.Javascript+import Text.ParserCombinators.Parsec hiding (State)+import Data.Map (fromList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe)+import qualified Data.Set as Set++-- | Full name of language.+syntaxName :: String+syntaxName = "Ruby/Rails/RHTML"++-- | Filename extensions for this language.+syntaxExtensions :: String+syntaxExtensions = "*.rhtml;*.html.erb"++-- | Highlight source code using this syntax definition.+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState++parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine++-- | Parse an expression using appropriate local context.+parseExpression :: KateParser Token+parseExpression = do+ st <- getState+ let oldLang = synStLanguage st+ setState $ st { synStLanguage = "Ruby/Rails/RHTML" }+ context <- currentContext <|> (pushContext "Start" >> currentContext)+ result <- parseRules context+ optional $ eof >> pEndLine+ updateState $ \st -> st { synStLanguage = oldLang }+ return result++startingState = SyntaxState {synStContexts = fromList [("Ruby/Rails/RHTML",["Start"])], synStLanguage = "Ruby/Rails/RHTML", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}++pEndLine = do+ context <- currentContext+ case context of+ "Start" -> return ()+ "FindHTML" -> return ()+ "FindEntityRefs" -> return ()+ "FindPEntityRefs" -> return ()+ "FindAttributes" -> return ()+ "FindDTDRules" -> return ()+ "Comment" -> return ()+ "CDATA" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "El Open" -> return ()+ "El Close" -> return ()+ "El Close 2" -> return ()+ "El Close 3" -> return ()+ "CSS" -> return ()+ "CSS content" -> return ()+ "JS" -> return ()+ "JS content" -> return ()+ "JS comment close" -> (popContext) >> pEndLine+ "Value" -> return ()+ "Value NQ" -> (popContext >> popContext) >> pEndLine+ "Value DQ" -> return ()+ "Value SQ" -> return ()+ "rubysourceline" -> (popContext) >> pEndLine+ "rubysource" -> return ()+ "Line Continue" -> (popContext) >> pEndLine+ "Quoted String" -> return ()+ "Apostrophed String" -> return ()+ "Command String" -> return ()+ "Embedded documentation" -> return ()+ "RegEx 1" -> return ()+ "Subst" -> return ()+ "Short Subst" -> (popContext) >> pEndLine+ "Member Access" -> (popContext) >> pEndLine+ "Comment Line" -> (popContext) >> pEndLine+ "General Comment" -> (popContext) >> pEndLine+ "RDoc Label" -> (popContext) >> pEndLine+ "find_heredoc" -> (popContext) >> pEndLine+ "find_indented_heredoc" -> (popContext) >> pEndLine+ "indented_heredoc" -> return ()+ "apostrophed_indented_heredoc" -> return ()+ "normal_heredoc" -> return ()+ "apostrophed_normal_heredoc" -> return ()+ "heredoc_rules" -> return ()+ "find_gdl_input" -> (popContext) >> pEndLine+ "gdl_dq_string_1" -> return ()+ "gdl_dq_string_1_nested" -> return ()+ "gdl_dq_string_2" -> return ()+ "gdl_dq_string_2_nested" -> return ()+ "gdl_dq_string_3" -> return ()+ "gdl_dq_string_3_nested" -> return ()+ "gdl_dq_string_4" -> return ()+ "gdl_dq_string_4_nested" -> return ()+ "gdl_dq_string_5" -> return ()+ "dq_string_rules" -> return ()+ "gdl_token_array_1" -> return ()+ "gdl_token_array_1_nested" -> return ()+ "gdl_token_array_2" -> return ()+ "gdl_token_array_2_nested" -> return ()+ "gdl_token_array_3" -> return ()+ "gdl_token_array_3_nested" -> return ()+ "gdl_token_array_4" -> return ()+ "gdl_token_array_4_nested" -> return ()+ "gdl_token_array_5" -> return ()+ "token_array_rules" -> return ()+ "gdl_apostrophed_1" -> return ()+ "gdl_apostrophed_1_nested" -> return ()+ "gdl_apostrophed_2" -> return ()+ "gdl_apostrophed_2_nested" -> return ()+ "gdl_apostrophed_3" -> return ()+ "gdl_apostrophed_3_nested" -> return ()+ "gdl_apostrophed_4" -> return ()+ "gdl_apostrophed_4_nested" -> return ()+ "gdl_apostrophed_5" -> return ()+ "apostrophed_rules" -> return ()+ "gdl_shell_command_1" -> return ()+ "gdl_shell_command_1_nested" -> return ()+ "gdl_shell_command_2" -> return ()+ "gdl_shell_command_2_nested" -> return ()+ "gdl_shell_command_3" -> return ()+ "gdl_shell_command_3_nested" -> return ()+ "gdl_shell_command_4" -> return ()+ "gdl_shell_command_4_nested" -> return ()+ "gdl_shell_command_5" -> return ()+ "shell_command_rules" -> return ()+ "gdl_regexpr_1" -> return ()+ "gdl_regexpr_1_nested" -> return ()+ "gdl_regexpr_2" -> return ()+ "gdl_regexpr_2_nested" -> return ()+ "gdl_regexpr_3" -> return ()+ "gdl_regexpr_3_nested" -> return ()+ "gdl_regexpr_4" -> return ()+ "gdl_regexpr_4_nested" -> return ()+ "gdl_regexpr_5" -> return ()+ "regexpr_rules" -> return ()+ "DATA" -> return ()+ _ -> return ()++withAttribute attr txt = do+ when (null txt) $ fail "Parser matched no text"+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt)++parseExpressionInternal = do+ context <- currentContext+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))++list_keywords = Set.fromList $ words $ "BEGIN END and begin break case defined? do else elsif end ensure for if in include next not or redo rescue retry return then unless until when while yield"+list_access'2dcontrol = Set.fromList $ words $ "private_class_method private protected public_class_method public"+list_attribute'2ddefinitions = Set.fromList $ words $ "attr_reader attr_writer attr_accessor"+list_definitions = Set.fromList $ words $ "alias module class def undef"+list_pseudo'2dvariables = Set.fromList $ words $ "self super nil false true caller __FILE__ __LINE__"+list_default'2dglobals = Set.fromList $ words $ "$stdout $defout $stderr $deferr $stdin"+list_kernel'2dmethods = Set.fromList $ words $ "abort at_exit autoload autoload? binding block_given? callcc caller catch chomp chomp! chop chop! eval exec exit exit! fail fork format getc gets global_variables gsub gsub! iterator? lambda load local_variables loop method_missing open p print printf proc putc puts raise rand readline readlines require scan select set_trace_func sleep split sprintf srand sub sub! syscall system test throw trace_var trap untrace_var warn auto_complete_field auto_complete_result auto_discovery_link_tag auto_link benchmark button_to cache capture check_box check_box_tag collection_select concat content_for content_tag country_options_for_select country_select current_page? date_select datetime_select debug define_javascript_functions distance_of_time_in_words distance_of_time_in_words_to_now draggable_element drop_receiving_element end_form_tag error_message_on error_messages_for escape_javascript evaluate_remote_response excerpt file_field file_field_tag finish_upload_status form form_remote_tag form_tag form_tag_with_upload_progress h hidden_field hidden_field_tag highlight human_size image_path image_submit_tag image_tag input javascript_include_tag javascript_path javascript_tag link_image_to link_to link_to_function link_to_if link_to_image link_to_remote link_to_unless link_to_unless_current mail_to markdown number_to_currency number_to_human_size number_to_percentage number_to_phone number_with_delimiter number_with_precision observe_field observe_form option_groups_from_collection_for_select options_for_select options_from_collection_for_select pagination_links password_field password_field_tag periodically_call_remote pluralize radio_button radio_button_tag register_template_handler render render_file render_template sanitize select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year simple_format sortable_element start_form_tag strip_links stylesheet_link_tag stylesheet_path submit_tag submit_to_remote tag text_area text_area_tag text_field text_field_tag text_field_with_auto_complete textilize textilize_without_paragraph time_ago_in_words time_zone_options_for_select time_zone_select truncate update_element_function upload_progress_status upload_progress_text upload_progress_update_bar_js upload_status_progress_bar_tag upload_status_tag upload_status_text_tag url_for visual_effect word_wrap"+list_attention = Set.fromList $ words $ "TODO FIXME NOTE"++regex_'3c'25'3d'3f = compileRegex "<%=?"+regex_'3c'21DOCTYPE'5cs'2b = compileRegex "<!DOCTYPE\\s+"+regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a = compileRegex "<\\?[\\w:-]*"+regex_'3cstyle'5cb = compileRegex "<style\\b"+regex_'3cscript'5cb = compileRegex "<script\\b"+regex_'3cpre'5cb = compileRegex "<pre\\b"+regex_'3cdiv'5cb = compileRegex "<div\\b"+regex_'3ctable'5cb = compileRegex "<table\\b"+regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "<[A-Za-z_:][\\w.:_-]*"+regex_'3c'2fpre'5cb = compileRegex "</pre\\b"+regex_'3c'2fdiv'5cb = compileRegex "</div\\b"+regex_'3c'2ftable'5cb = compileRegex "</table\\b"+regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "</[A-Za-z_:][\\w.:_-]*"+regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b = compileRegex "&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\\w.:_-]*);"+regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b = compileRegex "%[A-Za-z_:][\\w.:_-]*;"+regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "[A-Za-z_:][\\w.:_-]*"+regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "\\s+[A-Za-z_:][\\w.:_-]*"+regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb = compileRegex "<!(ELEMENT|ENTITY|ATTLIST|NOTATION)\\b"+regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b = compileRegex "-(-(?!->))+"+regex_'5cS = compileRegex "\\S"+regex_'3c'2fstyle'5cb = compileRegex "</style\\b"+regex_'3c'2fscript'5cb = compileRegex "</script\\b"+regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 = compileRegex "//(?=.*</script\\b)"+regex_'2f'28'3f'21'3e'29 = compileRegex "/(?!>)"+regex_'5b'5e'2f'3e'3c'22'27'5cs'5d = compileRegex "[^/><\"'\\s]"+regex_'2d'3f'25'3e = compileRegex "-?%>"+regex_'5f'5fEND'5f'5f'24 = compileRegex "__END__$"+regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"+regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb = compileRegex "(\\=|\\(|\\[|\\{)\\s*(if|unless|while|until)\\b"+regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "(while|until)\\b(?!.*\\bdo\\b)"+regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\;\\s*(while|until)\\b(?!.*\\bdo\\b)"+regex_'28if'7cunless'29'5cb = compileRegex "(if|unless)\\b"+regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb = compileRegex "\\;\\s*(if|unless)\\b"+regex_'5cbclass'5cb = compileRegex "\\bclass\\b"+regex_'5cbmodule'5cb = compileRegex "\\bmodule\\b"+regex_'5cbbegin'5cb = compileRegex "\\bbegin\\b"+regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\bfor\\b(?!.*\\bdo\\b)"+regex_'5cbcase'5cb = compileRegex "\\bcase\\b"+regex_'5cbdo'5cb = compileRegex "\\bdo\\b"+regex_'5cbdef'5cb = compileRegex "\\bdef\\b"+regex_'5cbend'5cb = compileRegex "\\bend\\b"+regex_'28'5cb'7c'5e'5cs'2a'29'28else'7celsif'7crescue'7censure'29'28'5cs'2b'7c'24'29 = compileRegex "(\\b|^\\s*)(else|elsif|rescue|ensure)(\\s+|$)"+regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 = compileRegex "\\.[_a-z][_a-zA-Z0-9]*(\\?|\\!|\\b)"+regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS = compileRegex "\\s\\?(\\\\M\\-)?(\\\\C\\-)?\\\\?\\S"+regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "\\$[a-zA-Z_0-9]+"+regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb = compileRegex "\\$\\-[a-zA-z_]\\b"+regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'5d = compileRegex "\\$[\\d_*`\\!:?'/\\\\\\-\\&]"+regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb = compileRegex "\\b[_A-Z]+[A-Z_0-9]+\\b"+regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb = compileRegex "\\b[A-Z]+_*([0-9]|[a-z])[_a-zA-Z0-9]*\\b"+regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b = compileRegex "\\b\\-?0[xX][_0-9a-fA-F]+"+regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b = compileRegex "\\b\\-?0[bB][_01]+"+regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a = compileRegex "\\b\\-?0[1-7][_0-7]*"+regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f = compileRegex "\\b\\-?[0-9][0-9_]*\\.[0-9][0-9_]*([eE]\\-?[1-9][0-9]*(\\.[0-9]*)?)?"+regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb = compileRegex "\\b\\-?[1-9][0-9_]*\\b"+regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<-(?=\\w+|[\"'])"+regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|[\"'])"+regex_'5cs'5b'5c'3f'5c'3a'5c'25'2f'5d'5cs = compileRegex "\\s[\\?\\:\\%/]\\s"+regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b = compileRegex "[|&<>\\^\\+*~\\-=]+"+regex_'5cs'21 = compileRegex "\\s!"+regex_'2f'3d'5cs = compileRegex "/=\\s"+regex_'3a'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a = compileRegex ":[a-zA-Z_][a-zA-Z0-9_]*"+regex_'23'5cs'2aBEGIN'2e'2a'24 = compileRegex "#\\s*BEGIN.*$"+regex_'23'5cs'2aEND'2e'2a'24 = compileRegex "#\\s*END.*$"+regex_'23 = compileRegex "#"+regex_'5cs'23 = compileRegex "\\s#"+regex_'5b'5c'5b'5c'5d'5d'2b = compileRegex "[\\[\\]]+"+regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@[a-zA-Z_0-9]+"+regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@@[a-zA-Z_0-9]+"+regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxw'5d'3f'5b'5e'5cs'3e'5d'29 = compileRegex "\\s*[%](?=[Qqxw]?[^\\s>])"+regex_'5c'5c'5c'22 = compileRegex "\\\\\\\""+regex_'23'40'7b1'2c2'7d = compileRegex "#@{1,2}"+regex_'5c'5c'5c'27 = compileRegex "\\\\\\'"+regex_'5c'5c'5c'60 = compileRegex "\\\\\\`"+regex_'5c'5c'5c'2f = compileRegex "\\\\\\/"+regex_'5b'5e'5c'5c'5d'24 = compileRegex "[^\\\\]$"+regex_'2f'5buiomxn'5d'2a = compileRegex "/[uiomxn]*"+regex_'5cw'28'3f'21'5cw'29 = compileRegex "\\w(?!\\w)"+regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?(?=[^\\w\\d\\.\\:])"+regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?"+regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[A-Z]+_*(\\d|[a-z])\\w*(?=[^\\w\\d\\.\\:])"+regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a = compileRegex "[A-Z]+_*([0-9]|[a-z])\\w*"+regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[_A-Z][_A-Z0-9]*(?=[^\\w\\d\\.\\:])"+regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a = compileRegex "[_A-Z][_A-Z0-9]*"+regex_'5cW = compileRegex "\\W"+regex_'5cw'5c'3a'5c'3a'5cs = compileRegex "\\w\\:\\:\\s"+regex_'27'28'5cw'2b'29'27 = compileRegex "'(\\w+)'"+regex_'22'3f'28'5cw'2b'29'22'3f = compileRegex "\"?(\\w+)\"?"+regex_w'5c'28 = compileRegex "w\\("+regex_w'5c'7b = compileRegex "w\\{"+regex_w'5c'5b = compileRegex "w\\["+regex_w'3c = compileRegex "w<"+regex_w'28'5b'5e'5cs'5cw'5d'29 = compileRegex "w([^\\s\\w])"+regex_q'5c'28 = compileRegex "q\\("+regex_q'5c'7b = compileRegex "q\\{"+regex_q'5c'5b = compileRegex "q\\["+regex_q'3c = compileRegex "q<"+regex_q'28'5b'5e'5cs'5cw'5d'29 = compileRegex "q([^\\s\\w])"+regex_x'5c'28 = compileRegex "x\\("+regex_x'5c'7b = compileRegex "x\\{"+regex_x'5c'5b = compileRegex "x\\["+regex_x'3c = compileRegex "x<"+regex_x'28'5b'5e'5cs'5cw'5d'29 = compileRegex "x([^\\s\\w])"+regex_r'5c'28 = compileRegex "r\\("+regex_r'5c'7b = compileRegex "r\\{"+regex_r'5c'5b = compileRegex "r\\["+regex_r'3c = compileRegex "r<"+regex_r'28'5b'5e'5cs'5cw'5d'29 = compileRegex "r([^\\s\\w])"+regex_Q'3f'5c'28 = compileRegex "Q?\\("+regex_Q'3f'5c'7b = compileRegex "Q?\\{"+regex_Q'3f'5c'5b = compileRegex "Q?\\["+regex_Q'3f'3c = compileRegex "Q?<"+regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 = compileRegex "Q?([^\\s\\w])"+regex_'5c'29'5buiomxn'5d'2a = compileRegex "\\)[uiomxn]*"+regex_'5c'7d'5buiomxn'5d'2a = compileRegex "\\}[uiomxn]*"+regex_'5c'5d'5buiomxn'5d'2a = compileRegex "\\][uiomxn]*"+regex_'3e'5buiomxn'5d'2a = compileRegex ">[uiomxn]*"++defaultAttributes = [("Start",NormalTok),("FindHTML",NormalTok),("FindEntityRefs",NormalTok),("FindPEntityRefs",NormalTok),("FindAttributes",NormalTok),("FindDTDRules",NormalTok),("Comment",CommentTok),("CDATA",NormalTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",StringTok),("Doctype Markupdecl SQ",StringTok),("El Open",NormalTok),("El Close",NormalTok),("El Close 2",NormalTok),("El Close 3",NormalTok),("CSS",NormalTok),("CSS content",NormalTok),("JS",NormalTok),("JS content",NormalTok),("JS comment close",CommentTok),("Value",NormalTok),("Value NQ",NormalTok),("Value DQ",StringTok),("Value SQ",StringTok),("rubysourceline",NormalTok),("rubysource",NormalTok),("Line Continue",NormalTok),("Quoted String",StringTok),("Apostrophed String",StringTok),("Command String",StringTok),("Embedded documentation",CommentTok),("RegEx 1",OtherTok),("Subst",NormalTok),("Short Subst",OtherTok),("Member Access",NormalTok),("Comment Line",CommentTok),("General Comment",CommentTok),("RDoc Label",OtherTok),("find_heredoc",NormalTok),("find_indented_heredoc",NormalTok),("indented_heredoc",NormalTok),("apostrophed_indented_heredoc",NormalTok),("normal_heredoc",NormalTok),("apostrophed_normal_heredoc",NormalTok),("heredoc_rules",NormalTok),("find_gdl_input",NormalTok),("gdl_dq_string_1",StringTok),("gdl_dq_string_1_nested",StringTok),("gdl_dq_string_2",StringTok),("gdl_dq_string_2_nested",StringTok),("gdl_dq_string_3",StringTok),("gdl_dq_string_3_nested",StringTok),("gdl_dq_string_4",StringTok),("gdl_dq_string_4_nested",StringTok),("gdl_dq_string_5",StringTok),("dq_string_rules",StringTok),("gdl_token_array_1",StringTok),("gdl_token_array_1_nested",StringTok),("gdl_token_array_2",StringTok),("gdl_token_array_2_nested",StringTok),("gdl_token_array_3",StringTok),("gdl_token_array_3_nested",StringTok),("gdl_token_array_4",StringTok),("gdl_token_array_4_nested",StringTok),("gdl_token_array_5",StringTok),("token_array_rules",StringTok),("gdl_apostrophed_1",StringTok),("gdl_apostrophed_1_nested",StringTok),("gdl_apostrophed_2",StringTok),("gdl_apostrophed_2_nested",StringTok),("gdl_apostrophed_3",StringTok),("gdl_apostrophed_3_nested",StringTok),("gdl_apostrophed_4",StringTok),("gdl_apostrophed_4_nested",StringTok),("gdl_apostrophed_5",StringTok),("apostrophed_rules",StringTok),("gdl_shell_command_1",StringTok),("gdl_shell_command_1_nested",StringTok),("gdl_shell_command_2",StringTok),("gdl_shell_command_2_nested",StringTok),("gdl_shell_command_3",StringTok),("gdl_shell_command_3_nested",StringTok),("gdl_shell_command_4",StringTok),("gdl_shell_command_4_nested",StringTok),("gdl_shell_command_5",StringTok),("shell_command_rules",StringTok),("gdl_regexpr_1",OtherTok),("gdl_regexpr_1_nested",OtherTok),("gdl_regexpr_2",OtherTok),("gdl_regexpr_2_nested",OtherTok),("gdl_regexpr_3",OtherTok),("gdl_regexpr_3_nested",OtherTok),("gdl_regexpr_4",OtherTok),("gdl_regexpr_4_nested",OtherTok),("gdl_regexpr_5",OtherTok),("regexpr_rules",OtherTok),("DATA",NormalTok)]++parseRules "Start" =+ ((parseRules "FindHTML"))++parseRules "FindHTML" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pString False "%" >>= withAttribute KeywordTok) >>~ pushContext "rubysourceline")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pRegExpr regex_'3cstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "CSS")+ <|>+ ((pRegExpr regex_'3cscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "JS")+ <|>+ ((pRegExpr regex_'3cpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3cdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3ctable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Open")+ <|>+ ((pRegExpr regex_'3c'2fpre'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2fdiv'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2ftable'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El Close")+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((parseRules "FindEntityRefs")))++parseRules "FindEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&<" >>= withAttribute ErrorTok)))++parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute ErrorTok)))++parseRules "FindAttributes" =+ (((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value"))++parseRules "FindDTDRules" =+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl")++parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok)))++parseRules "CDATA" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok)))++parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext))++parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset"))++parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((parseRules "FindDTDRules"))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs")))++parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl SQ"))++parseRules "Doctype Markupdecl DQ" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs")))++parseRules "Doctype Markupdecl SQ" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs")))++parseRules "El Open" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "El Close" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "El Close 2" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "El Close 3" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "CSS" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "CSS content")+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "CSS content" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pRegExpr regex_'3c'2fstyle'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((Text.Highlighting.Kate.Syntax.Css.parseExpression)))++parseRules "JS" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "JS content")+ <|>+ ((parseRules "FindAttributes"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok)))++parseRules "JS content" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 2")+ <|>+ ((pRegExpr regex_'2f'2f'28'3f'3d'2e'2a'3c'2fscript'5cb'29 >>= withAttribute CommentTok) >>~ pushContext "JS comment close")+ <|>+ ((Text.Highlighting.Kate.Syntax.Javascript.parseExpression)))++parseRules "JS comment close" =+ (((pRegExpr regex_'3c'2fscript'5cb >>= withAttribute KeywordTok) >>~ pushContext "El Close 3")+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))))++parseRules "Value" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Value DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Value SQ")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ (pushContext "Value NQ" >> currentContext >>= parseRules))++parseRules "Value NQ" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((parseRules "FindEntityRefs"))+ <|>+ ((pRegExpr regex_'2f'28'3f'21'3e'29 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5b'5e'2f'3e'3c'22'27'5cs'5d >>= withAttribute StringTok))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "Value DQ" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs")))++parseRules "Value SQ" =+ (((pRegExpr regex_'3c'25'3d'3f >>= withAttribute KeywordTok) >>~ pushContext "rubysource")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs")))++parseRules "rubysourceline" =+ ((parseRules "rubysource"))++parseRules "rubysource" =+ (((pLineContinue >>= withAttribute NormalTok) >>~ pushContext "Line Continue")+ <|>+ ((pRegExpr regex_'2d'3f'25'3e >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pColumn 0 >> pRegExpr regex_'5f'5fEND'5f'5f'24 >>= withAttribute KeywordTok) >>~ pushContext "DATA")+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbclass'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbmodule'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbcase'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdo'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdef'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5cb'7c'5e'5cs'2a'29'28else'7celsif'7crescue'7censure'29'28'5cs'2b'7c'24'29 >>= withAttribute KeywordTok))+ <|>+ ((pString False "..." >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS >>= withAttribute DecValTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attribute'2ddefinitions >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_access'2dcontrol >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_definitions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_pseudo'2dvariables >>= withAttribute DecValTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_default'2dglobals >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_kernel'2dmethods >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'5d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb >>= withAttribute DecValTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pString False "=begin" >>= withAttribute CommentTok) >>~ pushContext "Embedded documentation")+ <|>+ ((pRegExpr regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute CharTok) >>~ pushContext "find_indented_heredoc")+ <|>+ ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute CharTok) >>~ pushContext "find_heredoc")+ <|>+ ((pDetectChar False '.' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '&' '&' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '|' '|' >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5cs'5b'5c'3f'5c'3a'5c'25'2f'5d'5cs >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5cs'21 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'2f'3d'5cs >>= withAttribute CharTok))+ <|>+ ((pString False "%=" >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute CharTok) >>~ pushContext "Member Access")+ <|>+ ((pRegExpr regex_'3a'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Quoted String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Apostrophed String")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "Command String")+ <|>+ ((pString False "?#" >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23 >>= withAttribute CommentTok) >>~ pushContext "Comment Line")+ <|>+ ((pRegExpr regex_'5cs'23 >>= withAttribute CommentTok) >>~ pushContext "General Comment")+ <|>+ ((pRegExpr regex_'5b'5c'5b'5c'5d'5d'2b >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '/' >>= withAttribute OtherTok) >>~ pushContext "RegEx 1")+ <|>+ ((pRegExpr regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxw'5d'3f'5b'5e'5cs'3e'5d'29 >>= withAttribute OtherTok) >>~ pushContext "find_gdl_input"))++parseRules "Line Continue" =+ (((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((parseRules "rubysource")))++parseRules "Quoted String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'22 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "Apostrophed String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'27 >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "Command String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'60 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pHlCChar >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "Embedded documentation" =+ ((pColumn 0 >> pString False "=end" >>= withAttribute CommentTok) >>~ (popContext))++parseRules "RegEx 1" =+ (((pRegExpr regex_'5c'5c'5c'2f >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5b'5e'5c'5c'5d'24 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pRegExpr regex_'2f'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "Subst" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "rubysource")))++parseRules "Short Subst" =+ (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cw'28'3f'21'5cw'29 >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "Member Access" =+ (((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '.' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "=+-*/%|&[]{}~" >>= withAttribute CharTok) >>~ (popContext))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pAnyChar "()\\" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cW >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "Comment Line" =+ (((pRegExpr regex_'5cw'5c'3a'5c'3a'5cs >>= withAttribute CommentTok) >>~ pushContext "RDoc Label")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attention >>= withAttribute AlertTok))+ <|>+ ((pRegExpr regex_'2d'3f'25'3e >>= withAttribute KeywordTok) >>~ (popContext >> popContext)))++parseRules "General Comment" =+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attention >>= withAttribute DecValTok))++parseRules "RDoc Label" =+ pzero++parseRules "find_heredoc" =+ (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute KeywordTok) >>~ pushContext "apostrophed_normal_heredoc")+ <|>+ ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute KeywordTok) >>~ pushContext "normal_heredoc"))++parseRules "find_indented_heredoc" =+ (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute KeywordTok) >>~ pushContext "apostrophed_indented_heredoc")+ <|>+ ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute KeywordTok) >>~ pushContext "indented_heredoc"))++parseRules "indented_heredoc" =+ (((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "heredoc_rules")))++parseRules "apostrophed_indented_heredoc" =+ ((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))++parseRules "normal_heredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "heredoc_rules")))++parseRules "apostrophed_normal_heredoc" =+ ((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))++parseRules "heredoc_rules" =+ (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "find_gdl_input" =+ (((pRegExpr regex_w'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_1")+ <|>+ ((pRegExpr regex_w'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_2")+ <|>+ ((pRegExpr regex_w'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_3")+ <|>+ ((pRegExpr regex_w'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_4")+ <|>+ ((pRegExpr regex_w'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_5")+ <|>+ ((pRegExpr regex_q'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_1")+ <|>+ ((pRegExpr regex_q'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_2")+ <|>+ ((pRegExpr regex_q'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_3")+ <|>+ ((pRegExpr regex_q'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_4")+ <|>+ ((pRegExpr regex_q'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_5")+ <|>+ ((pRegExpr regex_x'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_1")+ <|>+ ((pRegExpr regex_x'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_2")+ <|>+ ((pRegExpr regex_x'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_3")+ <|>+ ((pRegExpr regex_x'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_4")+ <|>+ ((pRegExpr regex_x'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_5")+ <|>+ ((pRegExpr regex_r'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1")+ <|>+ ((pRegExpr regex_r'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2")+ <|>+ ((pRegExpr regex_r'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3")+ <|>+ ((pRegExpr regex_r'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4")+ <|>+ ((pRegExpr regex_r'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_5")+ <|>+ ((pRegExpr regex_Q'3f'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_1")+ <|>+ ((pRegExpr regex_Q'3f'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_2")+ <|>+ ((pRegExpr regex_Q'3f'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_3")+ <|>+ ((pRegExpr regex_Q'3f'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_4")+ <|>+ ((pRegExpr regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_5"))++parseRules "gdl_dq_string_1" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_1_nested" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_dq_string_2" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_2_nested"))++parseRules "gdl_dq_string_2_nested" =+ (((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_3" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_3_nested" =+ (((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_4" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_4_nested" =+ (((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_5" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "dq_string_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "gdl_token_array_1" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_1_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_2" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_2_nested"))++parseRules "gdl_token_array_2_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_3" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_3_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_4" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_4_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_5" =+ (((parseRules "token_array_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "token_array_rules" =+ ((pString False "\\\\" >>= withAttribute StringTok))++parseRules "gdl_apostrophed_1" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_1_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_2" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_2_nested"))++parseRules "gdl_apostrophed_2_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_3" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_3_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_4" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_4_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_5" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "apostrophed_rules" =+ ((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))++parseRules "gdl_shell_command_1" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_1_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_2" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_2_nested"))++parseRules "gdl_shell_command_2_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_3" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_3_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_4" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_4_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_5" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "shell_command_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "gdl_regexpr_1" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1_nested")+ <|>+ ((pRegExpr regex_'5c'29'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_1_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_2" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'7d'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2_nested"))++parseRules "gdl_regexpr_2_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_3" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3_nested")+ <|>+ ((pRegExpr regex_'5c'5d'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_3_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_4" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4_nested")+ <|>+ ((pRegExpr regex_'3e'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_4_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_5" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute OtherTok))+ <|>+ ((pRegExprDynamic "\\s*%1[uiomxn]*" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "regexpr_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "DATA" = pzero parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Ruby.hs view
@@ -1,1099 +1,1012 @@-{- This module was generated from data in the Kate syntax highlighting file ruby.xml, version 1.24,- by Stefan Lang (langstefan@gmx.at), Sebastian Vuorinen (sebastian.vuorinen@helsinki.fi), Robin Pedersen (robinpeder@gmail.com), Miquel Sabaté (mikisabate@gmail.com) -}--module Text.Highlighting.Kate.Syntax.Ruby ( 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 Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "Ruby"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.rb;*.rjs;*.rxml;*.xml.erb;*.js.erb;*.rake;Rakefile;Gemfile;*.gemspec"---- | 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 = "Ruby" }- 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 [("Ruby",["Normal"])], synStLanguage = "Ruby", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "Normal" -> return () >> pHandleEndLine- "check_div_1" -> (popContext) >> pEndLine- "check_div_1_pop" -> (popContext >> popContext) >> pEndLine- "check_div_2" -> (popContext) >> pEndLine- "check_div_2_internal" -> (popContext >> popContext) >> pEndLine- "check_div_2_pop" -> (popContext >> popContext) >> pEndLine- "check_div_2_pop_internal" -> (popContext >> popContext >> popContext) >> pEndLine- "Line Continue" -> (popContext) >> pEndLine- "Find closing block brace" -> return () >> pHandleEndLine- "Quoted String" -> return () >> pHandleEndLine- "Apostrophed String" -> return () >> pHandleEndLine- "Command String" -> return () >> pHandleEndLine- "Embedded documentation" -> return () >> pHandleEndLine- "RegEx 1" -> return () >> pHandleEndLine- "Subst" -> return () >> pHandleEndLine- "Short Subst" -> (popContext) >> pEndLine- "Member Access" -> (popContext) >> pEndLine- "Comment Line" -> (popContext) >> pEndLine- "General Comment" -> (popContext) >> pEndLine- "RDoc Label" -> (popContext) >> pEndLine- "find_heredoc" -> (popContext) >> pEndLine- "find_indented_heredoc" -> (popContext) >> pEndLine- "indented_heredoc" -> return () >> pHandleEndLine- "apostrophed_indented_heredoc" -> return () >> pHandleEndLine- "normal_heredoc" -> return () >> pHandleEndLine- "apostrophed_normal_heredoc" -> return () >> pHandleEndLine- "heredoc_rules" -> return () >> pHandleEndLine- "find_gdl_input" -> (popContext) >> pEndLine- "gdl_dq_string_1" -> return () >> pHandleEndLine- "gdl_dq_string_1_nested" -> return () >> pHandleEndLine- "gdl_dq_string_2" -> return () >> pHandleEndLine- "gdl_dq_string_2_nested" -> return () >> pHandleEndLine- "gdl_dq_string_3" -> return () >> pHandleEndLine- "gdl_dq_string_3_nested" -> return () >> pHandleEndLine- "gdl_dq_string_4" -> return () >> pHandleEndLine- "gdl_dq_string_4_nested" -> return () >> pHandleEndLine- "gdl_dq_string_5" -> return () >> pHandleEndLine- "dq_string_rules" -> return () >> pHandleEndLine- "gdl_token_array_1" -> return () >> pHandleEndLine- "gdl_token_array_1_nested" -> return () >> pHandleEndLine- "gdl_token_array_2" -> return () >> pHandleEndLine- "gdl_token_array_2_nested" -> return () >> pHandleEndLine- "gdl_token_array_3" -> return () >> pHandleEndLine- "gdl_token_array_3_nested" -> return () >> pHandleEndLine- "gdl_token_array_4" -> return () >> pHandleEndLine- "gdl_token_array_4_nested" -> return () >> pHandleEndLine- "gdl_token_array_5" -> return () >> pHandleEndLine- "token_array_rules" -> return () >> pHandleEndLine- "gdl_apostrophed_1" -> return () >> pHandleEndLine- "gdl_apostrophed_1_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_2" -> return () >> pHandleEndLine- "gdl_apostrophed_2_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_3" -> return () >> pHandleEndLine- "gdl_apostrophed_3_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_4" -> return () >> pHandleEndLine- "gdl_apostrophed_4_nested" -> return () >> pHandleEndLine- "gdl_apostrophed_5" -> return () >> pHandleEndLine- "apostrophed_rules" -> return () >> pHandleEndLine- "gdl_shell_command_1" -> return () >> pHandleEndLine- "gdl_shell_command_1_nested" -> return () >> pHandleEndLine- "gdl_shell_command_2" -> return () >> pHandleEndLine- "gdl_shell_command_2_nested" -> return () >> pHandleEndLine- "gdl_shell_command_3" -> return () >> pHandleEndLine- "gdl_shell_command_3_nested" -> return () >> pHandleEndLine- "gdl_shell_command_4" -> return () >> pHandleEndLine- "gdl_shell_command_4_nested" -> return () >> pHandleEndLine- "gdl_shell_command_5" -> return () >> pHandleEndLine- "shell_command_rules" -> return () >> pHandleEndLine- "gdl_regexpr_1" -> return () >> pHandleEndLine- "gdl_regexpr_1_nested" -> return () >> pHandleEndLine- "gdl_regexpr_2" -> return () >> pHandleEndLine- "gdl_regexpr_2_nested" -> return () >> pHandleEndLine- "gdl_regexpr_3" -> return () >> pHandleEndLine- "gdl_regexpr_3_nested" -> return () >> pHandleEndLine- "gdl_regexpr_4" -> return () >> pHandleEndLine- "gdl_regexpr_4_nested" -> return () >> pHandleEndLine- "gdl_regexpr_5" -> return () >> pHandleEndLine- "regexpr_rules" -> return () >> pHandleEndLine- "DATA" -> return () >> pHandleEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Attribute Definition","ot"),("Access Control","kw"),("Definition","kw"),("Pseudo variable","dv"),("Dec","dv"),("Float","fl"),("Char","ch"),("Octal","bn"),("Hex","bn"),("Bin","bn"),("Symbol","st"),("String","st"),("Raw String","st"),("Command","st"),("Regular Expression","ot"),("Substitution","ot"),("GDL input","ot"),("Default globals","dt"),("Global Variable","dt"),("Global Constant","dt"),("Constant","dt"),("Constant Value","dt"),("Instance Variable","ot"),("Class Variable","ot"),("Comment","co"),("Blockcomment","co"),("RDoc Value","ot"),("Here Document","ot"),("Error","er"),("Expression","ot")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_keywords = Set.fromList $ words $ "BEGIN END and begin break case defined? do else elsif end ensure for if in include next not or redo rescue retry return then unless until when yield"-list_access'2dcontrol = Set.fromList $ words $ "private_class_method private protected public_class_method public"-list_attribute'2ddefinitions = Set.fromList $ words $ "attr_reader attr_writer attr_accessor"-list_definitions = Set.fromList $ words $ "alias module class def undef"-list_pseudo'2dvariables = Set.fromList $ words $ "self super nil false true caller __FILE__ __LINE__"-list_default'2dglobals = Set.fromList $ words $ "$stdout $defout $stderr $deferr $stdin"-list_kernel'2dmethods = Set.fromList $ words $ "abort at_exit autoload autoload? binding block_given? callcc caller catch chomp chomp! chop chop! eval exec exit exit! fail fork format getc gets global_variables gsub gsub! iterator? lambda load local_variables loop method_missing open p print printf proc putc puts raise rand readline readlines require require_relative scan select set_trace_func sleep split sprintf srand sub sub! syscall system test throw trace_var trap untrace_var warn"--regex_'5f'5fEND'5f'5f'24 = compileRegex "__END__$"-regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"-regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb = compileRegex "(\\=|\\(|\\[|\\{)\\s*(if|unless|while|until)\\b"-regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "(while|until)\\b(?!.*\\bdo\\b)"-regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\;\\s*(while|until)\\b(?!.*\\bdo\\b)"-regex_'28if'7cunless'29'5cb = compileRegex "(if|unless)\\b"-regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb = compileRegex "\\;\\s*(if|unless)\\b"-regex_'5cbclass'5cb = compileRegex "\\bclass\\b"-regex_'5cbmodule'5cb = compileRegex "\\bmodule\\b"-regex_'5cbbegin'5cb = compileRegex "\\bbegin\\b"-regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\bfor\\b(?!.*\\bdo\\b)"-regex_'5cbcase'5cb = compileRegex "\\bcase\\b"-regex_'5cbdo'5cb = compileRegex "\\bdo\\b"-regex_'5cbdef'5cb = compileRegex "\\bdef\\b"-regex_'5cbend'5cb = compileRegex "\\bend\\b"-regex_'5cb'28else'7celsif'7crescue'7censure'29'5cb = compileRegex "\\b(else|elsif|rescue|ensure)\\b"-regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 = compileRegex "\\.[_a-z][_a-zA-Z0-9]*(\\?|\\!|\\b)"-regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS = compileRegex "\\s\\?(\\\\M\\-)?(\\\\C\\-)?\\\\?\\S"-regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "\\$[a-zA-Z_0-9]+"-regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb = compileRegex "\\$\\-[a-zA-z_]\\b"-regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'22'5d = compileRegex "\\$[\\d_*`\\!:?'/\\\\\\-\\&\"]"-regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb = compileRegex "\\b[_A-Z]+[A-Z_0-9]+\\b"-regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb = compileRegex "\\b[A-Z]+_*([0-9]|[a-z])[_a-zA-Z0-9]*\\b"-regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b = compileRegex "\\b\\-?0[xX][_0-9a-fA-F]+"-regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b = compileRegex "\\b\\-?0[bB][_01]+"-regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a = compileRegex "\\b\\-?0[1-7][_0-7]*"-regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f = compileRegex "\\b\\-?[0-9][0-9_]*\\.[0-9][0-9_]*([eE]\\-?[1-9][0-9]*(\\.[0-9]*)?)?"-regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb = compileRegex "\\b\\-?[1-9][0-9_]*\\b"-regex_'3dbegin'28'3f'3a'5cs'7c'24'29 = compileRegex "=begin(?:\\s|$)"-regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<-(?=\\w+|[\"'])"-regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|[\"'])"-regex_'5cs'5b'5c'3f'5c'3a'5c'25'5d'5cs = compileRegex "\\s[\\?\\:\\%]\\s"-regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b = compileRegex "[|&<>\\^\\+*~\\-=]+"-regex_'5cs'21 = compileRegex "\\s!"-regex_'2f'3d'5cs = compileRegex "/=\\s"-regex_'3a'28'40'7b1'2c2'7d'7c'5c'24'29'3f'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5b'3d'3f'21'5d'3f = compileRegex ":(@{1,2}|\\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?"-regex_'3a'5c'5b'5c'5d'3d'3f = compileRegex ":\\[\\]=?"-regex_'23'5cs'2aBEGIN'2e'2a'24 = compileRegex "#\\s*BEGIN.*$"-regex_'23'5cs'2aEND'2e'2a'24 = compileRegex "#\\s*END.*$"-regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@[a-zA-Z_0-9]+"-regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@@[a-zA-Z_0-9]+"-regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxwW'5d'3f'5b'5e'5cs'5d'29 = compileRegex "\\s*[%](?=[QqxwW]?[^\\s])"-regex_'5cs'2a = compileRegex "\\s*"-regex_'5cs'2b = compileRegex "\\s+"-regex_'5b'2f'25'5d'28'3f'3d'5cs'29 = compileRegex "[/%](?=\\s)"-regex_'2f'28'3f'3d'5cs'29 = compileRegex "/(?=\\s)"-regex_'5c'5c'5c'22 = compileRegex "\\\\\\\""-regex_'23'40'7b1'2c2'7d = compileRegex "#@{1,2}"-regex_'5c'5c'5c'27 = compileRegex "\\\\\\'"-regex_'5c'5c'5c'60 = compileRegex "\\\\\\`"-regex_'3dend'28'3f'3a'5cs'2e'2a'7c'24'29 = compileRegex "=end(?:\\s.*|$)"-regex_'5c'5c'5c'2f = compileRegex "\\\\\\/"-regex_'2f'5buiomxn'5d'2a = compileRegex "/[uiomxn]*"-regex_'5cw'28'3f'21'5cw'29 = compileRegex "\\w(?!\\w)"-regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?(?=[^\\w\\d\\.\\:])"-regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?"-regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[A-Z]+_*(\\d|[a-z])\\w*(?=[^\\w\\d\\.\\:])"-regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a = compileRegex "[A-Z]+_*([0-9]|[a-z])\\w*"-regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[_A-Z][_A-Z0-9]*(?=[^\\w\\d\\.\\:])"-regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a = compileRegex "[_A-Z][_A-Z0-9]*"-regex_'5cW = compileRegex "\\W"-regex_'5cw'5c'3a'5c'3a'5cs = compileRegex "\\w\\:\\:\\s"-regex_'27'28'5cw'2b'29'27 = compileRegex "'(\\w+)'"-regex_'22'3f'28'5cw'2b'29'22'3f = compileRegex "\"?(\\w+)\"?"-regex_w'5c'28 = compileRegex "w\\("-regex_w'5c'7b = compileRegex "w\\{"-regex_w'5c'5b = compileRegex "w\\["-regex_w'3c = compileRegex "w<"-regex_w'28'5b'5e'5cs'5cw'5d'29 = compileRegex "w([^\\s\\w])"-regex_W'5c'28 = compileRegex "W\\("-regex_W'5c'7b = compileRegex "W\\{"-regex_W'5c'5b = compileRegex "W\\["-regex_W'3c = compileRegex "W<"-regex_W'28'5b'5e'5cs'5cw'5d'29 = compileRegex "W([^\\s\\w])"-regex_q'5c'28 = compileRegex "q\\("-regex_q'5c'7b = compileRegex "q\\{"-regex_q'5c'5b = compileRegex "q\\["-regex_q'3c = compileRegex "q<"-regex_q'28'5b'5e'5cs'5cw'5d'29 = compileRegex "q([^\\s\\w])"-regex_x'5c'28 = compileRegex "x\\("-regex_x'5c'7b = compileRegex "x\\{"-regex_x'5c'5b = compileRegex "x\\["-regex_x'3c = compileRegex "x<"-regex_x'28'5b'5e'5cs'5cw'5d'29 = compileRegex "x([^\\s\\w])"-regex_r'5c'28 = compileRegex "r\\("-regex_r'5c'7b = compileRegex "r\\{"-regex_r'5c'5b = compileRegex "r\\["-regex_r'3c = compileRegex "r<"-regex_r'28'5b'5e'5cs'5cw'5d'29 = compileRegex "r([^\\s\\w])"-regex_Q'3f'5c'28 = compileRegex "Q?\\("-regex_Q'3f'5c'7b = compileRegex "Q?\\{"-regex_Q'3f'5c'5b = compileRegex "Q?\\["-regex_Q'3f'3c = compileRegex "Q?<"-regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 = compileRegex "Q?([^\\s\\w])"-regex_'5c'29'5buiomxn'5d'2a = compileRegex "\\)[uiomxn]*"-regex_'5c'7d'5buiomxn'5d'2a = compileRegex "\\}[uiomxn]*"-regex_'5c'5d'5buiomxn'5d'2a = compileRegex "\\][uiomxn]*"-regex_'3e'5buiomxn'5d'2a = compileRegex ">[uiomxn]*"--defaultAttributes = [("Normal","Normal Text"),("check_div_1","Normal Text"),("check_div_1_pop","Normal Text"),("check_div_2","Normal Text"),("check_div_2_internal","Normal Text"),("check_div_2_pop","Normal Text"),("check_div_2_pop_internal","Normal Text"),("Line Continue","Normal Text"),("Find closing block brace","Normal Text"),("Quoted String","String"),("Apostrophed String","Raw String"),("Command String","Command"),("Embedded documentation","Blockcomment"),("RegEx 1","Regular Expression"),("Subst","Normal Text"),("Short Subst","Substitution"),("Member Access","Member"),("Comment Line","Comment"),("General Comment","Comment"),("RDoc Label","RDoc Value"),("find_heredoc","Normal Text"),("find_indented_heredoc","Normal Text"),("indented_heredoc","Here Document"),("apostrophed_indented_heredoc","Here Document"),("normal_heredoc","Here Document"),("apostrophed_normal_heredoc","Here Document"),("heredoc_rules","Normal Text"),("find_gdl_input","Normal Text"),("gdl_dq_string_1","String"),("gdl_dq_string_1_nested","String"),("gdl_dq_string_2","String"),("gdl_dq_string_2_nested","String"),("gdl_dq_string_3","String"),("gdl_dq_string_3_nested","String"),("gdl_dq_string_4","String"),("gdl_dq_string_4_nested","String"),("gdl_dq_string_5","String"),("dq_string_rules","String"),("gdl_token_array_1","String"),("gdl_token_array_1_nested","String"),("gdl_token_array_2","String"),("gdl_token_array_2_nested","String"),("gdl_token_array_3","String"),("gdl_token_array_3_nested","String"),("gdl_token_array_4","String"),("gdl_token_array_4_nested","String"),("gdl_token_array_5","String"),("token_array_rules","String"),("gdl_apostrophed_1","Raw String"),("gdl_apostrophed_1_nested","Raw String"),("gdl_apostrophed_2","Raw String"),("gdl_apostrophed_2_nested","Raw String"),("gdl_apostrophed_3","Raw String"),("gdl_apostrophed_3_nested","Raw String"),("gdl_apostrophed_4","Raw String"),("gdl_apostrophed_4_nested","Raw String"),("gdl_apostrophed_5","Raw String"),("apostrophed_rules","Raw String"),("gdl_shell_command_1","Command"),("gdl_shell_command_1_nested","Command"),("gdl_shell_command_2","Command"),("gdl_shell_command_2_nested","Command"),("gdl_shell_command_3","Command"),("gdl_shell_command_3_nested","Command"),("gdl_shell_command_4","Command"),("gdl_shell_command_4_nested","Command"),("gdl_shell_command_5","Command"),("shell_command_rules","Command"),("gdl_regexpr_1","Regular Expression"),("gdl_regexpr_1_nested","Regular Expression"),("gdl_regexpr_2","Regular Expression"),("gdl_regexpr_2_nested","Regular Expression"),("gdl_regexpr_3","Regular Expression"),("gdl_regexpr_3_nested","Regular Expression"),("gdl_regexpr_4","Regular Expression"),("gdl_regexpr_4_nested","Regular Expression"),("gdl_regexpr_5","Regular Expression"),("regexpr_rules","Regular Expression"),("DATA","Data")]--parseRules "Normal" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Normal Text") >>~ pushContext "Line Continue")- <|>- ((pColumn 0 >> pRegExpr regex_'5f'5fEND'5f'5f'24 >>= withAttribute "Keyword") >>~ pushContext "DATA")- <|>- ((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "Find closing block brace")- <|>- ((pRegExpr regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbclass'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbmodule'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbcase'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbdo'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbdef'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cbend'5cb >>= withAttribute "Keyword"))- <|>- ((pRegExpr regex_'5cb'28else'7celsif'7crescue'7censure'29'5cb >>= withAttribute "Keyword"))- <|>- ((pString False "..." >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '.' '.' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 >>= withAttribute "Message") >>~ pushContext "check_div_2")- <|>- ((pRegExpr regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS >>= withAttribute "Dec") >>~ pushContext "check_div_1")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attribute'2ddefinitions >>= withAttribute "Attribute Definition") >>~ pushContext "check_div_2")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_access'2dcontrol >>= withAttribute "Access Control") >>~ pushContext "check_div_2")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_definitions >>= withAttribute "Definition"))- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_pseudo'2dvariables >>= withAttribute "Pseudo variable") >>~ pushContext "check_div_1")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_default'2dglobals >>= withAttribute "Default globals") >>~ pushContext "check_div_2")- <|>- ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_kernel'2dmethods >>= withAttribute "Kernel methods") >>~ pushContext "check_div_2")- <|>- ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Global Variable") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb >>= withAttribute "Global Variable") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'22'5d >>= withAttribute "Default globals") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb >>= withAttribute "Global Constant") >>~ pushContext "check_div_2")- <|>- ((pRegExpr regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb >>= withAttribute "Constant") >>~ pushContext "check_div_2")- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b >>= withAttribute "Hex") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b >>= withAttribute "Bin") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a >>= withAttribute "Octal") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f >>= withAttribute "Float") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb >>= withAttribute "Dec") >>~ pushContext "check_div_1")- <|>- ((pInt >>= withAttribute "Dec") >>~ pushContext "check_div_1")- <|>- ((pHlCChar >>= withAttribute "Char") >>~ pushContext "check_div_1")- <|>- ((pColumn 0 >> pRegExpr regex_'3dbegin'28'3f'3a'5cs'7c'24'29 >>= withAttribute "Blockcomment") >>~ pushContext "Embedded documentation")- <|>- ((pRegExpr regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_indented_heredoc")- <|>- ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute "Operator") >>~ pushContext "find_heredoc")- <|>- ((pDetectChar False '.' >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '&' '&' >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False '|' '|' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5cs'5b'5c'3f'5c'3a'5c'25'5d'5cs >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5cs'21 >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'2f'3d'5cs >>= withAttribute "Operator"))- <|>- ((pString False "%=" >>= withAttribute "Operator"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Operator") >>~ pushContext "Member Access")- <|>- ((pRegExpr regex_'3a'28'40'7b1'2c2'7d'7c'5c'24'29'3f'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5b'3d'3f'21'5d'3f >>= withAttribute "Symbol") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'3a'5c'5b'5c'5d'3d'3f >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "Quoted String")- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ pushContext "Apostrophed String")- <|>- ((pDetectChar False '`' >>= withAttribute "Command") >>~ pushContext "Command String")- <|>- ((pString False "?#" >>= withAttribute "Normal Text"))- <|>- ((pColumn 0 >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pColumn 0 >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "General Comment")- <|>- ((pDetectChar False '[' >>= withAttribute "Delimiter"))- <|>- ((pDetectChar False ']' >>= withAttribute "Delimiter") >>~ pushContext "check_div_1")- <|>- ((pDetectChar False '{' >>= withAttribute "Delimiter"))- <|>- ((pDetectChar False '}' >>= withAttribute "Delimiter") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Instance Variable") >>~ pushContext "check_div_1")- <|>- ((pRegExpr regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute "Class Variable") >>~ pushContext "check_div_1")- <|>- ((pDetectChar False '/' >>= withAttribute "Regular Expression") >>~ pushContext "RegEx 1")- <|>- ((pRegExpr regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxwW'5d'3f'5b'5e'5cs'5d'29 >>= withAttribute "GDL input") >>~ pushContext "find_gdl_input")- <|>- ((pDetectChar False ')' >>= withAttribute "Normal Text") >>~ pushContext "check_div_1")- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text") >>~ pushContext "check_div_2"))- return (attr, result)--parseRules "check_div_1" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a >>= withAttribute "Normal Text"))- <|>- ((pAnyChar "/%" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "check_div_1_pop" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a >>= withAttribute "Normal Text"))- <|>- ((pAnyChar "/%" >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "check_div_2" = - do (attr, result) <- (((pAnyChar "/%" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Normal Text") >>~ pushContext "check_div_2_internal")- <|>- ((popContext) >> return ([], "")))- return (attr, result)--parseRules "check_div_2_internal" = - do (attr, result) <- (((pRegExpr regex_'5b'2f'25'5d'28'3f'3d'5cs'29 >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "check_div_2_pop" = - do (attr, result) <- (((pAnyChar "/%" >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cs'2b >>= withAttribute "Normal Text") >>~ pushContext "check_div_2_pop_internal")- <|>- ((popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "check_div_2_pop_internal" = - do (attr, result) <- (((pDetectChar False '%' >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'2f'28'3f'3d'5cs'29 >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext))- <|>- ((popContext >> popContext >> popContext) >> return ([], "")))- return (attr, result)--parseRules "Line Continue" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute "Keyword"))- <|>- ((parseRules "Normal")))- return (attr, result)--parseRules "Find closing block brace" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Operator") >>~ pushContext "check_div_1_pop")- <|>- ((parseRules "Normal")))- return (attr, result)--parseRules "Quoted String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'22 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "check_div_1_pop"))- return (attr, result)--parseRules "Apostrophed String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'27 >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Raw String") >>~ pushContext "check_div_1_pop"))- return (attr, result)--parseRules "Command String" = - do (attr, result) <- (((pString False "\\\\" >>= withAttribute "String"))- <|>- ((pRegExpr regex_'5c'5c'5c'60 >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pDetectChar False '`' >>= withAttribute "Command") >>~ pushContext "check_div_1_pop"))- return (attr, result)--parseRules "Embedded documentation" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'3dend'28'3f'3a'5cs'2e'2a'7c'24'29 >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)--parseRules "RegEx 1" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5c'2f >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst")- <|>- ((pRegExpr regex_'2f'5buiomxn'5d'2a >>= withAttribute "Regular Expression") >>~ pushContext "check_div_1_pop"))- return (attr, result)--parseRules "Subst" = - do (attr, result) <- (((pDetectChar False '}' >>= withAttribute "Substitution") >>~ (popContext))- <|>- ((parseRules "Normal")))- return (attr, result)--parseRules "Short Subst" = - do (attr, result) <- (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution"))- <|>- ((pRegExpr regex_'5cw'28'3f'21'5cw'29 >>= withAttribute "Substitution") >>~ (popContext)))- return (attr, result)--parseRules "Member Access" = - do (attr, result) <- (((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Message") >>~ pushContext "check_div_2_pop")- <|>- ((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f >>= withAttribute "Message"))- <|>- ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Constant") >>~ pushContext "check_div_2_pop")- <|>- ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a >>= withAttribute "Constant"))- <|>- ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute "Constant Value") >>~ pushContext "check_div_2_pop")- <|>- ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a >>= withAttribute "Constant Value"))- <|>- ((pDetect2Chars False ':' ':' >>= withAttribute "Operator"))- <|>- ((pDetectChar False '.' >>= withAttribute "Member"))- <|>- ((pAnyChar "=+-*/%|&[]{}~" >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pAnyChar "()\\" >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pRegExpr regex_'5cW >>= withAttribute "Member") >>~ (popContext)))- return (attr, result)--parseRules "Comment Line" = - do (attr, result) <- (((pRegExpr regex_'5cw'5c'3a'5c'3a'5cs >>= withAttribute "Comment") >>~ pushContext "RDoc Label")- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)--parseRules "General Comment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)--parseRules "RDoc Label" = - pzero--parseRules "find_heredoc" = - do (attr, result) <- (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute "Keyword") >>~ pushContext "apostrophed_normal_heredoc")- <|>- ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute "Keyword") >>~ pushContext "normal_heredoc"))- return (attr, result)--parseRules "find_indented_heredoc" = - do (attr, result) <- (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute "Keyword") >>~ pushContext "apostrophed_indented_heredoc")- <|>- ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute "Keyword") >>~ pushContext "indented_heredoc"))- return (attr, result)--parseRules "indented_heredoc" = - do (attr, result) <- (((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((parseRules "heredoc_rules")))- return (attr, result)--parseRules "apostrophed_indented_heredoc" = - do (attr, result) <- ((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- return (attr, result)--parseRules "normal_heredoc" = - do (attr, result) <- (((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- <|>- ((parseRules "heredoc_rules")))- return (attr, result)--parseRules "apostrophed_normal_heredoc" = - do (attr, result) <- ((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute "Keyword") >>~ (popContext >> popContext))- return (attr, result)--parseRules "heredoc_rules" = - do (attr, result) <- (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "find_gdl_input" = - do (attr, result) <- (((pRegExpr regex_w'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_1")- <|>- ((pRegExpr regex_w'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_2")- <|>- ((pRegExpr regex_w'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_3")- <|>- ((pRegExpr regex_w'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_4")- <|>- ((pRegExpr regex_w'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_5")- <|>- ((pRegExpr regex_W'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_1")- <|>- ((pRegExpr regex_W'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_2")- <|>- ((pRegExpr regex_W'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_3")- <|>- ((pRegExpr regex_W'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_4")- <|>- ((pRegExpr regex_W'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_token_array_5")- <|>- ((pRegExpr regex_q'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_1")- <|>- ((pRegExpr regex_q'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_2")- <|>- ((pRegExpr regex_q'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_3")- <|>- ((pRegExpr regex_q'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_4")- <|>- ((pRegExpr regex_q'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_apostrophed_5")- <|>- ((pRegExpr regex_x'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_1")- <|>- ((pRegExpr regex_x'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_2")- <|>- ((pRegExpr regex_x'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_3")- <|>- ((pRegExpr regex_x'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_4")- <|>- ((pRegExpr regex_x'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_shell_command_5")- <|>- ((pRegExpr regex_r'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_1")- <|>- ((pRegExpr regex_r'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_2")- <|>- ((pRegExpr regex_r'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_3")- <|>- ((pRegExpr regex_r'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_4")- <|>- ((pRegExpr regex_r'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_regexpr_5")- <|>- ((pRegExpr regex_Q'3f'5c'28 >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_1")- <|>- ((pRegExpr regex_Q'3f'5c'7b >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_2")- <|>- ((pRegExpr regex_Q'3f'5c'5b >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_3")- <|>- ((pRegExpr regex_Q'3f'3c >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_4")- <|>- ((pRegExpr regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute "GDL input") >>~ pushContext "gdl_dq_string_5"))- return (attr, result)--parseRules "gdl_dq_string_1" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "String"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_1_nested" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_dq_string_2" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_2_nested"))- return (attr, result)--parseRules "gdl_dq_string_2_nested" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_3" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "String"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_3_nested" = - do (attr, result) <- (((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_4" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "String"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_dq_string_4_nested" = - do (attr, result) <- (((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_dq_string_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "String") >>~ (popContext))- <|>- ((parseRules "dq_string_rules")))- return (attr, result)--parseRules "gdl_dq_string_5" = - do (attr, result) <- (((parseRules "dq_string_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "dq_string_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "String"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "gdl_token_array_1" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "String"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_token_array_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_1_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "String") >>~ pushContext "gdl_token_array_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_2" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_token_array_2_nested"))- return (attr, result)--parseRules "gdl_token_array_2_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "String") >>~ pushContext "gdl_token_array_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_3" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "String"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_token_array_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_3_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "String") >>~ pushContext "gdl_token_array_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_4" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "String"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_token_array_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_token_array_4_nested" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "String") >>~ pushContext "gdl_token_array_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_token_array_5" = - do (attr, result) <- (((parseRules "token_array_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "token_array_rules" = - do (attr, result) <- ((pString False "\\\\" >>= withAttribute "String"))- return (attr, result)--parseRules "gdl_apostrophed_1" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '(' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_1_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_2" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_2_nested"))- return (attr, result)--parseRules "gdl_apostrophed_2_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_3" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '[' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_3_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_4" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Raw String"))- <|>- ((pDetectChar False '<' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_apostrophed_4_nested" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Raw String") >>~ pushContext "gdl_apostrophed_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Raw String") >>~ (popContext)))- return (attr, result)--parseRules "gdl_apostrophed_5" = - do (attr, result) <- (((parseRules "apostrophed_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Raw String"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "apostrophed_rules" = - do (attr, result) <- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Raw String"))- return (attr, result)--parseRules "gdl_shell_command_1" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Command"))- <|>- ((pDetectChar False '(' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_1_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_2" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Command"))- <|>- ((pDetectChar False '}' >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_2_nested"))- return (attr, result)--parseRules "gdl_shell_command_2_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_3" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Command"))- <|>- ((pDetectChar False '[' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_3_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_4" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Command"))- <|>- ((pDetectChar False '<' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_shell_command_4_nested" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Command") >>~ pushContext "gdl_shell_command_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Command") >>~ (popContext)))- return (attr, result)--parseRules "gdl_shell_command_5" = - do (attr, result) <- (((parseRules "shell_command_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Command"))- <|>- ((pRegExprDynamic "\\s*%1" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "shell_command_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Command"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "gdl_regexpr_1" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '(' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_1_nested")- <|>- ((pRegExpr regex_'5c'29'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_1_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '(' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_1_nested")- <|>- ((pDetectChar False ')' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_2" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'5c'7d'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_2_nested"))- return (attr, result)--parseRules "gdl_regexpr_2_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '{' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_2_nested")- <|>- ((pDetectChar False '}' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_3" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '[' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_3_nested")- <|>- ((pRegExpr regex_'5c'5d'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_3_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '[' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_3_nested")- <|>- ((pDetectChar False ']' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_4" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetect2Chars False '\\' '>' >>= withAttribute "Regular Expression"))- <|>- ((pDetectChar False '<' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_4_nested")- <|>- ((pRegExpr regex_'3e'5buiomxn'5d'2a >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "gdl_regexpr_4_nested" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pDetectChar False '<' >>= withAttribute "Regular Expression") >>~ pushContext "gdl_regexpr_4_nested")- <|>- ((pDetectChar False '>' >>= withAttribute "Regular Expression") >>~ (popContext)))- return (attr, result)--parseRules "gdl_regexpr_5" = - do (attr, result) <- (((parseRules "regexpr_rules"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Regular Expression"))- <|>- ((pRegExprDynamic "\\s*%1[uiomxn]*" >>= withAttribute "GDL input") >>~ (popContext >> popContext)))- return (attr, result)--parseRules "regexpr_rules" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Regular Expression"))- <|>- ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute "Substitution") >>~ pushContext "Short Subst")- <|>- ((pDetect2Chars False '#' '{' >>= withAttribute "Substitution") >>~ pushContext "Subst"))- return (attr, result)--parseRules "DATA" = +{- This module was generated from data in the Kate syntax+ highlighting file ruby.xml, version 1.24, by Stefan Lang (langstefan@gmx.at), Sebastian Vuorinen (sebastian.vuorinen@helsinki.fi), Robin Pedersen (robinpeder@gmail.com), Miquel Sabaté (mikisabate@gmail.com) -}++module Text.Highlighting.Kate.Syntax.Ruby+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types+import Text.Highlighting.Kate.Common+import qualified Text.Highlighting.Kate.Syntax.Alert+import Text.ParserCombinators.Parsec hiding (State)+import Data.Map (fromList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe)+import qualified Data.Set as Set++-- | Full name of language.+syntaxName :: String+syntaxName = "Ruby"++-- | Filename extensions for this language.+syntaxExtensions :: String+syntaxExtensions = "*.rb;*.rjs;*.rxml;*.xml.erb;*.js.erb;*.rake;Rakefile;Gemfile;*.gemspec"++-- | Highlight source code using this syntax definition.+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState++parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine++-- | Parse an expression using appropriate local context.+parseExpression :: KateParser Token+parseExpression = do+ st <- getState+ let oldLang = synStLanguage st+ setState $ st { synStLanguage = "Ruby" }+ context <- currentContext <|> (pushContext "Normal" >> currentContext)+ result <- parseRules context+ optional $ eof >> pEndLine+ updateState $ \st -> st { synStLanguage = oldLang }+ return result++startingState = SyntaxState {synStContexts = fromList [("Ruby",["Normal"])], synStLanguage = "Ruby", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}++pEndLine = do+ context <- currentContext+ case context of+ "Normal" -> return ()+ "check_div_1" -> (popContext) >> pEndLine+ "check_div_1_pop" -> (popContext >> popContext) >> pEndLine+ "check_div_2" -> (popContext) >> pEndLine+ "check_div_2_internal" -> (popContext >> popContext) >> pEndLine+ "check_div_2_pop" -> (popContext >> popContext) >> pEndLine+ "check_div_2_pop_internal" -> (popContext >> popContext >> popContext) >> pEndLine+ "Line Continue" -> (popContext) >> pEndLine+ "Find closing block brace" -> return ()+ "Quoted String" -> return ()+ "Apostrophed String" -> return ()+ "Command String" -> return ()+ "Embedded documentation" -> return ()+ "RegEx 1" -> return ()+ "Subst" -> return ()+ "Short Subst" -> (popContext) >> pEndLine+ "Member Access" -> (popContext) >> pEndLine+ "Comment Line" -> (popContext) >> pEndLine+ "General Comment" -> (popContext) >> pEndLine+ "RDoc Label" -> (popContext) >> pEndLine+ "find_heredoc" -> (popContext) >> pEndLine+ "find_indented_heredoc" -> (popContext) >> pEndLine+ "indented_heredoc" -> return ()+ "apostrophed_indented_heredoc" -> return ()+ "normal_heredoc" -> return ()+ "apostrophed_normal_heredoc" -> return ()+ "heredoc_rules" -> return ()+ "find_gdl_input" -> (popContext) >> pEndLine+ "gdl_dq_string_1" -> return ()+ "gdl_dq_string_1_nested" -> return ()+ "gdl_dq_string_2" -> return ()+ "gdl_dq_string_2_nested" -> return ()+ "gdl_dq_string_3" -> return ()+ "gdl_dq_string_3_nested" -> return ()+ "gdl_dq_string_4" -> return ()+ "gdl_dq_string_4_nested" -> return ()+ "gdl_dq_string_5" -> return ()+ "dq_string_rules" -> return ()+ "gdl_token_array_1" -> return ()+ "gdl_token_array_1_nested" -> return ()+ "gdl_token_array_2" -> return ()+ "gdl_token_array_2_nested" -> return ()+ "gdl_token_array_3" -> return ()+ "gdl_token_array_3_nested" -> return ()+ "gdl_token_array_4" -> return ()+ "gdl_token_array_4_nested" -> return ()+ "gdl_token_array_5" -> return ()+ "token_array_rules" -> return ()+ "gdl_apostrophed_1" -> return ()+ "gdl_apostrophed_1_nested" -> return ()+ "gdl_apostrophed_2" -> return ()+ "gdl_apostrophed_2_nested" -> return ()+ "gdl_apostrophed_3" -> return ()+ "gdl_apostrophed_3_nested" -> return ()+ "gdl_apostrophed_4" -> return ()+ "gdl_apostrophed_4_nested" -> return ()+ "gdl_apostrophed_5" -> return ()+ "apostrophed_rules" -> return ()+ "gdl_shell_command_1" -> return ()+ "gdl_shell_command_1_nested" -> return ()+ "gdl_shell_command_2" -> return ()+ "gdl_shell_command_2_nested" -> return ()+ "gdl_shell_command_3" -> return ()+ "gdl_shell_command_3_nested" -> return ()+ "gdl_shell_command_4" -> return ()+ "gdl_shell_command_4_nested" -> return ()+ "gdl_shell_command_5" -> return ()+ "shell_command_rules" -> return ()+ "gdl_regexpr_1" -> return ()+ "gdl_regexpr_1_nested" -> return ()+ "gdl_regexpr_2" -> return ()+ "gdl_regexpr_2_nested" -> return ()+ "gdl_regexpr_3" -> return ()+ "gdl_regexpr_3_nested" -> return ()+ "gdl_regexpr_4" -> return ()+ "gdl_regexpr_4_nested" -> return ()+ "gdl_regexpr_5" -> return ()+ "regexpr_rules" -> return ()+ "DATA" -> return ()+ _ -> return ()++withAttribute attr txt = do+ when (null txt) $ fail "Parser matched no text"+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt)++parseExpressionInternal = do+ context <- currentContext+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes))++list_keywords = Set.fromList $ words $ "BEGIN END and begin break case defined? do else elsif end ensure for if in include next not or redo rescue retry return then unless until when yield"+list_access'2dcontrol = Set.fromList $ words $ "private_class_method private protected public_class_method public"+list_attribute'2ddefinitions = Set.fromList $ words $ "attr_reader attr_writer attr_accessor"+list_definitions = Set.fromList $ words $ "alias module class def undef"+list_pseudo'2dvariables = Set.fromList $ words $ "self super nil false true caller __FILE__ __LINE__"+list_default'2dglobals = Set.fromList $ words $ "$stdout $defout $stderr $deferr $stdin"+list_kernel'2dmethods = Set.fromList $ words $ "abort at_exit autoload autoload? binding block_given? callcc caller catch chomp chomp! chop chop! eval exec exit exit! fail fork format getc gets global_variables gsub gsub! iterator? lambda load local_variables loop method_missing open p print printf proc putc puts raise rand readline readlines require require_relative scan select set_trace_func sleep split sprintf srand sub sub! syscall system test throw trace_var trap untrace_var warn"++regex_'5f'5fEND'5f'5f'24 = compileRegex "__END__$"+regex_'23'21'5c'2f'2e'2a = compileRegex "#!\\/.*"+regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb = compileRegex "(\\=|\\(|\\[|\\{)\\s*(if|unless|while|until)\\b"+regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "(while|until)\\b(?!.*\\bdo\\b)"+regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\;\\s*(while|until)\\b(?!.*\\bdo\\b)"+regex_'28if'7cunless'29'5cb = compileRegex "(if|unless)\\b"+regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb = compileRegex "\\;\\s*(if|unless)\\b"+regex_'5cbclass'5cb = compileRegex "\\bclass\\b"+regex_'5cbmodule'5cb = compileRegex "\\bmodule\\b"+regex_'5cbbegin'5cb = compileRegex "\\bbegin\\b"+regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 = compileRegex "\\bfor\\b(?!.*\\bdo\\b)"+regex_'5cbcase'5cb = compileRegex "\\bcase\\b"+regex_'5cbdo'5cb = compileRegex "\\bdo\\b"+regex_'5cbdef'5cb = compileRegex "\\bdef\\b"+regex_'5cbend'5cb = compileRegex "\\bend\\b"+regex_'5cb'28else'7celsif'7crescue'7censure'29'5cb = compileRegex "\\b(else|elsif|rescue|ensure)\\b"+regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 = compileRegex "\\.[_a-z][_a-zA-Z0-9]*(\\?|\\!|\\b)"+regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS = compileRegex "\\s\\?(\\\\M\\-)?(\\\\C\\-)?\\\\?\\S"+regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "\\$[a-zA-Z_0-9]+"+regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb = compileRegex "\\$\\-[a-zA-z_]\\b"+regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'22'5d = compileRegex "\\$[\\d_*`\\!:?'/\\\\\\-\\&\"]"+regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb = compileRegex "\\b[_A-Z]+[A-Z_0-9]+\\b"+regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb = compileRegex "\\b[A-Z]+_*([0-9]|[a-z])[_a-zA-Z0-9]*\\b"+regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b = compileRegex "\\b\\-?0[xX][_0-9a-fA-F]+"+regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b = compileRegex "\\b\\-?0[bB][_01]+"+regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a = compileRegex "\\b\\-?0[1-7][_0-7]*"+regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f = compileRegex "\\b\\-?[0-9][0-9_]*\\.[0-9][0-9_]*([eE]\\-?[1-9][0-9]*(\\.[0-9]*)?)?"+regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb = compileRegex "\\b\\-?[1-9][0-9_]*\\b"+regex_'3dbegin'28'3f'3a'5cs'7c'24'29 = compileRegex "=begin(?:\\s|$)"+regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<-(?=\\w+|[\"'])"+regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 = compileRegex "\\s*<<(?=\\w+|[\"'])"+regex_'5cs'5b'5c'3f'5c'3a'5c'25'5d'5cs = compileRegex "\\s[\\?\\:\\%]\\s"+regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b = compileRegex "[|&<>\\^\\+*~\\-=]+"+regex_'5cs'21 = compileRegex "\\s!"+regex_'2f'3d'5cs = compileRegex "/=\\s"+regex_'3a'28'40'7b1'2c2'7d'7c'5c'24'29'3f'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5b'3d'3f'21'5d'3f = compileRegex ":(@{1,2}|\\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?"+regex_'3a'5c'5b'5c'5d'3d'3f = compileRegex ":\\[\\]=?"+regex_'23'5cs'2aBEGIN'2e'2a'24 = compileRegex "#\\s*BEGIN.*$"+regex_'23'5cs'2aEND'2e'2a'24 = compileRegex "#\\s*END.*$"+regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@[a-zA-Z_0-9]+"+regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b = compileRegex "@@[a-zA-Z_0-9]+"+regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxwW'5d'3f'5b'5e'5cs'5d'29 = compileRegex "\\s*[%](?=[QqxwW]?[^\\s])"+regex_'5cs'2a = compileRegex "\\s*"+regex_'5cs'2b = compileRegex "\\s+"+regex_'5b'2f'25'5d'28'3f'3d'5cs'29 = compileRegex "[/%](?=\\s)"+regex_'2f'28'3f'3d'5cs'29 = compileRegex "/(?=\\s)"+regex_'5c'5c'5c'22 = compileRegex "\\\\\\\""+regex_'23'40'7b1'2c2'7d = compileRegex "#@{1,2}"+regex_'5c'5c'5c'27 = compileRegex "\\\\\\'"+regex_'5c'5c'5c'60 = compileRegex "\\\\\\`"+regex_'3dend'28'3f'3a'5cs'2e'2a'7c'24'29 = compileRegex "=end(?:\\s.*|$)"+regex_'5c'5c'5c'2f = compileRegex "\\\\\\/"+regex_'2f'5buiomxn'5d'2a = compileRegex "/[uiomxn]*"+regex_'5cw'28'3f'21'5cw'29 = compileRegex "\\w(?!\\w)"+regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?(?=[^\\w\\d\\.\\:])"+regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f = compileRegex "\\.?[_a-z]\\w*(\\?|\\!)?"+regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[A-Z]+_*(\\d|[a-z])\\w*(?=[^\\w\\d\\.\\:])"+regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a = compileRegex "[A-Z]+_*([0-9]|[a-z])\\w*"+regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 = compileRegex "[_A-Z][_A-Z0-9]*(?=[^\\w\\d\\.\\:])"+regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a = compileRegex "[_A-Z][_A-Z0-9]*"+regex_'5cW = compileRegex "\\W"+regex_'5cw'5c'3a'5c'3a'5cs = compileRegex "\\w\\:\\:\\s"+regex_'27'28'5cw'2b'29'27 = compileRegex "'(\\w+)'"+regex_'22'3f'28'5cw'2b'29'22'3f = compileRegex "\"?(\\w+)\"?"+regex_w'5c'28 = compileRegex "w\\("+regex_w'5c'7b = compileRegex "w\\{"+regex_w'5c'5b = compileRegex "w\\["+regex_w'3c = compileRegex "w<"+regex_w'28'5b'5e'5cs'5cw'5d'29 = compileRegex "w([^\\s\\w])"+regex_W'5c'28 = compileRegex "W\\("+regex_W'5c'7b = compileRegex "W\\{"+regex_W'5c'5b = compileRegex "W\\["+regex_W'3c = compileRegex "W<"+regex_W'28'5b'5e'5cs'5cw'5d'29 = compileRegex "W([^\\s\\w])"+regex_q'5c'28 = compileRegex "q\\("+regex_q'5c'7b = compileRegex "q\\{"+regex_q'5c'5b = compileRegex "q\\["+regex_q'3c = compileRegex "q<"+regex_q'28'5b'5e'5cs'5cw'5d'29 = compileRegex "q([^\\s\\w])"+regex_x'5c'28 = compileRegex "x\\("+regex_x'5c'7b = compileRegex "x\\{"+regex_x'5c'5b = compileRegex "x\\["+regex_x'3c = compileRegex "x<"+regex_x'28'5b'5e'5cs'5cw'5d'29 = compileRegex "x([^\\s\\w])"+regex_r'5c'28 = compileRegex "r\\("+regex_r'5c'7b = compileRegex "r\\{"+regex_r'5c'5b = compileRegex "r\\["+regex_r'3c = compileRegex "r<"+regex_r'28'5b'5e'5cs'5cw'5d'29 = compileRegex "r([^\\s\\w])"+regex_Q'3f'5c'28 = compileRegex "Q?\\("+regex_Q'3f'5c'7b = compileRegex "Q?\\{"+regex_Q'3f'5c'5b = compileRegex "Q?\\["+regex_Q'3f'3c = compileRegex "Q?<"+regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 = compileRegex "Q?([^\\s\\w])"+regex_'5c'29'5buiomxn'5d'2a = compileRegex "\\)[uiomxn]*"+regex_'5c'7d'5buiomxn'5d'2a = compileRegex "\\}[uiomxn]*"+regex_'5c'5d'5buiomxn'5d'2a = compileRegex "\\][uiomxn]*"+regex_'3e'5buiomxn'5d'2a = compileRegex ">[uiomxn]*"++defaultAttributes = [("Normal",NormalTok),("check_div_1",NormalTok),("check_div_1_pop",NormalTok),("check_div_2",NormalTok),("check_div_2_internal",NormalTok),("check_div_2_pop",NormalTok),("check_div_2_pop_internal",NormalTok),("Line Continue",NormalTok),("Find closing block brace",NormalTok),("Quoted String",StringTok),("Apostrophed String",StringTok),("Command String",StringTok),("Embedded documentation",CommentTok),("RegEx 1",OtherTok),("Subst",NormalTok),("Short Subst",OtherTok),("Member Access",NormalTok),("Comment Line",CommentTok),("General Comment",CommentTok),("RDoc Label",OtherTok),("find_heredoc",NormalTok),("find_indented_heredoc",NormalTok),("indented_heredoc",OtherTok),("apostrophed_indented_heredoc",OtherTok),("normal_heredoc",OtherTok),("apostrophed_normal_heredoc",OtherTok),("heredoc_rules",NormalTok),("find_gdl_input",NormalTok),("gdl_dq_string_1",StringTok),("gdl_dq_string_1_nested",StringTok),("gdl_dq_string_2",StringTok),("gdl_dq_string_2_nested",StringTok),("gdl_dq_string_3",StringTok),("gdl_dq_string_3_nested",StringTok),("gdl_dq_string_4",StringTok),("gdl_dq_string_4_nested",StringTok),("gdl_dq_string_5",StringTok),("dq_string_rules",StringTok),("gdl_token_array_1",StringTok),("gdl_token_array_1_nested",StringTok),("gdl_token_array_2",StringTok),("gdl_token_array_2_nested",StringTok),("gdl_token_array_3",StringTok),("gdl_token_array_3_nested",StringTok),("gdl_token_array_4",StringTok),("gdl_token_array_4_nested",StringTok),("gdl_token_array_5",StringTok),("token_array_rules",StringTok),("gdl_apostrophed_1",StringTok),("gdl_apostrophed_1_nested",StringTok),("gdl_apostrophed_2",StringTok),("gdl_apostrophed_2_nested",StringTok),("gdl_apostrophed_3",StringTok),("gdl_apostrophed_3_nested",StringTok),("gdl_apostrophed_4",StringTok),("gdl_apostrophed_4_nested",StringTok),("gdl_apostrophed_5",StringTok),("apostrophed_rules",StringTok),("gdl_shell_command_1",StringTok),("gdl_shell_command_1_nested",StringTok),("gdl_shell_command_2",StringTok),("gdl_shell_command_2_nested",StringTok),("gdl_shell_command_3",StringTok),("gdl_shell_command_3_nested",StringTok),("gdl_shell_command_4",StringTok),("gdl_shell_command_4_nested",StringTok),("gdl_shell_command_5",StringTok),("shell_command_rules",StringTok),("gdl_regexpr_1",OtherTok),("gdl_regexpr_1_nested",OtherTok),("gdl_regexpr_2",OtherTok),("gdl_regexpr_2_nested",OtherTok),("gdl_regexpr_3",OtherTok),("gdl_regexpr_3_nested",OtherTok),("gdl_regexpr_4",OtherTok),("gdl_regexpr_4_nested",OtherTok),("gdl_regexpr_5",OtherTok),("regexpr_rules",OtherTok),("DATA",NormalTok)]++parseRules "Normal" =+ (((pLineContinue >>= withAttribute NormalTok) >>~ pushContext "Line Continue")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5f'5fEND'5f'5f'24 >>= withAttribute KeywordTok) >>~ pushContext "DATA")+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'21'5c'2f'2e'2a >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Find closing block brace")+ <|>+ ((pRegExpr regex_'28'5c'3d'7c'5c'28'7c'5c'5b'7c'5c'7b'29'5cs'2a'28if'7cunless'7cwhile'7cuntil'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'3b'5cs'2a'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5c'3b'5cs'2a'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbclass'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbmodule'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbbegin'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbfor'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbcase'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdo'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbdef'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cbend'5cb >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'5cb'28else'7celsif'7crescue'7censure'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((pString False "..." >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '.' '.' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'2e'5b'5fa'2dz'5d'5b'5fa'2dzA'2dZ0'2d9'5d'2a'28'5c'3f'7c'5c'21'7c'5cb'29 >>= withAttribute NormalTok) >>~ pushContext "check_div_2")+ <|>+ ((pRegExpr regex_'5cs'5c'3f'28'5c'5cM'5c'2d'29'3f'28'5c'5cC'5c'2d'29'3f'5c'5c'3f'5cS >>= withAttribute DecValTok) >>~ pushContext "check_div_1")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_attribute'2ddefinitions >>= withAttribute OtherTok) >>~ pushContext "check_div_2")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_access'2dcontrol >>= withAttribute KeywordTok) >>~ pushContext "check_div_2")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_definitions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_pseudo'2dvariables >>= withAttribute DecValTok) >>~ pushContext "check_div_1")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_default'2dglobals >>= withAttribute DataTypeTok) >>~ pushContext "check_div_2")+ <|>+ ((pKeyword " \n\t.():+,-<=>%&*/;[]^{|}~\\" list_kernel'2dmethods >>= withAttribute NormalTok) >>~ pushContext "check_div_2")+ <|>+ ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute DataTypeTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5c'24'5c'2d'5ba'2dzA'2dz'5f'5d'5cb >>= withAttribute DataTypeTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5c'24'5b'5cd'5f'2a'60'5c'21'3a'3f'27'2f'5c'5c'5c'2d'5c'26'22'5d >>= withAttribute DataTypeTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5cb'5b'5fA'2dZ'5d'2b'5bA'2dZ'5f0'2d9'5d'2b'5cb >>= withAttribute DataTypeTok) >>~ pushContext "check_div_2")+ <|>+ ((pRegExpr regex_'5cb'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5b'5fa'2dzA'2dZ0'2d9'5d'2a'5cb >>= withAttribute DataTypeTok) >>~ pushContext "check_div_2")+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5bxX'5d'5b'5f0'2d9a'2dfA'2dF'5d'2b >>= withAttribute BaseNTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5bbB'5d'5b'5f01'5d'2b >>= withAttribute BaseNTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f0'5b1'2d7'5d'5b'5f0'2d7'5d'2a >>= withAttribute BaseNTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f'5b0'2d9'5d'5b0'2d9'5f'5d'2a'5c'2e'5b0'2d9'5d'5b0'2d9'5f'5d'2a'28'5beE'5d'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5d'2a'28'5c'2e'5b0'2d9'5d'2a'29'3f'29'3f >>= withAttribute FloatTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'5cb'5c'2d'3f'5b1'2d9'5d'5b0'2d9'5f'5d'2a'5cb >>= withAttribute DecValTok) >>~ pushContext "check_div_1")+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "check_div_1")+ <|>+ ((pHlCChar >>= withAttribute CharTok) >>~ pushContext "check_div_1")+ <|>+ ((pColumn 0 >> pRegExpr regex_'3dbegin'28'3f'3a'5cs'7c'24'29 >>= withAttribute CommentTok) >>~ pushContext "Embedded documentation")+ <|>+ ((pRegExpr regex_'5cs'2a'3c'3c'2d'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute NormalTok) >>~ pushContext "find_indented_heredoc")+ <|>+ ((pRegExpr regex_'5cs'2a'3c'3c'28'3f'3d'5cw'2b'7c'5b'22'27'5d'29 >>= withAttribute NormalTok) >>~ pushContext "find_heredoc")+ <|>+ ((pDetectChar False '.' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '&' '&' >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False '|' '|' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'5b'5c'3f'5c'3a'5c'25'5d'5cs >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5b'7c'26'3c'3e'5c'5e'5c'2b'2a'7e'5c'2d'3d'5d'2b >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cs'21 >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2f'3d'5cs >>= withAttribute NormalTok))+ <|>+ ((pString False "%=" >>= withAttribute NormalTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute NormalTok) >>~ pushContext "Member Access")+ <|>+ ((pRegExpr regex_'3a'28'40'7b1'2c2'7d'7c'5c'24'29'3f'5ba'2dzA'2dZ'5f'5d'5ba'2dzA'2dZ0'2d9'5f'5d'2a'5b'3d'3f'21'5d'3f >>= withAttribute StringTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'3a'5c'5b'5c'5d'3d'3f >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Quoted String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Apostrophed String")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "Command String")+ <|>+ ((pString False "?#" >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "General Comment")+ <|>+ ((pDetectChar False '[' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute NormalTok) >>~ pushContext "check_div_1")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute OtherTok) >>~ pushContext "check_div_1")+ <|>+ ((pRegExpr regex_'40'40'5ba'2dzA'2dZ'5f0'2d9'5d'2b >>= withAttribute OtherTok) >>~ pushContext "check_div_1")+ <|>+ ((pDetectChar False '/' >>= withAttribute OtherTok) >>~ pushContext "RegEx 1")+ <|>+ ((pRegExpr regex_'5cs'2a'5b'25'5d'28'3f'3d'5bQqxwW'5d'3f'5b'5e'5cs'5d'29 >>= withAttribute OtherTok) >>~ pushContext "find_gdl_input")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ pushContext "check_div_1")+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok) >>~ pushContext "check_div_2"))++parseRules "check_div_1" =+ (((pRegExpr regex_'5cs'2a >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "/%" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "check_div_1_pop" =+ (((pRegExpr regex_'5cs'2a >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "/%" >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "check_div_2" =+ (((pAnyChar "/%" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute NormalTok) >>~ pushContext "check_div_2_internal")+ <|>+ ((popContext) >> currentContext >>= parseRules))++parseRules "check_div_2_internal" =+ (((pRegExpr regex_'5b'2f'25'5d'28'3f'3d'5cs'29 >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "check_div_2_pop" =+ (((pAnyChar "/%" >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cs'2b >>= withAttribute NormalTok) >>~ pushContext "check_div_2_pop_internal")+ <|>+ ((popContext >> popContext) >> currentContext >>= parseRules))++parseRules "check_div_2_pop_internal" =+ (((pDetectChar False '%' >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'2f'28'3f'3d'5cs'29 >>= withAttribute NormalTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((popContext >> popContext >> popContext) >> currentContext >>= parseRules))++parseRules "Line Continue" =+ (((pFirstNonSpace >> pRegExpr regex_'28while'7cuntil'29'5cb'28'3f'21'2e'2a'5cbdo'5cb'29 >>= withAttribute KeywordTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'28if'7cunless'29'5cb >>= withAttribute KeywordTok))+ <|>+ ((parseRules "Normal")))++parseRules "Find closing block brace" =+ (((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "check_div_1_pop")+ <|>+ ((parseRules "Normal")))++parseRules "Quoted String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'22 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "check_div_1_pop"))++parseRules "Apostrophed String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'27 >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "check_div_1_pop"))++parseRules "Command String" =+ (((pString False "\\\\" >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'5c'5c'5c'60 >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "check_div_1_pop"))++parseRules "Embedded documentation" =+ (((pColumn 0 >> pRegExpr regex_'3dend'28'3f'3a'5cs'2e'2a'7c'24'29 >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))))++parseRules "RegEx 1" =+ (((pRegExpr regex_'5c'5c'5c'2f >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst")+ <|>+ ((pRegExpr regex_'2f'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ pushContext "check_div_1_pop"))++parseRules "Subst" =+ (((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((parseRules "Normal")))++parseRules "Short Subst" =+ (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5cw'28'3f'21'5cw'29 >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "Member Access" =+ (((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute NormalTok) >>~ pushContext "check_div_2_pop")+ <|>+ ((pRegExpr regex_'5c'2e'3f'5b'5fa'2dz'5d'5cw'2a'28'5c'3f'7c'5c'21'29'3f >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5cd'7c'5ba'2dz'5d'29'5cw'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute DataTypeTok) >>~ pushContext "check_div_2_pop")+ <|>+ ((pRegExpr regex_'5bA'2dZ'5d'2b'5f'2a'28'5b0'2d9'5d'7c'5ba'2dz'5d'29'5cw'2a >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a'28'3f'3d'5b'5e'5cw'5cd'5c'2e'5c'3a'5d'29 >>= withAttribute DataTypeTok) >>~ pushContext "check_div_2_pop")+ <|>+ ((pRegExpr regex_'5b'5fA'2dZ'5d'5b'5fA'2dZ0'2d9'5d'2a >>= withAttribute DataTypeTok))+ <|>+ ((pDetect2Chars False ':' ':' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '.' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "=+-*/%|&[]{}~" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pAnyChar "()\\" >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cW >>= withAttribute NormalTok) >>~ (popContext)))++parseRules "Comment Line" =+ (((pRegExpr regex_'5cw'5c'3a'5c'3a'5cs >>= withAttribute CommentTok) >>~ pushContext "RDoc Label")+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))))++parseRules "General Comment" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))++parseRules "RDoc Label" =+ pzero++parseRules "find_heredoc" =+ (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute KeywordTok) >>~ pushContext "apostrophed_normal_heredoc")+ <|>+ ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute KeywordTok) >>~ pushContext "normal_heredoc"))++parseRules "find_indented_heredoc" =+ (((pRegExpr regex_'27'28'5cw'2b'29'27 >>= withAttribute KeywordTok) >>~ pushContext "apostrophed_indented_heredoc")+ <|>+ ((pRegExpr regex_'22'3f'28'5cw'2b'29'22'3f >>= withAttribute KeywordTok) >>~ pushContext "indented_heredoc"))++parseRules "indented_heredoc" =+ (((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "heredoc_rules")))++parseRules "apostrophed_indented_heredoc" =+ ((pFirstNonSpace >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))++parseRules "normal_heredoc" =+ (((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "heredoc_rules")))++parseRules "apostrophed_normal_heredoc" =+ ((pColumn 0 >> pRegExprDynamic "%1$" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))++parseRules "heredoc_rules" =+ (((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "find_gdl_input" =+ (((pRegExpr regex_w'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_1")+ <|>+ ((pRegExpr regex_w'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_2")+ <|>+ ((pRegExpr regex_w'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_3")+ <|>+ ((pRegExpr regex_w'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_4")+ <|>+ ((pRegExpr regex_w'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_5")+ <|>+ ((pRegExpr regex_W'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_1")+ <|>+ ((pRegExpr regex_W'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_2")+ <|>+ ((pRegExpr regex_W'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_3")+ <|>+ ((pRegExpr regex_W'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_4")+ <|>+ ((pRegExpr regex_W'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_token_array_5")+ <|>+ ((pRegExpr regex_q'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_1")+ <|>+ ((pRegExpr regex_q'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_2")+ <|>+ ((pRegExpr regex_q'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_3")+ <|>+ ((pRegExpr regex_q'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_4")+ <|>+ ((pRegExpr regex_q'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_apostrophed_5")+ <|>+ ((pRegExpr regex_x'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_1")+ <|>+ ((pRegExpr regex_x'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_2")+ <|>+ ((pRegExpr regex_x'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_3")+ <|>+ ((pRegExpr regex_x'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_4")+ <|>+ ((pRegExpr regex_x'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_shell_command_5")+ <|>+ ((pRegExpr regex_r'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1")+ <|>+ ((pRegExpr regex_r'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2")+ <|>+ ((pRegExpr regex_r'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3")+ <|>+ ((pRegExpr regex_r'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4")+ <|>+ ((pRegExpr regex_r'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_5")+ <|>+ ((pRegExpr regex_Q'3f'5c'28 >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_1")+ <|>+ ((pRegExpr regex_Q'3f'5c'7b >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_2")+ <|>+ ((pRegExpr regex_Q'3f'5c'5b >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_3")+ <|>+ ((pRegExpr regex_Q'3f'3c >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_4")+ <|>+ ((pRegExpr regex_Q'3f'28'5b'5e'5cs'5cw'5d'29 >>= withAttribute OtherTok) >>~ pushContext "gdl_dq_string_5"))++parseRules "gdl_dq_string_1" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_1_nested" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_dq_string_2" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_2_nested"))++parseRules "gdl_dq_string_2_nested" =+ (((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_3" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_3_nested" =+ (((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_4" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_dq_string_4_nested" =+ (((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_dq_string_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "dq_string_rules")))++parseRules "gdl_dq_string_5" =+ (((parseRules "dq_string_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "dq_string_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "gdl_token_array_1" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_1_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_2" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_2_nested"))++parseRules "gdl_token_array_2_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_3" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_3_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_4" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_token_array_4_nested" =+ (((parseRules "token_array_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_token_array_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_token_array_5" =+ (((parseRules "token_array_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "token_array_rules" =+ ((pString False "\\\\" >>= withAttribute StringTok))++parseRules "gdl_apostrophed_1" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_1_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_2" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_2_nested"))++parseRules "gdl_apostrophed_2_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_3" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_3_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_4" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_apostrophed_4_nested" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_apostrophed_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_apostrophed_5" =+ (((parseRules "apostrophed_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "apostrophed_rules" =+ ((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))++parseRules "gdl_shell_command_1" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_1_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_2" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_2_nested"))++parseRules "gdl_shell_command_2_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_3" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_3_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_4" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_shell_command_4_nested" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute StringTok) >>~ pushContext "gdl_shell_command_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute StringTok) >>~ (popContext)))++parseRules "gdl_shell_command_5" =+ (((parseRules "shell_command_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\s*%1" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "shell_command_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "gdl_regexpr_1" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1_nested")+ <|>+ ((pRegExpr regex_'5c'29'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_1_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '(' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_1_nested")+ <|>+ ((pDetectChar False ')' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_2" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'7d'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2_nested"))++parseRules "gdl_regexpr_2_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_2_nested")+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_3" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3_nested")+ <|>+ ((pRegExpr regex_'5c'5d'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_3_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '[' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_3_nested")+ <|>+ ((pDetectChar False ']' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_4" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetect2Chars False '\\' '>' >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4_nested")+ <|>+ ((pRegExpr regex_'3e'5buiomxn'5d'2a >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "gdl_regexpr_4_nested" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pDetectChar False '<' >>= withAttribute OtherTok) >>~ pushContext "gdl_regexpr_4_nested")+ <|>+ ((pDetectChar False '>' >>= withAttribute OtherTok) >>~ (popContext)))++parseRules "gdl_regexpr_5" =+ (((parseRules "regexpr_rules"))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute OtherTok))+ <|>+ ((pRegExprDynamic "\\s*%1[uiomxn]*" >>= withAttribute OtherTok) >>~ (popContext >> popContext)))++parseRules "regexpr_rules" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'23'40'7b1'2c2'7d >>= withAttribute OtherTok) >>~ pushContext "Short Subst")+ <|>+ ((pDetect2Chars False '#' '{' >>= withAttribute OtherTok) >>~ pushContext "Subst"))++parseRules "DATA" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Scala.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file scala.xml, version 1.0,- by Stephane Micheloud (stephane.micheloud@epfl.ch) -}+{- This module was generated from data in the Kate syntax+ highlighting file scala.xml, version 1.0, by Stephane Micheloud (stephane.micheloud@epfl.ch) -} -module Text.Highlighting.Kate.Syntax.Scala ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Scala+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Javadoc-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Scala"@@ -20,60 +23,47 @@ syntaxExtensions = "*.scala" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Scala" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Scala",["Normal"])], synStLanguage = "Scala", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Scala",["Normal"])], synStLanguage = "Scala", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Printf" -> (popContext) >> pEndLine "PrintfString" -> (popContext) >> pEndLine "Member" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Commentar 2" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("StaticImports","kw"),("Imports","kw"),("Data Type","dt"),("Decimal","dv"),("Octal","bn"),("Hex","bn"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("PrintfString","st"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_scala2 = Set.fromList $ words $ "Actor ActorProxy ActorTask ActorThread AllRef Any AnyRef Application AppliedType Array ArrayBuffer Attribute BoxedArray BoxedBooleanArray BoxedByteArray BoxedCharArray Buffer BufferedIterator Char Console Enumeration Fluid Function IScheduler ImmutableMapAdaptor ImmutableSetAdaptor Int Iterable List ListBuffer None Option Ordered Pair PartialFunction Pid Predef PriorityQueue PriorityQueueProxy Reaction Ref Responder RichInt RichString Rule RuleTransformer Script Seq SerialVersionUID Some Stream Symbol TcpService TcpServiceWorker Triple Unit Value WorkerThread serializable transient volatile" list_java15 = Set.fromList $ words $ "ACTIVE ACTIVITY_COMPLETED ACTIVITY_REQUIRED ARG_IN ARG_INOUT ARG_OUT AWTError AWTEvent AWTEventListener AWTEventListenerProxy AWTEventMulticaster AWTException AWTKeyStroke AWTPermission AbstractAction AbstractBorder AbstractButton AbstractCellEditor AbstractCollection AbstractColorChooserPanel AbstractDocument AbstractDocument.AttributeContext AbstractDocument.Content AbstractDocument.ElementEdit AbstractExecutorService AbstractInterruptibleChannel AbstractLayoutCache AbstractLayoutCache.NodeDimensions AbstractList AbstractListModel AbstractMap AbstractMethodError AbstractPreferences AbstractQueue AbstractQueuedSynchronizer AbstractSelectableChannel AbstractSelectionKey AbstractSelector AbstractSequentialList AbstractSet AbstractSpinnerModel AbstractTableModel AbstractUndoableEdit AbstractWriter AccessControlContext AccessControlException AccessController AccessException Accessible AccessibleAction AccessibleAttributeSequence AccessibleBundle AccessibleComponent AccessibleContext AccessibleEditableText AccessibleExtendedComponent AccessibleExtendedTable AccessibleExtendedText AccessibleHyperlink AccessibleHypertext AccessibleIcon AccessibleKeyBinding AccessibleObject AccessibleRelation AccessibleRelationSet AccessibleResourceBundle AccessibleRole AccessibleSelection AccessibleState AccessibleStateSet AccessibleStreamable AccessibleTable AccessibleTableModelChange AccessibleText AccessibleTextSequence AccessibleValue AccountException AccountExpiredException AccountLockedException AccountNotFoundException Acl AclEntry AclNotFoundException Action ActionEvent ActionListener ActionMap ActionMapUIResource Activatable ActivateFailedException ActivationDesc ActivationException ActivationGroup ActivationGroupDesc ActivationGroupDesc.CommandEnvironment ActivationGroupID ActivationGroup_Stub ActivationID ActivationInstantiator ActivationMonitor ActivationSystem Activator ActiveEvent ActivityCompletedException ActivityRequiredException AdapterActivator AdapterActivatorOperations AdapterAlreadyExists AdapterAlreadyExistsHelper AdapterInactive AdapterInactiveHelper AdapterManagerIdHelper AdapterNameHelper AdapterNonExistent AdapterNonExistentHelper AdapterStateHelper AddressHelper Adjustable AdjustmentEvent AdjustmentListener Adler32 AffineTransform AffineTransformOp AlgorithmParameterGenerator AlgorithmParameterGeneratorSpi AlgorithmParameterSpec AlgorithmParameters AlgorithmParametersSpi AllPermission AlphaComposite AlreadyBound AlreadyBoundException AlreadyBoundHelper AlreadyBoundHolder AlreadyConnectedException AncestorEvent AncestorListener AnnotatedElement Annotation Annotation AnnotationFormatError AnnotationTypeMismatchException Any AnyHolder AnySeqHelper AnySeqHelper AnySeqHolder AppConfigurationEntry AppConfigurationEntry.LoginModuleControlFlag Appendable Applet AppletContext AppletInitializer AppletStub ApplicationException Arc2D Arc2D.Double Arc2D.Float Area AreaAveragingScaleFilter ArithmeticException Array Array ArrayBlockingQueue ArrayIndexOutOfBoundsException ArrayList ArrayStoreException ArrayType Arrays AssertionError AsyncBoxView AsynchronousCloseException AtomicBoolean AtomicInteger AtomicIntegerArray AtomicIntegerFieldUpdater AtomicLong AtomicLongArray AtomicLongFieldUpdater AtomicMarkableReference AtomicReference AtomicReferenceArray AtomicReferenceFieldUpdater AtomicStampedReference Attr Attribute Attribute Attribute AttributeChangeNotification AttributeChangeNotificationFilter AttributeException AttributeInUseException AttributeList AttributeList AttributeList AttributeListImpl AttributeModificationException AttributeNotFoundException AttributeSet AttributeSet AttributeSet.CharacterAttribute AttributeSet.ColorAttribute AttributeSet.FontAttribute AttributeSet.ParagraphAttribute AttributeSetUtilities AttributeValueExp AttributedCharacterIterator AttributedCharacterIterator.Attribute AttributedString Attributes Attributes Attributes Attributes.Name Attributes2 Attributes2Impl AttributesImpl AudioClip AudioFileFormat AudioFileFormat.Type AudioFileReader AudioFileWriter AudioFormat AudioFormat.Encoding AudioInputStream AudioPermission AudioSystem AuthPermission AuthProvider AuthenticationException AuthenticationException AuthenticationNotSupportedException Authenticator Authenticator.RequestorType AuthorizeCallback Autoscroll BAD_CONTEXT BAD_INV_ORDER BAD_OPERATION BAD_PARAM BAD_POLICY BAD_POLICY_TYPE BAD_POLICY_VALUE BAD_QOS BAD_TYPECODE BMPImageWriteParam BackingStoreException BadAttributeValueExpException BadBinaryOpValueExpException BadKind BadLocationException BadPaddingException BadStringOperationException BandCombineOp BandedSampleModel BaseRowSet BasicArrowButton BasicAttribute BasicAttributes BasicBorders BasicBorders.ButtonBorder BasicBorders.FieldBorder BasicBorders.MarginBorder BasicBorders.MenuBarBorder BasicBorders.RadioButtonBorder BasicBorders.RolloverButtonBorder BasicBorders.SplitPaneBorder BasicBorders.ToggleButtonBorder BasicButtonListener BasicButtonUI BasicCheckBoxMenuItemUI BasicCheckBoxUI BasicColorChooserUI BasicComboBoxEditor BasicComboBoxEditor.UIResource BasicComboBoxRenderer BasicComboBoxRenderer.UIResource BasicComboBoxUI BasicComboPopup BasicControl BasicDesktopIconUI BasicDesktopPaneUI BasicDirectoryModel BasicEditorPaneUI BasicFileChooserUI BasicFormattedTextFieldUI BasicGraphicsUtils BasicHTML BasicIconFactory BasicInternalFrameTitlePane BasicInternalFrameUI BasicLabelUI BasicListUI BasicLookAndFeel BasicMenuBarUI BasicMenuItemUI BasicMenuUI BasicOptionPaneUI BasicOptionPaneUI.ButtonAreaLayout BasicPanelUI BasicPasswordFieldUI BasicPermission BasicPopupMenuSeparatorUI BasicPopupMenuUI BasicProgressBarUI BasicRadioButtonMenuItemUI BasicRadioButtonUI BasicRootPaneUI BasicScrollBarUI BasicScrollPaneUI BasicSeparatorUI BasicSliderUI BasicSpinnerUI BasicSplitPaneDivider BasicSplitPaneUI BasicStroke BasicTabbedPaneUI BasicTableHeaderUI BasicTableUI BasicTextAreaUI BasicTextFieldUI BasicTextPaneUI BasicTextUI BasicTextUI.BasicCaret BasicTextUI.BasicHighlighter BasicToggleButtonUI BasicToolBarSeparatorUI BasicToolBarUI BasicToolTipUI BasicTreeUI BasicViewportUI BatchUpdateException BeanContext BeanContextChild BeanContextChildComponentProxy BeanContextChildSupport BeanContextContainerProxy BeanContextEvent BeanContextMembershipEvent BeanContextMembershipListener BeanContextProxy BeanContextServiceAvailableEvent BeanContextServiceProvider BeanContextServiceProviderBeanInfo BeanContextServiceRevokedEvent BeanContextServiceRevokedListener BeanContextServices BeanContextServicesListener BeanContextServicesSupport BeanContextServicesSupport.BCSSServiceProvider BeanContextSupport BeanContextSupport.BCSIterator BeanDescriptor BeanInfo Beans BevelBorder Bidi BigDecimal BigInteger BinaryRefAddr BindException Binding Binding BindingHelper BindingHolder BindingIterator BindingIteratorHelper BindingIteratorHolder BindingIteratorOperations BindingIteratorPOA BindingListHelper BindingListHolder BindingType BindingTypeHelper BindingTypeHolder BitSet Blob BlockView BlockingQueue Book Boolean BooleanControl BooleanControl.Type BooleanHolder BooleanSeqHelper BooleanSeqHolder Border BorderFactory BorderLayout BorderUIResource BorderUIResource.BevelBorderUIResource BorderUIResource.CompoundBorderUIResource BorderUIResource.EmptyBorderUIResource BorderUIResource.EtchedBorderUIResource BorderUIResource.LineBorderUIResource BorderUIResource.MatteBorderUIResource BorderUIResource.TitledBorderUIResource BoundedRangeModel Bounds Bounds Box Box.Filler BoxLayout BoxView BoxedValueHelper BreakIterator BrokenBarrierException Buffer BufferCapabilities BufferCapabilities.FlipContents BufferOverflowException BufferStrategy BufferUnderflowException BufferedImage BufferedImageFilter BufferedImageOp BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter Button ButtonGroup ButtonModel ButtonUI Byte ByteArrayInputStream ByteArrayOutputStream ByteBuffer ByteChannel ByteHolder ByteLookupTable ByteOrder CDATASection CMMException CODESET_INCOMPATIBLE COMM_FAILURE CRC32 CRL CRLException CRLSelector CSS CSS.Attribute CTX_RESTRICT_SCOPE CacheRequest CacheResponse CachedRowSet Calendar Callable CallableStatement Callback CallbackHandler CancelablePrintJob CancellationException CancelledKeyException CannotProceed CannotProceedException CannotProceedHelper CannotProceedHolder CannotRedoException CannotUndoException Canvas CardLayout Caret CaretEvent CaretListener CellEditor CellEditorListener CellRendererPane CertPath CertPath.CertPathRep CertPathBuilder CertPathBuilderException CertPathBuilderResult CertPathBuilderSpi CertPathParameters CertPathTrustManagerParameters CertPathValidator CertPathValidatorException CertPathValidatorResult CertPathValidatorSpi CertSelector CertStore CertStoreException CertStoreParameters CertStoreSpi Certificate Certificate Certificate Certificate.CertificateRep CertificateEncodingException CertificateEncodingException CertificateException CertificateException CertificateExpiredException CertificateExpiredException CertificateFactory CertificateFactorySpi CertificateNotYetValidException CertificateNotYetValidException CertificateParsingException CertificateParsingException ChangeEvent ChangeListener ChangedCharSetException Channel ChannelBinding Channels CharArrayReader CharArrayWriter CharBuffer CharConversionException CharHolder CharSeqHelper CharSeqHolder CharSequence Character Character.Subset Character.UnicodeBlock CharacterCodingException CharacterData CharacterIterator Charset CharsetDecoder CharsetEncoder CharsetProvider Checkbox CheckboxGroup CheckboxMenuItem CheckedInputStream CheckedOutputStream Checksum Choice ChoiceCallback ChoiceFormat Chromaticity Cipher CipherInputStream CipherOutputStream CipherSpi Class ClassCastException ClassCircularityError ClassDefinition ClassDesc ClassFileTransformer ClassFormatError ClassLoader ClassLoaderRepository ClassLoadingMXBean ClassNotFoundException ClientRequestInfo ClientRequestInfoOperations ClientRequestInterceptor ClientRequestInterceptorOperations Clip Clipboard ClipboardOwner Clob CloneNotSupportedException Cloneable Closeable ClosedByInterruptException ClosedChannelException ClosedSelectorException CodeSets CodeSigner CodeSource Codec CodecFactory CodecFactoryHelper CodecFactoryOperations CodecOperations CoderMalfunctionError CoderResult CodingErrorAction CollationElementIterator CollationKey Collator Collection CollectionCertStoreParameters Collections Color ColorChooserComponentFactory ColorChooserUI ColorConvertOp ColorModel ColorSelectionModel ColorSpace ColorSupported ColorType ColorUIResource ComboBoxEditor ComboBoxModel ComboBoxUI ComboPopup Comment CommunicationException Comparable Comparator CompilationMXBean Compiler CompletionService CompletionStatus CompletionStatusHelper Component ComponentAdapter ComponentColorModel ComponentEvent ComponentIdHelper ComponentInputMap ComponentInputMapUIResource ComponentListener ComponentOrientation ComponentSampleModel ComponentUI ComponentView Composite CompositeContext CompositeData CompositeDataSupport CompositeName CompositeType CompositeView CompoundBorder CompoundControl CompoundControl.Type CompoundEdit CompoundName Compression ConcurrentHashMap ConcurrentLinkedQueue ConcurrentMap ConcurrentModificationException Condition Configuration ConfigurationException ConfirmationCallback ConnectException ConnectException ConnectIOException Connection ConnectionEvent ConnectionEventListener ConnectionPendingException ConnectionPoolDataSource ConsoleHandler Constructor Container ContainerAdapter ContainerEvent ContainerListener ContainerOrderFocusTraversalPolicy ContentHandler ContentHandler ContentHandlerFactory ContentModel Context Context ContextList ContextNotEmptyException ContextualRenderedImageFactory Control Control Control.Type ControlFactory ControllerEventListener ConvolveOp CookieHandler CookieHolder Copies CopiesSupported CopyOnWriteArrayList CopyOnWriteArraySet CountDownLatch CounterMonitor CounterMonitorMBean CredentialException CredentialExpiredException CredentialNotFoundException CropImageFilter CubicCurve2D CubicCurve2D.Double CubicCurve2D.Float Currency Current Current Current CurrentHelper CurrentHelper CurrentHelper CurrentHolder CurrentOperations CurrentOperations CurrentOperations Cursor CustomMarshal CustomValue Customizer CyclicBarrier DATA_CONVERSION DESKeySpec DESedeKeySpec DGC DHGenParameterSpec DHKey DHParameterSpec DHPrivateKey DHPrivateKeySpec DHPublicKey DHPublicKeySpec DISCARDING DOMConfiguration DOMError DOMErrorHandler DOMException DOMImplementation DOMImplementationLS DOMImplementationList DOMImplementationRegistry DOMImplementationSource DOMLocator DOMLocator DOMResult DOMSource DOMStringList DSAKey DSAKeyPairGenerator DSAParameterSpec DSAParams DSAPrivateKey DSAPrivateKeySpec DSAPublicKey DSAPublicKeySpec DTD DTDConstants DTDHandler DataBuffer DataBufferByte DataBufferDouble DataBufferFloat DataBufferInt DataBufferShort DataBufferUShort DataFlavor DataFormatException DataInput DataInputStream DataInputStream DataLine DataLine.Info DataOutput DataOutputStream DataOutputStream DataSource DataTruncation DatabaseMetaData DatagramChannel DatagramPacket DatagramSocket DatagramSocketImpl DatagramSocketImplFactory DatatypeConfigurationException DatatypeConstants DatatypeConstants.Field DatatypeFactory Date Date DateFormat DateFormat.Field DateFormatSymbols DateFormatter DateTimeAtCompleted DateTimeAtCreation DateTimeAtProcessing DateTimeSyntax DebugGraphics DecimalFormat DecimalFormatSymbols DeclHandler DefaultBoundedRangeModel DefaultButtonModel DefaultCaret DefaultCellEditor DefaultColorSelectionModel DefaultComboBoxModel DefaultDesktopManager DefaultEditorKit DefaultEditorKit.BeepAction DefaultEditorKit.CopyAction DefaultEditorKit.CutAction DefaultEditorKit.DefaultKeyTypedAction DefaultEditorKit.InsertBreakAction DefaultEditorKit.InsertContentAction DefaultEditorKit.InsertTabAction DefaultEditorKit.PasteAction DefaultFocusManager DefaultFocusTraversalPolicy DefaultFormatter DefaultFormatterFactory DefaultHandler DefaultHandler2 DefaultHighlighter DefaultHighlighter.DefaultHighlightPainter DefaultKeyboardFocusManager DefaultListCellRenderer DefaultListCellRenderer.UIResource DefaultListModel DefaultListSelectionModel DefaultLoaderRepository DefaultLoaderRepository DefaultMenuLayout DefaultMetalTheme DefaultMutableTreeNode DefaultPersistenceDelegate DefaultSingleSelectionModel DefaultStyledDocument DefaultStyledDocument.AttributeUndoableEdit DefaultStyledDocument.ElementSpec DefaultTableCellRenderer DefaultTableCellRenderer.UIResource DefaultTableColumnModel DefaultTableModel DefaultTextUI DefaultTreeCellEditor DefaultTreeCellRenderer DefaultTreeModel DefaultTreeSelectionModel DefinitionKind DefinitionKindHelper Deflater DeflaterOutputStream DelayQueue Delayed Delegate Delegate Delegate DelegationPermission Deprecated Descriptor DescriptorAccess DescriptorSupport DesignMode DesktopIconUI DesktopManager DesktopPaneUI Destination DestroyFailedException Destroyable Dialog Dictionary DigestException DigestInputStream DigestOutputStream Dimension Dimension2D DimensionUIResource DirContext DirObjectFactory DirStateFactory DirStateFactory.Result DirectColorModel DirectoryManager DisplayMode DnDConstants Doc DocAttribute DocAttributeSet DocFlavor DocFlavor.BYTE_ARRAY DocFlavor.CHAR_ARRAY DocFlavor.INPUT_STREAM DocFlavor.READER DocFlavor.SERVICE_FORMATTED DocFlavor.STRING DocFlavor.URL DocPrintJob Document Document DocumentBuilder DocumentBuilderFactory DocumentEvent DocumentEvent.ElementChange DocumentEvent.EventType DocumentFilter DocumentFilter.FilterBypass DocumentFragment DocumentHandler DocumentListener DocumentName DocumentParser DocumentType Documented DomainCombiner DomainManager DomainManagerOperations Double DoubleBuffer DoubleHolder DoubleSeqHelper DoubleSeqHolder DragGestureEvent DragGestureListener DragGestureRecognizer DragSource DragSourceAdapter DragSourceContext DragSourceDragEvent DragSourceDropEvent DragSourceEvent DragSourceListener DragSourceMotionListener Driver DriverManager DriverPropertyInfo DropTarget DropTarget.DropTargetAutoScroller DropTargetAdapter DropTargetContext DropTargetDragEvent DropTargetDropEvent DropTargetEvent DropTargetListener DuplicateFormatFlagsException DuplicateName DuplicateNameHelper Duration DynAny DynAny DynAnyFactory DynAnyFactoryHelper DynAnyFactoryOperations DynAnyHelper DynAnyOperations DynAnySeqHelper DynArray DynArray DynArrayHelper DynArrayOperations DynEnum DynEnum DynEnumHelper DynEnumOperations DynFixed DynFixed DynFixedHelper DynFixedOperations DynSequence DynSequence DynSequenceHelper DynSequenceOperations DynStruct DynStruct DynStructHelper DynStructOperations DynUnion DynUnion DynUnionHelper DynUnionOperations DynValue DynValue DynValueBox DynValueBoxOperations DynValueCommon DynValueCommonOperations DynValueHelper DynValueOperations DynamicImplementation DynamicImplementation DynamicMBean ECField ECFieldF2m ECFieldFp ECGenParameterSpec ECKey ECParameterSpec ECPoint ECPrivateKey ECPrivateKeySpec ECPublicKey ECPublicKeySpec ENCODING_CDR_ENCAPS EOFException EditorKit Element Element Element ElementIterator ElementType Ellipse2D Ellipse2D.Double Ellipse2D.Float EllipticCurve EmptyBorder EmptyStackException EncodedKeySpec Encoder Encoding EncryptedPrivateKeyInfo Entity Entity EntityReference EntityResolver EntityResolver2 Enum EnumConstantNotPresentException EnumControl EnumControl.Type EnumMap EnumSet EnumSyntax Enumeration Environment Error ErrorHandler ErrorListener ErrorManager EtchedBorder Event EventContext EventDirContext EventHandler EventListener EventListenerList EventListenerProxy EventObject EventQueue EventSetDescriptor Exception ExceptionDetailMessage ExceptionInInitializerError ExceptionList ExceptionListener Exchanger ExecutionException Executor ExecutorCompletionService ExecutorService Executors ExemptionMechanism ExemptionMechanismException ExemptionMechanismSpi ExpandVetoException ExportException Expression ExtendedRequest ExtendedResponse Externalizable FREE_MEM FactoryConfigurationError FailedLoginException FeatureDescriptor Fidelity Field FieldNameHelper FieldNameHelper FieldPosition FieldView File FileCacheImageInputStream FileCacheImageOutputStream FileChannel FileChannel.MapMode FileChooserUI FileDescriptor FileDialog FileFilter FileFilter FileHandler FileImageInputStream FileImageOutputStream FileInputStream FileLock FileLockInterruptionException FileNameMap FileNotFoundException FileOutputStream FilePermission FileReader FileSystemView FileView FileWriter FilenameFilter Filter FilterInputStream FilterOutputStream FilterReader FilterWriter FilteredImageSource FilteredRowSet Finishings FixedHeightLayoutCache FixedHolder FlatteningPathIterator FlavorEvent FlavorException FlavorListener FlavorMap FlavorTable Float FloatBuffer FloatControl FloatControl.Type FloatHolder FloatSeqHelper FloatSeqHolder FlowLayout FlowView FlowView.FlowStrategy Flushable FocusAdapter FocusEvent FocusListener FocusManager FocusTraversalPolicy Font FontFormatException FontMetrics FontRenderContext FontUIResource FormSubmitEvent FormSubmitEvent.MethodType FormView Format Format.Field FormatConversionProvider FormatFlagsConversionMismatchException FormatMismatch FormatMismatchHelper Formattable FormattableFlags Formatter Formatter FormatterClosedException ForwardRequest ForwardRequest ForwardRequestHelper ForwardRequestHelper Frame Future FutureTask GSSContext GSSCredential GSSException GSSManager GSSName GZIPInputStream GZIPOutputStream GapContent GarbageCollectorMXBean GatheringByteChannel GaugeMonitor GaugeMonitorMBean GeneralPath GeneralSecurityException GenericArrayType GenericDeclaration GenericSignatureFormatError GlyphJustificationInfo GlyphMetrics GlyphVector GlyphView GlyphView.GlyphPainter GradientPaint GraphicAttribute Graphics Graphics2D GraphicsConfigTemplate GraphicsConfiguration GraphicsDevice GraphicsEnvironment GrayFilter GregorianCalendar GridBagConstraints GridBagLayout GridLayout Group Guard GuardedObject HOLDING HTML HTML.Attribute HTML.Tag HTML.UnknownTag HTMLDocument HTMLDocument.Iterator HTMLEditorKit HTMLEditorKit.HTMLFactory HTMLEditorKit.HTMLTextAction HTMLEditorKit.InsertHTMLTextAction HTMLEditorKit.LinkController HTMLEditorKit.Parser HTMLEditorKit.ParserCallback HTMLFrameHyperlinkEvent HTMLWriter Handler HandlerBase HandshakeCompletedEvent HandshakeCompletedListener HasControls HashAttributeSet HashDocAttributeSet HashMap HashPrintJobAttributeSet HashPrintRequestAttributeSet HashPrintServiceAttributeSet HashSet Hashtable HeadlessException HierarchyBoundsAdapter HierarchyBoundsListener HierarchyEvent HierarchyListener Highlighter Highlighter.Highlight Highlighter.HighlightPainter HostnameVerifier HttpRetryException HttpURLConnection HttpsURLConnection HyperlinkEvent HyperlinkEvent.EventType HyperlinkListener ICC_ColorSpace ICC_Profile ICC_ProfileGray ICC_ProfileRGB IDLEntity IDLType IDLTypeHelper IDLTypeOperations ID_ASSIGNMENT_POLICY_ID ID_UNIQUENESS_POLICY_ID IIOByteBuffer IIOException IIOImage IIOInvalidTreeException IIOMetadata IIOMetadataController IIOMetadataFormat IIOMetadataFormatImpl IIOMetadataNode IIOParam IIOParamController IIOReadProgressListener IIOReadUpdateListener IIOReadWarningListener IIORegistry IIOServiceProvider IIOWriteProgressListener IIOWriteWarningListener IMPLICIT_ACTIVATION_POLICY_ID IMP_LIMIT INACTIVE INITIALIZE INTERNAL INTF_REPOS INVALID_ACTIVITY INVALID_TRANSACTION INV_FLAG INV_IDENT INV_OBJREF INV_POLICY IOException IOR IORHelper IORHolder IORInfo IORInfoOperations IORInterceptor IORInterceptorOperations IORInterceptor_3_0 IORInterceptor_3_0Helper IORInterceptor_3_0Holder IORInterceptor_3_0Operations IRObject IRObjectOperations Icon IconUIResource IconView IdAssignmentPolicy IdAssignmentPolicyOperations IdAssignmentPolicyValue IdUniquenessPolicy IdUniquenessPolicyOperations IdUniquenessPolicyValue IdentifierHelper Identity IdentityHashMap IdentityScope IllegalAccessError IllegalAccessException IllegalArgumentException IllegalBlockSizeException IllegalBlockingModeException IllegalCharsetNameException IllegalClassFormatException IllegalComponentStateException IllegalFormatCodePointException IllegalFormatConversionException IllegalFormatException IllegalFormatFlagsException IllegalFormatPrecisionException IllegalFormatWidthException IllegalMonitorStateException IllegalPathStateException IllegalSelectorException IllegalStateException IllegalThreadStateException Image ImageCapabilities ImageConsumer ImageFilter ImageGraphicAttribute ImageIO ImageIcon ImageInputStream ImageInputStreamImpl ImageInputStreamSpi ImageObserver ImageOutputStream ImageOutputStreamImpl ImageOutputStreamSpi ImageProducer ImageReadParam ImageReader ImageReaderSpi ImageReaderWriterSpi ImageTranscoder ImageTranscoderSpi ImageTypeSpecifier ImageView ImageWriteParam ImageWriter ImageWriterSpi ImagingOpException ImplicitActivationPolicy ImplicitActivationPolicyOperations ImplicitActivationPolicyValue IncompatibleClassChangeError IncompleteAnnotationException InconsistentTypeCode InconsistentTypeCode InconsistentTypeCodeHelper IndexColorModel IndexOutOfBoundsException IndexedPropertyChangeEvent IndexedPropertyDescriptor IndirectionException Inet4Address Inet6Address InetAddress InetSocketAddress Inflater InflaterInputStream InheritableThreadLocal Inherited InitialContext InitialContextFactory InitialContextFactoryBuilder InitialDirContext InitialLdapContext InlineView InputContext InputEvent InputMap InputMapUIResource InputMethod InputMethodContext InputMethodDescriptor InputMethodEvent InputMethodHighlight InputMethodListener InputMethodRequests InputMismatchException InputSource InputStream InputStream InputStream InputStreamReader InputSubset InputVerifier Insets InsetsUIResource InstanceAlreadyExistsException InstanceNotFoundException InstantiationError InstantiationException Instrument Instrumentation InsufficientResourcesException IntBuffer IntHolder Integer IntegerSyntax Interceptor InterceptorOperations InternalError InternalFrameAdapter InternalFrameEvent InternalFrameFocusTraversalPolicy InternalFrameListener InternalFrameUI InternationalFormatter InterruptedException InterruptedIOException InterruptedNamingException InterruptibleChannel IntrospectionException IntrospectionException Introspector Invalid InvalidActivityException InvalidAddress InvalidAddressHelper InvalidAddressHolder InvalidAlgorithmParameterException InvalidApplicationException InvalidAttributeIdentifierException InvalidAttributeValueException InvalidAttributeValueException InvalidAttributesException InvalidClassException InvalidDnDOperationException InvalidKeyException InvalidKeyException InvalidKeySpecException InvalidMarkException InvalidMidiDataException InvalidName InvalidName InvalidName InvalidNameException InvalidNameHelper InvalidNameHelper InvalidNameHolder InvalidObjectException InvalidOpenTypeException InvalidParameterException InvalidParameterSpecException InvalidPolicy InvalidPolicyHelper InvalidPreferencesFormatException InvalidPropertiesFormatException InvalidRelationIdException InvalidRelationServiceException InvalidRelationTypeException InvalidRoleInfoException InvalidRoleValueException InvalidSearchControlsException InvalidSearchFilterException InvalidSeq InvalidSlot InvalidSlotHelper InvalidTargetObjectTypeException InvalidTransactionException InvalidTypeForEncoding InvalidTypeForEncodingHelper InvalidValue InvalidValue InvalidValueHelper InvocationEvent InvocationHandler InvocationTargetException InvokeHandler IstringHelper ItemEvent ItemListener ItemSelectable Iterable Iterator IvParameterSpec JApplet JButton JCheckBox JCheckBoxMenuItem JColorChooser JComboBox JComboBox.KeySelectionManager JComponent JDesktopPane JDialog JEditorPane JFileChooser JFormattedTextField JFormattedTextField.AbstractFormatter JFormattedTextField.AbstractFormatterFactory JFrame JInternalFrame JInternalFrame.JDesktopIcon JLabel JLayeredPane JList JMException JMRuntimeException JMXAuthenticator JMXConnectionNotification JMXConnector JMXConnectorFactory JMXConnectorProvider JMXConnectorServer JMXConnectorServerFactory JMXConnectorServerMBean JMXConnectorServerProvider JMXPrincipal JMXProviderException JMXServerErrorException JMXServiceURL JMenu JMenuBar JMenuItem JOptionPane JPEGHuffmanTable JPEGImageReadParam JPEGImageWriteParam JPEGQTable JPanel JPasswordField JPopupMenu JPopupMenu.Separator JProgressBar JRadioButton JRadioButtonMenuItem JRootPane JScrollBar JScrollPane JSeparator JSlider JSpinner JSpinner.DateEditor JSpinner.DefaultEditor JSpinner.ListEditor JSpinner.NumberEditor JSplitPane JTabbedPane JTable JTable.PrintMode JTableHeader JTextArea JTextComponent JTextComponent.KeyBinding JTextField JTextPane JToggleButton JToggleButton.ToggleButtonModel JToolBar JToolBar.Separator JToolTip JTree JTree.DynamicUtilTreeNode JTree.EmptySelectionModel JViewport JWindow JarEntry JarException JarFile JarInputStream JarOutputStream JarURLConnection JdbcRowSet JobAttributes JobAttributes.DefaultSelectionType JobAttributes.DestinationType JobAttributes.DialogType JobAttributes.MultipleDocumentHandlingType JobAttributes.SidesType JobHoldUntil JobImpressions JobImpressionsCompleted JobImpressionsSupported JobKOctets JobKOctetsProcessed JobKOctetsSupported JobMediaSheets JobMediaSheetsCompleted JobMediaSheetsSupported JobMessageFromOperator JobName JobOriginatingUserName JobPriority JobPrioritySupported JobSheets JobState JobStateReason JobStateReasons JoinRowSet Joinable KerberosKey KerberosPrincipal KerberosTicket Kernel Key KeyAdapter KeyAgreement KeyAgreementSpi KeyAlreadyExistsException KeyEvent KeyEventDispatcher KeyEventPostProcessor KeyException KeyFactory KeyFactorySpi KeyGenerator KeyGeneratorSpi KeyListener KeyManagementException KeyManager KeyManagerFactory KeyManagerFactorySpi KeyPair KeyPairGenerator KeyPairGeneratorSpi KeyRep KeyRep.Type KeySpec KeyStore KeyStore.Builder KeyStore.CallbackHandlerProtection KeyStore.Entry KeyStore.LoadStoreParameter KeyStore.PasswordProtection KeyStore.PrivateKeyEntry KeyStore.ProtectionParameter KeyStore.SecretKeyEntry KeyStore.TrustedCertificateEntry KeyStoreBuilderParameters KeyStoreException KeyStoreSpi KeyStroke KeyboardFocusManager Keymap LDAPCertStoreParameters LIFESPAN_POLICY_ID LOCATION_FORWARD LSException LSInput LSLoadEvent LSOutput LSParser LSParserFilter LSProgressEvent LSResourceResolver LSSerializer LSSerializerFilter Label LabelUI LabelView LanguageCallback LastOwnerException LayeredHighlighter LayeredHighlighter.LayerPainter LayoutFocusTraversalPolicy LayoutManager LayoutManager2 LayoutQueue LdapContext LdapName LdapReferralException Lease Level LexicalHandler LifespanPolicy LifespanPolicyOperations LifespanPolicyValue LimitExceededException Line Line.Info Line2D Line2D.Double Line2D.Float LineBorder LineBreakMeasurer LineEvent LineEvent.Type LineListener LineMetrics LineNumberInputStream LineNumberReader LineUnavailableException LinkException LinkLoopException LinkRef LinkageError LinkedBlockingQueue LinkedHashMap LinkedHashSet LinkedList List List ListCellRenderer ListDataEvent ListDataListener ListIterator ListModel ListResourceBundle ListSelectionEvent ListSelectionListener ListSelectionModel ListUI ListView ListenerNotFoundException LoaderHandler LocalObject Locale LocateRegistry Locator Locator2 Locator2Impl LocatorImpl Lock LockSupport LogManager LogRecord LogStream Logger LoggingMXBean LoggingPermission LoginContext LoginException LoginModule Long LongBuffer LongHolder LongLongSeqHelper LongLongSeqHolder LongSeqHelper LongSeqHolder LookAndFeel LookupOp LookupTable MARSHAL MBeanAttributeInfo MBeanConstructorInfo MBeanException MBeanFeatureInfo MBeanInfo MBeanNotificationInfo MBeanOperationInfo MBeanParameterInfo MBeanPermission MBeanRegistration MBeanRegistrationException MBeanServer MBeanServerBuilder MBeanServerConnection MBeanServerDelegate MBeanServerDelegateMBean MBeanServerFactory MBeanServerForwarder MBeanServerInvocationHandler MBeanServerNotification MBeanServerNotificationFilter MBeanServerPermission MBeanTrustPermission MGF1ParameterSpec MLet MLetMBean Mac MacSpi MalformedInputException MalformedLinkException MalformedObjectNameException MalformedParameterizedTypeException MalformedURLException ManageReferralControl ManagementFactory ManagementPermission ManagerFactoryParameters Manifest Map Map.Entry MappedByteBuffer MarshalException MarshalledObject MaskFormatter MatchResult Matcher Math MathContext MatteBorder Media MediaName MediaPrintableArea MediaSize MediaSize.Engineering MediaSize.ISO MediaSize.JIS MediaSize.NA MediaSize.Other MediaSizeName MediaTracker MediaTray Member MemoryCacheImageInputStream MemoryCacheImageOutputStream MemoryHandler MemoryImageSource MemoryMXBean MemoryManagerMXBean MemoryNotificationInfo MemoryPoolMXBean MemoryType MemoryUsage Menu MenuBar MenuBarUI MenuComponent MenuContainer MenuDragMouseEvent MenuDragMouseListener MenuElement MenuEvent MenuItem MenuItemUI MenuKeyEvent MenuKeyListener MenuListener MenuSelectionManager MenuShortcut MessageDigest MessageDigestSpi MessageFormat MessageFormat.Field MessageProp MetaEventListener MetaMessage MetalBorders MetalBorders.ButtonBorder MetalBorders.Flush3DBorder MetalBorders.InternalFrameBorder MetalBorders.MenuBarBorder MetalBorders.MenuItemBorder MetalBorders.OptionDialogBorder MetalBorders.PaletteBorder MetalBorders.PopupMenuBorder MetalBorders.RolloverButtonBorder MetalBorders.ScrollPaneBorder MetalBorders.TableHeaderBorder MetalBorders.TextFieldBorder MetalBorders.ToggleButtonBorder MetalBorders.ToolBarBorder MetalButtonUI MetalCheckBoxIcon MetalCheckBoxUI MetalComboBoxButton MetalComboBoxEditor MetalComboBoxEditor.UIResource MetalComboBoxIcon MetalComboBoxUI MetalDesktopIconUI MetalFileChooserUI MetalIconFactory MetalIconFactory.FileIcon16 MetalIconFactory.FolderIcon16 MetalIconFactory.PaletteCloseIcon MetalIconFactory.TreeControlIcon MetalIconFactory.TreeFolderIcon MetalIconFactory.TreeLeafIcon MetalInternalFrameTitlePane MetalInternalFrameUI MetalLabelUI MetalLookAndFeel MetalMenuBarUI MetalPopupMenuSeparatorUI MetalProgressBarUI MetalRadioButtonUI MetalRootPaneUI MetalScrollBarUI MetalScrollButton MetalScrollPaneUI MetalSeparatorUI MetalSliderUI MetalSplitPaneUI MetalTabbedPaneUI MetalTextFieldUI MetalTheme MetalToggleButtonUI MetalToolBarUI MetalToolTipUI MetalTreeUI Method MethodDescriptor MidiChannel MidiDevice MidiDevice.Info MidiDeviceProvider MidiEvent MidiFileFormat MidiFileReader MidiFileWriter MidiMessage MidiSystem MidiUnavailableException MimeTypeParseException MinimalHTMLWriter MissingFormatArgumentException MissingFormatWidthException MissingResourceException Mixer Mixer.Info MixerProvider ModelMBean ModelMBeanAttributeInfo ModelMBeanConstructorInfo ModelMBeanInfo ModelMBeanInfoSupport ModelMBeanNotificationBroadcaster ModelMBeanNotificationInfo ModelMBeanOperationInfo ModificationItem Modifier Monitor MonitorMBean MonitorNotification MonitorSettingException MouseAdapter MouseDragGestureRecognizer MouseEvent MouseInfo MouseInputAdapter MouseInputListener MouseListener MouseMotionAdapter MouseMotionListener MouseWheelEvent MouseWheelListener MultiButtonUI MultiColorChooserUI MultiComboBoxUI MultiDesktopIconUI MultiDesktopPaneUI MultiDoc MultiDocPrintJob MultiDocPrintService MultiFileChooserUI MultiInternalFrameUI MultiLabelUI MultiListUI MultiLookAndFeel MultiMenuBarUI MultiMenuItemUI MultiOptionPaneUI MultiPanelUI MultiPixelPackedSampleModel MultiPopupMenuUI MultiProgressBarUI MultiRootPaneUI MultiScrollBarUI MultiScrollPaneUI MultiSeparatorUI MultiSliderUI MultiSpinnerUI MultiSplitPaneUI MultiTabbedPaneUI MultiTableHeaderUI MultiTableUI MultiTextUI MultiToolBarUI MultiToolTipUI MultiTreeUI MultiViewportUI MulticastSocket MultipleComponentProfileHelper MultipleComponentProfileHolder MultipleDocumentHandling MultipleMaster MutableAttributeSet MutableComboBoxModel MutableTreeNode NON_EXISTENT NO_IMPLEMENT NO_MEMORY NO_PERMISSION NO_RESOURCES NO_RESPONSE NVList Name NameAlreadyBoundException NameCallback NameClassPair NameComponent NameComponentHelper NameComponentHolder NameDynAnyPair NameDynAnyPairHelper NameDynAnyPairSeqHelper NameHelper NameHolder NameList NameNotFoundException NameParser NameValuePair NameValuePair NameValuePairHelper NameValuePairHelper NameValuePairSeqHelper NamedNodeMap NamedValue NamespaceChangeListener NamespaceContext NamespaceSupport Naming NamingContext NamingContextExt NamingContextExtHelper NamingContextExtHolder NamingContextExtOperations NamingContextExtPOA NamingContextHelper NamingContextHolder NamingContextOperations NamingContextPOA NamingEnumeration NamingEvent NamingException NamingExceptionEvent NamingListener NamingManager NamingSecurityException NavigationFilter NavigationFilter.FilterBypass NegativeArraySizeException NetPermission NetworkInterface NoClassDefFoundError NoConnectionPendingException NoContext NoContextHelper NoInitialContextException NoPermissionException NoRouteToHostException NoServant NoServantHelper NoSuchAlgorithmException NoSuchAttributeException NoSuchElementException NoSuchFieldError NoSuchFieldException NoSuchMethodError NoSuchMethodException NoSuchObjectException NoSuchPaddingException NoSuchProviderException Node NodeChangeEvent NodeChangeListener NodeList NonReadableChannelException NonWritableChannelException NoninvertibleTransformException NotActiveException NotBoundException NotCompliantMBeanException NotContextException NotEmpty NotEmptyHelper NotEmptyHolder NotFound NotFoundHelper NotFoundHolder NotFoundReason NotFoundReasonHelper NotFoundReasonHolder NotOwnerException NotSerializableException NotYetBoundException NotYetConnectedException Notation Notification NotificationBroadcaster NotificationBroadcasterSupport NotificationEmitter NotificationFilter NotificationFilterSupport NotificationListener NotificationResult NullCipher NullPointerException Number NumberFormat NumberFormat.Field NumberFormatException NumberFormatter NumberOfDocuments NumberOfInterveningJobs NumberUp NumberUpSupported NumericShaper OAEPParameterSpec OBJECT_NOT_EXIST OBJ_ADAPTER OMGVMCID ORB ORB ORBIdHelper ORBInitInfo ORBInitInfoOperations ORBInitializer ORBInitializerOperations ObjID Object Object ObjectAlreadyActive ObjectAlreadyActiveHelper ObjectChangeListener ObjectFactory ObjectFactoryBuilder ObjectHelper ObjectHolder ObjectIdHelper ObjectIdHelper ObjectImpl ObjectImpl ObjectInput ObjectInputStream ObjectInputStream.GetField ObjectInputValidation ObjectInstance ObjectName ObjectNotActive ObjectNotActiveHelper ObjectOutput ObjectOutputStream ObjectOutputStream.PutField ObjectReferenceFactory ObjectReferenceFactoryHelper ObjectReferenceFactoryHolder ObjectReferenceTemplate ObjectReferenceTemplateHelper ObjectReferenceTemplateHolder ObjectReferenceTemplateSeqHelper ObjectReferenceTemplateSeqHolder ObjectStreamClass ObjectStreamConstants ObjectStreamException ObjectStreamField ObjectView Observable Observer OceanTheme OctetSeqHelper OctetSeqHolder Oid OpenDataException OpenMBeanAttributeInfo OpenMBeanAttributeInfoSupport OpenMBeanConstructorInfo OpenMBeanConstructorInfoSupport OpenMBeanInfo OpenMBeanInfoSupport OpenMBeanOperationInfo OpenMBeanOperationInfoSupport OpenMBeanParameterInfo OpenMBeanParameterInfoSupport OpenType OpenType OperatingSystemMXBean Operation OperationNotSupportedException OperationsException Option OptionPaneUI OptionalDataException OrientationRequested OutOfMemoryError OutputDeviceAssigned OutputKeys OutputStream OutputStream OutputStream OutputStreamWriter OverlappingFileLockException OverlayLayout Override Owner PBEKey PBEKeySpec PBEParameterSpec PDLOverrideSupported PERSIST_STORE PKCS8EncodedKeySpec PKIXBuilderParameters PKIXCertPathBuilderResult PKIXCertPathChecker PKIXCertPathValidatorResult PKIXParameters POA POAHelper POAManager POAManagerOperations POAOperations PRIVATE_MEMBER PSSParameterSpec PSource PSource.PSpecified PUBLIC_MEMBER Pack200 Pack200.Packer Pack200.Unpacker Package PackedColorModel PageAttributes PageAttributes.ColorType PageAttributes.MediaType PageAttributes.OrientationRequestedType PageAttributes.OriginType PageAttributes.PrintQualityType PageFormat PageRanges Pageable PagedResultsControl PagedResultsResponseControl PagesPerMinute PagesPerMinuteColor Paint PaintContext PaintEvent Panel PanelUI Paper ParagraphView ParagraphView Parameter ParameterBlock ParameterDescriptor ParameterMetaData ParameterMode ParameterModeHelper ParameterModeHolder ParameterizedType ParseException ParsePosition Parser Parser ParserAdapter ParserConfigurationException ParserDelegator ParserFactory PartialResultException PasswordAuthentication PasswordCallback PasswordView Patch PathIterator Pattern PatternSyntaxException Permission Permission PermissionCollection Permissions PersistenceDelegate PersistentMBean PhantomReference Pipe Pipe.SinkChannel Pipe.SourceChannel PipedInputStream PipedOutputStream PipedReader PipedWriter PixelGrabber PixelInterleavedSampleModel PlainDocument PlainView Point Point2D Point2D.Double Point2D.Float PointerInfo Policy Policy Policy PolicyError PolicyErrorCodeHelper PolicyErrorHelper PolicyErrorHolder PolicyFactory PolicyFactoryOperations PolicyHelper PolicyHolder PolicyListHelper PolicyListHolder PolicyNode PolicyOperations PolicyQualifierInfo PolicyTypeHelper Polygon PooledConnection Popup PopupFactory PopupMenu PopupMenuEvent PopupMenuListener PopupMenuUI Port Port.Info PortUnreachableException PortableRemoteObject PortableRemoteObjectDelegate Position Position.Bias Predicate PreferenceChangeEvent PreferenceChangeListener Preferences PreferencesFactory PreparedStatement PresentationDirection Principal Principal PrincipalHolder PrintEvent PrintException PrintGraphics PrintJob PrintJobAdapter PrintJobAttribute PrintJobAttributeEvent PrintJobAttributeListener PrintJobAttributeSet PrintJobEvent PrintJobListener PrintQuality PrintRequestAttribute PrintRequestAttributeSet PrintService PrintServiceAttribute PrintServiceAttributeEvent PrintServiceAttributeListener PrintServiceAttributeSet PrintServiceLookup PrintStream PrintWriter Printable PrinterAbortException PrinterException PrinterGraphics PrinterIOException PrinterInfo PrinterIsAcceptingJobs PrinterJob PrinterLocation PrinterMakeAndModel PrinterMessageFromOperator PrinterMoreInfo PrinterMoreInfoManufacturer PrinterName PrinterResolution PrinterState PrinterStateReason PrinterStateReasons PrinterURI PriorityBlockingQueue PriorityQueue PrivateClassLoader PrivateCredentialPermission PrivateKey PrivateMLet PrivilegedAction PrivilegedActionException PrivilegedExceptionAction Process ProcessBuilder ProcessingInstruction ProfileDataException ProfileIdHelper ProgressBarUI ProgressMonitor ProgressMonitorInputStream Properties PropertyChangeEvent PropertyChangeListener PropertyChangeListenerProxy PropertyChangeSupport PropertyDescriptor PropertyEditor PropertyEditorManager PropertyEditorSupport PropertyPermission PropertyResourceBundle PropertyVetoException ProtectionDomain ProtocolException Provider Provider.Service ProviderException Proxy Proxy Proxy.Type ProxySelector PublicKey PushbackInputStream PushbackReader QName QuadCurve2D QuadCurve2D.Double QuadCurve2D.Float Query QueryEval QueryExp Queue QueuedJobCount RC2ParameterSpec RC5ParameterSpec REBIND REQUEST_PROCESSING_POLICY_ID RGBImageFilter RMIClassLoader RMIClassLoaderSpi RMIClientSocketFactory RMIConnection RMIConnectionImpl RMIConnectionImpl_Stub RMIConnector RMIConnectorServer RMICustomMaxStreamFormat RMIFailureHandler RMIIIOPServerImpl RMIJRMPServerImpl RMISecurityException RMISecurityManager RMIServer RMIServerImpl RMIServerImpl_Stub RMIServerSocketFactory RMISocketFactory RSAKey RSAKeyGenParameterSpec RSAMultiPrimePrivateCrtKey RSAMultiPrimePrivateCrtKeySpec RSAOtherPrimeInfo RSAPrivateCrtKey RSAPrivateCrtKeySpec RSAPrivateKey RSAPrivateKeySpec RSAPublicKey RSAPublicKeySpec RTFEditorKit Random RandomAccess RandomAccessFile Raster RasterFormatException RasterOp Rdn ReadOnlyBufferException ReadWriteLock Readable ReadableByteChannel Reader RealmCallback RealmChoiceCallback Receiver Rectangle Rectangle2D Rectangle2D.Double Rectangle2D.Float RectangularShape ReentrantLock ReentrantReadWriteLock ReentrantReadWriteLock.ReadLock ReentrantReadWriteLock.WriteLock Ref RefAddr Reference Reference ReferenceQueue ReferenceUriSchemesSupported Referenceable ReferralException ReflectPermission ReflectionException RefreshFailedException Refreshable Region RegisterableService Registry RegistryHandler RejectedExecutionException RejectedExecutionHandler Relation RelationException RelationNotFoundException RelationNotification RelationService RelationServiceMBean RelationServiceNotRegisteredException RelationSupport RelationSupportMBean RelationType RelationTypeNotFoundException RelationTypeSupport RemarshalException Remote RemoteCall RemoteException RemoteObject RemoteObjectInvocationHandler RemoteRef RemoteServer RemoteStub RenderContext RenderableImage RenderableImageOp RenderableImageProducer RenderedImage RenderedImageFactory Renderer RenderingHints RenderingHints.Key RepaintManager ReplicateScaleFilter RepositoryIdHelper Request RequestInfo RequestInfoOperations RequestProcessingPolicy RequestProcessingPolicyOperations RequestProcessingPolicyValue RequestingUserName RequiredModelMBean RescaleOp ResolutionSyntax ResolveResult Resolver ResourceBundle ResponseCache ResponseHandler Result ResultSet ResultSetMetaData Retention RetentionPolicy ReverbType Robot Role RoleInfo RoleInfoNotFoundException RoleList RoleNotFoundException RoleResult RoleStatus RoleUnresolved RoleUnresolvedList RootPaneContainer RootPaneUI RoundRectangle2D RoundRectangle2D.Double RoundRectangle2D.Float RoundingMode RowMapper RowSet RowSetEvent RowSetInternal RowSetListener RowSetMetaData RowSetMetaDataImpl RowSetReader RowSetWarning RowSetWriter RuleBasedCollator RunTime RunTimeOperations Runnable Runtime RuntimeErrorException RuntimeException RuntimeMBeanException RuntimeMXBean RuntimeOperationsException RuntimePermission SAXException SAXNotRecognizedException SAXNotSupportedException SAXParseException SAXParser SAXParserFactory SAXResult SAXSource SAXTransformerFactory SERVANT_RETENTION_POLICY_ID SQLData SQLException SQLInput SQLInputImpl SQLOutput SQLOutputImpl SQLPermission SQLWarning SSLContext SSLContextSpi SSLEngine SSLEngineResult SSLEngineResult.HandshakeStatus SSLEngineResult.Status SSLException SSLHandshakeException SSLKeyException SSLPeerUnverifiedException SSLPermission SSLProtocolException SSLServerSocket SSLServerSocketFactory SSLSession SSLSessionBindingEvent SSLSessionBindingListener SSLSessionContext SSLSocket SSLSocketFactory SUCCESSFUL SYNC_WITH_TRANSPORT SYSTEM_EXCEPTION SampleModel Sasl SaslClient SaslClientFactory SaslException SaslServer SaslServerFactory Savepoint Scanner ScatteringByteChannel ScheduledExecutorService ScheduledFuture ScheduledThreadPoolExecutor Schema SchemaFactory SchemaFactoryLoader SchemaViolationException ScrollBarUI ScrollPane ScrollPaneAdjustable ScrollPaneConstants ScrollPaneLayout ScrollPaneLayout.UIResource ScrollPaneUI Scrollable Scrollbar SealedObject SearchControls SearchResult SecretKey SecretKeyFactory SecretKeyFactorySpi SecretKeySpec SecureCacheResponse SecureClassLoader SecureRandom SecureRandomSpi Security SecurityException SecurityManager SecurityPermission Segment SelectableChannel SelectionKey Selector SelectorProvider Semaphore SeparatorUI Sequence SequenceInputStream Sequencer Sequencer.SyncMode SerialArray SerialBlob SerialClob SerialDatalink SerialException SerialJavaObject SerialRef SerialStruct Serializable SerializablePermission Servant ServantActivator ServantActivatorHelper ServantActivatorOperations ServantActivatorPOA ServantAlreadyActive ServantAlreadyActiveHelper ServantLocator ServantLocatorHelper ServantLocatorOperations ServantLocatorPOA ServantManager ServantManagerOperations ServantNotActive ServantNotActiveHelper ServantObject ServantRetentionPolicy ServantRetentionPolicyOperations ServantRetentionPolicyValue ServerCloneException ServerError ServerException ServerIdHelper ServerNotActiveException ServerRef ServerRequest ServerRequestInfo ServerRequestInfoOperations ServerRequestInterceptor ServerRequestInterceptorOperations ServerRuntimeException ServerSocket ServerSocketChannel ServerSocketFactory ServiceContext ServiceContextHelper ServiceContextHolder ServiceContextListHelper ServiceContextListHolder ServiceDetail ServiceDetailHelper ServiceIdHelper ServiceInformation ServiceInformationHelper ServiceInformationHolder ServiceNotFoundException ServicePermission ServiceRegistry ServiceRegistry.Filter ServiceUI ServiceUIFactory ServiceUnavailableException Set SetOfIntegerSyntax SetOverrideType SetOverrideTypeHelper Severity Shape ShapeGraphicAttribute SheetCollate Short ShortBuffer ShortBufferException ShortHolder ShortLookupTable ShortMessage ShortSeqHelper ShortSeqHolder Sides Signature SignatureException SignatureSpi SignedObject Signer SimpleAttributeSet SimpleBeanInfo SimpleDateFormat SimpleDoc SimpleFormatter SimpleTimeZone SimpleType SinglePixelPackedSampleModel SingleSelectionModel Size2DSyntax SizeLimitExceededException SizeRequirements SizeSequence Skeleton SkeletonMismatchException SkeletonNotFoundException SliderUI Socket SocketAddress SocketChannel SocketException SocketFactory SocketHandler SocketImpl SocketImplFactory SocketOptions SocketPermission SocketSecurityException SocketTimeoutException SoftBevelBorder SoftReference SortControl SortKey SortResponseControl SortedMap SortedSet SortingFocusTraversalPolicy Soundbank SoundbankReader SoundbankResource Source SourceDataLine SourceLocator SpinnerDateModel SpinnerListModel SpinnerModel SpinnerNumberModel SpinnerUI SplitPaneUI Spring SpringLayout SpringLayout.Constraints SslRMIClientSocketFactory SslRMIServerSocketFactory Stack StackOverflowError StackTraceElement StandardMBean StartTlsRequest StartTlsResponse State StateEdit StateEditable StateFactory Statement Statement StreamCorruptedException StreamHandler StreamPrintService StreamPrintServiceFactory StreamResult StreamSource StreamTokenizer Streamable StreamableValue StrictMath String StringBuffer StringBufferInputStream StringBuilder StringCharacterIterator StringContent StringHolder StringIndexOutOfBoundsException StringMonitor StringMonitorMBean StringNameHelper StringReader StringRefAddr StringSelection StringSeqHelper StringSeqHolder StringTokenizer StringValueExp StringValueHelper StringWriter Stroke Struct StructMember StructMemberHelper Stub StubDelegate StubNotFoundException Style StyleConstants StyleConstants.CharacterConstants StyleConstants.ColorConstants StyleConstants.FontConstants StyleConstants.ParagraphConstants StyleContext StyleSheet StyleSheet.BoxPainter StyleSheet.ListPainter StyledDocument StyledEditorKit StyledEditorKit.AlignmentAction StyledEditorKit.BoldAction StyledEditorKit.FontFamilyAction StyledEditorKit.FontSizeAction StyledEditorKit.ForegroundAction StyledEditorKit.ItalicAction StyledEditorKit.StyledTextAction StyledEditorKit.UnderlineAction Subject SubjectDelegationPermission SubjectDomainCombiner SupportedValuesAttribute SuppressWarnings SwingConstants SwingPropertyChangeSupport SwingUtilities SyncFactory SyncFactoryException SyncFailedException SyncProvider SyncProviderException SyncResolver SyncScopeHelper SynchronousQueue SynthConstants SynthContext SynthGraphicsUtils SynthLookAndFeel SynthPainter SynthStyle SynthStyleFactory Synthesizer SysexMessage System SystemColor SystemException SystemFlavorMap TAG_ALTERNATE_IIOP_ADDRESS TAG_CODE_SETS TAG_INTERNET_IOP TAG_JAVA_CODEBASE TAG_MULTIPLE_COMPONENTS TAG_ORB_TYPE TAG_POLICIES TAG_RMI_CUSTOM_MAX_STREAM_FORMAT TCKind THREAD_POLICY_ID TIMEOUT TRANSACTION_MODE TRANSACTION_REQUIRED TRANSACTION_ROLLEDBACK TRANSACTION_UNAVAILABLE TRANSIENT TRANSPORT_RETRY TabExpander TabSet TabStop TabableView TabbedPaneUI TableCellEditor TableCellRenderer TableColumn TableColumnModel TableColumnModelEvent TableColumnModelListener TableHeaderUI TableModel TableModelEvent TableModelListener TableUI TableView TabularData TabularDataSupport TabularType TagElement TaggedComponent TaggedComponentHelper TaggedComponentHolder TaggedProfile TaggedProfileHelper TaggedProfileHolder Target TargetDataLine TargetedNotification Templates TemplatesHandler Text TextAction TextArea TextAttribute TextComponent TextEvent TextField TextHitInfo TextInputCallback TextLayout TextLayout.CaretPolicy TextListener TextMeasurer TextOutputCallback TextSyntax TextUI TexturePaint Thread Thread.State Thread.UncaughtExceptionHandler ThreadDeath ThreadFactory ThreadGroup ThreadInfo ThreadLocal ThreadMXBean ThreadPolicy ThreadPolicyOperations ThreadPolicyValue ThreadPoolExecutor ThreadPoolExecutor.AbortPolicy ThreadPoolExecutor.CallerRunsPolicy ThreadPoolExecutor.DiscardOldestPolicy ThreadPoolExecutor.DiscardPolicy Throwable Tie TileObserver Time TimeLimitExceededException TimeUnit TimeZone TimeoutException Timer Timer Timer TimerAlarmClockNotification TimerMBean TimerNotification TimerTask Timestamp Timestamp TitledBorder TooManyListenersException ToolBarUI ToolTipManager ToolTipUI Toolkit Track TransactionRequiredException TransactionRolledbackException TransactionService TransactionalWriter TransferHandler Transferable TransformAttribute Transformer TransformerConfigurationException TransformerException TransformerFactory TransformerFactoryConfigurationError TransformerHandler Transmitter Transparency TreeCellEditor TreeCellRenderer TreeExpansionEvent TreeExpansionListener TreeMap TreeModel TreeModelEvent TreeModelListener TreeNode TreePath TreeSelectionEvent TreeSelectionListener TreeSelectionModel TreeSet TreeUI TreeWillExpandListener TrustAnchor TrustManager TrustManagerFactory TrustManagerFactorySpi Type TypeCode TypeCodeHolder TypeInfo TypeInfoProvider TypeMismatch TypeMismatch TypeMismatch TypeMismatchHelper TypeMismatchHelper TypeNotPresentException TypeVariable Types UID UIDefaults UIDefaults.ActiveValue UIDefaults.LazyInputMap UIDefaults.LazyValue UIDefaults.ProxyLazyValue UIManager UIManager.LookAndFeelInfo UIResource ULongLongSeqHelper ULongLongSeqHolder ULongSeqHelper ULongSeqHolder UNKNOWN UNKNOWN UNSUPPORTED_POLICY UNSUPPORTED_POLICY_VALUE URI URIException URIResolver URISyntax URISyntaxException URL URLClassLoader URLConnection URLDecoder URLEncoder URLStreamHandler URLStreamHandlerFactory URLStringHelper USER_EXCEPTION UShortSeqHelper UShortSeqHolder UTFDataFormatException UUID UndeclaredThrowableException UndoManager UndoableEdit UndoableEditEvent UndoableEditListener UndoableEditSupport UnexpectedException UnicastRemoteObject UnionMember UnionMemberHelper UnknownEncoding UnknownEncodingHelper UnknownError UnknownException UnknownFormatConversionException UnknownFormatFlagsException UnknownGroupException UnknownHostException UnknownHostException UnknownObjectException UnknownServiceException UnknownUserException UnknownUserExceptionHelper UnknownUserExceptionHolder UnmappableCharacterException UnmarshalException UnmodifiableClassException UnmodifiableSetException UnrecoverableEntryException UnrecoverableKeyException Unreferenced UnresolvedAddressException UnresolvedPermission UnsatisfiedLinkError UnsolicitedNotification UnsolicitedNotificationEvent UnsolicitedNotificationListener UnsupportedAddressTypeException UnsupportedAudioFileException UnsupportedCallbackException UnsupportedCharsetException UnsupportedClassVersionError UnsupportedEncodingException UnsupportedFlavorException UnsupportedLookAndFeelException UnsupportedOperationException UserDataHandler UserException Util UtilDelegate Utilities VMID VM_ABSTRACT VM_CUSTOM VM_NONE VM_TRUNCATABLE Validator ValidatorHandler ValueBase ValueBaseHelper ValueBaseHolder ValueExp ValueFactory ValueHandler ValueHandlerMultiFormat ValueInputStream ValueMember ValueMemberHelper ValueOutputStream VariableHeightLayoutCache Vector VerifyError VersionSpecHelper VetoableChangeListener VetoableChangeListenerProxy VetoableChangeSupport View ViewFactory ViewportLayout ViewportUI VirtualMachineError Visibility VisibilityHelper VoiceStatus Void VolatileImage WCharSeqHelper WCharSeqHolder WStringSeqHelper WStringSeqHolder WStringValueHelper WeakHashMap WeakReference WebRowSet WildcardType Window WindowAdapter WindowConstants WindowEvent WindowFocusListener WindowListener WindowStateListener WrappedPlainView WritableByteChannel WritableRaster WritableRenderedImage WriteAbortedException Writer WrongAdapter WrongAdapterHelper WrongPolicy WrongPolicyHelper WrongTransaction WrongTransactionHelper WrongTransactionHolder X500Principal X500PrivateCredential X509CRL X509CRLEntry X509CRLSelector X509CertSelector X509Certificate X509Certificate X509EncodedKeySpec X509ExtendedKeyManager X509Extension X509KeyManager X509TrustManager XAConnection XADataSource XAException XAResource XMLConstants XMLDecoder XMLEncoder XMLFilter XMLFilterImpl XMLFormatter XMLGregorianCalendar XMLParseException XMLReader XMLReaderAdapter XMLReaderFactory XPath XPathConstants XPathException XPathExpression XPathExpressionException XPathFactory XPathFactoryConfigurationException XPathFunction XPathFunctionException XPathFunctionResolver XPathVariableResolver Xid XmlReader XmlWriter ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream ZoneView _BindingIteratorImplBase _BindingIteratorStub _DynAnyFactoryStub _DynAnyStub _DynArrayStub _DynEnumStub _DynFixedStub _DynSequenceStub _DynStructStub _DynUnionStub _DynValueStub _IDLTypeStub _NamingContextExtStub _NamingContextImplBase _NamingContextStub _PolicyStub _Remote_Stub _ServantActivatorStub _ServantLocatorStub"@@ -90,106 +80,100 @@ regex_'25'28'25'7cn'29 = compileRegex "%(%|n)" regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 = compileRegex "\\b[_a-zA-Z]\\w*(?=[\\s]*)" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Printf","Printf"),("PrintfString","PrintfString"),("Member","Normal Text"),("Commentar 1","Comment"),("Commentar 2","Comment")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Printf",NormalTok),("PrintfString",StringTok),("Member",NormalTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok)] -parseRules "Normal" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java15 >>= withAttribute "Java15"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_scala2 >>= withAttribute "Scala2"))- <|>- (withChildren (pFloat >>= withAttribute "Float") ((pAnyChar "fF" >>= withAttribute "Float")))- <|>- ((pHlCOct >>= withAttribute "Octal"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- (withChildren (pInt >>= withAttribute "Decimal") (((pString False "ULL" >>= withAttribute "Decimal"))- <|>- ((pString False "LUL" >>= withAttribute "Decimal"))- <|>- ((pString False "LLU" >>= withAttribute "Decimal"))- <|>- ((pString False "UL" >>= withAttribute "Decimal"))- <|>- ((pString False "LU" >>= withAttribute "Decimal"))- <|>- ((pString False "LL" >>= withAttribute "Decimal"))- <|>- ((pString False "U" >>= withAttribute "Decimal"))- <|>- ((pString False "L" >>= withAttribute "Decimal"))))- <|>- ((pHlCChar >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'5c'2e'28format'7cprintf'29'5cb >>= withAttribute "Function") >>~ pushContext "Printf")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute "Function"))- <|>- ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute "Symbol") >>~ pushContext "Member")- <|>- ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "Normal" =+ (((Text.Highlighting.Kate.Syntax.Javadoc.parseExpression))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_java15 >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_scala2 >>= withAttribute NormalTok))+ <|>+ (withChildren (pFloat >>= withAttribute FloatTok) ((pAnyChar "fF" >>= withAttribute FloatTok)))+ <|>+ ((pHlCOct >>= withAttribute BaseNTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ (withChildren (pInt >>= withAttribute DecValTok) (((pString False "ULL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LUL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LLU" >>= withAttribute DecValTok))+ <|>+ ((pString False "UL" >>= withAttribute DecValTok))+ <|>+ ((pString False "LU" >>= withAttribute DecValTok))+ <|>+ ((pString False "LL" >>= withAttribute DecValTok))+ <|>+ ((pString False "U" >>= withAttribute DecValTok))+ <|>+ ((pString False "L" >>= withAttribute DecValTok))))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aBEGIN'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2f'2f'5cs'2aEND'2e'2a'24 >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'5c'2e'28format'7cprintf'29'5cb >>= withAttribute FunctionTok) >>~ pushContext "Printf")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cb'5b'5f'5cw'5d'5b'5f'5cw'5cd'5d'2a'28'3f'3d'5b'5cs'5d'2a'28'2f'5c'2a'5cs'2a'5cd'2b'5cs'2a'5c'2a'2f'5cs'2a'29'3f'5b'28'5d'29 >>= withAttribute FunctionTok))+ <|>+ ((pRegExpr regex_'5b'2e'5d'7b1'2c1'7d >>= withAttribute NormalTok) >>~ pushContext "Member")+ <|>+ ((pAnyChar ":!%&()+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Printf" = - do (attr, result) <- (((pDetectChar False ';' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "PrintfString"))- return (attr, result)+parseRules "Printf" =+ (((pDetectChar False ';' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "PrintfString")) -parseRules "PrintfString" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28'5c'2e'5cd'2b'29'3f'5ba'2dhosxA'2dCEGHSX'5d >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28t'7cT'29'28a'7cA'7cb'7cB'7cc'7cC'7cd'7cD'7ce'7cF'7ch'7cH'7cI'7cj'7ck'7cl'7cL'7cm'7cM'7cN'7cp'7cP'7cQ'7cr'7cR'7cs'7cS'7cT'7cy'7cY'7cz'7cZ'29 >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'25'28'25'7cn'29 >>= withAttribute "String Char")))- return (attr, result)+parseRules "PrintfString" =+ (((pLineContinue >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28'5c'2e'5cd'2b'29'3f'5ba'2dhosxA'2dCEGHSX'5d >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'28'5cd'2b'5c'24'29'3f'28'2d'7c'23'7c'5c'2b'7c'5c_'7c0'7c'2c'7c'5c'28'29'2a'5cd'2a'28t'7cT'29'28a'7cA'7cb'7cB'7cc'7cC'7cd'7cD'7ce'7cF'7ch'7cH'7cI'7cj'7ck'7cl'7cL'7cm'7cM'7cN'7cp'7cP'7cQ'7cr'7cR'7cs'7cS'7cT'7cy'7cY'7cz'7cZ'29 >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'25'28'25'7cn'29 >>= withAttribute CharTok))) -parseRules "Member" = - do (attr, result) <- (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute "Function") >>~ (popContext))- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "Member" =+ (((pRegExpr regex_'5cb'5b'5fa'2dzA'2dZ'5d'5cw'2a'28'3f'3d'5b'5cs'5d'2a'29 >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Commentar 1" = +parseRules "Commentar 1" = pzero -parseRules "Commentar 2" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar 2" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Scheme.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file scheme.xml, version 1.12,- by Dominik Haumann (dhdev@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file scheme.xml, version 1.12, by Dominik Haumann (dhdev@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Scheme ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Scheme+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Scheme"@@ -19,65 +22,52 @@ syntaxExtensions = "*.scm;*.ss;*.scheme;*.guile" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Scheme" } context <- currentContext <|> (pushContext "Level0" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Scheme",["Level0"])], synStLanguage = "Scheme", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Scheme",["Level0"])], synStLanguage = "Scheme", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Level0" -> return () >> pHandleEndLine- "Default" -> return () >> pHandleEndLine- "MultiLineComment" -> return () >> pHandleEndLine+ "Level0" -> return ()+ "Default" -> return ()+ "MultiLineComment" -> return () "SpecialNumber" -> (popContext) >> pEndLine- "String" -> return () >> pHandleEndLine- "function_decl" -> return () >> pHandleEndLine- "Level1" -> return () >> pHandleEndLine- "Level2" -> return () >> pHandleEndLine- "Level3" -> return () >> pHandleEndLine- "Level4" -> return () >> pHandleEndLine- "Level5" -> return () >> pHandleEndLine- "Level6" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "String" -> return ()+ "function_decl" -> return ()+ "Level1" -> return ()+ "Level2" -> return ()+ "Level3" -> return ()+ "Level4" -> return ()+ "Level5" -> return ()+ "Level6" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Definition","kw"),("Operator","kw"),("Function","fu"),("Data","dt"),("Decimal","dv"),("BaseN","bn"),("Float","fl"),("Char","ch"),("String","st"),("Comment","co"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_operators = Set.fromList $ words $ "<= < = => >= > - / *,* *) +" list_characters = Set.fromList $ words $ "#\\nul #\\soh #\\stx #\\etx #\\eot #\\enq #\\ack #\\bel #\\bs #\\ht #\\nl #\\vt #\\np #\\cr #\\so #\\si #\\dle #\\dc1 #\\dc2 #\\dc3 #\\dc4 #\\nak #\\syn #\\etb #\\can #\\em #\\sub #\\esc #\\fs #\\gs #\\rs #\\us #\\space #\\sp #\\newline #\\nl #\\tab #\\ht #\\backspace #\\bs #\\return #\\cr #\\page #\\np #\\null #\\nul"@@ -94,119 +84,107 @@ regex_'5cd'2a'28'5c'2e'5cd'2b'29'3f = compileRegex "\\d*(\\.\\d+)?" regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a = compileRegex "\\s*[A-Za-z0-9-+\\<\\>//\\*]*\\s*" -defaultAttributes = [("Level0","Normal"),("Default","Normal"),("MultiLineComment","Comment"),("SpecialNumber","Normal"),("String","String"),("function_decl","Function"),("Level1","Normal"),("Level2","Normal"),("Level3","Normal"),("Level4","Normal"),("Level5","Normal"),("Level6","Normal")]+defaultAttributes = [("Level0",NormalTok),("Default",NormalTok),("MultiLineComment",CommentTok),("SpecialNumber",NormalTok),("String",StringTok),("function_decl",FunctionTok),("Level1",NormalTok),("Level2",NormalTok),("Level3",NormalTok),("Level4",NormalTok),("Level5",NormalTok),("Level6",NormalTok)] -parseRules "Level0" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets1") >>~ pushContext "Level1")- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level0" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level1")+ <|>+ ((parseRules "Default"))) -parseRules "Default" = - do (attr, result) <- (((pRegExpr regex_'3b'2b'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'3b'2b'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pDetect2Chars False '#' '!' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_defines >>= withAttribute "Definition") >>~ pushContext "function_decl")- <|>- ((pKeyword " \n\t.(),%&;[]^{|}~" list_characters >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pRegExpr regex_'23'5bbodxei'5d >>= withAttribute "Char") >>~ pushContext "SpecialNumber")- <|>- ((pRegExpr regex_'23'5btf'5d >>= withAttribute "Decimal"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '(' >>= withAttribute "Brackets1") >>~ pushContext "Level1"))- return (attr, result)+parseRules "Default" =+ (((pRegExpr regex_'3b'2b'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'3b'2b'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pRegExpr regex_'3b'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pDetect2Chars False '#' '!' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_operators >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_defines >>= withAttribute KeywordTok) >>~ pushContext "function_decl")+ <|>+ ((pKeyword " \n\t.(),%&;[]^{|}~" list_characters >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pRegExpr regex_'23'5bbodxei'5d >>= withAttribute CharTok) >>~ pushContext "SpecialNumber")+ <|>+ ((pRegExpr regex_'23'5btf'5d >>= withAttribute DecValTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level1")) -parseRules "MultiLineComment" = - do (attr, result) <- ((pColumn 0 >> pRegExpr regex_'21'23'5cs'2a'24 >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "MultiLineComment" =+ ((pColumn 0 >> pRegExpr regex_'21'23'5cs'2a'24 >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "SpecialNumber" = - do (attr, result) <- (((pRegExpr regex_'5cd'2a'28'5c'2e'5cd'2b'29'3f >>= withAttribute "Decimal") >>~ (popContext))- <|>- (return () >> return ([], "")))- return (attr, result)+parseRules "SpecialNumber" =+ (((pRegExpr regex_'5cd'2a'28'5c'2e'5cd'2b'29'3f >>= withAttribute DecValTok) >>~ (popContext))+ <|>+ (currentContext >>= parseRules)) -parseRules "String" = - do (attr, result) <- (((pKeyword " \n\t.(),%&;[]^{|}~" list_characters >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetect2Chars False '\\' '"' >>= withAttribute "Char"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pKeyword " \n\t.(),%&;[]^{|}~" list_characters >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'23'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '"' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "function_decl" = - do (attr, result) <- ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute "Function") >>~ (popContext))- return (attr, result)+parseRules "function_decl" =+ ((pRegExpr regex_'5cs'2a'5bA'2dZa'2dz0'2d9'2d'2b'5c'3c'5c'3e'2f'2f'5c'2a'5d'2a'5cs'2a >>= withAttribute FunctionTok) >>~ (popContext)) -parseRules "Level1" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets2") >>~ pushContext "Level2")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets1") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level1" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level2")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) -parseRules "Level2" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets3") >>~ pushContext "Level3")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets2") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level2" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level3")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) -parseRules "Level3" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets4") >>~ pushContext "Level4")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets3") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level3" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level4")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) -parseRules "Level4" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets5") >>~ pushContext "Level5")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets4") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level4" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level5")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) -parseRules "Level5" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets6") >>~ pushContext "Level6")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets5") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level5" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level6")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) -parseRules "Level6" = - do (attr, result) <- (((pDetectChar False '(' >>= withAttribute "Brackets1") >>~ pushContext "Level1")- <|>- ((pDetectChar False ')' >>= withAttribute "Brackets6") >>~ (popContext))- <|>- ((parseRules "Default")))- return (attr, result)+parseRules "Level6" =+ (((pDetectChar False '(' >>= withAttribute NormalTok) >>~ pushContext "Level1")+ <|>+ ((pDetectChar False ')' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "Default"))) parseRules "" = parseRules "Level0"
Text/Highlighting/Kate/Syntax/Sci.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file sci.xml, version 1.03,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file sci.xml, version 1.03, by -} -module Text.Highlighting.Kate.Syntax.Sci ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Sci+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "scilab"@@ -19,54 +22,41 @@ syntaxExtensions = "*.sci;*.sce" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "scilab" } context <- currentContext <|> (pushContext "main" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("scilab",["main"])], synStLanguage = "scilab", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("scilab",["main"])], synStLanguage = "scilab", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "main" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "main" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Function-keywords","fu"),("functions","fu"),("Decimal","dv"),("Float","fl"),("Comment","co"),("String","st")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_Structure'2dkeywords = Set.fromList $ words $ "do else for if elseif end select then while" list_Control'2dkeywords = Set.fromList $ words $ "abort break quit return resume pause"@@ -77,29 +67,28 @@ regex_'2f'2f'2e'2a'24 = compileRegex "//.*$" -defaultAttributes = [("main","Normal Text")]+defaultAttributes = [("main",NormalTok)] -parseRules "main" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Structure'2dkeywords >>= withAttribute "Structure-keywords"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Control'2dkeywords >>= withAttribute "Control-keywords"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Function'2dkeywords >>= withAttribute "Function-keywords"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Warning'2dkeywords >>= withAttribute "Warning-keywords"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Constants'2dkeyword >>= withAttribute "Constants-keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_functions >>= withAttribute "functions"))- <|>- ((pFloat >>= withAttribute "Flo"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'2f'2f'2e'2a'24 >>= withAttribute "Comment"))- <|>- ((pRangeDetect '"' '"' >>= withAttribute "String")))- return (attr, result)+parseRules "main" =+ (((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Structure'2dkeywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Control'2dkeywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Function'2dkeywords >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Warning'2dkeywords >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_Constants'2dkeyword >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pFloat >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'2f'2f'2e'2a'24 >>= withAttribute CommentTok))+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute StringTok))) parseRules "" = parseRules "main"
Text/Highlighting/Kate/Syntax/Sed.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file sed.xml, version 1.0,- by Bart Sas (bart.sas@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file sed.xml, version 1.0, by Bart Sas (bart.sas@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Sed ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Sed+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,81 +21,68 @@ syntaxExtensions = "*.sed" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "sed" } context <- currentContext <|> (pushContext "BeginningOfLine" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("sed",["BeginningOfLine"])], synStLanguage = "sed", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("sed",["BeginningOfLine"])], synStLanguage = "sed", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "BeginningOfLine" -> return () >> pHandleEndLine- "FirstAddressRegex" -> pushContext "Error" >> pHandleEndLine- "AfterFirstAddress" -> pushContext "BeginningOfLine" >> pHandleEndLine- "AfterFirstAddress2" -> pushContext "BeginningOfLine" >> pHandleEndLine- "SecondAddress" -> pushContext "Error" >> pHandleEndLine- "SecondAddressRegex" -> pushContext "Error" >> pHandleEndLine- "AfterSecondAddress" -> pushContext "Error" >> pHandleEndLine- "Step" -> pushContext "Error" >> pHandleEndLine- "Command" -> pushContext "Error" >> pHandleEndLine- "SCommand" -> pushContext "Error" >> pHandleEndLine- "SRegex" -> pushContext "Error" >> pHandleEndLine- "SReplacement" -> pushContext "Error" >> pHandleEndLine- "SFlags" -> pushContext "BeginningOfLine" >> pHandleEndLine- "WFlag" -> pushContext "BeginningOfLine" >> pHandleEndLine- "YCommand" -> pushContext "Error" >> pHandleEndLine- "YSourceList" -> pushContext "Error" >> pHandleEndLine- "YDestList" -> pushContext "Error" >> pHandleEndLine- "AICCommand" -> pushContext "Error" >> pHandleEndLine- "LiteralText" -> pushContext "BeginningOfLine" >> pHandleEndLine- "BTCommand" -> pushContext "BeginningOfLine" >> pHandleEndLine- "WRCommand" -> pushContext "Error" >> pHandleEndLine- "LCommand" -> pushContext "BeginningOfLine" >> pHandleEndLine- "QCommand" -> pushContext "BeginningOfLine" >> pHandleEndLine- "Label" -> pushContext "Error" >> pHandleEndLine- "AfterCommand" -> pushContext "BeginningOfLine" >> pHandleEndLine- "Regex" -> pushContext "Error" >> pHandleEndLine- "Comment" -> pushContext "BeginningOfLine" >> pHandleEndLine- "Error" -> pushContext "BeginningOfLine" >> pHandleEndLine- _ -> pHandleEndLine+ "BeginningOfLine" -> return ()+ "FirstAddressRegex" -> pushContext "Error" >> return ()+ "AfterFirstAddress" -> pushContext "BeginningOfLine" >> return ()+ "AfterFirstAddress2" -> pushContext "BeginningOfLine" >> return ()+ "SecondAddress" -> pushContext "Error" >> return ()+ "SecondAddressRegex" -> pushContext "Error" >> return ()+ "AfterSecondAddress" -> pushContext "Error" >> return ()+ "Step" -> pushContext "Error" >> return ()+ "Command" -> pushContext "Error" >> return ()+ "SCommand" -> pushContext "Error" >> return ()+ "SRegex" -> pushContext "Error" >> return ()+ "SReplacement" -> pushContext "Error" >> return ()+ "SFlags" -> pushContext "BeginningOfLine" >> return ()+ "WFlag" -> pushContext "BeginningOfLine" >> return ()+ "YCommand" -> pushContext "Error" >> return ()+ "YSourceList" -> pushContext "Error" >> return ()+ "YDestList" -> pushContext "Error" >> return ()+ "AICCommand" -> pushContext "Error" >> return ()+ "LiteralText" -> pushContext "BeginningOfLine" >> return ()+ "BTCommand" -> pushContext "BeginningOfLine" >> return ()+ "WRCommand" -> pushContext "Error" >> return ()+ "LCommand" -> pushContext "BeginningOfLine" >> return ()+ "QCommand" -> pushContext "BeginningOfLine" >> return ()+ "Label" -> pushContext "Error" >> return ()+ "AfterCommand" -> pushContext "BeginningOfLine" >> return ()+ "Regex" -> pushContext "Error" >> return ()+ "Comment" -> pushContext "BeginningOfLine" >> return ()+ "Error" -> pushContext "BeginningOfLine" >> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Regex","st"),("Regex Escape","ch"),("Replacement","st"),("Repl Escape","ch"),("Char List","st"),("Char List Escape","ch"),("Separator","st"),("Line Number","dv"),("Step","dv"),("Last Line","ot"),("Negation","ot"),("Command","kw"),("Label","fu"),("Flag","dt"),("Repl Number","dv"),("Exit Code","dv"),("Filename","bn"),("Wrap Length","dv"),("Line Continue","ot"),("Literal Text","ot"),("Literal Escape","ot"),("Comment","co"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'28'2f'29 = compileRegex "(/)"@@ -103,342 +93,316 @@ regex_'5cS'2b = compileRegex "\\S+" regex_'5cw'2b = compileRegex "\\w+" -defaultAttributes = [("BeginningOfLine","Normal"),("FirstAddressRegex","Regex"),("AfterFirstAddress","Normal"),("AfterFirstAddress2","Normal"),("SecondAddress","Normal"),("SecondAddressRegex","Regex"),("AfterSecondAddress","Normal"),("Step","Normal"),("Command","Normal"),("SCommand","Normal"),("SRegex","Regex"),("SReplacement","Replacement"),("SFlags","Normal"),("WFlag","Normal"),("YCommand","Normal"),("YSourceList","Char List"),("YDestList","Char List"),("AICCommand","Normal"),("LiteralText","Literal Text"),("BTCommand","Normal"),("WRCommand","Normal"),("LCommand","Normal"),("QCommand","Normal"),("Label","Normal"),("AfterCommand","Normal"),("Regex","Regex"),("Comment","Comment"),("Error","Error")]+defaultAttributes = [("BeginningOfLine",NormalTok),("FirstAddressRegex",StringTok),("AfterFirstAddress",NormalTok),("AfterFirstAddress2",NormalTok),("SecondAddress",NormalTok),("SecondAddressRegex",StringTok),("AfterSecondAddress",NormalTok),("Step",NormalTok),("Command",NormalTok),("SCommand",NormalTok),("SRegex",StringTok),("SReplacement",StringTok),("SFlags",NormalTok),("WFlag",NormalTok),("YCommand",NormalTok),("YSourceList",StringTok),("YDestList",StringTok),("AICCommand",NormalTok),("LiteralText",OtherTok),("BTCommand",NormalTok),("WRCommand",NormalTok),("LCommand",NormalTok),("QCommand",NormalTok),("Label",NormalTok),("AfterCommand",NormalTok),("Regex",StringTok),("Comment",CommentTok),("Error",ErrorTok)] -parseRules "BeginningOfLine" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'28'2f'29 >>= withAttribute "Separator") >>~ pushContext "FirstAddressRegex")- <|>- ((pRegExpr regex_'5c'5c'28'5cS'29 >>= withAttribute "Separator") >>~ pushContext "FirstAddressRegex")- <|>- ((pInt >>= withAttribute "Line Number") >>~ pushContext "AfterFirstAddress")- <|>- ((pDetectChar False '$' >>= withAttribute "Last Line") >>~ pushContext "AfterFirstAddress")- <|>- ((pDetectChar False '}' >>= withAttribute "Brace") >>~ pushContext "AfterCommand")- <|>- ((pDetectChar False ':' >>= withAttribute "Label") >>~ pushContext "Label")- <|>- ((pDetectChar False '!' >>= withAttribute "Negation") >>~ pushContext "Command")- <|>- ((parseRules "Command"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "BeginningOfLine" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'28'2f'29 >>= withAttribute StringTok) >>~ pushContext "FirstAddressRegex")+ <|>+ ((pRegExpr regex_'5c'5c'28'5cS'29 >>= withAttribute StringTok) >>~ pushContext "FirstAddressRegex")+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "AfterFirstAddress")+ <|>+ ((pDetectChar False '$' >>= withAttribute OtherTok) >>~ pushContext "AfterFirstAddress")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "AfterCommand")+ <|>+ ((pDetectChar False ':' >>= withAttribute FunctionTok) >>~ pushContext "Label")+ <|>+ ((pDetectChar False '!' >>= withAttribute OtherTok) >>~ pushContext "Command")+ <|>+ ((parseRules "Command"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "FirstAddressRegex" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Regex"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Regex Escape"))- <|>- ((pRegExprDynamic "%1" >>= withAttribute "Separator") >>~ pushContext "AfterFirstAddress")- <|>- ((parseRules "Regex")))- return (attr, result)+parseRules "FirstAddressRegex" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "%1" >>= withAttribute StringTok) >>~ pushContext "AfterFirstAddress")+ <|>+ ((parseRules "Regex"))) -parseRules "AfterFirstAddress" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False '!' >>= withAttribute "Negation") >>~ pushContext "Command")- <|>- ((parseRules "AfterFirstAddress2"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "AfterFirstAddress" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '!' >>= withAttribute OtherTok) >>~ pushContext "Command")+ <|>+ ((parseRules "AfterFirstAddress2"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "AfterFirstAddress2" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False ',' >>= withAttribute "Normal") >>~ pushContext "SecondAddress")- <|>- ((pDetectChar False '~' >>= withAttribute "Normal") >>~ pushContext "Step")- <|>- ((parseRules "Command"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "AfterFirstAddress2" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ',' >>= withAttribute NormalTok) >>~ pushContext "SecondAddress")+ <|>+ ((pDetectChar False '~' >>= withAttribute NormalTok) >>~ pushContext "Step")+ <|>+ ((parseRules "Command"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "SecondAddress" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'28'2f'29 >>= withAttribute "Separator") >>~ pushContext "SecondAddressRegex")- <|>- ((pRegExpr regex_'5c'5c'28'5cS'29 >>= withAttribute "Separator") >>~ pushContext "SecondAddressRegex")- <|>- ((pInt >>= withAttribute "Line Number") >>~ pushContext "AfterSecondAddress")- <|>- ((pDetectChar False '$' >>= withAttribute "Last Line") >>~ pushContext "AfterSecondAddress")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "SecondAddress" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'2f'29 >>= withAttribute StringTok) >>~ pushContext "SecondAddressRegex")+ <|>+ ((pRegExpr regex_'5c'5c'28'5cS'29 >>= withAttribute StringTok) >>~ pushContext "SecondAddressRegex")+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "AfterSecondAddress")+ <|>+ ((pDetectChar False '$' >>= withAttribute OtherTok) >>~ pushContext "AfterSecondAddress")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "SecondAddressRegex" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Regex"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Regex Escape"))- <|>- ((pRegExprDynamic "%1" >>= withAttribute "Separator") >>~ pushContext "AfterSecondAddress")- <|>- ((parseRules "Regex")))- return (attr, result)+parseRules "SecondAddressRegex" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "%1" >>= withAttribute StringTok) >>~ pushContext "AfterSecondAddress")+ <|>+ ((parseRules "Regex"))) -parseRules "AfterSecondAddress" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False '!' >>= withAttribute "Negation") >>~ pushContext "Command")- <|>- ((parseRules "Command"))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "AfterSecondAddress" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '!' >>= withAttribute OtherTok) >>~ pushContext "Command")+ <|>+ ((parseRules "Command"))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "Step" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pInt >>= withAttribute "Step") >>~ pushContext "Command")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "Step" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "Command")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "Command" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False 's' >>= withAttribute "Command") >>~ pushContext "SCommand")- <|>- ((pDetectChar False 'y' >>= withAttribute "Command") >>~ pushContext "YCommand")- <|>- ((pAnyChar "dpnDNPhHgGxFvz=" >>= withAttribute "Command") >>~ pushContext "AfterCommand")- <|>- ((pAnyChar "aic" >>= withAttribute "Command") >>~ pushContext "AICCommand")- <|>- ((pAnyChar "bTt" >>= withAttribute "Command") >>~ pushContext "BTCommand")- <|>- ((pAnyChar "WwrR" >>= withAttribute "Command") >>~ pushContext "WRCommand")- <|>- ((pAnyChar "lL" >>= withAttribute "Command") >>~ pushContext "LCommand")- <|>- ((pAnyChar "qQ" >>= withAttribute "Command") >>~ pushContext "QCommand")- <|>- ((pDetectChar False '{' >>= withAttribute "Brace") >>~ pushContext "BeginningOfLine")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "Command" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False 's' >>= withAttribute KeywordTok) >>~ pushContext "SCommand")+ <|>+ ((pDetectChar False 'y' >>= withAttribute KeywordTok) >>~ pushContext "YCommand")+ <|>+ ((pAnyChar "dpnDNPhHgGxFvz=" >>= withAttribute KeywordTok) >>~ pushContext "AfterCommand")+ <|>+ ((pAnyChar "aic" >>= withAttribute KeywordTok) >>~ pushContext "AICCommand")+ <|>+ ((pAnyChar "bTt" >>= withAttribute KeywordTok) >>~ pushContext "BTCommand")+ <|>+ ((pAnyChar "WwrR" >>= withAttribute KeywordTok) >>~ pushContext "WRCommand")+ <|>+ ((pAnyChar "lL" >>= withAttribute KeywordTok) >>~ pushContext "LCommand")+ <|>+ ((pAnyChar "qQ" >>= withAttribute KeywordTok) >>~ pushContext "QCommand")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "BeginningOfLine")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "SCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'28'5cS'29 >>= withAttribute "Separator") >>~ pushContext "SRegex"))- return (attr, result)+parseRules "SCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5cS'29 >>= withAttribute StringTok) >>~ pushContext "SRegex")) -parseRules "SRegex" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Regex"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Regex Escape"))- <|>- ((pRegExprDynamic "(%1)" >>= withAttribute "Separator") >>~ pushContext "SReplacement")- <|>- ((parseRules "Regex")))- return (attr, result)+parseRules "SRegex" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "(%1)" >>= withAttribute StringTok) >>~ pushContext "SReplacement")+ <|>+ ((parseRules "Regex"))) -parseRules "SReplacement" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Replacement"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Repl Escape"))- <|>- ((pRegExprDynamic "%1" >>= withAttribute "Separator") >>~ pushContext "SFlags")- <|>- ((pRegExpr regex_'5c'5c'5b0'2d9LlUuE'5c'5c'26'5d >>= withAttribute "Repl Escape"))- <|>- ((pDetectChar False '&' >>= withAttribute "Repl Escape")))- return (attr, result)+parseRules "SReplacement" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "%1" >>= withAttribute StringTok) >>~ pushContext "SFlags")+ <|>+ ((pRegExpr regex_'5c'5c'5b0'2d9LlUuE'5c'5c'26'5d >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '&' >>= withAttribute CharTok))) -parseRules "SFlags" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pAnyChar "gpeIiMm" >>= withAttribute "Flag"))- <|>- ((pDetectChar False 'w' >>= withAttribute "Flag") >>~ pushContext "WFlag")- <|>- ((pInt >>= withAttribute "Repl Number"))- <|>- ((parseRules "AfterCommand")))- return (attr, result)+parseRules "SFlags" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pAnyChar "gpeIiMm" >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False 'w' >>= withAttribute DataTypeTok) >>~ pushContext "WFlag")+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((parseRules "AfterCommand"))) -parseRules "WFlag" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'5cS'2b >>= withAttribute "Filename") >>~ pushContext "SFlags"))- return (attr, result)+parseRules "WFlag" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cS'2b >>= withAttribute BaseNTok) >>~ pushContext "SFlags")) -parseRules "YCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'28'5cS'29 >>= withAttribute "Separator") >>~ pushContext "YSourceList"))- return (attr, result)+parseRules "YCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'28'5cS'29 >>= withAttribute StringTok) >>~ pushContext "YSourceList")) -parseRules "YSourceList" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Char List"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Char List Escape"))- <|>- ((pRegExprDynamic "(%1)" >>= withAttribute "Separator") >>~ pushContext "YDestList")- <|>- ((pDetect2Chars False '\\' 'n' >>= withAttribute "Char List Escape"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Char List Escape")))- return (attr, result)+parseRules "YSourceList" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "(%1)" >>= withAttribute StringTok) >>~ pushContext "YDestList")+ <|>+ ((pDetect2Chars False '\\' 'n' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))) -parseRules "YDestList" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Char List"))- <|>- ((pRegExprDynamic "\\\\%1" >>= withAttribute "Char List Escape"))- <|>- ((pRegExprDynamic "%1" >>= withAttribute "Separator") >>~ pushContext "AfterCommand")- <|>- ((pDetect2Chars False '\\' 'n' >>= withAttribute "Char List Escape"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Char List Escape")))- return (attr, result)+parseRules "YDestList" =+ (((pDetectSpaces >>= withAttribute StringTok))+ <|>+ ((pRegExprDynamic "\\\\%1" >>= withAttribute CharTok))+ <|>+ ((pRegExprDynamic "%1" >>= withAttribute StringTok) >>~ pushContext "AfterCommand")+ <|>+ ((pDetect2Chars False '\\' 'n' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))) -parseRules "AICCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pLineContinue >>= withAttribute "Line Continue") >>~ pushContext "LiteralText")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "AICCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pLineContinue >>= withAttribute OtherTok) >>~ pushContext "LiteralText")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "LiteralText" = - do (attr, result) <- (((pDetect2Chars False '\\' '\\' >>= withAttribute "Literal Escape") >>~ pushContext "LiteralText")- <|>- ((pLineContinue >>= withAttribute "Line Continue") >>~ pushContext "LiteralText")- <|>- ((pDetectChar False '\\' >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "LiteralText" =+ (((pDetect2Chars False '\\' '\\' >>= withAttribute OtherTok) >>~ pushContext "LiteralText")+ <|>+ ((pLineContinue >>= withAttribute OtherTok) >>~ pushContext "LiteralText")+ <|>+ ((pDetectChar False '\\' >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "BTCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'5cw'2b >>= withAttribute "Label") >>~ pushContext "AfterCommand")- <|>- ((parseRules "AfterCommand")))- return (attr, result)+parseRules "BTCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cw'2b >>= withAttribute FunctionTok) >>~ pushContext "AfterCommand")+ <|>+ ((parseRules "AfterCommand"))) -parseRules "WRCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'5cS'2b >>= withAttribute "Filename") >>~ pushContext "AfterCommand"))- return (attr, result)+parseRules "WRCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cS'2b >>= withAttribute BaseNTok) >>~ pushContext "AfterCommand")) -parseRules "LCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pInt >>= withAttribute "Wrap Length") >>~ pushContext "AfterCommand")- <|>- ((parseRules "AfterCommand")))- return (attr, result)+parseRules "LCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "AfterCommand")+ <|>+ ((parseRules "AfterCommand"))) -parseRules "QCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pInt >>= withAttribute "Exit Code") >>~ pushContext "AfterCommand")- <|>- ((parseRules "AfterCommand")))- return (attr, result)+parseRules "QCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pInt >>= withAttribute DecValTok) >>~ pushContext "AfterCommand")+ <|>+ ((parseRules "AfterCommand"))) -parseRules "Label" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pRegExpr regex_'5cw'2b >>= withAttribute "Label") >>~ pushContext "AfterCommand")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "Label" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5cw'2b >>= withAttribute FunctionTok) >>~ pushContext "AfterCommand")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "AfterCommand" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal"))- <|>- ((pDetectChar False ';' >>= withAttribute "Normal") >>~ pushContext "BeginningOfLine")- <|>- ((pDetectChar False '}' >>= withAttribute "Brace") >>~ pushContext "AfterCommand")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error") >>~ pushContext "Error"))- return (attr, result)+parseRules "AfterCommand" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False ';' >>= withAttribute NormalTok) >>~ pushContext "BeginningOfLine")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ pushContext "AfterCommand")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok) >>~ pushContext "Error")) -parseRules "Regex" = - do (attr, result) <- (((pDetect2Chars False '\\' '(' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' ')' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '+' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '?' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '|' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '{' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '}' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '[' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' ']' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '.' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '*' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '\\' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '^' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '$' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' 'n' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' 't' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '0' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '1' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '2' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '3' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '4' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '5' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '6' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '7' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '8' >>= withAttribute "Regex Escape"))- <|>- ((pDetect2Chars False '\\' '9' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False '*' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False '.' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False '^' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False '$' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False '[' >>= withAttribute "Regex Escape"))- <|>- ((pDetectChar False ']' >>= withAttribute "Regex Escape")))- return (attr, result)+parseRules "Regex" =+ (((pDetect2Chars False '\\' '(' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' ')' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '+' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '?' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '|' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '{' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '}' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '[' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' ']' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '.' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '*' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '\\' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '^' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '$' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' 'n' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' 't' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '0' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '1' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '2' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '3' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '4' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '5' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '6' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '7' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '8' >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\\' '9' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '*' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '.' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '^' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute CharTok))) -parseRules "Comment" = +parseRules "Comment" = pzero -parseRules "Error" = +parseRules "Error" = pzero parseRules "" = parseRules "BeginningOfLine"
Text/Highlighting/Kate/Syntax/Sgml.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file sgml.xml, version 1.02,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file sgml.xml, version 1.02, by -} -module Text.Highlighting.Kate.Syntax.Sgml ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Sgml+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,94 +21,76 @@ syntaxExtensions = "*.sgml" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "SGML" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("SGML",["Normal Text"])], synStLanguage = "SGML", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("SGML",["Normal Text"])], synStLanguage = "SGML", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine- "Attribute" -> return () >> pHandleEndLine- "Value" -> return () >> pHandleEndLine- "Value 2" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Normal Text" -> return ()+ "Attribute" -> return ()+ "Value" -> return ()+ "Value 2" -> return ()+ "Comment" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Tag","kw"),("Attribute Name","ot"),("Attribute Value","dt"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a = compileRegex "<\\s*\\/?\\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" regex_'5cs'2a'3d'5cs'2a = compileRegex "\\s*=\\s*" -defaultAttributes = [("Normal Text","Normal Text"),("Attribute","Attribute Name"),("Value","Attribute Value"),("Value 2","Attribute Value"),("Comment","Comment")]+defaultAttributes = [("Normal Text",NormalTok),("Attribute",OtherTok),("Value",DataTypeTok),("Value 2",DataTypeTok),("Comment",CommentTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute "Tag") >>~ pushContext "Attribute"))- return (attr, result)+parseRules "Normal Text" =+ (((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5cs'2a'5c'2f'3f'5cs'2a'5ba'2dzA'2dZ'5f'3a'5d'5ba'2dzA'2dZ0'2d9'2e'5f'3a'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "Attribute")) -parseRules "Attribute" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Tag") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Tag") >>~ (popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "Value"))- return (attr, result)+parseRules "Attribute" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "Value")) -parseRules "Value" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Attribute Value") >>~ pushContext "Value 2"))- return (attr, result)+parseRules "Value" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ pushContext "Value 2")) -parseRules "Value 2" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Attribute Value") >>~ (popContext >> popContext))- return (attr, result)+parseRules "Value 2" =+ ((pDetectChar False '"' >>= withAttribute DataTypeTok) >>~ (popContext >> popContext)) -parseRules "Comment" = - do (attr, result) <- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Comment" =+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext)) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Sql.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file sql.xml, version 1.14,- by Yury Lebedev (yurylebedev@mail.ru) -}+{- This module was generated from data in the Kate syntax+ highlighting file sql.xml, version 1.14, by Yury Lebedev (yurylebedev@mail.ru) -} -module Text.Highlighting.Kate.Syntax.Sql ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Sql+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "SQL"@@ -19,60 +22,47 @@ syntaxExtensions = "*.sql;*.SQL" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "SQL" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("SQL",["Normal"])], synStLanguage = "SQL", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("SQL",["Normal"])], synStLanguage = "SQL", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "String literal" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "String literal" -> return () "Singleline PL/SQL-style comment" -> (popContext) >> pEndLine- "Multiline C-style comment" -> return () >> pHandleEndLine+ "Multiline C-style comment" -> return () "SQL*Plus remark directive" -> (popContext) >> pEndLine "User-defined identifier" -> (popContext) >> pEndLine "SQL*Plus directive to include file" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Data Type","dt"),("Decimal","dv"),("Hex","bn"),("Float","fl"),("String","st"),("String Char","ch"),("Comment","co"),("Identifier","ot"),("External Variable","ch"),("Symbol","ch"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "access account add admin administer advise after agent all all_rows allocate alter analyze ancillary and any archive archivelog as asc assertion associate at attribute attributes audit authenticated authid authorization autoallocate autoextend automatic backup become before begin behalf between binding bitmap block block_range body bound both break broadcast btitle buffer_pool build bulk by cache cache_instances call cancel cascade case category chained change check checkpoint child choose chunk class clear clone close close_cached_open_cursors cluster coalesce column columns column_value comment commit committed compatibility compile complete composite_limit compress compute connect connect_time consider consistent constant constraint constraints container contents context continue controlfile copy cost cpu_per_call cpu_per_session create create_stored_outlines cross cube current cursor cycle dangling data database datafile datafiles dba ddl deallocate debug declare default deferrable deferred definer degree delete demand desc determines dictionary dimension directory disable disassociate disconnect diskgroup dismount distinct distributed domain drop dynamic each else elsif empty enable end enforce entry escape estimate events except exception exceptions exchange excluding exclusive exec execute exists expire explain explosion extends extent extents externally failed_login_attempts false fast file filter first_rows flagger flashback flush following for force foreign freelist freelists fresh from full function functions generated global globally global_name grant group groups hash hashkeys having header heap hierarchy hour id identified identifier idgenerators idle_time if immediate in including increment incremental index indexed indexes indextype indextypes indicator initial initialized initially initrans inner insert instance instances instead intermediate intersect into invalidate is isolation isolation_level java join keep key kill label layer leading left less level library like limit link list local locator lock locked logfile logging logical_reads_per_call logical_reads_per_session logoff logon loop manage managed management master materialized maxarchlogs maxdatafiles maxextents maxinstances maxlogfiles maxloghistory maxlogmembers maxsize maxtrans maxvalue method member merge minimize minimum minextents minus minute minvalue mode modify monitoring mount move movement mts_dispatchers multiset named natural needed nested nested_table_id network never new next nls_calendar nls_characterset nls_comp nls_currency nls_date_format nls_date_language nls_iso_currency nls_lang nls_language nls_numeric_characters nls_sort nls_special_chars nls_territory no noarchivelog noaudit nocache nocompress nocycle noforce nologging nomaxvalue nominimize nominvalue nomonitoring none noorder nooverride noparallel norely noresetlogs noreverse normal nosegment nosort not nothing novalidate nowait null nulls objno objno_reuse of off offline oid oidindex old on online only opcode open operator optimal optimizer_goal option or order organization out outer outline over overflow overlaps own package packages parallel parameters parent partition partitions partition_hash partition_range password password_grace_time password_life_time password_lock_time password_reuse_max password_reuse_time password_verify_function pctfree pctincrease pctthreshold pctused pctversion percent permanent plan plsql_debug post_transaction prebuilt preceding prepare present preserve previous primary prior private private_sga privilege privileges procedure profile public purge query queue quota random range rba read reads rebuild records_per_block recover recoverable recovery recycle reduced references referencing refresh rely rename replace reset resetlogs resize resolve resolver resource restrict restricted resume return returning reuse reverse revoke rewrite right role roles rollback rollup row rownum rows rule sample savepoint scan scan_instances schema scn scope sd_all sd_inhibit sd_show segment seg_block seg_file select selectivity sequence serializable servererror session session_cached_cursors sessions_per_user set share shared shared_pool shrink shutdown singletask size skip skip_unusable_indexes snapshot some sort source specification split sql_trace standby start startup statement_id statistics static stop storage store structure submultiset subpartition subpartitions successful summary supplemental suspend switch sys_op_bitvec sys_op_enforce_not_null$ sys_op_noexpand sys_op_ntcimg$ synonym sysdba sysoper system table tables tablespace tablespace_no tabno tempfile temporary than the then thread through timeout timezone_hour timezone_minute time_zone to toplevel trace tracing trailing transaction transitional trigger triggers true truncate type types unarchived unbound unbounded undo uniform union unique unlimited unlock unrecoverable until unusable unused upd_indexes updatable update uppper usage use use_stored_outlines user_defined using validate validation values view when whenever where with without work write" list_operators = Set.fromList $ words $ "+ - * / || = != <> < <= > >= ~= ^= := => ** .."@@ -86,73 +76,69 @@ regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d = compileRegex "@@?[^@ \\t\\r\\n]" regex_'26'26'3f'5cw'2b = compileRegex "&&?\\w+" -defaultAttributes = [("Normal","Normal Text"),("String literal","String"),("Singleline PL/SQL-style comment","Comment"),("Multiline C-style comment","Comment"),("SQL*Plus remark directive","Comment"),("User-defined identifier","Identifier"),("SQL*Plus directive to include file","Preprocessor")]+defaultAttributes = [("Normal",NormalTok),("String literal",StringTok),("Singleline PL/SQL-style comment",CommentTok),("Multiline C-style comment",CommentTok),("SQL*Plus remark directive",CommentTok),("User-defined identifier",OtherTok),("SQL*Plus directive to include file",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_types >>= withAttribute "Data Type"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'25'28'3f'3abulk'5f'28'3f'3aexceptions'7crowcount'29'7cfound'7cisopen'7cnotfound'7crowcount'7crowtype'7ctype'29'5cb >>= withAttribute "Data Type"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String literal")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "Singleline PL/SQL-style comment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Multiline C-style comment")- <|>- ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute "Comment") >>~ pushContext "SQL*Plus remark directive")- <|>- ((pDetectChar False '"' >>= withAttribute "Identifier") >>~ pushContext "User-defined identifier")- <|>- ((pRegExpr regex_'28'3a'7c'26'26'3f'29'5cw'2b >>= withAttribute "External Variable"))- <|>- ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute "Preprocessor") >>~ pushContext "SQL*Plus directive to include file"))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_operators >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'28'3f'3abulk'5f'28'3f'3aexceptions'7crowcount'29'7cfound'7cisopen'7cnotfound'7crowcount'7crowtype'7ctype'29'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String literal")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "Singleline PL/SQL-style comment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Multiline C-style comment")+ <|>+ ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute CommentTok) >>~ pushContext "SQL*Plus remark directive")+ <|>+ ((pDetectChar False '"' >>= withAttribute OtherTok) >>~ pushContext "User-defined identifier")+ <|>+ ((pRegExpr regex_'28'3a'7c'26'26'3f'29'5cw'2b >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute OtherTok) >>~ pushContext "SQL*Plus directive to include file")) -parseRules "String literal" = - do (attr, result) <- (((pDetect2Chars False '\\' '\'' >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pRegExpr regex_'26'26'3f'5cw'2b >>= withAttribute "External Variable"))- <|>- ((pDetect2Chars False '\'' '\'' >>= withAttribute "String Char"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String literal" =+ (((pDetect2Chars False '\\' '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'26'26'3f'5cw'2b >>= withAttribute CharTok))+ <|>+ ((pDetect2Chars False '\'' '\'' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Singleline PL/SQL-style comment" = +parseRules "Singleline PL/SQL-style comment" = pzero -parseRules "Multiline C-style comment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Multiline C-style comment" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "SQL*Plus remark directive" = +parseRules "SQL*Plus remark directive" = pzero -parseRules "User-defined identifier" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Identifier") >>~ (popContext))- return (attr, result)+parseRules "User-defined identifier" =+ ((pDetectChar False '"' >>= withAttribute OtherTok) >>~ (popContext)) -parseRules "SQL*Plus directive to include file" = +parseRules "SQL*Plus directive to include file" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/SqlMysql.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file sql-mysql.xml, version 1.13,- by Shane Wright (me@shanewright.co.uk) -}+{- This module was generated from data in the Kate syntax+ highlighting file sql-mysql.xml, version 1.13, by Shane Wright (me@shanewright.co.uk) -} -module Text.Highlighting.Kate.Syntax.SqlMysql ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.SqlMysql+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "SQL (MySQL)"@@ -19,60 +22,47 @@ syntaxExtensions = "*.sql;*.SQL" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "SQL (MySQL)" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("SQL (MySQL)",["Normal"])], synStLanguage = "SQL (MySQL)", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("SQL (MySQL)",["Normal"])], synStLanguage = "SQL (MySQL)", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine- "String2" -> return () >> pHandleEndLine- "Name" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "String" -> return ()+ "String2" -> return ()+ "Name" -> return () "SingleLineComment" -> (popContext) >> pEndLine- "MultiLineComment" -> return () >> pHandleEndLine+ "MultiLineComment" -> return () "Preprocessor" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Data Type","dt"),("Decimal","dv"),("Float","fl"),("Hex","bn"),("String","st"),("Name","st"),("String Char","ch"),("Comment","co"),("Symbol","ch"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "access add all alter analyze and as asc auto_increment bdb berkeleydb between both by cascade case change charset column columns constraint create cross current_date current_time current_timestamp database databases day_hour day_minute day_second dec default delayed delete desc describe distinct distinctrow drop else enclosed escaped exists explain fields for foreign from fulltext function grant group having high_priority if ignore in index infile inner innodb insert interval into is join key keys kill leading left like limit lines load lock low_priority master_server_id match mrg_myisam natural national not null numeric on optimize option optionally or order outer outfile partial precision primary privileges procedure purge read references regexp rename replace require restrict returns revoke right rlike select set show soname sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join striped table tables terminated then to trailing truncate type union unique unlock unsigned update usage use user_resources using values varying when where with write xor year_month zerofill" list_operators = Set.fromList $ words $ "+ - * / || = != <> < <= > >= ~= ^= := => ** .."@@ -86,94 +76,89 @@ regex_'2f'24 = compileRegex "/$" regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d = compileRegex "@@?[^@ \\t\\r\\n]" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("String2","String"),("Name","Name"),("SingleLineComment","Comment"),("MultiLineComment","Comment"),("Preprocessor","Preprocessor")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("String2",StringTok),("Name",StringTok),("SingleLineComment",CommentTok),("MultiLineComment",CommentTok),("Preprocessor",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_SET'28'3f'3d'5cs'2a'5c'28'29 >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'5cbCHARACTER_SET'5cb >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t(),%&;?[]{}\\" list_types >>= withAttribute "Data Type"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'25'28'3f'3abulk'5f'28'3f'3aexceptions'7crowcount'29'7cfound'7cisopen'7cnotfound'7crowcount'7crowtype'7ctype'29'5cb >>= withAttribute "Data Type"))- <|>- ((pHlCHex >>= withAttribute "Hex"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String2")- <|>- ((pDetectChar False '`' >>= withAttribute "Name") >>~ pushContext "Name")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pAnyChar ":&" >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pDetectChar False '.' >>= withAttribute "String Char")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_SET'28'3f'3d'5cs'2a'5c'28'29 >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5cbCHARACTER_SET'5cb >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_operators >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t(),%&;?[]{}\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'25'28'3f'3abulk'5f'28'3f'3aexceptions'7crowcount'29'7cfound'7cisopen'7cnotfound'7crowcount'7crowtype'7ctype'29'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pHlCHex >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String2")+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ pushContext "Name")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pAnyChar ":&" >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pDetectChar False '.' >>= withAttribute CharTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '&' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '&' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "String2" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '&' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String2" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '&' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Name" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Name") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '`' >>= withAttribute "Name") >>~ (popContext)))- return (attr, result)+parseRules "Name" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '`' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "SingleLineComment" = +parseRules "SingleLineComment" = pzero -parseRules "MultiLineComment" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "MultiLineComment" =+ (((pLineContinue >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Preprocessor" = +parseRules "Preprocessor" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/SqlPostgresql.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file sql-postgresql.xml, version 1.10,- by Shane Wright (me@shanewright.co.uk) -}+{- This module was generated from data in the Kate syntax+ highlighting file sql-postgresql.xml, version 1.10, by Shane Wright (me@shanewright.co.uk) -} -module Text.Highlighting.Kate.Syntax.SqlPostgresql ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.SqlPostgresql+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "SQL (PostgreSQL)"@@ -19,62 +22,49 @@ syntaxExtensions = "*.sql;*.SQL" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "SQL (PostgreSQL)" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("SQL (PostgreSQL)",["Normal"])], synStLanguage = "SQL (PostgreSQL)", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("SQL (PostgreSQL)",["Normal"])], synStLanguage = "SQL (PostgreSQL)", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = False, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine- "CreateFunction" -> return () >> pHandleEndLine- "FunctionBody" -> return () >> pHandleEndLine- "MultiLineString" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine+ "Normal" -> return ()+ "CreateFunction" -> return ()+ "FunctionBody" -> return ()+ "MultiLineString" -> return ()+ "String" -> return () "SingleLineComment" -> (popContext) >> pEndLine- "MultiLineComment" -> return () >> pHandleEndLine+ "MultiLineComment" -> return () "Identifier" -> (popContext) >> pEndLine "Preprocessor" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Function","fu"),("Data Type","dt"),("Decimal","dv"),("Float","fl"),("String","st"),("String Char","ch"),("Comment","co"),("Identifier","ot"),("Symbol","ch"),("Preprocessor","ot")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "abort access action add admin after aggregate alias all allocate alter analyse analyze any are as asc asensitive assertion assignment asymmetric at atomic authorization backward before begin between binary both breadth by c cache call called cardinality cascade cascaded case cast catalog catalog_name chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics check checked checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema column column_name command_function command_function_code comment commit committed completion condition_number connect connection connection_name constraint constraint_catalog constraint_name constraint_schema constraints constructor contains continue convert copy corresponding count create createdb createuser cross cube current current_date current_path current_role current_time current_timestamp current_user cursor cursor_name cycle data database date datetime_interval_code datetime_interval_precision day deallocate dec decimal declare default deferrable deferred defined definer delete delimiters depth deref desc describe descriptor destroy destructor deterministic diagnostics dictionary disconnect dispatch distinct do domain double drop dynamic dynamic_function dynamic_function_code each else encoding encrypted end end-exec equals escape every except exception exclusive exec execute existing exists explain external fetch final first for force foreign fortran forward found free freeze from full function g general generated get global go goto grant granted group grouping handler having hierarchy hold host hour identity ignore ilike immediate immutable implementation in increment index indicator infix inherits initialize initially inner inout input insensitive insert instance instantiable instead intersect interval into invoker is isnull isolation iterate join k key key_member key_type lancompiler language large last lateral leading left length less level like limit listen load local localtime localtimestamp location locator lock lower m map match max maxvalue message_length message_octet_length message_text method min minute minvalue mod mode modifies modify module month more move mumps name names national natural new next no nocreatedb nocreateuser none not nothing notify notnull null nullable nullif number numeric object octet_length of off offset oids old on only open operation operator option options order ordinality out outer output overlaps overlay overriding owner pad parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parameters partial pascal password path pendant pli position postfix precision prefix preorder prepare preserve primary prior privileges procedural procedure public read reads real recursive ref references referencing reindex relative rename repeatable replace reset restrict result return returned_length returned_octet_length returned_sqlstate returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row row_count rows rule savepoint scale schema schema_name scope scroll search second section security select self sensitive sequence serializable server_name session session_user set setof sets share show similar simple size some source space specific specific_name specifictype sql sqlcode sqlerror sqlexception sqlstate sqlwarning stable start state statement static statistics stdin stdout structure style subclass_origin sublist substring sum symmetric sysid system system_user table table_name temp template temporary terminate than then timezone_hour timezone_minute to toast trailing transaction transaction_active transactions_committed transactions_rolled_back transform transforms translate translation treat trigger trigger_catalog trigger_name trigger_schema trim truncate trusted type uncommitted under unencrypted union unique unknown unlisten unnamed unnest until update upper usage user user_defined_type_catalog user_defined_type_name user_defined_type_schema using vacuum valid value values variable varying verbose version view volatile when whenever where with without work write year zone false true" list_operators = Set.fromList $ words $ "+ - * / || |/ ||/ ! !! @ & | # << >> % ^ = != <> < <= > >= ~ ~* !~ !~* ^= := => ** .. and or not ## && &< &> <-> <^ >^ ?# ?- ?-| @-@ ?| ?|| @@ ~= <<= >>="@@ -93,100 +83,93 @@ regex_'2f'24 = compileRegex "/$" regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d = compileRegex "@@?[^@ \\t\\r\\n]" -defaultAttributes = [("Normal","Normal Text"),("CreateFunction","Normal Text"),("FunctionBody","Normal Text"),("MultiLineString","String"),("String","String"),("SingleLineComment","Comment"),("MultiLineComment","Comment"),("Identifier","Identifier"),("Preprocessor","Preprocessor")]+defaultAttributes = [("Normal",NormalTok),("CreateFunction",NormalTok),("FunctionBody",NormalTok),("MultiLineString",StringTok),("String",StringTok),("SingleLineComment",CommentTok),("MultiLineComment",CommentTok),("Identifier",OtherTok),("Preprocessor",OtherTok)] -parseRules "Normal" = - do (attr, result) <- (((pString False "CREATE FUNCTION" >>= withAttribute "Keyword") >>~ pushContext "CreateFunction")- <|>- ((pKeyword " \n\t(),;[]{}\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t(),;[]{}\\" list_operators >>= withAttribute "Operator"))- <|>- ((pKeyword " \n\t(),;[]{}\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t(),;[]{}\\" list_types >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25bulk'5fexceptions'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25bulk'5frowcount'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25found'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25isopen'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25notfound'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25rowcount'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25rowtype'5cb >>= withAttribute "Data Type"))- <|>- ((pRegExpr regex_'25type'5cb >>= withAttribute "Data Type"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "MultiLineComment")- <|>- ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute "Comment") >>~ pushContext "SingleLineComment")- <|>- ((pDetectChar False '"' >>= withAttribute "Comment") >>~ pushContext "Identifier")- <|>- ((pAnyChar ":&" >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pRegExprDynamic "\\$([^\\$\\n\\r]*)\\$" >>= withAttribute "Operator") >>~ pushContext "MultiLineString"))- return (attr, result)+parseRules "Normal" =+ (((pString False "CREATE FUNCTION" >>= withAttribute KeywordTok) >>~ pushContext "CreateFunction")+ <|>+ ((pKeyword " \n\t(),;[]{}\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t(),;[]{}\\" list_operators >>= withAttribute NormalTok))+ <|>+ ((pKeyword " \n\t(),;[]{}\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t(),;[]{}\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25bulk'5fexceptions'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25bulk'5frowcount'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25found'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25isopen'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25notfound'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25rowcount'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25rowtype'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'25type'5cb >>= withAttribute DataTypeTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "MultiLineComment")+ <|>+ ((pColumn 0 >> pRegExpr regex_rem'5cb >>= withAttribute CommentTok) >>~ pushContext "SingleLineComment")+ <|>+ ((pDetectChar False '"' >>= withAttribute CommentTok) >>~ pushContext "Identifier")+ <|>+ ((pAnyChar ":&" >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'2f'24 >>= withAttribute CharTok))+ <|>+ ((pColumn 0 >> pRegExpr regex_'40'40'3f'5b'5e'40_'5ct'5cr'5cn'5d >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pRegExprDynamic "\\$([^\\$\\n\\r]*)\\$" >>= withAttribute NormalTok) >>~ pushContext "MultiLineString")) -parseRules "CreateFunction" = - do (attr, result) <- (((pRegExprDynamic "\\$([^\\$\\n\\r]*)\\$" >>= withAttribute "Function") >>~ pushContext "FunctionBody")- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "CreateFunction" =+ (((pRegExprDynamic "\\$([^\\$\\n\\r]*)\\$" >>= withAttribute FunctionTok) >>~ pushContext "FunctionBody")+ <|>+ ((parseRules "Normal"))) -parseRules "FunctionBody" = - do (attr, result) <- (((pRegExprDynamic "\\$%1\\$" >>= withAttribute "Function") >>~ (popContext >> popContext))- <|>- ((parseRules "Normal")))- return (attr, result)+parseRules "FunctionBody" =+ (((pRegExprDynamic "\\$%1\\$" >>= withAttribute FunctionTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "Normal"))) -parseRules "MultiLineString" = - do (attr, result) <- ((pRegExprDynamic "\\$%1\\$" >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)+parseRules "MultiLineString" =+ ((pRegExprDynamic "\\$%1\\$" >>= withAttribute NormalTok) >>~ (popContext)) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ (popContext))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '&' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '&' >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "SingleLineComment" = +parseRules "SingleLineComment" = pzero -parseRules "MultiLineComment" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "MultiLineComment" =+ (((pLineContinue >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Identifier" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Identifier") >>~ (popContext))- return (attr, result)+parseRules "Identifier" =+ ((pDetectChar False '"' >>= withAttribute OtherTok) >>~ (popContext)) -parseRules "Preprocessor" = +parseRules "Preprocessor" = pzero parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Tcl.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file tcl.xml, version 1.10,- by -}+{- This module was generated from data in the Kate syntax+ highlighting file tcl.xml, version 1.10, by -} -module Text.Highlighting.Kate.Syntax.Tcl ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Tcl+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Tcl/Tk"@@ -19,57 +22,44 @@ syntaxExtensions = "*.tcl;*.tk" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Tcl/Tk" } context <- currentContext <|> (pushContext "Base" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Tcl/Tk",["Base"])], synStLanguage = "Tcl/Tk", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Tcl/Tk",["Base"])], synStLanguage = "Tcl/Tk", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Base" -> return () >> pHandleEndLine- "String" -> return () >> pHandleEndLine+ "Base" -> return ()+ "String" -> return () "Comment" -> (popContext) >> pEndLine- "New command line" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "New command line" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Decimal","dv"),("Float","fl"),("String","st"),("Comment","co"),("Parameter","ot"),("Variable","dt"),("Char","ch"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "after append AppleScript argv argc array auto_execk auto_load auto_mkindex auto_path auto_reset beep bell binary bind bindtags bgerror break button canvas case catch cd checkbutton clipboard clock close concat console continue dde destroy else elseif encoding entry env eof error errorCode errorInfo eval event exec exit expr fblocked fconfigure fcopy file fileevent flush focus font for foreach format frame gets glob global grab grid history if image incr info interp join label lappend lindex linsert list listbox llength load lower lrange lreplace lsearch lsort menu menubutton message namespace open option OptProc pack package parray pid place pkg_mkindex proc puts pwd radiobutton raise read regexp registry regsub rename resource return scale scan scrollbar seek selection send set socket source split string subst switch tclLog tcl_endOfWord tcl_findLibrary tcl_library tcl_patchLevel tcl_platform tcl_precision tcl_rcFileName tcl_rcRsrcName tcl_startOfNextWord tcl_startOfPreviousWord tcl_traceCompile tcl_traceExec tcl_version tcl_wordBreakAfter tcl_wordBreakBefore tell text time tk tkTabToWindow tkwait tk_chooseColor tk_chooseDirectory tk_focusFollowMouse tk_focusNext tk_focusPrev tk_getOpenFile tk_getSaveFile tk_library tk_messageBox tk_optionMenu tk_patchLevel tk_popup tk_strictMotif tk_version toplevel trace unknown unset update uplevel upvar variable vwait while winfo wm" list_keywords'2dopt = Set.fromList $ words $ "add args atime attributes body bytelength cancel channels clicks cmdcount commands compare complete convertfrom convertto copy default delete dirname equal executable exists extension first forget format functions globals hostname idle ifneeded index info is isdirectory isfile join last length level library link loaded locals lstat map match mkdir mtime nameofexecutable names nativename normalize number owned patchlevel pathtype present procs provide range readable readlink remove rename repeat replace require rootname scan script seconds separator sharedlibextension size split stat system tail tclversion tolower totitle toupper trim trimleft trimright type unknown variable vars vcompare vdelete versions vinfo volumes vsatisfies wordend wordstart writable activate actual addtag append appname aspect atom atomname bbox bind broadcast canvasx canvasy caret cells cget children class clear client clone colormapfull colormapwindows command configure containing coords create current curselection dchars debug deiconify delta depth deselect dlineinfo dtag dump edit entrycget entryconfigure families find flash focus focusmodel fpixels fraction frame generate geometry get gettags grid group handle height hide iconbitmap iconify iconmask iconname iconposition iconwindow icursor id identify image insert interps inuse invoke ismapped itemcget itemconfigure keys lower manager mark maxsize measure metrics minsize move name nearest overrideredirect own panecget paneconfigure panes parent pathname pixels pointerx pointerxy pointery positionfrom post postcascade postscript protocol proxy raise release reqheight reqwidth resizable rgb rootx rooty scale scaling screen screencells screendepth screenheight screenmmheight screenmmwidth screenvisual screenwidth search see select selection server set show sizefrom stackorder state status tag title toplevel transient types unpost useinputmethods validate values viewable visual visualid visualsavailable vrootheight vrootwidth vrootx vrooty width window windowingsystem withdraw x xview y"@@ -85,62 +75,59 @@ regex_'5cs'2a'23 = compileRegex "\\s*#" regex_'2e = compileRegex "." -defaultAttributes = [("Base","Normal Text"),("String","String"),("Comment","Comment"),("New command line","Normal Text")]+defaultAttributes = [("Base",NormalTok),("String",StringTok),("Comment",CommentTok),("New command line",NormalTok)] -parseRules "Base" = - do (attr, result) <- (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute "Region Marker"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords'2dopt >>= withAttribute "Parameter"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pRegExpr regex_'5cs'2d'5cw'2b >>= withAttribute "Parameter"))- <|>- ((pRegExpr regex_'5c'24'5c'7b'28'5b'5e'5c'7d'5d'7c'5c'5c'5c'7d'29'2b'5c'7d >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5c'24'28'3a'3a'7c'5cw'29'2b >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'22'7b2'7d >>= withAttribute "String"))- <|>- ((pRegExpr regex_'22 >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False ';' >>= withAttribute "Normal Text") >>~ pushContext "New command line")- <|>- ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pDetectChar False '{' >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '}' >>= withAttribute "Keyword"))- <|>- ((pDetectChar False '[' >>= withAttribute "Keyword"))- <|>- ((pDetectChar False ']' >>= withAttribute "Keyword")))- return (attr, result)+parseRules "Base" =+ (((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aBEGIN'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'23'5cs'2aEND'2e'2a'24 >>= withAttribute RegionMarkerTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords'2dopt >>= withAttribute OtherTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pRegExpr regex_'5cs'2d'5cw'2b >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5c'7b'28'5b'5e'5c'7d'5d'7c'5c'5c'5c'7d'29'2b'5c'7d >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'24'28'3a'3a'7c'5cw'29'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'22'7b2'7d >>= withAttribute StringTok))+ <|>+ ((pRegExpr regex_'22 >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False ';' >>= withAttribute NormalTok) >>~ pushContext "New command line")+ <|>+ ((pFirstNonSpace >> pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok))) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- <|>- ((pDetectChar False '$' >>= withAttribute "Variable")))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((pDetectChar False '$' >>= withAttribute DataTypeTok))) -parseRules "Comment" = +parseRules "Comment" = pzero -parseRules "New command line" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a'23 >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((lookAhead (pRegExpr regex_'2e) >> return ([],"") ) >>~ (popContext)))- return (attr, result)+parseRules "New command line" =+ (((pRegExpr regex_'5cs'2a'23 >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((lookAhead (pRegExpr regex_'2e) >> return (NormalTok,"") ) >>~ (popContext))) parseRules "" = parseRules "Base"
Text/Highlighting/Kate/Syntax/Texinfo.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file texinfo.xml, version 0.2,- by Daniel Franke (franke.daniel@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file texinfo.xml, version 0.2, by Daniel Franke (franke.daniel@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Texinfo ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Texinfo+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,58 +22,45 @@ syntaxExtensions = "*.texi" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Texinfo" } context <- currentContext <|> (pushContext "Normal Text" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Texinfo",["Normal Text"])], synStLanguage = "Texinfo", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Texinfo",["Normal Text"])], synStLanguage = "Texinfo", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal Text" -> return () >> pHandleEndLine+ "Normal Text" -> return () "singleLineComment" -> (popContext) >> pEndLine- "multiLineComment" -> return () >> pHandleEndLine- "nodeFolding" -> return () >> pHandleEndLine- "folding" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "multiLineComment" -> return ()+ "nodeFolding" -> return ()+ "folding" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Command","fu")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'40c'28omment'29'3f'5cb = compileRegex "@c(omment)?\\b"@@ -80,41 +70,36 @@ regex_'40'5b'5cw'5d'2b'28'5c'7b'28'5b'5cw'5d'2b'5b'5cs'5d'2a'29'2b'5c'7d'29'3f = compileRegex "@[\\w]+(\\{([\\w]+[\\s]*)+\\})?" regex_'40end_'28menu'7csmallexample'7ctable'7cmultitable'29'5cb = compileRegex "@end (menu|smallexample|table|multitable)\\b" -defaultAttributes = [("Normal Text","Normal Text"),("singleLineComment","Comment"),("multiLineComment","Comment"),("nodeFolding","Normal Text"),("folding","Normal Text")]+defaultAttributes = [("Normal Text",NormalTok),("singleLineComment",CommentTok),("multiLineComment",CommentTok),("nodeFolding",NormalTok),("folding",NormalTok)] -parseRules "Normal Text" = - do (attr, result) <- (((pRegExpr regex_'40c'28omment'29'3f'5cb >>= withAttribute "Comment") >>~ pushContext "singleLineComment")- <|>- ((pRegExpr regex_'40ignore'5cb >>= withAttribute "Comment") >>~ pushContext "multiLineComment")- <|>- ((pRegExpr regex_'40node'5cb >>= withAttribute "Command") >>~ pushContext "nodeFolding")- <|>- ((pRegExpr regex_'40'28menu'7csmallexample'7ctable'7cmultitable'29'5cb >>= withAttribute "Command") >>~ pushContext "folding")- <|>- ((pRegExpr regex_'40'5b'5cw'5d'2b'28'5c'7b'28'5b'5cw'5d'2b'5b'5cs'5d'2a'29'2b'5c'7d'29'3f >>= withAttribute "Command")))- return (attr, result)+parseRules "Normal Text" =+ (((pRegExpr regex_'40c'28omment'29'3f'5cb >>= withAttribute CommentTok) >>~ pushContext "singleLineComment")+ <|>+ ((pRegExpr regex_'40ignore'5cb >>= withAttribute CommentTok) >>~ pushContext "multiLineComment")+ <|>+ ((pRegExpr regex_'40node'5cb >>= withAttribute FunctionTok) >>~ pushContext "nodeFolding")+ <|>+ ((pRegExpr regex_'40'28menu'7csmallexample'7ctable'7cmultitable'29'5cb >>= withAttribute FunctionTok) >>~ pushContext "folding")+ <|>+ ((pRegExpr regex_'40'5b'5cw'5d'2b'28'5c'7b'28'5b'5cw'5d'2b'5b'5cs'5d'2a'29'2b'5c'7d'29'3f >>= withAttribute FunctionTok))) -parseRules "singleLineComment" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)+parseRules "singleLineComment" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "multiLineComment" = - do (attr, result) <- (((pString False "@end ignore" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression)))- return (attr, result)+parseRules "multiLineComment" =+ (((pString False "@end ignore" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))) -parseRules "nodeFolding" = - do (attr, result) <- (((lookAhead (pRegExpr regex_'40node'5cb) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "Normal Text")))- return (attr, result)+parseRules "nodeFolding" =+ (((lookAhead (pRegExpr regex_'40node'5cb) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "Normal Text"))) -parseRules "folding" = - do (attr, result) <- (((pRegExpr regex_'40end_'28menu'7csmallexample'7ctable'7cmultitable'29'5cb >>= withAttribute "Command") >>~ (popContext))- <|>- ((parseRules "Normal Text")))- return (attr, result)+parseRules "folding" =+ (((pRegExpr regex_'40end_'28menu'7csmallexample'7ctable'7cmultitable'29'5cb >>= withAttribute FunctionTok) >>~ (popContext))+ <|>+ ((parseRules "Normal Text"))) parseRules "" = parseRules "Normal Text"
Text/Highlighting/Kate/Syntax/Verilog.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file verilog.xml, version 1.09,- by Yevgen Voronenko (ysv22@drexel.edu), Ryan Dalzell (ryan@tullyroan.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file verilog.xml, version 1.09, by Yevgen Voronenko (ysv22@drexel.edu), Ryan Dalzell (ryan@tullyroan.com) -} -module Text.Highlighting.Kate.Syntax.Verilog ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Verilog+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "Verilog"@@ -20,63 +23,50 @@ syntaxExtensions = "*.v;*.V;*.vl" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Verilog" } context <- currentContext <|> (pushContext "Normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Verilog",["Normal"])], synStLanguage = "Verilog", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Verilog",["Normal"])], synStLanguage = "Verilog", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Normal" -> return () >> pHandleEndLine+ "Normal" -> return () "String" -> (popContext) >> pEndLine "Commentar 1" -> (popContext) >> pEndLine- "Commentar 2" -> return () >> pHandleEndLine+ "Commentar 2" -> return () "Preprocessor" -> (popContext) >> pEndLine- "Commentar/Preprocessor" -> return () >> pHandleEndLine+ "Commentar/Preprocessor" -> return () "Some Context" -> (popContext) >> pEndLine- "Some Context2" -> return () >> pHandleEndLine+ "Some Context2" -> return () "Block name" -> (popContext) >> pEndLine- "Port" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Port" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Decimal","bn"),("Octal","bn"),("Hex","bn"),("Binary","bn"),("Float","fl"),("String","st"),("String Char","ch"),("Comment","co"),("Alert","al"),("Preprocessor","ot"),("Prep. Lib","fl"),("System Task","dt"),("Integer","dv"),("Delay","bn"),("Block name","dt"),("Drive/charge strength","bn"),("Gate instantiation","dt"),("Port map","dt"),("Case label","dv")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "macromodule table endtable specify specparam endspecify defparam default if ifnone else forever while for wait repeat disable assign deassign force release always initial edge posedge negedge config endconfig library design liblist cell use instance" list_beginwords = Set.fromList $ words $ "begin fork module case casex casez task function generate"@@ -96,108 +86,99 @@ regex_'5c'24'5ba'2dzA'2dZ'5f'5d'2b'5cw'2a = compileRegex "\\$[a-zA-Z_]+\\w*" regex_'23'5b'5cd'5f'5d'2b = compileRegex "#[\\d_]+" -defaultAttributes = [("Normal","Normal Text"),("String","String"),("Commentar 1","Comment"),("Commentar 2","Comment"),("Preprocessor","Preprocessor"),("Commentar/Preprocessor","Comment"),("Some Context","Normal Text"),("Some Context2","Comment"),("Block name","Block name"),("Port","Normal Text")]+defaultAttributes = [("Normal",NormalTok),("String",StringTok),("Commentar 1",CommentTok),("Commentar 2",CommentTok),("Preprocessor",OtherTok),("Commentar/Preprocessor",CommentTok),("Some Context",NormalTok),("Some Context2",CommentTok),("Block name",DataTypeTok),("Port",NormalTok)] -parseRules "Normal" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_begin'5c_'2a'3a >>= withAttribute "Keyword") >>~ pushContext "Block name")- <|>- ((pRegExpr regex_fork'5c_'2a'3a >>= withAttribute "Keyword") >>~ pushContext "Block name")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_beginwords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_endwords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_strength >>= withAttribute "Drive/charge strength"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_gates >>= withAttribute "Gate instantiation"))- <|>- ((pRegExpr regex_'5b'5cd'5f'5d'2a'27d'5b'5cd'5f'5d'2b >>= withAttribute "Decimal"))- <|>- ((pRegExpr regex_'5b'5cd'5f'5d'2a'27o'5b0'2d7xXzZ'5f'5d'2b >>= withAttribute "Octal"))- <|>- ((pRegExpr regex_'5b'5cd'5f'5d'2a'27h'5b'5cda'2dfA'2dFxXzZ'5f'5d'2b >>= withAttribute "Hex"))- <|>- ((pRegExpr regex_'5b'5cd'5f'5d'2a'27b'5b01'5fzZxX'5d'2b >>= withAttribute "Binary"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Integer"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5f'2c_'5ct'5d'2b'5cs'2a'3a >>= withAttribute "Case label"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar 2")- <|>- ((pAnyChar "!%&()+,-<=+/:;>?[]^{|}~@" >>= withAttribute "Symbol"))- <|>- ((pColumn 0 >> pDetectChar False '`' >>= withAttribute "Preprocessor") >>~ pushContext "Preprocessor")- <|>- ((pRegExpr regex_'5c'60'5ba'2dzA'2dZ'5f'5d'2b'5cw'2a >>= withAttribute "Preprocessor"))- <|>- ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5d'2b'5cw'2a >>= withAttribute "System Task"))- <|>- ((pRegExpr regex_'23'5b'5cd'5f'5d'2b >>= withAttribute "Delay")))- return (attr, result)+parseRules "Normal" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_begin'5c_'2a'3a >>= withAttribute KeywordTok) >>~ pushContext "Block name")+ <|>+ ((pRegExpr regex_fork'5c_'2a'3a >>= withAttribute KeywordTok) >>~ pushContext "Block name")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_beginwords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_endwords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_strength >>= withAttribute BaseNTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_gates >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5b'5cd'5f'5d'2a'27d'5b'5cd'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5b'5cd'5f'5d'2a'27o'5b0'2d7xXzZ'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5b'5cd'5f'5d'2a'27h'5b'5cda'2dfA'2dFxXzZ'5f'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pRegExpr regex_'5b'5cd'5f'5d'2a'27b'5b01'5fzZxX'5d'2b >>= withAttribute BaseNTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5ba'2dzA'2dZ0'2d9'5f'2c_'5ct'5d'2b'5cs'2a'3a >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar 2")+ <|>+ ((pAnyChar "!%&()+,-<=+/:;>?[]^{|}~@" >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pDetectChar False '`' >>= withAttribute OtherTok) >>~ pushContext "Preprocessor")+ <|>+ ((pRegExpr regex_'5c'60'5ba'2dzA'2dZ'5f'5d'2b'5cw'2a >>= withAttribute OtherTok))+ <|>+ ((pRegExpr regex_'5c'24'5ba'2dzA'2dZ'5f'5d'2b'5cw'2a >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'23'5b'5cd'5f'5d'2b >>= withAttribute BaseNTok))) -parseRules "String" = - do (attr, result) <- (((pLineContinue >>= withAttribute "String") >>~ pushContext "Some Context")- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pLineContinue >>= withAttribute StringTok) >>~ pushContext "Some Context")+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Commentar 1" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- return (attr, result)+parseRules "Commentar 1" =+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd))) -parseRules "Commentar 2" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Commentar 2" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Preprocessor" = - do (attr, result) <- (((pLineContinue >>= withAttribute "Preprocessor") >>~ pushContext "Some Context")- <|>- ((pRangeDetect '"' '"' >>= withAttribute "Prep. Lib"))- <|>- ((pRangeDetect '<' '>' >>= withAttribute "Prep. Lib"))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "Commentar 1")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Commentar/Preprocessor"))- return (attr, result)+parseRules "Preprocessor" =+ (((pLineContinue >>= withAttribute OtherTok) >>~ pushContext "Some Context")+ <|>+ ((pRangeDetect '"' '"' >>= withAttribute FloatTok))+ <|>+ ((pRangeDetect '<' '>' >>= withAttribute FloatTok))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "Commentar 1")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Commentar/Preprocessor")) -parseRules "Commentar/Preprocessor" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "Commentar/Preprocessor" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "Some Context" = +parseRules "Some Context" = pzero -parseRules "Some Context2" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pFirstNonSpace >> pString False "#endif" >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Some Context2" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pFirstNonSpace >> pString False "#endif" >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Block name" = - do (attr, result) <- ((pDetectIdentifier >>= withAttribute "Data Type") >>~ (popContext))- return (attr, result)+parseRules "Block name" =+ ((pDetectIdentifier >>= withAttribute DataTypeTok) >>~ (popContext)) -parseRules "Port" = - do (attr, result) <- ((pDetectIdentifier >>= withAttribute "Normal Text") >>~ (popContext))- return (attr, result)+parseRules "Port" =+ ((pDetectIdentifier >>= withAttribute NormalTok) >>~ (popContext)) parseRules "" = parseRules "Normal"
Text/Highlighting/Kate/Syntax/Vhdl.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file vhdl.xml, version 1.10,- by Rocky Scaletta (rocky@purdue.edu), Stefan Endrullis (stefan@endrullis.de), Florent Ouchet (outchy@users.sourceforge.net), Chris Higgs (chiggs.99@gmail.com), Jan Michel (jan@mueschelsoft.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file vhdl.xml, version 1.10, by Rocky Scaletta (rocky@purdue.edu), Stefan Endrullis (stefan@endrullis.de), Florent Ouchet (outchy@users.sourceforge.net), Chris Higgs (chiggs.99@gmail.com), Jan Michel (jan@mueschelsoft.de) -} -module Text.Highlighting.Kate.Syntax.Vhdl ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Vhdl+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "VHDL"@@ -19,79 +22,66 @@ syntaxExtensions = "*.vhdl;*.vhd" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "VHDL" } context <- currentContext <|> (pushContext "start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("VHDL",["start"])], synStLanguage = "VHDL", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("VHDL",["start"])], synStLanguage = "VHDL", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "start" -> return () >> pHandleEndLine- "package" -> return () >> pHandleEndLine- "packagebody" -> return () >> pHandleEndLine- "architecture_main" -> return () >> pHandleEndLine- "arch_decl" -> return () >> pHandleEndLine- "detect_arch_parts" -> return () >> pHandleEndLine- "generate1" -> return () >> pHandleEndLine- "generate2" -> return () >> pHandleEndLine- "process1" -> return () >> pHandleEndLine- "proc_rules" -> return () >> pHandleEndLine- "instance" -> return () >> pHandleEndLine- "forOrWhile" -> return () >> pHandleEndLine- "if_start" -> return () >> pHandleEndLine- "if" -> return () >> pHandleEndLine- "case1" -> return () >> pHandleEndLine- "case2" -> return () >> pHandleEndLine- "caseWhen" -> return () >> pHandleEndLine- "entity" -> return () >> pHandleEndLine- "entity_main" -> return () >> pHandleEndLine- "preDetection" -> return () >> pHandleEndLine- "generalDetection" -> return () >> pHandleEndLine+ "start" -> return ()+ "package" -> return ()+ "packagebody" -> return ()+ "architecture_main" -> return ()+ "arch_decl" -> return ()+ "detect_arch_parts" -> return ()+ "generate1" -> return ()+ "generate2" -> return ()+ "process1" -> return ()+ "proc_rules" -> return ()+ "instance" -> return ()+ "forOrWhile" -> return ()+ "if_start" -> return ()+ "if" -> return ()+ "case1" -> return ()+ "case2" -> return ()+ "caseWhen" -> return ()+ "entity" -> return ()+ "entity_main" -> return ()+ "preDetection" -> return ()+ "generalDetection" -> return () "comment" -> (popContext) >> pEndLine- "string" -> return () >> pHandleEndLine+ "string" -> return () "attribute" -> (popContext) >> pEndLine- "quot in att" -> return () >> pHandleEndLine- "signal" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "quot in att" -> return ()+ "signal" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Data Type","dt"),("Comment","co"),("Integer","dv"),("Bit","ch"),("Error","er"),("Vector","st"),("Operator","ot"),("Attribute","bn"),("Region Marker","re"),("Signal","ot"),("Range","ot"),("Redirection","kw"),("Process","kw"),("Control","kw"),("Name","kw")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywordsToplevel = Set.fromList $ words $ "file library use" list_keywords = Set.fromList $ words $ "access after alias all array assert assume assume_guarantee attribute begin block body bus component constant context cover default disconnect downto end exit fairness file force function generate generic group guarded impure inertial is label linkage literal map new next null of on open others parameter port postponed procedure process property protected pure range record register reject release report return select sequence severity signal shared strong subtype to transport type unaffected units until variable vmode vprop vunit wait when with note warning error failure in inout out buffer and abs or xor xnor not mod nand nor rem rol ror sla sra sll srl"@@ -119,272 +109,247 @@ regex_generic = compileRegex "generic" regex_port = compileRegex "port" -defaultAttributes = [("start","Normal Text"),("package","Normal Text"),("packagebody","Normal Text"),("architecture_main","Normal Text"),("arch_decl","Normal Text"),("detect_arch_parts","Normal Text"),("generate1","Normal Text"),("generate2","Normal Text"),("process1","Normal Text"),("proc_rules","Normal Text"),("instance","Normal Text"),("forOrWhile","Normal Text"),("if_start","Normal Text"),("if","Normal Text"),("case1","Normal Text"),("case2","Normal Text"),("caseWhen","Normal Text"),("entity","Normal Text"),("entity_main","Normal Text"),("preDetection","Normal Text"),("generalDetection","Normal Text"),("comment","Comment"),("string","Vector"),("attribute","Attribute"),("quot in att","Attribute"),("signal","Normal Text")]+defaultAttributes = [("start",NormalTok),("package",NormalTok),("packagebody",NormalTok),("architecture_main",NormalTok),("arch_decl",NormalTok),("detect_arch_parts",NormalTok),("generate1",NormalTok),("generate2",NormalTok),("process1",NormalTok),("proc_rules",NormalTok),("instance",NormalTok),("forOrWhile",NormalTok),("if_start",NormalTok),("if",NormalTok),("case1",NormalTok),("case2",NormalTok),("caseWhen",NormalTok),("entity",NormalTok),("entity_main",NormalTok),("preDetection",NormalTok),("generalDetection",NormalTok),("comment",CommentTok),("string",StringTok),("attribute",BaseNTok),("quot in att",BaseNTok),("signal",NormalTok)] -parseRules "start" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((lookAhead (pRegExprDynamic "architecture\\s+(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)") >> return ([],"") ) >>~ pushContext "architecture_main")- <|>- ((pString False "entity" >>= withAttribute "Control") >>~ pushContext "entity")- <|>- ((lookAhead (pRegExpr regex_'28'5cb'29'28package'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis'29'5cb) >> return ([],"") ) >>~ pushContext "package")- <|>- ((lookAhead (pRegExpr regex_'28'5cb'29'28package'5cs'2bbody'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis'29'5cb) >> return ([],"") ) >>~ pushContext "packagebody")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordsToplevel >>= withAttribute "Keyword")))- return (attr, result)+parseRules "start" =+ (((parseRules "preDetection"))+ <|>+ ((lookAhead (pRegExprDynamic "architecture\\s+(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)") >> return (NormalTok,"") ) >>~ pushContext "architecture_main")+ <|>+ ((pString False "entity" >>= withAttribute KeywordTok) >>~ pushContext "entity")+ <|>+ ((lookAhead (pRegExpr regex_'28'5cb'29'28package'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis'29'5cb) >> return (NormalTok,"") ) >>~ pushContext "package")+ <|>+ ((lookAhead (pRegExpr regex_'28'5cb'29'28package'5cs'2bbody'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis'29'5cb) >> return (NormalTok,"") ) >>~ pushContext "packagebody")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywordsToplevel >>= withAttribute KeywordTok))) -parseRules "package" = - do (attr, result) <- (((pString True "%2" >>= withAttribute "Redirection"))- <|>- ((parseRules "preDetection"))- <|>- ((pString False "begin" >>= withAttribute "Redirection"))- <|>- ((pRegExprDynamic "(\\b)end(\\s+package)?(\\s+%3)?\\s*;" >>= withAttribute "Redirection") >>~ (popContext))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "package" =+ (((pString True "%2" >>= withAttribute KeywordTok))+ <|>+ ((parseRules "preDetection"))+ <|>+ ((pString False "begin" >>= withAttribute KeywordTok))+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+package)?(\\s+%3)?\\s*;" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "generalDetection"))) -parseRules "packagebody" = - do (attr, result) <- (((pString True "%2" >>= withAttribute "Redirection"))- <|>- ((parseRules "preDetection"))- <|>- ((pString False "begin" >>= withAttribute "Redirection"))- <|>- ((pRegExprDynamic "(\\b)end(\\s+package)?(\\s+%3)?\\s*;" >>= withAttribute "Redirection") >>~ (popContext))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "packagebody" =+ (((pString True "%2" >>= withAttribute KeywordTok))+ <|>+ ((parseRules "preDetection"))+ <|>+ ((pString False "begin" >>= withAttribute KeywordTok))+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+package)?(\\s+%3)?\\s*;" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "generalDetection"))) -parseRules "architecture_main" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExpr regex_architecture'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bof'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis >>= withAttribute "Control") >>~ pushContext "arch_decl")- <|>- ((pRegExprDynamic "(\\b)end(\\s+architecture)?(\\s+%1)?\\s*;" >>= withAttribute "Control") >>~ (popContext >> popContext))- <|>- ((pRegExprDynamic "(\\b)end(\\s+architecture)?(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*;" >>= withAttribute "Error") >>~ (popContext >> popContext))- <|>- ((parseRules "detect_arch_parts")))- return (attr, result)+parseRules "architecture_main" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExpr regex_architecture'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bof'5cs'2b'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2bis >>= withAttribute KeywordTok) >>~ pushContext "arch_decl")+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+architecture)?(\\s+%1)?\\s*;" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+architecture)?(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*;" >>= withAttribute ErrorTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "detect_arch_parts"))) -parseRules "arch_decl" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_signals >>= withAttribute "Signal") >>~ pushContext "signal")- <|>- ((pString False "component" >>= withAttribute "Control") >>~ pushContext "entity")- <|>- ((pString False "begin" >>= withAttribute "Control") >>~ (popContext))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "arch_decl" =+ (((parseRules "preDetection"))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_signals >>= withAttribute OtherTok) >>~ pushContext "signal")+ <|>+ ((pString False "component" >>= withAttribute KeywordTok) >>~ pushContext "entity")+ <|>+ ((pString False "begin" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((parseRules "generalDetection"))) -parseRules "detect_arch_parts" = - do (attr, result) <- (((lookAhead (pRegExprDynamic "(\\b)((\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*)(if|for).*\\s+generate\\b") >> return ([],"") ) >>~ pushContext "generate1")- <|>- ((lookAhead (pRegExprDynamic "(\\b)((\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*)?process\\b") >> return ([],"") ) >>~ pushContext "process1")- <|>- ((lookAhead (pRegExprDynamic "\\b(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)") >> return ([],"") ) >>~ pushContext "instance")- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "detect_arch_parts" =+ (((lookAhead (pRegExprDynamic "(\\b)((\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*)(if|for).*\\s+generate\\b") >> return (NormalTok,"") ) >>~ pushContext "generate1")+ <|>+ ((lookAhead (pRegExprDynamic "(\\b)((\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*)?process\\b") >> return (NormalTok,"") ) >>~ pushContext "process1")+ <|>+ ((lookAhead (pRegExprDynamic "\\b(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)\\s*:\\s*(\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)") >> return (NormalTok,"") ) >>~ pushContext "instance")+ <|>+ ((parseRules "generalDetection"))) -parseRules "generate1" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExpr regex_'28'5cb'29generate'5cb >>= withAttribute "Control") >>~ pushContext "generate2")- <|>- ((pRegExprDynamic "(\\b)%3\\b" >>= withAttribute "Name"))- <|>- ((pString False "for" >>= withAttribute "Control"))- <|>- ((pString False "if" >>= withAttribute "Control"))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "generate1" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExpr regex_'28'5cb'29generate'5cb >>= withAttribute KeywordTok) >>~ pushContext "generate2")+ <|>+ ((pRegExprDynamic "(\\b)%3\\b" >>= withAttribute KeywordTok))+ <|>+ ((pString False "for" >>= withAttribute KeywordTok))+ <|>+ ((pString False "if" >>= withAttribute KeywordTok))+ <|>+ ((parseRules "generalDetection"))) -parseRules "generate2" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pString False "begin" >>= withAttribute "Control"))- <|>- ((pRegExpr regex_'28'5cb'29end'5cs'2bgenerate'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute "Control") >>~ (popContext >> popContext))- <|>- ((parseRules "detect_arch_parts")))- return (attr, result)+parseRules "generate2" =+ (((parseRules "preDetection"))+ <|>+ ((pString False "begin" >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5cb'29end'5cs'2bgenerate'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "detect_arch_parts"))) -parseRules "process1" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExprDynamic "end\\s+process(\\s+%3)?\\s*;" >>= withAttribute "Process") >>~ (popContext))- <|>- ((pRegExprDynamic "end\\s+process(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)?" >>= withAttribute "Error") >>~ (popContext))- <|>- ((pString False "process" >>= withAttribute "Process"))- <|>- ((pString False "begin" >>= withAttribute "Process"))- <|>- ((parseRules "proc_rules")))- return (attr, result)+parseRules "process1" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExprDynamic "end\\s+process(\\s+%3)?\\s*;" >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExprDynamic "end\\s+process(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)?" >>= withAttribute ErrorTok) >>~ (popContext))+ <|>+ ((pString False "process" >>= withAttribute KeywordTok))+ <|>+ ((pString False "begin" >>= withAttribute KeywordTok))+ <|>+ ((parseRules "proc_rules"))) -parseRules "proc_rules" = - do (attr, result) <- (((pRegExpr regex_'28'5cb'29'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'28'3f'3d'5cs'2a'3a'28'3f'21'3d'29'29 >>= withAttribute "Name"))- <|>- ((pRegExpr regex_'28'5cb'29'28if'29'5cb >>= withAttribute "Control") >>~ pushContext "if_start")- <|>- ((lookAhead (pRegExprDynamic "(\\b)(case)\\b") >> return ([],"") ) >>~ pushContext "case1")- <|>- ((pRegExpr regex_'28'5cb'29'28'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2a'3a'5cs'2a'29'3f'28'28for'7cwhile'29'5cs'2b'2e'2b'5cs'2b'29'3floop'5cb >>= withAttribute "Control") >>~ pushContext "forOrWhile")- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "proc_rules" =+ (((pRegExpr regex_'28'5cb'29'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'28'3f'3d'5cs'2a'3a'28'3f'21'3d'29'29 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28'5cb'29'28if'29'5cb >>= withAttribute KeywordTok) >>~ pushContext "if_start")+ <|>+ ((lookAhead (pRegExprDynamic "(\\b)(case)\\b") >> return (NormalTok,"") ) >>~ pushContext "case1")+ <|>+ ((pRegExpr regex_'28'5cb'29'28'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'5cs'2a'3a'5cs'2a'29'3f'28'28for'7cwhile'29'5cs'2b'2e'2b'5cs'2b'29'3floop'5cb >>= withAttribute KeywordTok) >>~ pushContext "forOrWhile")+ <|>+ ((parseRules "generalDetection"))) -parseRules "instance" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExprDynamic "\\b%1\\b" >>= withAttribute "Name"))- <|>- ((pRegExprDynamic "\\b%2\\b" >>= withAttribute "Name"))- <|>- ((pDetect2Chars False ')' ';' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "instance" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExprDynamic "\\b%1\\b" >>= withAttribute KeywordTok))+ <|>+ ((pRegExprDynamic "\\b%2\\b" >>= withAttribute KeywordTok))+ <|>+ ((pDetect2Chars False ')' ';' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "generalDetection"))) -parseRules "forOrWhile" = - do (attr, result) <- (((pRegExpr regex_'28'5cb'29end'5cs'2bloop'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute "Control") >>~ (popContext))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_forOrWhile >>= withAttribute "Control"))- <|>- ((parseRules "proc_rules")))- return (attr, result)+parseRules "forOrWhile" =+ (((pRegExpr regex_'28'5cb'29end'5cs'2bloop'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_forOrWhile >>= withAttribute KeywordTok))+ <|>+ ((parseRules "proc_rules"))) -parseRules "if_start" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pString False "then" >>= withAttribute "Control") >>~ pushContext "if")- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "if_start" =+ (((parseRules "preDetection"))+ <|>+ ((pString False "then" >>= withAttribute KeywordTok) >>~ pushContext "if")+ <|>+ ((parseRules "generalDetection"))) -parseRules "if" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExpr regex_'28'5cb'29end'5cs'2bif'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute "Control") >>~ (popContext >> popContext))- <|>- ((parseRules "proc_rules"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_if >>= withAttribute "Control")))- return (attr, result)+parseRules "if" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExpr regex_'28'5cb'29end'5cs'2bif'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "proc_rules"))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_if >>= withAttribute KeywordTok))) -parseRules "case1" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pString False "is" >>= withAttribute "Keyword") >>~ pushContext "case2")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_case >>= withAttribute "Control")))- return (attr, result)+parseRules "case1" =+ (((parseRules "preDetection"))+ <|>+ ((pString False "is" >>= withAttribute KeywordTok) >>~ pushContext "case2")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_case >>= withAttribute KeywordTok))) -parseRules "case2" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExpr regex_'28'5cb'29end'5cs'2bcase'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute "Control") >>~ (popContext >> popContext))- <|>- ((pString False "when" >>= withAttribute "Control") >>~ pushContext "caseWhen")- <|>- ((parseRules "proc_rules")))- return (attr, result)+parseRules "case2" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExpr regex_'28'5cb'29end'5cs'2bcase'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "when" >>= withAttribute KeywordTok) >>~ pushContext "caseWhen")+ <|>+ ((parseRules "proc_rules"))) -parseRules "caseWhen" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((lookAhead (pRegExpr regex_'28'5cb'29when'5cb) >> return ([],"") ) >>~ (popContext))- <|>- ((lookAhead (pRegExpr regex_'28'5cb'29end'5cs'2bcase'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b) >> return ([],"") ) >>~ (popContext))- <|>- ((parseRules "proc_rules")))- return (attr, result)+parseRules "caseWhen" =+ (((parseRules "preDetection"))+ <|>+ ((lookAhead (pRegExpr regex_'28'5cb'29when'5cb) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((lookAhead (pRegExpr regex_'28'5cb'29end'5cs'2bcase'28'5cs'2b'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29'3f'5cs'2a'3b) >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((parseRules "proc_rules"))) -parseRules "entity" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExpr regex_'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29 >>= withAttribute "Name") >>~ pushContext "entity_main")- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "entity" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExpr regex_'28'5cb'28'3f'21'28'3f'3aprocess'7cconstant'7csignal'7cvariable'29'29'28'5bA'2dZa'2dz'5f'5d'5bA'2dZa'2dz0'2d9'5f'5d'2a'29'5cb'29 >>= withAttribute KeywordTok) >>~ pushContext "entity_main")+ <|>+ ((parseRules "generalDetection"))) -parseRules "entity_main" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pRegExprDynamic "(\\b)end(\\s+(entity|component))?(\\s+%1)?\\s*;" >>= withAttribute "Control") >>~ (popContext >> popContext))- <|>- ((pRegExprDynamic "(\\b)end(\\s+(entity|component))?(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)?\\s*;" >>= withAttribute "Error") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_generic >>= withAttribute "Control"))- <|>- ((pRegExpr regex_port >>= withAttribute "Control"))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "entity_main" =+ (((parseRules "preDetection"))+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+(entity|component))?(\\s+%1)?\\s*;" >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExprDynamic "(\\b)end(\\s+(entity|component))?(\\s+\\b(?!(?:process|constant|signal|variable))([A-Za-z_][A-Za-z0-9_]*)\\b)?\\s*;" >>= withAttribute ErrorTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_generic >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_port >>= withAttribute KeywordTok))+ <|>+ ((parseRules "generalDetection"))) -parseRules "preDetection" = - do (attr, result) <- (((pDetect2Chars False '-' '-' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetectChar False '"' >>= withAttribute "Vector") >>~ pushContext "string")- <|>- ((pAnyChar "[&><=:+\\-*\\/|].," >>= withAttribute "Operator"))- <|>- ((pDetectChar False '\'' >>= withAttribute "Attribute") >>~ pushContext "attribute"))- return (attr, result)+parseRules "preDetection" =+ (((pDetect2Chars False '-' '-' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pAnyChar "[&><=:+\\-*\\/|].," >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute BaseNTok) >>~ pushContext "attribute")) -parseRules "generalDetection" = - do (attr, result) <- (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute "Data Type"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_signals >>= withAttribute "Signal") >>~ pushContext "signal")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_range >>= withAttribute "Range"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pInt >>= withAttribute "Integer"))- <|>- ((pHlCChar >>= withAttribute "Bit"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text")))- return (attr, result)+parseRules "generalDetection" =+ (((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_types >>= withAttribute DataTypeTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_signals >>= withAttribute OtherTok) >>~ pushContext "signal")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_range >>= withAttribute OtherTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pHlCChar >>= withAttribute CharTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))) -parseRules "comment" = +parseRules "comment" = pzero -parseRules "string" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Vector") >>~ (popContext))- return (attr, result)+parseRules "string" =+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext)) -parseRules "attribute" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Attribute") >>~ pushContext "quot in att")- <|>- ((pDetectChar False ' ' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "Attribute") >>~ (popContext))- <|>- ((pAnyChar "()=<>" >>= withAttribute "Attribute") >>~ (popContext)))- return (attr, result)+parseRules "attribute" =+ (((pDetectChar False '"' >>= withAttribute BaseNTok) >>~ pushContext "quot in att")+ <|>+ ((pDetectChar False ' ' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pAnyChar "()=<>" >>= withAttribute BaseNTok) >>~ (popContext))) -parseRules "quot in att" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "Attribute") >>~ (popContext))- return (attr, result)+parseRules "quot in att" =+ ((pDetectChar False '"' >>= withAttribute BaseNTok) >>~ (popContext)) -parseRules "signal" = - do (attr, result) <- (((parseRules "preDetection"))- <|>- ((pDetectChar False ';' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((parseRules "generalDetection")))- return (attr, result)+parseRules "signal" =+ (((parseRules "preDetection"))+ <|>+ ((pDetectChar False ';' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "generalDetection"))) parseRules "" = parseRules "start"
− Text/Highlighting/Kate/Syntax/Xharbour.hs
@@ -1,174 +0,0 @@-{- This module was generated from data in the Kate syntax highlighting file xharbour.xml, version 1.04,- by Giancarlo Niccolai (giancarlo@niccolai.ws) -}--module Text.Highlighting.Kate.Syntax.Xharbour ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions-import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)-import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)--import qualified Data.Set as Set--- | Full name of language.-syntaxName :: String-syntaxName = "xHarbour"---- | Filename extensions for this language.-syntaxExtensions :: String-syntaxExtensions = "*.prg;*.PRG;*.ch"---- | 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 = "xHarbour" }- context <- currentContext <|> (pushContext "TopLevel" >> 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 [("xHarbour",["TopLevel"])], synStLanguage = "xHarbour", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine--pEndLine = do- lookAhead $ newline <|> (eof >> return '\n')- context <- currentContext- case context of- "TopLevel" -> return () >> pHandleEndLine- "comment" -> (popContext) >> pEndLine- "ml_comment" -> return () >> pHandleEndLine- "string" -> (popContext) >> pEndLine- "stringc" -> (popContext) >> pEndLine- "logic" -> (popContext) >> pEndLine- "ClassContext" -> return () >> pHandleEndLine- _ -> pHandleEndLine--withAttribute attr txt = do- when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Keyword","kw"),("Comment","co"),("Operator","bn"),("Number","dv"),("Function","fu"),("String","st"),("Preprocessor","ot")]--parseExpressionInternal = do- context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))--list_keywords = Set.fromList $ words $ "local global extern field each as set clear screen databases all close color date else elseif in to do loop catch exit box say case switch self super say get read use select otherwise index alias like has return static on off nil ? class external"-list_context'5fbeginners = Set.fromList $ words $ "for if switch while try begin procedure function method"-list_context'5fterminators = Set.fromList $ words $ "next end endif enddo endcase"-list_class'5fkeywords = Set.fromList $ words $ "data inline method classdata init from hidden"-list_set'5fcommands = Set.fromList $ words $ "invalid exact fixed decimals dateformat epoch path default exclusive softseek unique deleted cancel debug typeahead color cursor console alternate altfile device extra extrafile printer printfile margin bell confirm escape insert exit intensity scoreboard delimiters delimchars wrap message mcenter scrollbreak eventmask videomode mblocksize mfileext strictread optimize autopen autorder autoshare language idlerepeat trace tracefile tracestack filecase dircase dirseparator"-list_functions = Set.fromList $ words $ "aadd adel achoice aclone aeval ains ascan asize adir afill atail asort array tassociativearray bin21 bin2l bin2u bin2w i2bin l2bin u2bin w2bin eval fieldblock fieldwblock inkey lastkey mcol mrow nextkey empty word descend __dbdelim __dbsdf os __run alert browse dbedit outerr outstd readkey readvar __atprompt __input __menuto __nonoallert __typefile __xrestscreen __xsavescreen dbappend dbclearfilter dbcloseall dbclosearea dbcommit dbcommitall dbcreate dbdelete dbeval dbf dbfilter dbgobottom dbgoto dbgotop dbrecall dbrlock dbrlocklist dbrunlock dbseek dbselectarea dbsetdriver dbsetfilter dbskip dbstruct dbunlock dbunlockall dbusearea indexext indexkey indexord ordbagext ordbagname ordcondset ordcreate orddestroy ordfor ordkey ordlistadd ordlistclear ordlistrebuild ordname ordnumber ordsetfocus rddlist rddname rddsetdefault __dbcontinue __dbzap __fledit __rddsetdefault __dbcopystruct __dbcopyxstruct __dbcreate __dbstructfilter dbskipper cdow cmonth ctod date day days dow dtoc dtos month year getenv set setmode settypeahead version __setcentury __setfunction break errorsys throw errornew hb_setkeysave hb_setkeycheck hb_setkeyget setkey __quit __wait file frename __dir col maxcol maxrow row hb_colorindex curdir dirchange dirremove diskspace fclose fcreate ferase ferror fopen fread freadstr fseek fwrite hb_diskspace hb_feof isdisk makedir abs exp int log max min mod round sqrt hb_isbyref procfile procline procname type valtype valtoprg tone hb_langname hb_langselect isaffirm isnegative nationmsg pcount hb_pvalue alltrim asc at chr hardcr hb_ansitooem hb_oemtoansi hb_valtostr isalpha isdigit islower isupper left len lower ltrim memotran padc padl padr rat replicate right rtrim space str strtran strzero substr transform trim upper val devoutpict elaptime seconds secs time do threadstart threadstop threadsleep threadkill threadjoin createmutex destroymutex mutexlock mutexunlock subscribe subscribenow notify notifyall waitforthreads killallthreads inetinit inetcleanup inetcreate inetdestroy inetconnect inetserver inetaccept inetsettimeout inetgettimeout inetcleartimeout inetrecv inetrecvall inetsend inetsendall inetdgram inetdgramrecv inetdgramsend inetaddress inetport ineterror ineterrordesc inetgethosts inetconnectip hb_regex hb_regexmatch hb_regexsplit hb_regexcomp hb_readini hb_writeini hb_random hb_chechsum hb_crypt hb_decrypt hb_hextonum hb_numtohex hb_exec hb_execfromarray hb_class hb_keyput hb_osnewline"-list_pragma = Set.fromList $ words $ "#include #if #ifdef #ifndef #endif #else #define"--regex_CLASS'5b'5ct_'5d'2b = compileRegex "CLASS[\\t ]+"-regex_DO'5b'5ct_'5d'2bCASE'5b'5ct_'5d'2a'24 = compileRegex "DO[\\t ]+CASE[\\t ]*$"-regex_return_'3f = compileRegex "return ?"-regex_'5cd'2b = compileRegex "\\d+"-regex_END'28CLASS'29'3f_'2a'24 = compileRegex "END(CLASS)? *$"--defaultAttributes = [("TopLevel","Normal Text"),("comment","Comment"),("ml_comment","Comment"),("string","String"),("stringc","String"),("logic","Operator"),("ClassContext","Normal Text")]--parseRules "TopLevel" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "ml_comment")- <|>- ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "stringc")- <|>- ((pString False ".and." >>= withAttribute "Operator"))- <|>- ((pString False ".or." >>= withAttribute "Operator"))- <|>- ((pString False ".not." >>= withAttribute "Operator"))- <|>- ((pString False ".f." >>= withAttribute "Operator"))- <|>- ((pString False ".t." >>= withAttribute "Operator"))- <|>- ((pAnyChar ":=!" >>= withAttribute "Operator"))- <|>- ((pDetectChar False '@' >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_CLASS'5b'5ct_'5d'2b >>= withAttribute "Keyword") >>~ pushContext "ClassContext")- <|>- ((pFirstNonSpace >> pRegExpr regex_DO'5b'5ct_'5d'2bCASE'5b'5ct_'5d'2a'24 >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_context'5fbeginners >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_context'5fterminators >>= withAttribute "Keyword"))- <|>- ((pColumn 0 >> pRegExpr regex_return_'3f >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_set'5fcommands >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_pragma >>= withAttribute "Preprocessor"))- <|>- ((pDetect2Chars False '-' '>' >>= withAttribute "Operator"))- <|>- ((pRegExpr regex_'5cd'2b >>= withAttribute "Number")))- return (attr, result)--parseRules "comment" = - pzero--parseRules "ml_comment" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)--parseRules "string" = - do (attr, result) <- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext))- return (attr, result)--parseRules "stringc" = - do (attr, result) <- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext))- return (attr, result)--parseRules "logic" = - do (attr, result) <- ((pDetectChar False '.' >>= withAttribute "Operator") >>~ (popContext))- return (attr, result)--parseRules "ClassContext" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "ml_comment")- <|>- ((pFirstNonSpace >> pDetectChar False '*' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_class'5fkeywords >>= withAttribute "Keyword"))- <|>- ((pFirstNonSpace >> pRegExpr regex_END'28CLASS'29'3f_'2a'24 >>= withAttribute "Keyword") >>~ (popContext)))- return (attr, result)--parseRules "" = parseRules "TopLevel"--parseRules x = fail $ "Unknown context" ++ x
Text/Highlighting/Kate/Syntax/Xml.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file xml.xml, version 2.03,- by Wilbert Berendsen (wilbert@kde.nl) -}+{- This module was generated from data in the Kate syntax+ highlighting file xml.xml, version 2.03, by Wilbert Berendsen (wilbert@kde.nl) -} -module Text.Highlighting.Kate.Syntax.Xml ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Xml+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,72 +22,59 @@ syntaxExtensions = "*.docbook;*.xml;*.rc;*.daml;*.rdf;*.rss;*.xspf;*.xsd;*.svg;*.ui;*.kcfg;*.qrc;*.wsdl" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "XML" } context <- currentContext <|> (pushContext "Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("XML",["Start"])], synStLanguage = "XML", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("XML",["Start"])], synStLanguage = "XML", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Start" -> return () >> pHandleEndLine- "FindXML" -> return () >> pHandleEndLine- "FindEntityRefs" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "Element" -> return () >> pHandleEndLine- "El Content" -> return () >> pHandleEndLine- "El End" -> return () >> pHandleEndLine- "Attribute" -> return () >> pHandleEndLine- "Value" -> return () >> pHandleEndLine- "Value DQ" -> return () >> pHandleEndLine- "Value SQ" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Start" -> return ()+ "FindXML" -> return ()+ "FindEntityRefs" -> return ()+ "FindPEntityRefs" -> return ()+ "Comment" -> return ()+ "CDATA" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "Element" -> return ()+ "El Content" -> return ()+ "El End" -> return ()+ "Attribute" -> return ()+ "Value" -> return ()+ "Value DQ" -> return ()+ "Value SQ" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("Element","kw"),("Attribute","ot"),("Value","st"),("EntityRef","dv"),("PEntityRef","dv"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'3c'21DOCTYPE'5cs'2b = compileRegex "<!DOCTYPE\\s+"@@ -99,157 +89,138 @@ regex_'5cS = compileRegex "\\S" regex_'3c'2f'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "</(?![0-9])[\\w_:][\\w.:_-]*" -defaultAttributes = [("Start","Normal Text"),("FindXML","Normal Text"),("FindEntityRefs","Other Text"),("FindPEntityRefs","Other Text"),("Comment","Comment"),("CDATA","Other Text"),("PI","Other Text"),("Doctype","Other Text"),("Doctype Internal Subset","Other Text"),("Doctype Markupdecl","Other Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("Element","Other Text"),("El Content","Other Text"),("El End","Other Text"),("Attribute","Other Text"),("Value","Other Text"),("Value DQ","Value"),("Value SQ","Value")]+defaultAttributes = [("Start",NormalTok),("FindXML",NormalTok),("FindEntityRefs",NormalTok),("FindPEntityRefs",NormalTok),("Comment",CommentTok),("CDATA",NormalTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",StringTok),("Doctype Markupdecl SQ",StringTok),("Element",NormalTok),("El Content",NormalTok),("El End",NormalTok),("Attribute",NormalTok),("Value",NormalTok),("Value DQ",StringTok),("Value SQ",StringTok)] -parseRules "Start" = - do (attr, result) <- ((parseRules "FindXML"))- return (attr, result)+parseRules "Start" =+ ((parseRules "FindXML")) -parseRules "FindXML" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pRegExpr regex_'3c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "Element")- <|>- ((parseRules "FindEntityRefs"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text")))- return (attr, result)+parseRules "FindXML" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pRegExpr regex_'3c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "Element")+ <|>+ ((parseRules "FindEntityRefs"))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))) -parseRules "FindEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pAnyChar "&<" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&<" >>= withAttribute ErrorTok))) -parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pRegExpr regex_'25'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntityRef"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute ErrorTok))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Error"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "CDATA" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Other Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Other Text"))- <|>- ((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "EntityRef")))- return (attr, result)+parseRules "CDATA" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)+parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset")) -parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)+parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl SQ")) -parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Element" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "El Content")- <|>- ((pColumn 0 >> pRegExpr regex_'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute") >>~ pushContext "Attribute")- <|>- ((pRegExpr regex_'5cs'2b'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute") >>~ pushContext "Attribute")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Element" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "El Content")+ <|>+ ((pColumn 0 >> pRegExpr regex_'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok) >>~ pushContext "Attribute")+ <|>+ ((pRegExpr regex_'5cs'2b'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok) >>~ pushContext "Attribute")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Content" = - do (attr, result) <- (((pRegExpr regex_'3c'2f'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El End")- <|>- ((parseRules "FindXML")))- return (attr, result)+parseRules "El Content" =+ (((pRegExpr regex_'3c'2f'28'3f'21'5b0'2d9'5d'29'5b'5cw'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El End")+ <|>+ ((parseRules "FindXML"))) -parseRules "El End" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El End" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Attribute" = - do (attr, result) <- (((pDetectChar False '=' >>= withAttribute "Attribute") >>~ pushContext "Value")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Attribute" =+ (((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Value DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Value SQ")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Value DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Value SQ")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Value DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "Value SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Xorg.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file xorg.xml, version 1.01,- by Jan Janssen (medhefgo@web.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file xorg.xml, version 1.01, by Jan Janssen (medhefgo@web.de) -} -module Text.Highlighting.Kate.Syntax.Xorg ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Xorg+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,114 +22,96 @@ syntaxExtensions = "xorg.conf" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "x.org Configuration" } context <- currentContext <|> (pushContext "xorg" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("x.org Configuration",["xorg"])], synStLanguage = "x.org Configuration", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("x.org Configuration",["xorg"])], synStLanguage = "x.org Configuration", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "xorg" -> return () >> pHandleEndLine- "Section" -> return () >> pHandleEndLine- "Section Content" -> return () >> pHandleEndLine+ "xorg" -> return ()+ "Section" -> return ()+ "Section Content" -> return () "Keyword" -> (popContext) >> pEndLine "Comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Section","fu"),("Section Name","st"),("Value","dt"),("Keyword","kw"),("Alert","er"),("Int","dv"),("Value2","ot"),("Float","fl"),("Comment","co")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'5cb'5cw'2b'5cb = compileRegex "\\b\\w+\\b" regex_'5b'5cw'5cd'5d'2b = compileRegex "[\\w\\d]+" -defaultAttributes = [("xorg","Normal Text"),("Section","Normal Text"),("Section Content","Normal Text"),("Keyword","Keyword"),("Comment","Comment")]+defaultAttributes = [("xorg",NormalTok),("Section",NormalTok),("Section Content",NormalTok),("Keyword",KeywordTok),("Comment",CommentTok)] -parseRules "xorg" = - do (attr, result) <- (((pString False "Section" >>= withAttribute "Section") >>~ pushContext "Section")- <|>- ((pDetectChar False '#' >>= withAttribute "Normal Text") >>~ pushContext "Comment"))- return (attr, result)+parseRules "xorg" =+ (((pString False "Section" >>= withAttribute FunctionTok) >>~ pushContext "Section")+ <|>+ ((pDetectChar False '#' >>= withAttribute NormalTok) >>~ pushContext "Comment")) -parseRules "Section" = - do (attr, result) <- (((pRangeDetect '"' '"' >>= withAttribute "Section Name") >>~ pushContext "Section Content")- <|>- ((pRangeDetect '\'' '\'' >>= withAttribute "Section Name") >>~ pushContext "Section Content")- <|>- ((pDetectIdentifier >>= withAttribute "Alert"))- <|>- ((pDetectChar False '#' >>= withAttribute "Normal Text") >>~ pushContext "Comment"))- return (attr, result)+parseRules "Section" =+ (((pRangeDetect '"' '"' >>= withAttribute StringTok) >>~ pushContext "Section Content")+ <|>+ ((pRangeDetect '\'' '\'' >>= withAttribute StringTok) >>~ pushContext "Section Content")+ <|>+ ((pDetectIdentifier >>= withAttribute ErrorTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute NormalTok) >>~ pushContext "Comment")) -parseRules "Section Content" = - do (attr, result) <- (((pString False "EndSection" >>= withAttribute "Section") >>~ (popContext >> popContext))- <|>- ((pString False "EndSubSection" >>= withAttribute "Section") >>~ (popContext >> popContext))- <|>- ((pString False "SubSection" >>= withAttribute "Section") >>~ pushContext "Section")- <|>- ((pRegExpr regex_'5cb'5cw'2b'5cb >>= withAttribute "Normal Text") >>~ pushContext "Keyword")- <|>- ((pDetectChar False '#' >>= withAttribute "Normal Text") >>~ pushContext "Comment"))- return (attr, result)+parseRules "Section Content" =+ (((pString False "EndSection" >>= withAttribute FunctionTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "EndSubSection" >>= withAttribute FunctionTok) >>~ (popContext >> popContext))+ <|>+ ((pString False "SubSection" >>= withAttribute FunctionTok) >>~ pushContext "Section")+ <|>+ ((pRegExpr regex_'5cb'5cw'2b'5cb >>= withAttribute NormalTok) >>~ pushContext "Keyword")+ <|>+ ((pDetectChar False '#' >>= withAttribute NormalTok) >>~ pushContext "Comment")) -parseRules "Keyword" = - do (attr, result) <- (((pRangeDetect '"' '"' >>= withAttribute "Value"))- <|>- ((pRangeDetect '\'' '\'' >>= withAttribute "Value"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Int"))- <|>- ((pRegExpr regex_'5b'5cw'5cd'5d'2b >>= withAttribute "Value2"))- <|>- ((pDetectChar False '#' >>= withAttribute "Keyword") >>~ pushContext "Comment"))- return (attr, result)+parseRules "Keyword" =+ (((pRangeDetect '"' '"' >>= withAttribute DataTypeTok))+ <|>+ ((pRangeDetect '\'' '\'' >>= withAttribute DataTypeTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'5b'5cw'5cd'5d'2b >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute KeywordTok) >>~ pushContext "Comment")) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) parseRules "" = parseRules "xorg"
Text/Highlighting/Kate/Syntax/Xslt.hs view
@@ -1,15 +1,18 @@-{- This module was generated from data in the Kate syntax highlighting file xslt.xml, version 1.03,- by Peter Lammich (views@gmx.de) -}+{- This module was generated from data in the Kate syntax+ highlighting file xslt.xml, version 1.03, by Peter Lammich (views@gmx.de) -} -module Text.Highlighting.Kate.Syntax.Xslt ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Xslt+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "xslt"@@ -19,75 +22,62 @@ syntaxExtensions = "*.xsl;*.xslt" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "xslt" } context <- currentContext <|> (pushContext "normalText" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("xslt",["normalText"])], synStLanguage = "xslt", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("xslt",["normalText"])], synStLanguage = "xslt", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = False, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normalText" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "detectEntRef" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "tagname" -> return () >> pHandleEndLine- "attributes" -> return () >> pHandleEndLine- "attrValue" -> return () >> pHandleEndLine- "xattributes" -> return () >> pHandleEndLine- "xattrValue" -> return () >> pHandleEndLine- "string" -> return () >> pHandleEndLine- "sqstring" -> return () >> pHandleEndLine- "comment" -> return () >> pHandleEndLine- "xpath" -> return () >> pHandleEndLine- "sqxpath" -> return () >> pHandleEndLine- "sqxpathstring" -> return () >> pHandleEndLine- "xpathstring" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "normalText" -> return ()+ "CDATA" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "detectEntRef" -> return ()+ "FindPEntityRefs" -> return ()+ "tagname" -> return ()+ "attributes" -> return ()+ "attrValue" -> return ()+ "xattributes" -> return ()+ "xattrValue" -> return ()+ "string" -> return ()+ "sqstring" -> return ()+ "comment" -> return ()+ "xpath" -> return ()+ "sqxpath" -> return ()+ "sqxpathstring" -> return ()+ "xpathstring" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Tag","kw"),("Attribute","ot"),("Invalid","er"),("Alert","al"),("Attribute Value","st"),("XPath","ot"),("XPath String","st"),("XPath Axis","kw"),("XPath/ XSLT Function","kw"),("XPath 2.0/ XSLT 2.0 Function","kw"),("Comment","co"),("XSLT Tag","kw"),("XSLT 2.0 Tag","kw"),("Entity Reference","dv"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("PEntity Reference","dv")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keytags = Set.fromList $ words $ "xsl:value-of xsl:output xsl:decimal-format xsl:apply-templates xsl:param xsl:transform xsl:namespace-alias xsl:comment xsl:element xsl:attribute xsl:apply-imports xsl:text xsl:when xsl:template xsl:processing-instruction xsl:include xsl:copy-of xsl:copy xsl:with-param xsl:stylesheet xsl:for-each xsl:choose xsl:sort xsl:otherwise xsl:key xsl:variable xsl:number xsl:message xsl:fallback xsl:strip-space xsl:import xsl:preserve-space xsl:if xsl:call-template xsl:attribute-set" list_keytags'5f2'2e0 = Set.fromList $ words $ "xsl:perform-sort xsl:import-schema xsl:for-each-group xsl:sequence xsl:non-matching-substring xsl:namespace xsl:next-match xsl:function xsl:analyze-string xsl:output-character xsl:matching-substring xsl:result-document xsl:character-map xsl:document"@@ -111,221 +101,199 @@ regex_'5c'24'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "\\$[A-Za-z_:][\\w.:_-]*" regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a = compileRegex "[A-Za-z_:][\\w.:_-]*" -defaultAttributes = [("normalText","Normal Text"),("CDATA","Normal Text"),("PI","Normal Text"),("Doctype","Normal Text"),("Doctype Internal Subset","Normal Text"),("Doctype Markupdecl","Normal Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("detectEntRef","Normal Text"),("FindPEntityRefs","Normal Text"),("tagname","Tag"),("attributes","Attribute"),("attrValue","Invalid"),("xattributes","Attribute"),("xattrValue","Invalid"),("string","Attribute Value"),("sqstring","Attribute Value"),("comment","Comment"),("xpath","XPath"),("sqxpath","XPath"),("sqxpathstring","XPath String"),("xpathstring","XPath String")]+defaultAttributes = [("normalText",NormalTok),("CDATA",NormalTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",NormalTok),("Doctype Markupdecl SQ",NormalTok),("detectEntRef",NormalTok),("FindPEntityRefs",NormalTok),("tagname",KeywordTok),("attributes",OtherTok),("attrValue",ErrorTok),("xattributes",OtherTok),("xattrValue",ErrorTok),("string",StringTok),("sqstring",StringTok),("comment",CommentTok),("xpath",OtherTok),("sqxpath",OtherTok),("sqxpathstring",StringTok),("xpathstring",StringTok)] -parseRules "normalText" = - do (attr, result) <- (((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pDetectChar False '<' >>= withAttribute "Tag") >>~ pushContext "tagname")- <|>- ((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "Entity Reference")))- return (attr, result)+parseRules "normalText" =+ (((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pDetectChar False '<' >>= withAttribute KeywordTok) >>~ pushContext "tagname")+ <|>+ ((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))) -parseRules "CDATA" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "Entity Reference")))- return (attr, result)+parseRules "CDATA" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)+parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset")) -parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)+parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "Doctype Markupdecl SQ")) -parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl DQ" =+ (((pDetectChar False '"' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl SQ" =+ (((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "detectEntRef" = - do (attr, result) <- ((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "Entity Reference"))- return (attr, result)+parseRules "detectEntRef" =+ ((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok)) -parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "Entity Reference"))- <|>- ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntity Reference"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute NormalTok))) -parseRules "tagname" = - do (attr, result) <- (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_keytags >>= withAttribute "XSLT Tag") >>~ pushContext "xattributes")- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_keytags'5f2'2e0 >>= withAttribute "XSLT 2.0 Tag") >>~ pushContext "xattributes")- <|>- ((pRegExpr regex_'5cs'2a >>= withAttribute "Attribute") >>~ pushContext "attributes")- <|>- ((pDetectChar False '>' >>= withAttribute "Tag") >>~ (popContext)))- return (attr, result)+parseRules "tagname" =+ (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_keytags >>= withAttribute KeywordTok) >>~ pushContext "xattributes")+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_keytags'5f2'2e0 >>= withAttribute KeywordTok) >>~ pushContext "xattributes")+ <|>+ ((pRegExpr regex_'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "attributes")+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "attributes" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Normal Text") >>~ pushContext "attrValue"))- return (attr, result)+parseRules "attributes" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute NormalTok) >>~ pushContext "attrValue")) -parseRules "attrValue" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Invalid") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Invalid") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Attribute Value") >>~ pushContext "string")- <|>- ((pDetectChar False '\'' >>= withAttribute "Attribute Value") >>~ pushContext "sqstring"))- return (attr, result)+parseRules "attrValue" =+ (((pDetect2Chars False '/' '>' >>= withAttribute ErrorTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute ErrorTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "sqstring")) -parseRules "xattributes" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Tag") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_select'5cs'2a'3d'5cs'2a >>= withAttribute "Attribute") >>~ pushContext "xattrValue")- <|>- ((pRegExpr regex_test'5cs'2a'3d'5cs'2a >>= withAttribute "Attribute") >>~ pushContext "xattrValue")- <|>- ((pRegExpr regex_match'5cs'2a'3d'5cs'2a >>= withAttribute "Attribute") >>~ pushContext "xattrValue")- <|>- ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute "Attribute") >>~ pushContext "attrValue"))- return (attr, result)+parseRules "xattributes" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_select'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "xattrValue")+ <|>+ ((pRegExpr regex_test'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "xattrValue")+ <|>+ ((pRegExpr regex_match'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "xattrValue")+ <|>+ ((pRegExpr regex_'5cs'2a'3d'5cs'2a >>= withAttribute OtherTok) >>~ pushContext "attrValue")) -parseRules "xattrValue" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Invalid") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Invalid") >>~ (popContext >> popContext >> popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "XPath") >>~ pushContext "xpath")- <|>- ((pDetectChar False '\'' >>= withAttribute "XPath") >>~ pushContext "sqxpath"))- return (attr, result)+parseRules "xattrValue" =+ (((pDetect2Chars False '/' '>' >>= withAttribute ErrorTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute ErrorTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute OtherTok) >>~ pushContext "xpath")+ <|>+ ((pDetectChar False '\'' >>= withAttribute OtherTok) >>~ pushContext "sqxpath")) -parseRules "string" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "XPath") >>~ pushContext "xpath")- <|>- ((pDetectChar False '"' >>= withAttribute "Attribute Value") >>~ (popContext >> popContext))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "string" =+ (((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "xpath")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "detectEntRef"))) -parseRules "sqstring" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "XPath") >>~ pushContext "sqxpath")- <|>- ((pDetectChar False '\'' >>= withAttribute "Attribute Value") >>~ (popContext >> popContext))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "sqstring" =+ (((pDetectChar False '{' >>= withAttribute OtherTok) >>~ pushContext "sqxpath")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext))+ <|>+ ((parseRules "detectEntRef"))) -parseRules "comment" = - do (attr, result) <- (((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Invalid"))- <|>- ((pRegExpr regex_'28FIXME'7cTODO'7cHACK'29 >>= withAttribute "Alert")))- return (attr, result)+parseRules "comment" =+ (((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok))+ <|>+ ((pRegExpr regex_'28FIXME'7cTODO'7cHACK'29 >>= withAttribute AlertTok))) -parseRules "xpath" = - do (attr, result) <- (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions >>= withAttribute "XPath/ XSLT Function"))- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions'5f2'2e0 >>= withAttribute "XPath 2.0/ XSLT 2.0 Function"))- <|>- ((pRegExpr regex_'28ancestor'7cancestor'2dor'2dself'7cattribute'7cchild'7cdescendant'7cdescendant'2dor'2dself'7cfollowing'7cfollowing'2dsibling'7cnamespace'7cparent'7cpreceding'7cpreceding'2dsibling'7cself'29'3a'3a >>= withAttribute "XPath Axis"))- <|>- ((pDetectChar False '}' >>= withAttribute "XPath") >>~ (popContext))- <|>- ((pDetectChar False '\'' >>= withAttribute "XPath String") >>~ pushContext "sqxpathstring")- <|>- ((pDetectChar False '"' >>= withAttribute "XPath") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'40'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "XPath Attribute"))- <|>- ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "XPath"))- <|>- ((pDetectChar False '$' >>= withAttribute "Invalid"))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "xpath" =+ (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions'5f2'2e0 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28ancestor'7cancestor'2dor'2dself'7cattribute'7cchild'7cdescendant'7cdescendant'2dor'2dself'7cfollowing'7cfollowing'2dsibling'7cnamespace'7cparent'7cpreceding'7cpreceding'2dsibling'7cself'29'3a'3a >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "sqxpathstring")+ <|>+ ((pDetectChar False '"' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'40'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute ErrorTok))+ <|>+ ((parseRules "detectEntRef"))) -parseRules "sqxpath" = - do (attr, result) <- (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions >>= withAttribute "XPath/ XSLT Function"))- <|>- ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions'5f2'2e0 >>= withAttribute "XPath 2.0/ XSLT 2.0 Function"))- <|>- ((pRegExpr regex_'28ancestor'7cancestor'2dor'2dself'7cattribute'7cchild'7cdescendant'7cdescendant'2dor'2dself'7cfollowing'7cfollowing'2dsibling'7cnamespace'7cparent'7cpreceding'7cpreceding'2dsibling'7cself'29'3a'3a >>= withAttribute "XPath Axis"))- <|>- ((pDetectChar False '}' >>= withAttribute "XPath") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "XPath String") >>~ pushContext "xpathstring")- <|>- ((pDetectChar False '\'' >>= withAttribute "XPath") >>~ (popContext >> popContext))- <|>- ((pRegExpr regex_'40'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "XPath Attribute"))- <|>- ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Variable"))- <|>- ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "XPath"))- <|>- ((pDetectChar False '$' >>= withAttribute "Invalid"))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "sqxpath" =+ (((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.()!+,<=>%&*/;?[]^{|}~\\\"{}" list_functions'5f2'2e0 >>= withAttribute KeywordTok))+ <|>+ ((pRegExpr regex_'28ancestor'7cancestor'2dor'2dself'7cattribute'7cchild'7cdescendant'7cdescendant'2dor'2dself'7cfollowing'7cfollowing'2dsibling'7cnamespace'7cparent'7cpreceding'7cpreceding'2dsibling'7cself'29'3a'3a >>= withAttribute KeywordTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "xpathstring")+ <|>+ ((pDetectChar False '\'' >>= withAttribute OtherTok) >>~ (popContext >> popContext))+ <|>+ ((pRegExpr regex_'40'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5c'24'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok))+ <|>+ ((pDetectChar False '$' >>= withAttribute ErrorTok))+ <|>+ ((parseRules "detectEntRef"))) -parseRules "sqxpathstring" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "XPath String") >>~ (popContext))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "sqxpathstring" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "detectEntRef"))) -parseRules "xpathstring" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "XPath String") >>~ (popContext))- <|>- ((parseRules "detectEntRef")))- return (attr, result)+parseRules "xpathstring" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "detectEntRef"))) parseRules "" = parseRules "normalText"
Text/Highlighting/Kate/Syntax/Xul.hs view
@@ -1,16 +1,19 @@-{- This module was generated from data in the Kate syntax highlighting file xul.xml, version 0.11,- by Wilbert Berendsen (wilbert@kde.nl), Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net), Marc Dassonneville (marc.dassonneville@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file xul.xml, version 0.11, by Wilbert Berendsen (wilbert@kde.nl), Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net), Marc Dassonneville (marc.dassonneville@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Xul ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Xul+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Alert-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)-+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set+ -- | Full name of language. syntaxName :: String syntaxName = "XUL"@@ -20,82 +23,69 @@ syntaxExtensions = "*.xul;*.xbl" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "XUL" } context <- currentContext <|> (pushContext "Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("XUL",["Start"])], synStLanguage = "XUL", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("XUL",["Start"])], synStLanguage = "XUL", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Start" -> return () >> pHandleEndLine- "FindXML" -> return () >> pHandleEndLine- "FindEntityRefs" -> return () >> pHandleEndLine- "FindPEntityRefs" -> return () >> pHandleEndLine- "Comment" -> return () >> pHandleEndLine- "PI" -> return () >> pHandleEndLine- "Doctype" -> return () >> pHandleEndLine- "Doctype Internal Subset" -> return () >> pHandleEndLine- "Doctype Markupdecl" -> return () >> pHandleEndLine- "Doctype Markupdecl DQ" -> return () >> pHandleEndLine- "Doctype Markupdecl SQ" -> return () >> pHandleEndLine- "Element" -> return () >> pHandleEndLine- "El Content" -> return () >> pHandleEndLine- "El End" -> return () >> pHandleEndLine- "Attribute" -> return () >> pHandleEndLine- "Value" -> return () >> pHandleEndLine- "Value DQ" -> return () >> pHandleEndLine- "Value SQ" -> return () >> pHandleEndLine- "CDATA" -> return () >> pHandleEndLine+ "Start" -> return ()+ "FindXML" -> return ()+ "FindEntityRefs" -> return ()+ "FindPEntityRefs" -> return ()+ "Comment" -> return ()+ "PI" -> return ()+ "Doctype" -> return ()+ "Doctype Internal Subset" -> return ()+ "Doctype Markupdecl" -> return ()+ "Doctype Markupdecl DQ" -> return ()+ "Doctype Markupdecl SQ" -> return ()+ "Element" -> return ()+ "El Content" -> return ()+ "El End" -> return ()+ "Attribute" -> return ()+ "Value" -> return ()+ "Value DQ" -> return ()+ "Value SQ" -> return ()+ "CDATA" -> return () "String" -> (popContext) >> pEndLine "String 1" -> (popContext) >> pEndLine "JSComment" -> (popContext) >> pEndLine- "Multi/inline Comment" -> return () >> pHandleEndLine- "Regular Expression" -> return () >> pHandleEndLine- "(Internal regex catch)" -> return () >> pHandleEndLine- "Regular Expression Character Class" -> return () >> pHandleEndLine+ "Multi/inline Comment" -> return ()+ "Regular Expression" -> return ()+ "(Internal regex catch)" -> return ()+ "Regular Expression Character Class" -> return () "(regex caret first check)" -> (popContext) >> pEndLine "(charclass caret first check)" -> (popContext) >> pEndLine "region_marker" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("CDATA","bn"),("Processing Instruction","kw"),("Doctype","dt"),("Element","kw"),("Attribute","ot"),("Value","st"),("EntityRef","dv"),("PEntityRef","dv"),("Error","er"),("Keyword","kw"),("Function","fu"),("Objects","kw"),("Math","kw"),("Events","kw"),("Data Type","dt"),("Decimal","dv"),("Float","fl"),("Char","ch"),("String","st"),("String Char","ch"),("Comment","co"),("Regular Expression","ot"),("Pattern Internal Operator","fl"),("Pattern Character Class","bn"),("Region Marker","re")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) list_keywords = Set.fromList $ words $ "if else for in while do continue break with try catch finally switch case new var function return delete true false void throw typeof const default" list_functions = Set.fromList $ words $ "escape isFinite isNaN Number parseFloat parseInt reload taint unescape untaint write"@@ -127,281 +117,252 @@ regex_'2f'2f'28'3f'3d'3b'29 = compileRegex "//(?=;)" regex_'5c'5c'5b'5c'5b'5c'5d'5d = compileRegex "\\\\[\\[\\]]" -defaultAttributes = [("Start","Normal Text"),("FindXML","Normal Text"),("FindEntityRefs","Normal Text"),("FindPEntityRefs","Normal Text"),("Comment","Comment"),("PI","Normal Text"),("Doctype","Normal Text"),("Doctype Internal Subset","Normal Text"),("Doctype Markupdecl","Normal Text"),("Doctype Markupdecl DQ","Value"),("Doctype Markupdecl SQ","Value"),("Element","Normal Text"),("El Content","Normal Text"),("El End","Normal Text"),("Attribute","Normal Text"),("Value","Normal Text"),("Value DQ","Value"),("Value SQ","Value"),("CDATA","Normal Text"),("String","String"),("String 1","String Char"),("JSComment","Comment"),("Multi/inline Comment","Comment"),("Regular Expression","Regular Expression"),("(Internal regex catch)","Normal Text"),("Regular Expression Character Class","Pattern Character Class"),("(regex caret first check)","Pattern Internal Operator"),("(charclass caret first check)","Pattern Internal Operator"),("region_marker","Region Marker")]+defaultAttributes = [("Start",NormalTok),("FindXML",NormalTok),("FindEntityRefs",NormalTok),("FindPEntityRefs",NormalTok),("Comment",CommentTok),("PI",NormalTok),("Doctype",NormalTok),("Doctype Internal Subset",NormalTok),("Doctype Markupdecl",NormalTok),("Doctype Markupdecl DQ",StringTok),("Doctype Markupdecl SQ",StringTok),("Element",NormalTok),("El Content",NormalTok),("El End",NormalTok),("Attribute",NormalTok),("Value",NormalTok),("Value DQ",StringTok),("Value SQ",StringTok),("CDATA",NormalTok),("String",StringTok),("String 1",CharTok),("JSComment",CommentTok),("Multi/inline Comment",CommentTok),("Regular Expression",OtherTok),("(Internal regex catch)",NormalTok),("Regular Expression Character Class",BaseNTok),("(regex caret first check)",FloatTok),("(charclass caret first check)",FloatTok),("region_marker",RegionMarkerTok)] -parseRules "Start" = - do (attr, result) <- ((parseRules "FindXML"))- return (attr, result)+parseRules "Start" =+ ((parseRules "FindXML")) -parseRules "FindXML" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pString False "<![CDATA[" >>= withAttribute "CDATA") >>~ pushContext "CDATA")- <|>- ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute "Doctype") >>~ pushContext "Doctype")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "Element")- <|>- ((parseRules "FindEntityRefs"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text")))- return (attr, result)+parseRules "FindXML" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pString False "<![CDATA[" >>= withAttribute BaseNTok) >>~ pushContext "CDATA")+ <|>+ ((pRegExpr regex_'3c'21DOCTYPE'5cs'2b >>= withAttribute DataTypeTok) >>~ pushContext "Doctype")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((pRegExpr regex_'3c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "Element")+ <|>+ ((parseRules "FindEntityRefs"))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))) -parseRules "FindEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pAnyChar "&<" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&<" >>= withAttribute ErrorTok))) -parseRules "FindPEntityRefs" = - do (attr, result) <- (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute "EntityRef"))- <|>- ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute "PEntityRef"))- <|>- ((pAnyChar "&%" >>= withAttribute "Error")))- return (attr, result)+parseRules "FindPEntityRefs" =+ (((pRegExpr regex_'26'28'23'5b0'2d9'5d'2b'7c'23'5bxX'5d'5b0'2d9A'2dFa'2df'5d'2b'7c'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'29'3b >>= withAttribute DecValTok))+ <|>+ ((pRegExpr regex_'25'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a'3b >>= withAttribute DecValTok))+ <|>+ ((pAnyChar "&%" >>= withAttribute ErrorTok))) -parseRules "Comment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((pString False "-->" >>= withAttribute "Comment") >>~ (popContext))- <|>- ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute "Error"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "Comment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((pString False "-->" >>= withAttribute CommentTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2d'28'2d'28'3f'21'2d'3e'29'29'2b >>= withAttribute ErrorTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "PI" = - do (attr, result) <- ((pDetect2Chars False '?' '>' >>= withAttribute "Processing Instruction") >>~ (popContext))- return (attr, result)+parseRules "PI" =+ ((pDetect2Chars False '?' '>' >>= withAttribute KeywordTok) >>~ (popContext)) -parseRules "Doctype" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '[' >>= withAttribute "Doctype") >>~ pushContext "Doctype Internal Subset"))- return (attr, result)+parseRules "Doctype" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '[' >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Internal Subset")) -parseRules "Doctype Internal Subset" = - do (attr, result) <- (((pDetectChar False ']' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute "Doctype") >>~ pushContext "Doctype Markupdecl")- <|>- ((pString False "<!--" >>= withAttribute "Comment") >>~ pushContext "Comment")- <|>- ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute "Processing Instruction") >>~ pushContext "PI")- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Internal Subset" =+ (((pDetectChar False ']' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'3c'21'28ELEMENT'7cENTITY'7cATTLIST'7cNOTATION'29'5cb >>= withAttribute DataTypeTok) >>~ pushContext "Doctype Markupdecl")+ <|>+ ((pString False "<!--" >>= withAttribute CommentTok) >>~ pushContext "Comment")+ <|>+ ((pRegExpr regex_'3c'5c'3f'5b'5cw'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "PI")+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Doctype") >>~ (popContext))- <|>- ((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Doctype Markupdecl SQ"))- return (attr, result)+parseRules "Doctype Markupdecl" =+ (((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Doctype Markupdecl SQ")) -parseRules "Doctype Markupdecl DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Doctype Markupdecl SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext))- <|>- ((parseRules "FindPEntityRefs")))- return (attr, result)+parseRules "Doctype Markupdecl SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext))+ <|>+ ((parseRules "FindPEntityRefs"))) -parseRules "Element" = - do (attr, result) <- (((pDetect2Chars False '/' '>' >>= withAttribute "Element") >>~ (popContext))- <|>- ((pDetectChar False '>' >>= withAttribute "Element") >>~ pushContext "El Content")- <|>- ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute") >>~ pushContext "Attribute")- <|>- ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Attribute") >>~ pushContext "Attribute")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Element" =+ (((pDetect2Chars False '/' '>' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ pushContext "El Content")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok) >>~ pushContext "Attribute")+ <|>+ ((pRegExpr regex_'5cs'2b'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute OtherTok) >>~ pushContext "Attribute")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "El Content" = - do (attr, result) <- (((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute "Element") >>~ pushContext "El End")- <|>- ((parseRules "FindXML")))- return (attr, result)+parseRules "El Content" =+ (((pRegExpr regex_'3c'2f'5bA'2dZa'2dz'5f'3a'5d'5b'5cw'2e'3a'5f'2d'5d'2a >>= withAttribute KeywordTok) >>~ pushContext "El End")+ <|>+ ((parseRules "FindXML"))) -parseRules "El End" = - do (attr, result) <- (((pDetectChar False '>' >>= withAttribute "Element") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "El End" =+ (((pDetectChar False '>' >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Attribute" = - do (attr, result) <- (((pDetectChar False '=' >>= withAttribute "Attribute") >>~ pushContext "Value")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Attribute" =+ (((pDetectChar False '=' >>= withAttribute OtherTok) >>~ pushContext "Value")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Value" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ pushContext "Value DQ")- <|>- ((pDetectChar False '\'' >>= withAttribute "Value") >>~ pushContext "Value SQ")- <|>- ((pRegExpr regex_'5cS >>= withAttribute "Error")))- return (attr, result)+parseRules "Value" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "Value DQ")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "Value SQ")+ <|>+ ((pRegExpr regex_'5cS >>= withAttribute ErrorTok))) -parseRules "Value DQ" = - do (attr, result) <- (((pDetectChar False '"' >>= withAttribute "Value") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value DQ" =+ (((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "Value SQ" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "Value") >>~ (popContext >> popContext >> popContext))- <|>- ((parseRules "FindEntityRefs")))- return (attr, result)+parseRules "Value SQ" =+ (((pDetectChar False '\'' >>= withAttribute StringTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((parseRules "FindEntityRefs"))) -parseRules "CDATA" = - do (attr, result) <- (((pString False "]]>" >>= withAttribute "CDATA") >>~ (popContext))- <|>- ((pString False "]]>" >>= withAttribute "EntityRef"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pString False "//BEGIN" >>= withAttribute "Region Marker") >>~ pushContext "region_marker")- <|>- ((pString False "//END" >>= withAttribute "Region Marker") >>~ pushContext "region_marker")- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute "Keyword"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute "Function"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_objects >>= withAttribute "Objects"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_math >>= withAttribute "Math"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_events >>= withAttribute "Events"))- <|>- ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_methods >>= withAttribute "Data Type"))- <|>- ((pDetectIdentifier >>= withAttribute "Normal Text"))- <|>- ((pFloat >>= withAttribute "Float"))- <|>- ((pInt >>= withAttribute "Decimal"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "String 1")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "JSComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Multi/inline Comment")- <|>- ((pRegExpr regex_'5b'3d'3f'3a'5d >>= withAttribute "Normal Text") >>~ pushContext "(Internal regex catch)")- <|>- ((pRegExpr regex_'5c'28 >>= withAttribute "Normal Text") >>~ pushContext "(Internal regex catch)")- <|>- ((pDetectChar False '{' >>= withAttribute "Symbol"))- <|>- ((pDetectChar False '}' >>= withAttribute "Symbol"))- <|>- ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute "Symbol")))- return (attr, result)+parseRules "CDATA" =+ (((pString False "]]>" >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((pString False "]]>" >>= withAttribute DecValTok))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pString False "//BEGIN" >>= withAttribute RegionMarkerTok) >>~ pushContext "region_marker")+ <|>+ ((pString False "//END" >>= withAttribute RegionMarkerTok) >>~ pushContext "region_marker")+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_keywords >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_functions >>= withAttribute FunctionTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_objects >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_math >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_events >>= withAttribute KeywordTok))+ <|>+ ((pKeyword " \n\t.():!+,-<=>%&*/;?[]^{|}~\\" list_methods >>= withAttribute DataTypeTok))+ <|>+ ((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pFloat >>= withAttribute FloatTok))+ <|>+ ((pInt >>= withAttribute DecValTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute StringTok) >>~ pushContext "String 1")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "JSComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Multi/inline Comment")+ <|>+ ((pRegExpr regex_'5b'3d'3f'3a'5d >>= withAttribute NormalTok) >>~ pushContext "(Internal regex catch)")+ <|>+ ((pRegExpr regex_'5c'28 >>= withAttribute NormalTok) >>~ pushContext "(Internal regex catch)")+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok))+ <|>+ ((pAnyChar ":!%&+,-/.*<=>?[]|~^;" >>= withAttribute NormalTok))) -parseRules "String" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pHlCStringChar >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pDetectIdentifier >>= withAttribute StringTok))+ <|>+ ((pHlCStringChar >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "String 1" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String Char"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String")- <|>- ((pDetectChar False '\'' >>= withAttribute "String Char") >>~ (popContext)))- return (attr, result)+parseRules "String 1" =+ (((pDetectIdentifier >>= withAttribute CharTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "JSComment" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Comment"))- <|>- ((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetectIdentifier >>= withAttribute "Comment")))- return (attr, result)+parseRules "JSComment" =+ (((pDetectSpaces >>= withAttribute CommentTok))+ <|>+ ((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetectIdentifier >>= withAttribute CommentTok))) -parseRules "Multi/inline Comment" = - do (attr, result) <- (((Text.Highlighting.Kate.Syntax.Alert.parseExpression))- <|>- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext)))- return (attr, result)+parseRules "Multi/inline Comment" =+ (((Text.Highlighting.Kate.Syntax.Alert.parseExpression >>= ((withAttribute CommentTok) . snd)))+ <|>+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext))) -parseRules "Regular Expression" = - do (attr, result) <- (((pRegExpr regex_'2f'5big'5d'7b0'2c2'7d >>= withAttribute "Regular Expression") >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'5c'5bbB'5d >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'5c'5bnrtvfDdSsWw'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pDetectChar False '[' >>= withAttribute "Pattern Character Class") >>~ pushContext "(charclass caret first check)")- <|>- ((pRegExpr regex_'5c'5c'2e >>= withAttribute "Pattern Internal Operator"))- <|>- ((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute "Pattern Internal Operator"))- <|>- ((pAnyChar "?+*()|" >>= withAttribute "Pattern Internal Operator")))- return (attr, result)+parseRules "Regular Expression" =+ (((pRegExpr regex_'2f'5big'5d'7b0'2c2'7d >>= withAttribute OtherTok) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'5c'7b'5b'5cd'2c_'5d'2b'5c'7d >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bbB'5d >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'5c'5bnrtvfDdSsWw'5d >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute BaseNTok) >>~ pushContext "(charclass caret first check)")+ <|>+ ((pRegExpr regex_'5c'5c'2e >>= withAttribute FloatTok))+ <|>+ ((pRegExpr regex_'5c'24'28'3f'3d'2f'29 >>= withAttribute FloatTok))+ <|>+ ((pAnyChar "?+*()|" >>= withAttribute FloatTok))) -parseRules "(Internal regex catch)" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a >>= withAttribute "Normal Text"))- <|>- ((pRegExpr regex_'2f'2f'28'3f'3d'3b'29 >>= withAttribute "Regular Expression") >>~ (popContext))- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "JSComment")- <|>- ((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "Multi/inline Comment")- <|>- ((pDetectChar False '/' >>= withAttribute "Regular Expression") >>~ pushContext "(regex caret first check)")- <|>- ((popContext) >> return ([], "")))- return (attr, result)+parseRules "(Internal regex catch)" =+ (((pRegExpr regex_'5cs'2a >>= withAttribute NormalTok))+ <|>+ ((pRegExpr regex_'2f'2f'28'3f'3d'3b'29 >>= withAttribute OtherTok) >>~ (popContext))+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "JSComment")+ <|>+ ((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "Multi/inline Comment")+ <|>+ ((pDetectChar False '/' >>= withAttribute OtherTok) >>~ pushContext "(regex caret first check)")+ <|>+ ((popContext) >> currentContext >>= parseRules)) -parseRules "Regular Expression Character Class" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'5b'5c'5b'5c'5d'5d >>= withAttribute "Pattern Character Class"))- <|>- ((pDetectChar False ']' >>= withAttribute "Pattern Character Class") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "Regular Expression Character Class" =+ (((pRegExpr regex_'5c'5c'5b'5c'5b'5c'5d'5d >>= withAttribute BaseNTok))+ <|>+ ((pDetectChar False ']' >>= withAttribute BaseNTok) >>~ (popContext >> popContext))) -parseRules "(regex caret first check)" = - do (attr, result) <- (((pDetectChar False '^' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "Regular Expression")- <|>- (pushContext "Regular Expression" >> return ([], "")))- return (attr, result)+parseRules "(regex caret first check)" =+ (((pDetectChar False '^' >>= withAttribute FloatTok) >>~ pushContext "Regular Expression")+ <|>+ (pushContext "Regular Expression" >> currentContext >>= parseRules)) -parseRules "(charclass caret first check)" = - do (attr, result) <- (((pDetectChar False '^' >>= withAttribute "Pattern Internal Operator") >>~ pushContext "Regular Expression Character Class")- <|>- (pushContext "Regular Expression Character Class" >> return ([], "")))- return (attr, result)+parseRules "(charclass caret first check)" =+ (((pDetectChar False '^' >>= withAttribute FloatTok) >>~ pushContext "Regular Expression Character Class")+ <|>+ (pushContext "Regular Expression Character Class" >> currentContext >>= parseRules)) -parseRules "region_marker" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "Region Marker"))- <|>- ((pDetectSpaces >>= withAttribute "Region Marker")))- return (attr, result)+parseRules "region_marker" =+ (((pDetectIdentifier >>= withAttribute RegionMarkerTok))+ <|>+ ((pDetectSpaces >>= withAttribute RegionMarkerTok))) parseRules "" = parseRules "Start"
Text/Highlighting/Kate/Syntax/Yacc.hs view
@@ -1,14 +1,17 @@-{- This module was generated from data in the Kate syntax highlighting file yacc.xml, version 1.03,- by Jan Villat (jan.villat@net2000.ch) -}+{- This module was generated from data in the Kate syntax+ highlighting file yacc.xml, version 1.03, by Jan Villat (jan.villat@net2000.ch) -} -module Text.Highlighting.Kate.Syntax.Yacc ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Yacc+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common import qualified Text.Highlighting.Kate.Syntax.Cpp-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -19,74 +22,61 @@ syntaxExtensions = "*.y;*.yy" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "Yacc/Bison" } context <- currentContext <|> (pushContext "Pre Start" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("Yacc/Bison",["Pre Start"])], synStLanguage = "Yacc/Bison", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("Yacc/Bison",["Pre Start"])], synStLanguage = "Yacc/Bison", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "Pre Start" -> return () >> pHandleEndLine- "C Declarations" -> return () >> pHandleEndLine- "Declarations" -> return () >> pHandleEndLine- "Union Start" -> return () >> pHandleEndLine- "Union In" -> return () >> pHandleEndLine- "Union InIn" -> return () >> pHandleEndLine- "Rules" -> return () >> pHandleEndLine- "Rule In" -> return () >> pHandleEndLine- "User Code" -> return () >> pHandleEndLine+ "Pre Start" -> return ()+ "C Declarations" -> return ()+ "Declarations" -> return ()+ "Union Start" -> return ()+ "Union In" -> return ()+ "Union InIn" -> return ()+ "Rules" -> return ()+ "Rule In" -> return ()+ "User Code" -> return () "Percent Command" -> (popContext) >> pEndLine "Percent Command In" -> (popContext >> popContext) >> pEndLine "PC type" -> (popContext >> popContext >> popContext) >> pEndLine- "Comment" -> return () >> pHandleEndLine- "CommentStar" -> return () >> pHandleEndLine- "CommentSlash" -> return () >> pHandleEndLine- "StringOrChar" -> return () >> pHandleEndLine+ "Comment" -> return ()+ "CommentStar" -> return ()+ "CommentSlash" -> return ()+ "StringOrChar" -> return () "String" -> (popContext) >> pEndLine "Char" -> (popContext) >> pEndLine- "Normal C Bloc" -> return () >> pHandleEndLine- "Dol" -> return () >> pHandleEndLine- "DolEnd" -> return () >> pHandleEndLine- _ -> pHandleEndLine+ "Normal C Bloc" -> return ()+ "Dol" -> return ()+ "DolEnd" -> return ()+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("Content-Type Delimiter","bn"),("Directive","kw"),("Rule","st"),("Backslash Code","st"),("Alert","al"),("String","st"),("String Char","ch"),("Data Type","dt")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'2e = compileRegex "."@@ -96,157 +86,136 @@ regex_'3c'5b'5e'3e'5d'2b'3e = compileRegex "<[^>]+>" regex_'5cd'2b = compileRegex "\\d+" -defaultAttributes = [("Pre Start","Normal Text"),("C Declarations","Normal Text"),("Declarations","Normal Text"),("Union Start","Normal Text"),("Union In","Normal Text"),("Union InIn","Normal Text"),("Rules","Rule"),("Rule In","Definition"),("User Code","Normal Text"),("Percent Command","Directive"),("Percent Command In","NormalText"),("PC type","Data Type"),("Comment","Comment"),("CommentStar","Comment"),("CommentSlash","Comment"),("StringOrChar","NormalText"),("String","String"),("Char","String Char"),("Normal C Bloc","Normal Text"),("Dol","Normal Text"),("DolEnd","Normal Text")]+defaultAttributes = [("Pre Start",NormalTok),("C Declarations",NormalTok),("Declarations",NormalTok),("Union Start",NormalTok),("Union In",NormalTok),("Union InIn",NormalTok),("Rules",StringTok),("Rule In",NormalTok),("User Code",NormalTok),("Percent Command",KeywordTok),("Percent Command In",NormalTok),("PC type",DataTypeTok),("Comment",CommentTok),("CommentStar",CommentTok),("CommentSlash",CommentTok),("StringOrChar",NormalTok),("String",StringTok),("Char",CharTok),("Normal C Bloc",NormalTok),("Dol",NormalTok),("DolEnd",NormalTok)] -parseRules "Pre Start" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "C Declarations")- <|>- ((lookAhead (pRegExpr regex_'2e) >> return ([],"") ) >>~ pushContext "Declarations"))- return (attr, result)+parseRules "Pre Start" =+ (((parseRules "Comment"))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute BaseNTok) >>~ pushContext "C Declarations")+ <|>+ ((lookAhead (pRegExpr regex_'2e) >> return (NormalTok,"") ) >>~ pushContext "Declarations")) -parseRules "C Declarations" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pColumn 0 >> pDetect2Chars False '%' '}' >>= withAttribute "Content-Type Delimiter") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "C Declarations" =+ (((parseRules "Comment"))+ <|>+ ((pColumn 0 >> pDetect2Chars False '%' '}' >>= withAttribute BaseNTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Declarations" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pString False "%union" >>= withAttribute "Directive") >>~ pushContext "Union Start")- <|>- ((pDetect2Chars False '%' '%' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "Rules")- <|>- ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "C Declarations")- <|>- ((pDetectChar False '%' >>= withAttribute "Directive") >>~ pushContext "Percent Command"))- return (attr, result)+parseRules "Declarations" =+ (((parseRules "Comment"))+ <|>+ ((pString False "%union" >>= withAttribute KeywordTok) >>~ pushContext "Union Start")+ <|>+ ((pDetect2Chars False '%' '%' >>= withAttribute BaseNTok) >>~ pushContext "Rules")+ <|>+ ((pColumn 0 >> pDetect2Chars False '%' '{' >>= withAttribute BaseNTok) >>~ pushContext "C Declarations")+ <|>+ ((pDetectChar False '%' >>= withAttribute KeywordTok) >>~ pushContext "Percent Command")) -parseRules "Union Start" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Union In")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Alert") >>~ (popContext)))- return (attr, result)+parseRules "Union Start" =+ (((parseRules "Comment"))+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Union In")+ <|>+ ((pRegExpr regex_'2e >>= withAttribute AlertTok) >>~ (popContext))) -parseRules "Union In" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Union InIn")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext >> popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Union In" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Union InIn")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext >> popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Union InIn" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Union InIn")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)))- return (attr, result)+parseRules "Union InIn" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Union InIn")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))) -parseRules "Rules" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pDetect2Chars False '%' '%' >>= withAttribute "Content-Type Delimiter") >>~ pushContext "User Code")- <|>- ((pDetectChar False ':' >>= withAttribute "Normal Text") >>~ pushContext "Rule In"))- return (attr, result)+parseRules "Rules" =+ (((parseRules "Comment"))+ <|>+ ((pDetect2Chars False '%' '%' >>= withAttribute BaseNTok) >>~ pushContext "User Code")+ <|>+ ((pDetectChar False ':' >>= withAttribute NormalTok) >>~ pushContext "Rule In")) -parseRules "Rule In" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((pDetectChar False ';' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Normal C Bloc")- <|>- ((pDetectChar False '|' >>= withAttribute "Normal Text"))- <|>- ((parseRules "StringOrChar")))- return (attr, result)+parseRules "Rule In" =+ (((parseRules "Comment"))+ <|>+ ((pDetectChar False ';' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Normal C Bloc")+ <|>+ ((pDetectChar False '|' >>= withAttribute NormalTok))+ <|>+ ((parseRules "StringOrChar"))) -parseRules "User Code" = - do (attr, result) <- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))- return (attr, result)+parseRules "User Code" =+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression)) -parseRules "Percent Command" = - do (attr, result) <- (((parseRules "Comment"))- <|>- ((lookAhead (pRegExpr regex_'5cW) >> return ([],"") ) >>~ pushContext "Percent Command In"))- return (attr, result)+parseRules "Percent Command" =+ (((parseRules "Comment"))+ <|>+ ((lookAhead (pRegExpr regex_'5cW) >> return (NormalTok,"") ) >>~ pushContext "Percent Command In")) -parseRules "Percent Command In" = - do (attr, result) <- (((parseRules "StringOrChar"))- <|>- ((pDetectChar False '<' >>= withAttribute "Data Type") >>~ pushContext "PC type"))- return (attr, result)+parseRules "Percent Command In" =+ (((parseRules "StringOrChar"))+ <|>+ ((pDetectChar False '<' >>= withAttribute DataTypeTok) >>~ pushContext "PC type")) -parseRules "PC type" = - do (attr, result) <- ((pDetectChar False '>' >>= withAttribute "Data Type") >>~ (popContext))- return (attr, result)+parseRules "PC type" =+ ((pDetectChar False '>' >>= withAttribute DataTypeTok) >>~ (popContext)) -parseRules "Comment" = - do (attr, result) <- (((pDetect2Chars False '/' '*' >>= withAttribute "Comment") >>~ pushContext "CommentStar")- <|>- ((pDetect2Chars False '/' '/' >>= withAttribute "Comment") >>~ pushContext "CommentSlash"))- return (attr, result)+parseRules "Comment" =+ (((pDetect2Chars False '/' '*' >>= withAttribute CommentTok) >>~ pushContext "CommentStar")+ <|>+ ((pDetect2Chars False '/' '/' >>= withAttribute CommentTok) >>~ pushContext "CommentSlash")) -parseRules "CommentStar" = - do (attr, result) <- ((pDetect2Chars False '*' '/' >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "CommentStar" =+ ((pDetect2Chars False '*' '/' >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "CommentSlash" = - do (attr, result) <- ((pRegExpr regex_'5b'5e'5c'5c'5d'24 >>= withAttribute "Comment") >>~ (popContext))- return (attr, result)+parseRules "CommentSlash" =+ ((pRegExpr regex_'5b'5e'5c'5c'5d'24 >>= withAttribute CommentTok) >>~ (popContext)) -parseRules "StringOrChar" = - do (attr, result) <- (((pDetectChar False '\'' >>= withAttribute "String Char") >>~ pushContext "Char")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "String"))- return (attr, result)+parseRules "StringOrChar" =+ (((pDetectChar False '\'' >>= withAttribute CharTok) >>~ pushContext "Char")+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ pushContext "String")) -parseRules "String" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "String" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute StringTok) >>~ (popContext))) -parseRules "Char" = - do (attr, result) <- (((pRegExpr regex_'5c'5c'2e >>= withAttribute "Backslash Code"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String Char") >>~ (popContext)))- return (attr, result)+parseRules "Char" =+ (((pRegExpr regex_'5c'5c'2e >>= withAttribute StringTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute CharTok) >>~ (popContext))) -parseRules "Normal C Bloc" = - do (attr, result) <- (((pDetectChar False '{' >>= withAttribute "Normal Text") >>~ pushContext "Normal C Bloc")- <|>- ((pDetectChar False '}' >>= withAttribute "Normal Text") >>~ (popContext))- <|>- ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))- <|>- ((pDetectChar False '$' >>= withAttribute "Directive") >>~ pushContext "Dol"))- return (attr, result)+parseRules "Normal C Bloc" =+ (((pDetectChar False '{' >>= withAttribute NormalTok) >>~ pushContext "Normal C Bloc")+ <|>+ ((pDetectChar False '}' >>= withAttribute NormalTok) >>~ (popContext))+ <|>+ ((Text.Highlighting.Kate.Syntax.Cpp.parseExpression))+ <|>+ ((pDetectChar False '$' >>= withAttribute KeywordTok) >>~ pushContext "Dol")) -parseRules "Dol" = - do (attr, result) <- (((pRegExpr regex_'3c'5b'5e'3e'5d'2b'3e >>= withAttribute "Data Type") >>~ pushContext "DolEnd")- <|>- (pushContext "DolEnd" >> return ([], "")))- return (attr, result)+parseRules "Dol" =+ (((pRegExpr regex_'3c'5b'5e'3e'5d'2b'3e >>= withAttribute DataTypeTok) >>~ pushContext "DolEnd")+ <|>+ (pushContext "DolEnd" >> currentContext >>= parseRules)) -parseRules "DolEnd" = - do (attr, result) <- (((pRegExpr regex_'5cd'2b >>= withAttribute "Directive") >>~ (popContext >> popContext))- <|>- ((pDetectChar False '$' >>= withAttribute "Directive") >>~ (popContext >> popContext)))- return (attr, result)+parseRules "DolEnd" =+ (((pRegExpr regex_'5cd'2b >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '$' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))) parseRules "" = parseRules "Pre Start"
Text/Highlighting/Kate/Syntax/Yaml.hs view
@@ -1,13 +1,16 @@-{- This module was generated from data in the Kate syntax highlighting file yaml.xml, version 1.1,- by Dr Orlovsky MA (dr.orlovsky@gmail.com) -}+{- This module was generated from data in the Kate syntax+ highlighting file yaml.xml, version 1.1, by Dr Orlovsky MA (dr.orlovsky@gmail.com) -} -module Text.Highlighting.Kate.Syntax.Yaml ( highlight, parseExpression, syntaxName, syntaxExtensions ) where-import Text.Highlighting.Kate.Definitions+module Text.Highlighting.Kate.Syntax.Yaml+ (highlight, parseExpression, syntaxName, syntaxExtensions)+where+import Text.Highlighting.Kate.Types import Text.Highlighting.Kate.Common-import Text.ParserCombinators.Parsec-import Control.Monad (when)+import Text.ParserCombinators.Parsec hiding (State) import Data.Map (fromList)-import Data.Maybe (fromMaybe, maybeToList)+import Control.Monad.State+import Data.Char (isSpace)+import Data.Maybe (fromMaybe) -- | Full name of language. syntaxName :: String@@ -18,73 +21,60 @@ syntaxExtensions = "*.yaml;*.yml" -- | 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+highlight :: String -> [SourceLine]+highlight input = evalState (mapM parseSourceLine $ lines input) startingState +parseSourceLine :: String -> State SyntaxState SourceLine+parseSourceLine = mkParseSourceLine parseExpressionInternal pEndLine+ -- | Parse an expression using appropriate local context.-parseExpression :: GenParser Char SyntaxState LabeledSource+parseExpression :: KateParser Token parseExpression = do st <- getState let oldLang = synStLanguage st setState $ st { synStLanguage = "YAML" } context <- currentContext <|> (pushContext "normal" >> currentContext) result <- parseRules context+ optional $ eof >> pEndLine 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 [("YAML",["normal"])], synStLanguage = "YAML", synStCurrentLine = "", synStCharsParsedInLine = 0, synStPrevChar = '\n', synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []}--parseSourceLine = manyTill parseExpressionInternal pEndLine+startingState = SyntaxState {synStContexts = fromList [("YAML",["normal"])], synStLanguage = "YAML", synStLineNumber = 0, synStPrevChar = '\n', synStPrevNonspace = False, synStCaseSensitive = True, synStKeywordCaseSensitive = True, synStCaptures = []} pEndLine = do- lookAhead $ newline <|> (eof >> return '\n') context <- currentContext case context of- "normal" -> return () >> pHandleEndLine+ "normal" -> return () "dash" -> (popContext) >> pEndLine "header" -> (popContext) >> pEndLine- "EOD" -> return () >> pHandleEndLine+ "EOD" -> return () "directive" -> (popContext) >> pEndLine "attribute" -> (popContext >> popContext) >> pEndLine- "attribute-inline" -> return () >> pHandleEndLine+ "attribute-inline" -> return () "attribute-pre" -> (popContext) >> pEndLine "attribute-pre-inline" -> (popContext) >> pEndLine- "list" -> return () >> pHandleEndLine- "hash" -> return () >> pHandleEndLine- "attribute-string" -> return () >> pHandleEndLine- "attribute-stringx" -> return () >> pHandleEndLine- "attribute-string-inline" -> return () >> pHandleEndLine- "attribute-stringx-inline" -> return () >> pHandleEndLine+ "list" -> return ()+ "hash" -> return ()+ "attribute-string" -> return ()+ "attribute-stringx" -> return ()+ "attribute-string-inline" -> return ()+ "attribute-stringx-inline" -> return () "attribute-end" -> (popContext >> popContext >> popContext) >> pEndLine "attribute-end-inline" -> (popContext >> popContext >> popContext) >> pEndLine- "string" -> return () >> pHandleEndLine- "stringx" -> return () >> pHandleEndLine+ "string" -> return ()+ "stringx" -> return () "comment" -> (popContext) >> pEndLine- _ -> pHandleEndLine+ _ -> return () withAttribute attr txt = do when (null txt) $ fail "Parser matched no text"- let labs = attr : maybeToList (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 (labs, txt)--styles = [("Comment","co"),("End of Document","co"),("Document Header","ot"),("Data Types","dt"),("Alias","dt"),("Reference","dt"),("Key","fu"),("Directive","ot"),("Operator","kw"),("Error","er")]+ updateState $ \st -> st { synStPrevChar = last txt+ , synStPrevNonspace = synStPrevNonspace st || not (all isSpace txt) }+ return (attr, txt) parseExpressionInternal = do context <- currentContext- parseRules context <|> (pDefault >>= withAttribute (fromMaybe "" $ lookup context defaultAttributes))+ parseRules context <|> (pDefault >>= withAttribute (fromMaybe NormalTok $ lookup context defaultAttributes)) regex_'2d'2d'2d = compileRegex "---"@@ -101,226 +91,210 @@ regex_'5cs'2a = compileRegex "\\s*" regex_'2c'5cs = compileRegex ",\\s" -defaultAttributes = [("normal","Normal Text"),("dash","List"),("header","Document Header"),("EOD","End of Document"),("directive","Directive"),("attribute","Attribute"),("attribute-inline","Attribute"),("attribute-pre","Attribute"),("attribute-pre-inline","Attribute"),("list","List"),("hash","Hash"),("attribute-string","String"),("attribute-stringx","String"),("attribute-string-inline","String"),("attribute-stringx-inline","String"),("attribute-end","Error"),("attribute-end-inline","Error"),("string","String"),("stringx","String"),("comment","Comment")]+defaultAttributes = [("normal",NormalTok),("dash",NormalTok),("header",OtherTok),("EOD",CommentTok),("directive",OtherTok),("attribute",NormalTok),("attribute-inline",NormalTok),("attribute-pre",NormalTok),("attribute-pre-inline",NormalTok),("list",NormalTok),("hash",NormalTok),("attribute-string",NormalTok),("attribute-stringx",NormalTok),("attribute-string-inline",NormalTok),("attribute-stringx-inline",NormalTok),("attribute-end",ErrorTok),("attribute-end-inline",ErrorTok),("string",NormalTok),("stringx",NormalTok),("comment",CommentTok)] -parseRules "normal" = - do (attr, result) <- (((pColumn 0 >> pRegExpr regex_'2d'2d'2d >>= withAttribute "Document Header") >>~ pushContext "header")- <|>- ((pColumn 0 >> pRegExpr regex_'5c'2e'5c'2e'5c'2e'24 >>= withAttribute "End of Document") >>~ pushContext "EOD")- <|>- ((pColumn 0 >> pRegExpr regex_'25 >>= withAttribute "Directive") >>~ pushContext "directive")- <|>- ((pDetectSpaces >>= withAttribute "Normal Text"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pFirstNonSpace >> pDetectChar False '-' >>= withAttribute "Operator") >>~ pushContext "dash")- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "list")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "hash")- <|>- ((pFirstNonSpace >> pRegExpr regex_'21'21'5cS'2b >>= withAttribute "Data Types"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'26'5cS'2b >>= withAttribute "Alias"))- <|>- ((pFirstNonSpace >> pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute "Reference"))- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "stringx"))- return (attr, result)+parseRules "normal" =+ (((pColumn 0 >> pRegExpr regex_'2d'2d'2d >>= withAttribute OtherTok) >>~ pushContext "header")+ <|>+ ((pColumn 0 >> pRegExpr regex_'5c'2e'5c'2e'5c'2e'24 >>= withAttribute CommentTok) >>~ pushContext "EOD")+ <|>+ ((pColumn 0 >> pRegExpr regex_'25 >>= withAttribute OtherTok) >>~ pushContext "directive")+ <|>+ ((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pFirstNonSpace >> pDetectChar False '-' >>= withAttribute KeywordTok) >>~ pushContext "dash")+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "list")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "hash")+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'21'21'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'26'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pFirstNonSpace >> pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "stringx")) -parseRules "dash" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "List"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pRegExpr regex_null'24 >>= withAttribute "Data Types"))- <|>- ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute "Data Types"))- <|>- ((pRegExpr regex_'26'5cS'2b >>= withAttribute "Alias"))- <|>- ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute "Reference"))- <|>- ((lookAhead (pRegExpr regex_'2e) >> return ([],"") ) >>~ (popContext)))- return (attr, result)+parseRules "dash" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pRegExpr regex_null'24 >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'26'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((lookAhead (pRegExpr regex_'2e) >> return (NormalTok,"") ) >>~ (popContext))) -parseRules "header" = - do (attr, result) <- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- return (attr, result)+parseRules "header" =+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment") -parseRules "EOD" = +parseRules "EOD" = pzero -parseRules "directive" = +parseRules "directive" = pzero -parseRules "attribute" = - do (attr, result) <- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- return (attr, result)+parseRules "attribute" =+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment") -parseRules "attribute-inline" = - do (attr, result) <- (((pDetectChar False ',' >>= withAttribute "Operator") >>~ (popContext >> popContext))- <|>- ((lookAhead (pDetectChar False '}') >> return ([],"") ) >>~ (popContext >> popContext))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment"))- return (attr, result)+parseRules "attribute-inline" =+ (((pDetectChar False ',' >>= withAttribute KeywordTok) >>~ (popContext >> popContext))+ <|>+ ((lookAhead (pDetectChar False '}') >> return (NormalTok,"") ) >>~ (popContext >> popContext))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")) -parseRules "attribute-pre" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Attribute"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pRegExpr regex_null'24 >>= withAttribute "Data Types"))- <|>- ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute "Data Types"))- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "list")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "hash")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "attribute-string")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "attribute-stringx")- <|>- ((pRegExpr regex_'26'5cS'2b >>= withAttribute "Alias") >>~ pushContext "attribute")- <|>- ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute "Reference") >>~ pushContext "attribute")- <|>- ((pRegExpr regex_'2e >>= withAttribute "Attribute") >>~ pushContext "attribute"))- return (attr, result)+parseRules "attribute-pre" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pRegExpr regex_null'24 >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "list")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "hash")+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "attribute-string")+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "attribute-stringx")+ <|>+ ((pRegExpr regex_'26'5cS'2b >>= withAttribute DataTypeTok) >>~ pushContext "attribute")+ <|>+ ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute DataTypeTok) >>~ pushContext "attribute")+ <|>+ ((pRegExpr regex_'2e >>= withAttribute NormalTok) >>~ pushContext "attribute")) -parseRules "attribute-pre-inline" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Attribute"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pString False "null" >>= withAttribute "Data Types"))- <|>- ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute "Data Types"))- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "list")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "hash")- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "attribute-string-inline")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "attribute-stringx-inline")- <|>- ((pRegExpr regex_'26'5cS'2b >>= withAttribute "Alias") >>~ pushContext "attribute-inline")- <|>- ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute "Reference") >>~ pushContext "attribute-inline")- <|>- ((pDetectChar False ',' >>= withAttribute "Operator") >>~ (popContext))- <|>- ((lookAhead (pDetectChar False '}') >> return ([],"") ) >>~ (popContext))- <|>- ((pRegExpr regex_'2e >>= withAttribute "Attribute") >>~ pushContext "attribute-inline"))- return (attr, result)+parseRules "attribute-pre-inline" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pString False "null" >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "list")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "hash")+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "attribute-string-inline")+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "attribute-stringx-inline")+ <|>+ ((pRegExpr regex_'26'5cS'2b >>= withAttribute DataTypeTok) >>~ pushContext "attribute-inline")+ <|>+ ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute DataTypeTok) >>~ pushContext "attribute-inline")+ <|>+ ((pDetectChar False ',' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((lookAhead (pDetectChar False '}') >> return (NormalTok,"") ) >>~ (popContext))+ <|>+ ((pRegExpr regex_'2e >>= withAttribute NormalTok) >>~ pushContext "attribute-inline")) -parseRules "list" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "List"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pDetectChar False ']' >>= withAttribute "Operator") >>~ (popContext))- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre")- <|>- ((pString False "null" >>= withAttribute "Data Types"))- <|>- ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute "Data Types"))- <|>- ((pDetectChar False '[' >>= withAttribute "Operator") >>~ pushContext "list")- <|>- ((pDetectChar False '{' >>= withAttribute "Operator") >>~ pushContext "hash")- <|>- ((pRegExpr regex_'26'5cS'2b >>= withAttribute "Alias"))- <|>- ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute "Reference"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "string")- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "stringx")- <|>- ((pDetectChar False ',' >>= withAttribute "Operator")))- return (attr, result)+parseRules "list" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pDetectChar False ']' >>= withAttribute KeywordTok) >>~ (popContext))+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre")+ <|>+ ((pString False "null" >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'21'21'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '[' >>= withAttribute KeywordTok) >>~ pushContext "list")+ <|>+ ((pDetectChar False '{' >>= withAttribute KeywordTok) >>~ pushContext "hash")+ <|>+ ((pRegExpr regex_'26'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pRegExpr regex_'5c'2a'5cS'2b >>= withAttribute DataTypeTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "string")+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "stringx")+ <|>+ ((pDetectChar False ',' >>= withAttribute KeywordTok))) -parseRules "hash" = - do (attr, result) <- (((pDetectSpaces >>= withAttribute "Hash"))- <|>- ((pDetectChar False '#' >>= withAttribute "Comment") >>~ pushContext "comment")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre-inline")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre-inline")- <|>- ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute "Key") >>~ pushContext "attribute-pre-inline")- <|>- ((pDetectChar False '}' >>= withAttribute "Operator") >>~ (popContext)))- return (attr, result)+parseRules "hash" =+ (((pDetectSpaces >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '#' >>= withAttribute CommentTok) >>~ pushContext "comment")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'5b'5e'22'27'23'2d'5d'5b'5e'3a'23'5d'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre-inline")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'22'5b'5e'22'23'5d'2b'22'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre-inline")+ <|>+ ((pRegExpr regex_'5c'3f'3f'5cs'2a'27'5b'5e'27'23'5d'2b'27'5cs'2a'3a >>= withAttribute FunctionTok) >>~ pushContext "attribute-pre-inline")+ <|>+ ((pDetectChar False '}' >>= withAttribute KeywordTok) >>~ (popContext))) -parseRules "attribute-string" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "attribute-end"))- return (attr, result)+parseRules "attribute-string" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "attribute-end")) -parseRules "attribute-stringx" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "attribute-end"))- return (attr, result)+parseRules "attribute-stringx" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "attribute-end")) -parseRules "attribute-string-inline" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ pushContext "attribute-end-inline"))- return (attr, result)+parseRules "attribute-string-inline" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ pushContext "attribute-end-inline")) -parseRules "attribute-stringx-inline" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ pushContext "attribute-end-inline"))- return (attr, result)+parseRules "attribute-stringx-inline" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ pushContext "attribute-end-inline")) -parseRules "attribute-end" = +parseRules "attribute-end" = pzero -parseRules "attribute-end-inline" = - do (attr, result) <- (((pRegExpr regex_'5cs'2a >>= withAttribute "Normal Text"))- <|>- ((lookAhead (pDetectChar False '}') >> return ([],"") ) >>~ (popContext >> popContext >> popContext))- <|>- ((pRegExpr regex_'2c'5cs >>= withAttribute "Operator") >>~ (popContext >> popContext >> popContext)))- return (attr, result)+parseRules "attribute-end-inline" =+ (((pRegExpr regex_'5cs'2a >>= withAttribute NormalTok))+ <|>+ ((lookAhead (pDetectChar False '}') >> return (NormalTok,"") ) >>~ (popContext >> popContext >> popContext))+ <|>+ ((pRegExpr regex_'2c'5cs >>= withAttribute KeywordTok) >>~ (popContext >> popContext >> popContext))) -parseRules "string" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '\'' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "string" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '\'' >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "stringx" = - do (attr, result) <- (((pDetectIdentifier >>= withAttribute "String"))- <|>- ((pDetectChar False '"' >>= withAttribute "String") >>~ (popContext)))- return (attr, result)+parseRules "stringx" =+ (((pDetectIdentifier >>= withAttribute NormalTok))+ <|>+ ((pDetectChar False '"' >>= withAttribute NormalTok) >>~ (popContext))) -parseRules "comment" = +parseRules "comment" = pzero parseRules "" = parseRules "normal"
+ Text/Highlighting/Kate/Types.hs view
@@ -0,0 +1,137 @@+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}+{- |+ Module : Text.Highlighting.Kate.Types+ Copyright : Copyright (C) 2008 John MacFarlane+ License : GNU GPL, version 2 or above ++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha + Portability : portable++Definitions for data structures needed by highlighting-kate.+-}++module Text.Highlighting.Kate.Types where+import qualified Data.Map as Map+import Text.ParserCombinators.Parsec+import Data.Word+import Text.Printf++-- | A stack of context names for each language. (Language-specific context+-- stacks must be maintained because of IncludeRules.)+type ContextStack = Map.Map String [String]++-- | State for syntax parser.+data SyntaxState = SyntaxState+ { synStContexts :: ContextStack -- ^ Stack of contexts+ , synStLanguage :: String -- ^ Language being parsed+ , synStLineNumber :: Int -- ^ Number of current line+ , synStPrevChar :: Char -- ^ Last character parsed+ , synStPrevNonspace :: Bool -- ^ True if we've parsed a nonspace+ , synStCaseSensitive :: Bool -- ^ Language is case-sensitive+ , synStKeywordCaseSensitive :: Bool -- ^ Keywords are case-sensitive+ , synStCaptures :: [String] -- ^ List of regex captures from+ -- last capturing match+ } deriving (Read, Show)++-- | A pair consisting of a list of attributes and some text.+type Token = (TokenType, String)++data TokenType = KeywordTok+ | DataTypeTok+ | DecValTok+ | BaseNTok+ | FloatTok+ | CharTok+ | StringTok+ | CommentTok+ | OtherTok+ | AlertTok+ | FunctionTok+ | RegionMarkerTok+ | ErrorTok+ | NormalTok+ deriving (Read, Show, Eq, Enum)++-- | A line of source, list of labeled source items.+type SourceLine = [Token]++type KateParser = GenParser Char SyntaxState++data TokenStyle = TokenStyle {+ tokenColor :: Maybe Color+ , tokenBackground :: Maybe Color+ , tokenBold :: Bool+ , tokenItalic :: Bool+ , tokenUnderline :: Bool+ } deriving (Show, Read)++defStyle :: TokenStyle+defStyle = TokenStyle {+ tokenColor = Nothing+ , tokenBackground = Nothing+ , tokenBold = False+ , tokenItalic = False+ , tokenUnderline = False+ }++data Color = RGB Word8 Word8 Word8 deriving (Show, Read)++class ToColor a where+ toColor :: a -> Maybe Color++instance ToColor String where+ toColor ['#',r1,r2,g1,g2,b1,b2] =+ case reads ['(','0','x',r1,r2,',','0','x',g1,g2,',','0','x',b1,b2,')'] of+ ((r,g,b),_) : _ -> Just $ RGB r g b+ _ -> Nothing+ toColor _ = Nothing++instance ToColor (Word8, Word8, Word8) where+ toColor (r,g,b) = Just $ RGB r g b++instance ToColor (Double, Double, Double) where+ toColor (r,g,b) | r >= 0 && g >= 0 && b >= 0 && r <= 1 && g <= 1 && b <= 1 =+ Just $ RGB (floor $ r * 255) (floor $ g * 255) (floor $ b * 255)+ toColor _ = Nothing++class FromColor a where+ fromColor :: Color -> a++instance FromColor String where+ fromColor (RGB r g b) = printf "#%02x%02x%02x" r g b++instance FromColor (Double, Double, Double) where+ fromColor (RGB r g b) = (fromIntegral r / 255, fromIntegral g / 255, fromIntegral b / 255)++instance FromColor (Word8, Word8, Word8) where+ fromColor (RGB r g b) = (r, g, b)++data Style = Style {+ tokenStyles :: [(TokenType, TokenStyle)]+ , defaultColor :: Maybe Color+ , backgroundColor :: Maybe Color+ , lineNumberColor :: Maybe Color+ , lineNumberBackgroundColor :: Maybe Color+ } deriving (Read, Show)++-- | Options for formatting source code.+data FormatOptions = FormatOptions{+ numberLines :: Bool -- ^ Number lines+ , startNumber :: Int -- ^ Number of first line+ , lineAnchors :: Bool -- ^ Anchors on each line number+ , titleAttributes :: Bool -- ^ Html titles with token types+ , codeClasses :: [String] -- ^ Additional classes for Html code tag+ , containerClasses :: [String] -- ^ Additional classes for Html container tag+ -- (pre or table depending on numberLines)+ } deriving (Eq, Show, Read)++defaultFormatOpts :: FormatOptions+defaultFormatOpts = FormatOptions{+ numberLines = False+ , startNumber = 1+ , lineAnchors = False+ , titleAttributes = False+ , codeClasses = []+ , containerClasses = []+ }
changelog view
@@ -1,3 +1,95 @@+highlighting-kate 0.4 (21 Jan 2012)++ * Text.Highlighting.Kate.Definitions has been renamed as+ Text.Highlighting.Kate.Types.++ * Text.Highlighting.Kate.Format was replaced by two modules,+ Text.Highlighting.Format.HTML and Text.Highlighting.Format.LaTeX.++ * Text.Highlighting.Kate no longer exports functions from Style or+ Format.++ * highlightAs now lazily consumes lines and returns a list+ of SourceLine. Previously, the entire input had to be+ parsed before any output was produced. The output type+ is no longer an Either; if a parsing error occurs, the+ offending line is highlighted as ErrorTok, and we continue+ with the next line without change of state.+ If you call highlightAs with a language that isn't supported,+ all lines will be highlighted as NormalTok.++ * Monadic 'fail' now used instead of 'error'. Closes Issue #10.+ Thanks to mcmaniac for suggesting these changes.++ * TokenType is used instead of String for token types.++ * Completely changed Formatting API.++ + Instead of formatAsHtml, we now have four functions:+ formatHtmlInline, formatHtmlBlock, formatLaTeXInline,+ formatLaTeXBlock.++ + The options parameter is now a record, FormatOptions,+ rather than a list, [FormatOption].++ + "Inline" is no longer a format option, since there are separate+ formatting functions for block and inline.++ + formatHtml no longer has a string parameter for language+ name, and the language name is no longer added as a class.++ + highlightingCss has been removed; we now have styleToHtml+ and styleToLaTeX, which take a Style and produce code for+ the HTML header or LaTeX preamble.++ + Only the short form of the attribute is now used.+ Removed OptDetailed.++ * blaze-html is now used instead of xhtml for HTML formatting.++ * Modules for individual languages are no longer exposed.++ * Removed BUGS; added link to github issue tracker in README.++ * Removed ilerp, mediawiki, xharbour syntaxes.++ * Updated haskell xml. Changed order of parsers in haskell.xml.+ This is needed so that floats can be parsed as floats.+ Otherwise '33.3' gets parsed as an integer, a function (.),+ and an integer. (These changes should be submitted upstream.)++ * Fixed lua highlighting problems.+ Improved lua highlighter. Removed doxygen-lua, which was messing+ things up.++ * Made pMatchRegex slightly faster.++ * Improved efficiency of pKeyword by checking to see if a+ potential keyword lies ahead.++ * Fixed normalizeTokens so that comments etc. don't get split up.++ * Made KateParser a synonym for GenParser Char SyntaxState.++ * Simplified pDefault. The check for non-newline is no longer+ needed.++ * Add sourceCode class to tr in tables.++ * Improved ParseSyntaxFiles.hs. It now generates no -Wall+ warnings. In addition, it produces cleaner syntax parsers.++ * Changed the SyntaxState type:+ Removed synStCurrentLine, synStCharsParsedInLine.+ Added synStLineNumber, synStPrevNonspace.++ * Common: Removed pHandleEndline. Added fromState.+ Added mkParseSourceLine.++ * Highlight executable: removed --css flag, added --style, --format.++ * Cleaned up Makefile, added clean, distclean targets.+ highlighting-kate 0.3.1 (27 Nov 2011) * Fixed a release bug in 0.3. The Clojure module was not included
highlighting-kate.cabal view
@@ -1,5 +1,5 @@ Name: highlighting-kate-Version: 0.3.1+Version: 0.4 Cabal-Version: >= 1.6 Build-Type: Simple Category: Text@@ -19,7 +19,6 @@ Maintainer: jgm@berkeley.edu Homepage: http://github.com/jgm/highlighting-kate Extra-Source-Files: README- BUGS changelog Highlight.hs ParseSyntaxFiles.hs@@ -53,7 +52,7 @@ xml/diff.xml xml/djangotemplate.xml xml/doxygen.xml- xml/doxygenlua.xml+ xml/doxygenlua.xml.bkp xml/dtd.xml xml/eiffel.xml xml/email.xml@@ -65,7 +64,6 @@ xml/haskell.xml xml/haxe.xml xml/html.xml- xml/ilerpg.xml xml/ini.xml xml/java.xml xml/javadoc.xml@@ -78,11 +76,11 @@ xml/lex.xml xml/literate-haskell.xml xml/lua.xml+ xml/lua.xml.bkp xml/makefile.xml xml/mandoc.xml xml/matlab.xml xml/maxima.xml- xml/mediawiki.xml xml/metafont.xml xml/mips.xml xml/modula-2.xml@@ -118,7 +116,6 @@ xml/texinfo.xml xml/verilog.xml xml/vhdl.xml- xml/xharbour.xml xml/xml.xml xml/xorg.xml xml/xslt.xml@@ -149,11 +146,15 @@ cpp-options: -D_PCRE_LIGHT else Build-depends: regex-pcre-builtin- Build-Depends: parsec, xhtml+ Build-Depends: parsec, mtl, blaze-html >= 0.4.2 && < 0.5 Exposed-Modules: Text.Highlighting.Kate Text.Highlighting.Kate.Syntax- Text.Highlighting.Kate.Definitions- Text.Highlighting.Kate.Format+ Text.Highlighting.Kate.Types+ Text.Highlighting.Kate.Styles+ Text.Highlighting.Kate.Format.HTML+ Text.Highlighting.Kate.Format.LaTeX+ Other-Modules: Text.Highlighting.Kate.Common+ Paths_highlighting_kate Text.Highlighting.Kate.Syntax.Actionscript Text.Highlighting.Kate.Syntax.Ada Text.Highlighting.Kate.Syntax.Alert@@ -179,7 +180,6 @@ Text.Highlighting.Kate.Syntax.Diff Text.Highlighting.Kate.Syntax.Djangotemplate Text.Highlighting.Kate.Syntax.Doxygen- Text.Highlighting.Kate.Syntax.Doxygenlua Text.Highlighting.Kate.Syntax.Dtd Text.Highlighting.Kate.Syntax.Eiffel Text.Highlighting.Kate.Syntax.Email@@ -191,7 +191,6 @@ Text.Highlighting.Kate.Syntax.Haskell Text.Highlighting.Kate.Syntax.Haxe Text.Highlighting.Kate.Syntax.Html- Text.Highlighting.Kate.Syntax.Ilerpg Text.Highlighting.Kate.Syntax.Ini Text.Highlighting.Kate.Syntax.Java Text.Highlighting.Kate.Syntax.Javadoc@@ -206,7 +205,6 @@ Text.Highlighting.Kate.Syntax.Mandoc Text.Highlighting.Kate.Syntax.Matlab Text.Highlighting.Kate.Syntax.Maxima- Text.Highlighting.Kate.Syntax.Mediawiki Text.Highlighting.Kate.Syntax.Metafont Text.Highlighting.Kate.Syntax.Mips Text.Highlighting.Kate.Syntax.Modula2@@ -241,15 +239,12 @@ Text.Highlighting.Kate.Syntax.Texinfo Text.Highlighting.Kate.Syntax.Verilog Text.Highlighting.Kate.Syntax.Vhdl- Text.Highlighting.Kate.Syntax.Xharbour Text.Highlighting.Kate.Syntax.Xml Text.Highlighting.Kate.Syntax.Xorg Text.Highlighting.Kate.Syntax.Xslt Text.Highlighting.Kate.Syntax.Xul Text.Highlighting.Kate.Syntax.Yacc Text.Highlighting.Kate.Syntax.Yaml- Other-Modules: Text.Highlighting.Kate.Common- Paths_highlighting_kate -- disable optimizations; it doesn't hurt performance much and -- massively improves compilation speed and memory usage Ghc-Options: -W -O0@@ -260,11 +255,11 @@ Executable Highlight Main-Is: Highlight.hs- Build-Depends: base, containers, xhtml, filepath+ Build-Depends: base, containers, blaze-html >= 0.4.2 && < 0.5, filepath if flag(pcre-light) cpp-options: -D_PCRE_LIGHT- Ghc-Options: -W -O0- Ghc-Prof-Options: -auto-all -caf-all+ Ghc-Options: -W -O0 -rtsopts+ Ghc-Prof-Options: -auto-all -caf-all -rtsopts -- the following line is needed to prevent gcc from consuming huge amounts of -- memory on platforms without a native code generator: Cc-Options: -O0@@ -273,4 +268,3 @@ Buildable: True else Buildable: False-
− xml/doxygenlua.xml
@@ -1,481 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE language SYSTEM "language.dtd"-[- <!ENTITY wordsep "([][,?;()]|\.$|\.?\s)"> <!-- things that end a TagWord -->-]>-<!--- Version 1.01 by Bruno Massa-- Based on the original Doxygen Highlighter version 1.0 from- Copyright 2004 Dominik Haumann (dhdev@gmx.de)- Copyright 2007 Matthew Woehlke (mw_triad@users.sourceforge.net)-- **********************************************************************- * This library is free software; you can redistribute it and/or *- * modify it under the terms of the GNU Lesser General Public *- * License as published by the Free Software Foundation; either *- * version 2 of the License, or (at your option) any later version. *- * *- * This library is distributed in the hope that it will be useful, *- * but WITHOUT ANY WARRANTY; without even the implied warranty of *- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *- * Lesser General Public License for more details. *- * *- * You should have received a copy of the GNU Lesser General Public *- * License along with this library; if not, write to the *- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *- * Boston, MA 02110-1301, USA. *- **********************************************************************- -->-<language name="DoxygenLua" version="1.01" kateversion="2.4" section="Markup" extensions="*.dox;*.doxygen" mimetype="text/x-doxygen" author="Bruno Massa (brmassa@gmail.com)" license="LGPL">- <highlighting>- <!-- note: all tags may begin with a \ or @ char- so if you add/change tags you have to do it twice -->- <list name="TagOnly">- <item> \arg </item>- <item> \attention </item>- <item> \author </item>- <item> \callgraph </item>- <item> \code </item>- <item> \dot </item>- <item> \else </item>- <item> \endcode </item>- <item> \endcond </item>- <item> \enddot </item>- <item> \endhtmlonly </item>- <item> \endif </item>- <item> \endlatexonly </item>- <item> \endlink </item>- <item> \endmanonly </item>- <item> \endverbatim </item>- <item> \endxmlonly </item>- <item> \f[ </item>- <item> \f] </item>- <item> \f$ </item>- <item> \hideinitializer </item>- <item> \htmlonly </item>- <item> \interface </item>- <item> \internal </item>- <item> \invariant </item>- <item> \~ </item>- <item> \@ </item>- <item> \$ </item>- <item> \\ </item>- <item> \# </item>- <item> \latexonly </item>- <item> \li </item>- <item> \manonly </item>- <item> \n </item>- <item> \nosubgrouping </item>- <item> \note </item>- <item> \only </item>- <item> \post </item>- <item> \pre </item>- <item> \remarks </item>- <item> \return </item>- <item> \returns </item>- <item> \sa </item>- <item> \see </item>- <item> \showinitializer </item>- <item> \since </item>- <item> \test </item>- <item> \todo </item>- <item> \verbatim </item>- <item> \warning </item>- <item> \xmlonly </item>-- <item> @arg </item>- <item> @attention </item>- <item> @author </item>- <item> @callgraph </item>- <item> @code </item>- <item> @dot </item>- <item> @else </item>- <item> @endcode </item>- <item> @endcond </item>- <item> @enddot </item>- <item> @endhtmlonly </item>- <item> @endif </item>- <item> @endlatexonly </item>- <item> @endlink </item>- <item> @endmanonly </item>- <item> @endverbatim </item>- <item> @endxmlonly </item>- <item> @f[ </item>- <item> @f] </item>- <item> @f$ </item>- <item> @hideinitializer </item>- <item> @htmlonly </item>- <item> @interface </item>- <item> @internal </item>- <item> @invariant </item>- <item> @~ </item>- <item> @@ </item>- <item> @$ </item>- <item> @\ </item>- <item> @# </item>- <item> @latexonly </item>- <item> @li </item>- <item> @manonly </item>- <item> @n </item>- <item> @nosubgrouping </item>- <item> @note </item>- <item> @only </item>- <item> @post </item>- <item> @pre </item>- <item> @remarks </item>- <item> @return </item>- <item> @returns </item>- <item> @sa </item>- <item> @see </item>- <item> @showinitializer </item>- <item> @since </item>- <item> @test </item>- <item> @todo </item>- <item> @verbatim </item>- <item> @warning </item>- <item> @xmlonly </item>- </list>-- <list name="TagWord">- <item> \addtogroup </item>- <item> \a </item>- <item> \anchor </item>- <item> \b </item>- <item> \c </item>- <item> \class </item>- <item> \cond </item>- <item> \copydoc </item>- <item> \def </item>- <item> \dontinclude </item>- <item> \dotfile </item>- <item> \e </item>- <item> \elseif </item>- <item> \em </item>- <item> \enum </item>- <item> \example </item>- <item> \exception </item>- <item> \exceptions </item>- <item> \file </item>- <item> \htmlinclude </item>- <item> \if </item>- <item> \ifnot </item>- <item> \include </item>- <item> \link </item>- <item> \namespace </item>- <item> \p </item>- <item> \package </item>- <item> \ref </item>- <item> \relatesalso </item>- <item> \relates </item>- <item> \retval </item>- <item> \throw </item>- <item> \throws </item>- <item> \verbinclude </item>- <item> \version </item>- <item> \xrefitem </item>-- <item> @addtogroup </item>- <item> @a </item>- <item> @anchor </item>- <item> @b </item>- <item> @c </item>- <item> @class </item>- <item> @cond </item>- <item> @copydoc </item>- <item> @def </item>- <item> @dontinclude </item>- <item> @dotfile </item>- <item> @e </item>- <item> @elseif </item>- <item> @em </item>- <item> @enum </item>- <item> @example </item>- <item> @exception </item>- <item> @exceptions </item>- <item> @file </item>- <item> @htmlinclude </item>- <item> @if </item>- <item> @ifnot </item>- <item> @include </item>- <item> @link </item>- <item> @namespace </item>- <item> @p </item>- <item> @package </item>- <item> @ref </item>- <item> @relatesalso </item>- <item> @relates </item>- <item> @retval </item>- <item> @throw </item>- <item> @throws </item>- <item> @verbinclude </item>- <item> @version </item>- <item> @xrefitem </item>- </list>- <list name="TagParam">- <item> \param </item>-- <item> @param </item>- </list>- <list name="TagWordWord">- <item> \image </item>-- <item> @image </item>- </list>- <list name="TagWordString">- <item> \defgroup </item>- <item> \page </item>- <item> \paragraph </item>- <item> \section </item>- <item> \struct </item>- <item> \subsection </item>- <item> \subsubsection </item>- <item> \union </item>- <item> \weakgroup </item>-- <item> @defgroup </item>- <item> @page </item>- <item> @paragraph </item>- <item> @section </item>- <item> @struct </item>- <item> @subsection </item>- <item> @subsubsection </item>- <item> @union </item>- <item> @weakgroup </item>- </list>- <list name="TagString">- <item> \addindex </item>- <item> \brief </item>- <item> \bug </item>- <item> \date </item>- <item> \deprecated </item>- <item> \fn </item>- <item> \ingroup </item>- <item> \line </item>- <item> \mainpage </item>- <item> \name </item>- <item> \overload </item>- <item> \par </item>- <item> \short </item>- <item> \skip </item>- <item> \skipline </item>- <item> \typedef </item>- <item> \until </item>- <item> \var </item>-- <item> @addindex </item>- <item> @brief </item>- <item> @bug </item>- <item> @date </item>- <item> @deprecated </item>- <item> @fn </item>- <item> @ingroup </item>- <item> @line </item>- <item> @mainpage </item>- <item> @name </item>- <item> @overload </item>- <item> @par </item>- <item> @short </item>- <item> @skip </item>- <item> @skipline </item>- <item> @typedef </item>- <item> @until </item>- <item> @var </item>- </list>- <contexts>- <!-- different formats:- @tag : TagOnly- @tag rest_of_line : TagString- @tag <word> : TagWord- @tag <word> <word> : TagWordWord- @tag <word> rest_of_line : TagWordString- -->- <context attribute="Normal Text" lineEndContext="#stay" name="Normal">- <RegExpr attribute="Comment" context="BlockComment" beginRegion="BlockComment" String="--\[(=*)\[" dynamic="true" />- <StringDetect attribute="Comment" context="LineComment" String="--"/>- </context>- <context attribute="Comment" lineEndContext="#pop" name="LineComment">- <DetectSpaces />- <IncludeRules context="##Alerts" />- <keyword attribute="Tags" context="#stay" String="TagOnly" />- <keyword attribute="Tags" context="SL_TagWord" String="TagWord" />- <keyword attribute="Tags" context="SL_TagParam" String="TagParam" />- <keyword attribute="Tags" context="SL_TagWordWord" String="TagWordWord" />- <keyword attribute="Tags" context="SL_TagString" String="TagString" />- <keyword attribute="Tags" context="SL_TagWordString" String="TagWordString" />- <DetectIdentifier />- <StringDetect attribute="HTML Comment" context="SL_htmlcomment" String="<!--" />- <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />- <RegExpr attribute="HTML Tag" context="SL_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />- </context>- <context attribute="Comment" lineEndContext="#stay" name="BlockComment" dynamic="true" >- <DetectSpaces />- <RegExpr attribute="Comment" context="#pop" endRegion="BlockComment" String="\]%1\]" dynamic="true" />- <IncludeRules context="##Alerts" />- <Detect2Chars attribute="Region" context="#stay" char="@" char1="{" />- <Detect2Chars attribute="Region" context="#stay" char="@" char1="}" />- <keyword attribute="Tags" context="#stay" String="TagOnly" />- <keyword attribute="Tags" context="ML_TagWord" String="TagWord" />- <keyword attribute="Tags" context="ML_TagParam" String="TagParam" />- <keyword attribute="Tags" context="ML_TagWordWord" String="TagWordWord" />- <keyword attribute="Tags" context="ML_TagString" String="TagString" />- <keyword attribute="Tags" context="ML_TagWordString" String="TagWordString" />- <DetectIdentifier />- <RegExpr attribute="Tags" context="#stay" String="\\(<|>)" />- <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />- <RegExpr attribute="HTML Tag" context="ML_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />- <StringDetect attribute="HTML Comment" context="ML_htmlcomment" String="<!--" />- </context>--<!-- NOTE: all contexts beginning with ML_ are for multiline comments- The following contexts contain a Detect2Chars that looks for a */ sequence to end multiline comments. Singleline comments do not have this limitation - that's why all contexts are copy&pasted and the line <Detect2Chars ... */> is removed. <IncludeRules context="acontext"> could be used instead but it would make context switching much more complex and very hard to understand! (But use IncludeRules where the rules don't refer to another SL_*/ML_* context, to help maintainability.)--->- <!-- tag contexts -->- <context attribute="Comment" lineEndContext="#pop" name="ML_TagWord">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <IncludeRules context="SL_TagWord" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="ML_TagParam">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <DetectSpaces />- <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[in]" />- <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[out]" />- <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[in,out]" />- <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="ML_TagWordWord">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <DetectSpaces />- <RegExpr attribute="Word" context="ML_Tag2ndWord" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <!-- TODO for kate 2.x, convert references to "#pop!ML_TagWord" -->- <context attribute="Comment" lineEndContext="#pop#pop" name="ML_Tag2ndWord">- <Detect2Chars attribute="Comment" context="#pop#pop" char="*" char1="/" lookAhead="true"/>- <IncludeRules context="SL_Tag2ndWord" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="ML_TagString">- <DetectSpaces />- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <StringDetect attribute="HTML Comment" context="ML_htmlcomment" String="<!--" />- <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />- <RegExpr attribute="HTML Tag" context="ML_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />- <RegExpr attribute="Description" context="#stay" String="." />- </context>- <context attribute="Comment" lineEndContext="#pop" name="ML_TagWordString">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <IncludeRules context="SL_TagWordString" />- </context>-- <!-- html contexts -->- <context name="ML_htmltag" attribute="Identifier" lineEndContext="#stay">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <Detect2Chars attribute="HTML Tag" context="#pop" char="/" char1=">" />- <DetectChar attribute="HTML Tag" context="#pop" char=">"/>- <RegExpr attribute="Identifier" context="ML_identifiers" String="\s*=\s*"/>- </context>- <context name="ML_htmlcomment" attribute="HTML Comment" lineEndContext="#stay">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <IncludeRules context="##Alerts" />- <StringDetect attribute="HTML Comment" context="#pop" String="-->" />- </context>- <context name="ML_identifiers" attribute="Identifier" lineEndContext="#stay">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <RegExpr attribute="String" context="#pop" String="\s*#?[a-zA-Z0-9]*" />- <DetectChar attribute="Types" context="ML_types1" char="'" />- <DetectChar attribute="Types" context="ML_types2" char=""" />- </context>- <context name="ML_types1" attribute="Types" lineEndContext="#stay">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <DetectChar attribute="Types" context="#pop#pop" char="'" />- </context>- <context name="ML_types2" attribute="Types" lineEndContext="#stay">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>- <DetectChar attribute="Types" context="#pop#pop" char=""" />- </context>--<!-- NOTE: all contexts beginning with SL_ are for singleline comments -->- <!-- tag contexts -->- <context attribute="Comment" lineEndContext="#pop" name="SL_TagWord">- <DetectSpaces />- <keyword attribute="Tags" context="#pop" String="TagWord" lookAhead="true"/>- <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="SL_TagParam">- <DetectSpaces />- <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[in]" />- <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[out]" />- <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[in,out]" />- <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="SL_TagWordWord">- <DetectSpaces />- <RegExpr attribute="Word" context="SL_Tag2ndWord" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <!-- TODO for kate 2.x, convert references to "#pop!SL_TagWord" -->- <context attribute="Comment" lineEndContext="#pop#pop" name="SL_Tag2ndWord">- <DetectSpaces />- <RegExpr attribute="Word" context="#pop#pop" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>- <context attribute="Comment" lineEndContext="#pop" name="SL_TagString">- <DetectSpaces />- <StringDetect attribute="HTML Comment" context="SL_htmlcomment" String="<!--" />- <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />- <RegExpr attribute="HTML Tag" context="SL_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />- <RegExpr attribute="Description" context="#stay" String="." />- </context>- <context attribute="Comment" lineEndContext="#pop" name="SL_TagWordString">- <DetectSpaces />- <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />- <RegExpr attribute="Word" context="#stay" String="\S" />- </context>-- <!-- html contexts -->- <context name="SL_htmltag" attribute="Identifier" lineEndContext="#pop">- <Detect2Chars attribute="HTML Tag" context="#pop" char="/" char1=">" />- <DetectChar attribute="HTML Tag" context="#pop" char=">"/>- <RegExpr attribute="Identifier" context="SL_identifiers" String="\s*=\s*"/>- </context>- <context name="SL_htmlcomment" attribute="HTML Comment" lineEndContext="#pop">- <IncludeRules context="##Alerts" />- <StringDetect attribute="HTML Comment" context="#pop" String="-->" />- </context>- <context name="SL_identifiers" attribute="Identifier" lineEndContext="#pop">- <RegExpr attribute="String" context="#pop" String="\s*#?[a-zA-Z0-9]*" />- <DetectChar attribute="Types" context="SL_types1" char="'" />- <DetectChar attribute="Types" context="SL_types2" char=""" />- </context>- <context name="SL_types1" attribute="Types" lineEndContext="#pop">- <DetectChar attribute="Types" context="#pop#pop" char="'" />- </context>- <context name="SL_types2" attribute="Types" lineEndContext="#pop">- <DetectChar attribute="Types" context="#pop#pop" char=""" />- </context>-- </contexts>- <itemDatas>- <itemData name="Normal Text" defStyleNum="dsNormal" />- <itemData name="Tags" defStyleNum="dsKeyword" color="#ca60ca" selColor="#ffffff" bold="1" italic="0" />- <itemData name="Word" defStyleNum="dsKeyword" color="#0095ff" selColor="#ffffff" bold="1" italic="0" />- <itemData name="HTML Tag" defStyleNum="dsKeyword"/>- <itemData name="Description" defStyleNum="dsString" />- <itemData name="Comment" defStyleNum="dsComment"/>- <itemData name="Region" defStyleNum="dsRegionMarker" />- <itemData name="Identifier" defStyleNum="dsOthers" />- <itemData name="HTML Comment" defStyleNum="dsComment" />- <itemData name="Types" defStyleNum="dsDataType" />- </itemDatas>- </highlighting>- <general>- <comments>- <comment name="singleLine" start="--" />- <comment name="multiLine" start="--[[" end="]]" />- </comments>- <keywords casesensitive="0" weakDeliminator="\$~" />- </general>-</language>
+ xml/doxygenlua.xml.bkp view
@@ -0,0 +1,481 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE language SYSTEM "language.dtd"+[+ <!ENTITY wordsep "([][,?;()]|\.$|\.?\s)"> <!-- things that end a TagWord -->+]>+<!--+ Version 1.01 by Bruno Massa++ Based on the original Doxygen Highlighter version 1.0 from+ Copyright 2004 Dominik Haumann (dhdev@gmx.de)+ Copyright 2007 Matthew Woehlke (mw_triad@users.sourceforge.net)++ **********************************************************************+ * This library is free software; you can redistribute it and/or *+ * modify it under the terms of the GNU Lesser General Public *+ * License as published by the Free Software Foundation; either *+ * version 2 of the License, or (at your option) any later version. *+ * *+ * This library is distributed in the hope that it will be useful, *+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *+ * Lesser General Public License for more details. *+ * *+ * You should have received a copy of the GNU Lesser General Public *+ * License along with this library; if not, write to the *+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *+ * Boston, MA 02110-1301, USA. *+ **********************************************************************+ -->+<language name="DoxygenLua" version="1.01" kateversion="2.4" section="Markup" extensions="*.dox;*.doxygen" mimetype="text/x-doxygen" author="Bruno Massa (brmassa@gmail.com)" license="LGPL">+ <highlighting>+ <!-- note: all tags may begin with a \ or @ char+ so if you add/change tags you have to do it twice -->+ <list name="TagOnly">+ <item> \arg </item>+ <item> \attention </item>+ <item> \author </item>+ <item> \callgraph </item>+ <item> \code </item>+ <item> \dot </item>+ <item> \else </item>+ <item> \endcode </item>+ <item> \endcond </item>+ <item> \enddot </item>+ <item> \endhtmlonly </item>+ <item> \endif </item>+ <item> \endlatexonly </item>+ <item> \endlink </item>+ <item> \endmanonly </item>+ <item> \endverbatim </item>+ <item> \endxmlonly </item>+ <item> \f[ </item>+ <item> \f] </item>+ <item> \f$ </item>+ <item> \hideinitializer </item>+ <item> \htmlonly </item>+ <item> \interface </item>+ <item> \internal </item>+ <item> \invariant </item>+ <item> \~ </item>+ <item> \@ </item>+ <item> \$ </item>+ <item> \\ </item>+ <item> \# </item>+ <item> \latexonly </item>+ <item> \li </item>+ <item> \manonly </item>+ <item> \n </item>+ <item> \nosubgrouping </item>+ <item> \note </item>+ <item> \only </item>+ <item> \post </item>+ <item> \pre </item>+ <item> \remarks </item>+ <item> \return </item>+ <item> \returns </item>+ <item> \sa </item>+ <item> \see </item>+ <item> \showinitializer </item>+ <item> \since </item>+ <item> \test </item>+ <item> \todo </item>+ <item> \verbatim </item>+ <item> \warning </item>+ <item> \xmlonly </item>++ <item> @arg </item>+ <item> @attention </item>+ <item> @author </item>+ <item> @callgraph </item>+ <item> @code </item>+ <item> @dot </item>+ <item> @else </item>+ <item> @endcode </item>+ <item> @endcond </item>+ <item> @enddot </item>+ <item> @endhtmlonly </item>+ <item> @endif </item>+ <item> @endlatexonly </item>+ <item> @endlink </item>+ <item> @endmanonly </item>+ <item> @endverbatim </item>+ <item> @endxmlonly </item>+ <item> @f[ </item>+ <item> @f] </item>+ <item> @f$ </item>+ <item> @hideinitializer </item>+ <item> @htmlonly </item>+ <item> @interface </item>+ <item> @internal </item>+ <item> @invariant </item>+ <item> @~ </item>+ <item> @@ </item>+ <item> @$ </item>+ <item> @\ </item>+ <item> @# </item>+ <item> @latexonly </item>+ <item> @li </item>+ <item> @manonly </item>+ <item> @n </item>+ <item> @nosubgrouping </item>+ <item> @note </item>+ <item> @only </item>+ <item> @post </item>+ <item> @pre </item>+ <item> @remarks </item>+ <item> @return </item>+ <item> @returns </item>+ <item> @sa </item>+ <item> @see </item>+ <item> @showinitializer </item>+ <item> @since </item>+ <item> @test </item>+ <item> @todo </item>+ <item> @verbatim </item>+ <item> @warning </item>+ <item> @xmlonly </item>+ </list>++ <list name="TagWord">+ <item> \addtogroup </item>+ <item> \a </item>+ <item> \anchor </item>+ <item> \b </item>+ <item> \c </item>+ <item> \class </item>+ <item> \cond </item>+ <item> \copydoc </item>+ <item> \def </item>+ <item> \dontinclude </item>+ <item> \dotfile </item>+ <item> \e </item>+ <item> \elseif </item>+ <item> \em </item>+ <item> \enum </item>+ <item> \example </item>+ <item> \exception </item>+ <item> \exceptions </item>+ <item> \file </item>+ <item> \htmlinclude </item>+ <item> \if </item>+ <item> \ifnot </item>+ <item> \include </item>+ <item> \link </item>+ <item> \namespace </item>+ <item> \p </item>+ <item> \package </item>+ <item> \ref </item>+ <item> \relatesalso </item>+ <item> \relates </item>+ <item> \retval </item>+ <item> \throw </item>+ <item> \throws </item>+ <item> \verbinclude </item>+ <item> \version </item>+ <item> \xrefitem </item>++ <item> @addtogroup </item>+ <item> @a </item>+ <item> @anchor </item>+ <item> @b </item>+ <item> @c </item>+ <item> @class </item>+ <item> @cond </item>+ <item> @copydoc </item>+ <item> @def </item>+ <item> @dontinclude </item>+ <item> @dotfile </item>+ <item> @e </item>+ <item> @elseif </item>+ <item> @em </item>+ <item> @enum </item>+ <item> @example </item>+ <item> @exception </item>+ <item> @exceptions </item>+ <item> @file </item>+ <item> @htmlinclude </item>+ <item> @if </item>+ <item> @ifnot </item>+ <item> @include </item>+ <item> @link </item>+ <item> @namespace </item>+ <item> @p </item>+ <item> @package </item>+ <item> @ref </item>+ <item> @relatesalso </item>+ <item> @relates </item>+ <item> @retval </item>+ <item> @throw </item>+ <item> @throws </item>+ <item> @verbinclude </item>+ <item> @version </item>+ <item> @xrefitem </item>+ </list>+ <list name="TagParam">+ <item> \param </item>++ <item> @param </item>+ </list>+ <list name="TagWordWord">+ <item> \image </item>++ <item> @image </item>+ </list>+ <list name="TagWordString">+ <item> \defgroup </item>+ <item> \page </item>+ <item> \paragraph </item>+ <item> \section </item>+ <item> \struct </item>+ <item> \subsection </item>+ <item> \subsubsection </item>+ <item> \union </item>+ <item> \weakgroup </item>++ <item> @defgroup </item>+ <item> @page </item>+ <item> @paragraph </item>+ <item> @section </item>+ <item> @struct </item>+ <item> @subsection </item>+ <item> @subsubsection </item>+ <item> @union </item>+ <item> @weakgroup </item>+ </list>+ <list name="TagString">+ <item> \addindex </item>+ <item> \brief </item>+ <item> \bug </item>+ <item> \date </item>+ <item> \deprecated </item>+ <item> \fn </item>+ <item> \ingroup </item>+ <item> \line </item>+ <item> \mainpage </item>+ <item> \name </item>+ <item> \overload </item>+ <item> \par </item>+ <item> \short </item>+ <item> \skip </item>+ <item> \skipline </item>+ <item> \typedef </item>+ <item> \until </item>+ <item> \var </item>++ <item> @addindex </item>+ <item> @brief </item>+ <item> @bug </item>+ <item> @date </item>+ <item> @deprecated </item>+ <item> @fn </item>+ <item> @ingroup </item>+ <item> @line </item>+ <item> @mainpage </item>+ <item> @name </item>+ <item> @overload </item>+ <item> @par </item>+ <item> @short </item>+ <item> @skip </item>+ <item> @skipline </item>+ <item> @typedef </item>+ <item> @until </item>+ <item> @var </item>+ </list>+ <contexts>+ <!-- different formats:+ @tag : TagOnly+ @tag rest_of_line : TagString+ @tag <word> : TagWord+ @tag <word> <word> : TagWordWord+ @tag <word> rest_of_line : TagWordString+ -->+ <context attribute="Normal Text" lineEndContext="#stay" name="Normal">+ <RegExpr attribute="Comment" context="BlockComment" beginRegion="BlockComment" String="--\[(=*)\[" dynamic="true" />+ <StringDetect attribute="Comment" context="LineComment" String="--"/>+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="LineComment">+ <DetectSpaces />+ <IncludeRules context="##Alerts" />+ <keyword attribute="Tags" context="#stay" String="TagOnly" />+ <keyword attribute="Tags" context="SL_TagWord" String="TagWord" />+ <keyword attribute="Tags" context="SL_TagParam" String="TagParam" />+ <keyword attribute="Tags" context="SL_TagWordWord" String="TagWordWord" />+ <keyword attribute="Tags" context="SL_TagString" String="TagString" />+ <keyword attribute="Tags" context="SL_TagWordString" String="TagWordString" />+ <DetectIdentifier />+ <StringDetect attribute="HTML Comment" context="SL_htmlcomment" String="<!--" />+ <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />+ <RegExpr attribute="HTML Tag" context="SL_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />+ </context>+ <context attribute="Comment" lineEndContext="#stay" name="BlockComment" dynamic="true" >+ <DetectSpaces />+ <RegExpr attribute="Comment" context="#pop" endRegion="BlockComment" String="\]%1\]" dynamic="true" />+ <IncludeRules context="##Alerts" />+ <Detect2Chars attribute="Region" context="#stay" char="@" char1="{" />+ <Detect2Chars attribute="Region" context="#stay" char="@" char1="}" />+ <keyword attribute="Tags" context="#stay" String="TagOnly" />+ <keyword attribute="Tags" context="ML_TagWord" String="TagWord" />+ <keyword attribute="Tags" context="ML_TagParam" String="TagParam" />+ <keyword attribute="Tags" context="ML_TagWordWord" String="TagWordWord" />+ <keyword attribute="Tags" context="ML_TagString" String="TagString" />+ <keyword attribute="Tags" context="ML_TagWordString" String="TagWordString" />+ <DetectIdentifier />+ <RegExpr attribute="Tags" context="#stay" String="\\(<|>)" />+ <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />+ <RegExpr attribute="HTML Tag" context="ML_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />+ <StringDetect attribute="HTML Comment" context="ML_htmlcomment" String="<!--" />+ </context>++<!-- NOTE: all contexts beginning with ML_ are for multiline comments+ The following contexts contain a Detect2Chars that looks for a */ sequence to end multiline comments. Singleline comments do not have this limitation - that's why all contexts are copy&pasted and the line <Detect2Chars ... */> is removed. <IncludeRules context="acontext"> could be used instead but it would make context switching much more complex and very hard to understand! (But use IncludeRules where the rules don't refer to another SL_*/ML_* context, to help maintainability.)+-->+ <!-- tag contexts -->+ <context attribute="Comment" lineEndContext="#pop" name="ML_TagWord">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <IncludeRules context="SL_TagWord" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="ML_TagParam">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <DetectSpaces />+ <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[in]" />+ <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[out]" />+ <StringDetect attribute="Tags" context="ML_Tag2ndWord" String="[in,out]" />+ <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="ML_TagWordWord">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <DetectSpaces />+ <RegExpr attribute="Word" context="ML_Tag2ndWord" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <!-- TODO for kate 2.x, convert references to "#pop!ML_TagWord" -->+ <context attribute="Comment" lineEndContext="#pop#pop" name="ML_Tag2ndWord">+ <Detect2Chars attribute="Comment" context="#pop#pop" char="*" char1="/" lookAhead="true"/>+ <IncludeRules context="SL_Tag2ndWord" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="ML_TagString">+ <DetectSpaces />+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <StringDetect attribute="HTML Comment" context="ML_htmlcomment" String="<!--" />+ <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />+ <RegExpr attribute="HTML Tag" context="ML_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />+ <RegExpr attribute="Description" context="#stay" String="." />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="ML_TagWordString">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <IncludeRules context="SL_TagWordString" />+ </context>++ <!-- html contexts -->+ <context name="ML_htmltag" attribute="Identifier" lineEndContext="#stay">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <Detect2Chars attribute="HTML Tag" context="#pop" char="/" char1=">" />+ <DetectChar attribute="HTML Tag" context="#pop" char=">"/>+ <RegExpr attribute="Identifier" context="ML_identifiers" String="\s*=\s*"/>+ </context>+ <context name="ML_htmlcomment" attribute="HTML Comment" lineEndContext="#stay">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <IncludeRules context="##Alerts" />+ <StringDetect attribute="HTML Comment" context="#pop" String="-->" />+ </context>+ <context name="ML_identifiers" attribute="Identifier" lineEndContext="#stay">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <RegExpr attribute="String" context="#pop" String="\s*#?[a-zA-Z0-9]*" />+ <DetectChar attribute="Types" context="ML_types1" char="'" />+ <DetectChar attribute="Types" context="ML_types2" char=""" />+ </context>+ <context name="ML_types1" attribute="Types" lineEndContext="#stay">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <DetectChar attribute="Types" context="#pop#pop" char="'" />+ </context>+ <context name="ML_types2" attribute="Types" lineEndContext="#stay">+ <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" lookAhead="true"/>+ <DetectChar attribute="Types" context="#pop#pop" char=""" />+ </context>++<!-- NOTE: all contexts beginning with SL_ are for singleline comments -->+ <!-- tag contexts -->+ <context attribute="Comment" lineEndContext="#pop" name="SL_TagWord">+ <DetectSpaces />+ <keyword attribute="Tags" context="#pop" String="TagWord" lookAhead="true"/>+ <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="SL_TagParam">+ <DetectSpaces />+ <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[in]" />+ <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[out]" />+ <StringDetect attribute="Tags" context="SL_Tag2ndWord" String="[in,out]" />+ <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="SL_TagWordWord">+ <DetectSpaces />+ <RegExpr attribute="Word" context="SL_Tag2ndWord" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <!-- TODO for kate 2.x, convert references to "#pop!SL_TagWord" -->+ <context attribute="Comment" lineEndContext="#pop#pop" name="SL_Tag2ndWord">+ <DetectSpaces />+ <RegExpr attribute="Word" context="#pop#pop" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="SL_TagString">+ <DetectSpaces />+ <StringDetect attribute="HTML Comment" context="SL_htmlcomment" String="<!--" />+ <Detect2Chars attribute="Comment" context="#stay" char="<" char1="<" />+ <RegExpr attribute="HTML Tag" context="SL_htmltag" String="<\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />+ <RegExpr attribute="Description" context="#stay" String="." />+ </context>+ <context attribute="Comment" lineEndContext="#pop" name="SL_TagWordString">+ <DetectSpaces />+ <RegExpr attribute="Word" context="#pop" String="\S(?=&wordsep;)" />+ <RegExpr attribute="Word" context="#stay" String="\S" />+ </context>++ <!-- html contexts -->+ <context name="SL_htmltag" attribute="Identifier" lineEndContext="#pop">+ <Detect2Chars attribute="HTML Tag" context="#pop" char="/" char1=">" />+ <DetectChar attribute="HTML Tag" context="#pop" char=">"/>+ <RegExpr attribute="Identifier" context="SL_identifiers" String="\s*=\s*"/>+ </context>+ <context name="SL_htmlcomment" attribute="HTML Comment" lineEndContext="#pop">+ <IncludeRules context="##Alerts" />+ <StringDetect attribute="HTML Comment" context="#pop" String="-->" />+ </context>+ <context name="SL_identifiers" attribute="Identifier" lineEndContext="#pop">+ <RegExpr attribute="String" context="#pop" String="\s*#?[a-zA-Z0-9]*" />+ <DetectChar attribute="Types" context="SL_types1" char="'" />+ <DetectChar attribute="Types" context="SL_types2" char=""" />+ </context>+ <context name="SL_types1" attribute="Types" lineEndContext="#pop">+ <DetectChar attribute="Types" context="#pop#pop" char="'" />+ </context>+ <context name="SL_types2" attribute="Types" lineEndContext="#pop">+ <DetectChar attribute="Types" context="#pop#pop" char=""" />+ </context>++ </contexts>+ <itemDatas>+ <itemData name="Normal Text" defStyleNum="dsNormal" />+ <itemData name="Tags" defStyleNum="dsKeyword" color="#ca60ca" selColor="#ffffff" bold="1" italic="0" />+ <itemData name="Word" defStyleNum="dsKeyword" color="#0095ff" selColor="#ffffff" bold="1" italic="0" />+ <itemData name="HTML Tag" defStyleNum="dsKeyword"/>+ <itemData name="Description" defStyleNum="dsString" />+ <itemData name="Comment" defStyleNum="dsComment"/>+ <itemData name="Region" defStyleNum="dsRegionMarker" />+ <itemData name="Identifier" defStyleNum="dsOthers" />+ <itemData name="HTML Comment" defStyleNum="dsComment" />+ <itemData name="Types" defStyleNum="dsDataType" />+ </itemDatas>+ </highlighting>+ <general>+ <comments>+ <comment name="singleLine" start="--" />+ <comment name="multiLine" start="--[[" end="]]" />+ </comments>+ <keywords casesensitive="0" weakDeliminator="\$~" />+ </general>+</language>
xml/haskell.xml view
@@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE language SYSTEM "language.dtd">-<language name="Haskell" version="2.0.3" kateversion="2.3" section="Sources" extensions="*.hs" mimetype="text/x-haskell" author="Nicolas Wu (zenzike@gmail.com)" license="LGPL" indenter="haskell">+<language name="Haskell" version="2.0.4" kateversion="2.3" section="Sources" extensions="*.hs" mimetype="text/x-haskell" author="Nicolas Wu (zenzike@gmail.com)" license="LGPL" indenter="haskell"> <highlighting> <list name="keywords"> <item> as </item>@@ -298,6 +298,11 @@ <item> LT </item> <item> GT </item> </list>+ <list name="class">+ <item> Applicative </item>+ <item> Foldable </item>+ <item> Traversable </item>+ </list> <contexts> <context attribute="Normal" lineEndContext="#stay" name="code"> <RegExpr attribute="Pragma" context="#stay" String="\{-#.*#-\}"/>@@ -309,17 +314,18 @@ <keyword attribute="Type Prelude" context="#stay" String="prelude type" /> <keyword attribute="Data Prelude" context="#stay" String="prelude data" /> <keyword attribute="Class Prelude" context="#stay" String="prelude class" />+ <keyword attribute="Class Prelude" context="#stay" String="class" /> <RegExpr attribute="Special" context="#stay" String="(::|=>|\->|<\-)" /> <AnyChar attribute="Special" context="#stay" String="∷⇒→←∀∃" /> <RegExpr attribute="Signature" context="#stay" String="\s*[a-z][a-zA-Z0-9_']*\s*(?=::[^\-!#\$%&\*\+/<=>\?\@\^\|~\.:])" /> <RegExpr attribute="Signature" context="#stay" String="\s*(\([\-!#\$%&\*\+/<=>\?\@\^\|~\.:]*\))*\s*(?=::[^\-!#\$%&\*\+/<=>\?\@\^\|~\.:])" />+ <RegExpr attribute="Float" context="#stay" String="\d+\.\d+" />+ <Int attribute="Decimal" context="#stay" /> <RegExpr attribute="Function" context="#stay" String="([A-Z][a-zA-Z0-9_']*\.)*[a-z][a-zA-Z0-9_']*" /> <RegExpr attribute="Operator" context="#stay" String="([A-Z][a-zA-Z0-0_']*\.)*[\-!#\$%&\*\+/<=>\?\@\^\|~\.:]+" /> <RegExpr attribute="Type" context="#stay" String="([A-Z][a-zA-Z0-9_']*\.)*[A-Z][a-zA-Z0-9_']*" /> - <Int attribute="Decimal" context="#stay" />- <RegExpr attribute="Float" context="#stay" String="\d+\.\d+" /> <DetectChar attribute="Char" context="char" char="'" /> <DetectChar attribute="String" context="string" char=""" />
− xml/ilerpg.xml
@@ -1,725 +0,0 @@-<!DOCTYPE language SYSTEM "language.dtd">-<!--- *************************************************************************- * *- * Syntax highlighting for IBM iSeries ILE RPG *- * Copyright (C) 2003, Nick Roux *- * *- *************************************************************************-- Updated: Nick Roux <nick@sundown.homeip.net>- Date: 2006/04/12- Version: 1.05- Added support for compiler directives and especially /free- Added positional check for opcodes and validation of conditioning indicators-- Author: Nick Roux <nick@sundown.homeip.net>- Date: Sometime during 2003- Version: 1.0-- This file contains the XML syntax highlighting description for the IBM- iSeries ILE RPG, for KATE, the KDE Advanced Editor. - Based on information from IBM publication SC09-2508-05- - Known problems: - 1) Calculation Specification Factor1 does not get highlighted- 2) Calculation Specification Extended Factor2 Continuation Line does not work correctly- 3) Everything from the start of Factor2 is assumed free format- 4) Will make a total mess of compile time array data, but that seems rather fitting- 5) Operation Code Extenders are not check/highlighted- 6) It is slow-- This program, including associated files, is free software. You may- distribute it and/or modify it under the terms of the GNU General Public- License as published by the Free Software Foundation; either Version 2 of- the license, or (at your option) any later version.-- This program is distributed in the hope that it will be useful, but- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License- for more details.-- You should have received a copy of the GNU General Public License along- with this program; if not, write to the Free Software Foundation, Inc.,- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA---->--<language name="ILERPG" version="1.05" kateversion="2.1" section="Sources" extensions="QRPG*.*;qrpg*.*" mimetype="text/x-ilerpg-src" casesensitive="0">- <highlighting>- <list name="dkeywords">- <item> EXTPROC </item>- <item> EXTPGM </item>- <item> OPDESC </item>- <item> DATFMT </item>- <item> DIM </item>- <item> LIKEDS </item>- <item> LIKEREC </item>- <item> LIKE </item>- <item> PROCPTR </item>- <item> TIMFMT </item>- <item> VARYING </item>- <item> ASCEND </item>- <item> CONST </item>- <item> NOOPT </item>- <item> OPTIONS </item>- <item> VALUE </item>- <item> QUALIFIED </item>- <item> INZ </item>- <item> BASED </item>- </list> - <list name="pkeywords">- <item> DATFMT </item>- <item> DIM </item>- <item> LIKE </item>- <item> LIKEDS </item>- <item> LIKEREC </item>- <item> PROCPTR </item>- <item> TIMFMT </item>- </list> - <list name="directives">- <item> FREE </item>- <item> END-FREE </item>- <item> TITLE </item>- <item> EJECT </item>- <item> SPACE </item>- <item> COPY </item>- <item> INCLUDE </item>- <item> DEFINE </item>- <item> UNDEFINE </item>- <item> IF </item>- <item> ELSE </item>- <item> EXEC </item>- <item> END-EXEC </item>- <item> ELSEIF </item>- <item> ENDIF </item>- <item> EOF </item>- </list> - <list name="directives2">- <item> NOT </item>- <item> DEFINED </item>- </list> - <list name="directives3">- <item> DEFINED </item>- </list> - <list name="biffs">- <item> ABS </item>- <item> ADDR </item>- <item> ALLOC </item>- <item> BITAND </item>- <item> BITNOT </item>- <item> BITOR </item>- <item> BITXOR </item>- <item> CHAR </item>- <item> CHECK </item>- <item> CHECKR </item>- <item> DATE </item>- <item> DAYS </item>- <item> DEC </item>- <item> DECH </item>- <item> DECPOS </item>- <item> DIFF </item>- <item> DIV </item>- <item> EDITC </item>- <item> EDITFLT </item>- <item> EDITW </item>- <item> ELEM </item>- <item> EOF </item>- <item> EQUAL </item>- <item> ERROR </item>- <item> FIELDS </item>- <item> FLOAT </item>- <item> FOUND </item>- <item> GRAPH </item>- <item> HOURS </item>- <item> INT </item>- <item> INTH </item>- <item> KDS </item>- <item> LEN </item>- <item> LOOKUP </item>- <item> LOOKUPLT </item>- <item> LOOKUPLE </item>- <item> LOOKUPGT </item>- <item> LOOKUPGE </item>- <item> MINUTES </item>- <item> MONTHS </item>- <item> MSECONDS </item>- <item> NULLIND </item>- <item> OCCUR </item>- <item> OPEN </item>- <item> PADDR </item>- <item> PARMS </item>- <item> REALLOC </item>- <item> REM </item>- <item> REPLACE </item>- <item> SCAN </item>- <item> SECONDS </item>- <item> SHTDN </item>- <item> SIZE </item>- <item> SQRT </item>- <item> STATUS </item>- <item> STR </item>- <item> SUBARR </item>- <item> SUBDT </item>- <item> SUBST </item>- <item> THIS </item>- <item> TIME </item>- <item> TIMESTAMP </item>- <item> TLOOKUP </item>- <item> TLOOKUPLT </item>- <item> TLOOKUPLE </item>- <item> TLOOKUPGT </item>- <item> TLOOKUPGE </item>- <item> TRIM </item>- <item> TRIML </item>- <item> TRIMR </item>- <item> UCS2 </item>- <item> UNS </item>- <item> UNSH </item>- <item> XFOOT </item>- <item> XLATE </item>- <item> YEARS </item>- </list>- <list name="evalopcodes2">- <item> IF </item>- </list>- <list name="evalopcodes3">- <item> DOW </item>- <item> DOU </item>- <item> FOR </item>- </list>- <list name="evalopcodes4">- <item> WHEN </item>- <item> EVAL </item>- </list>- <list name="evalopcodes5">- <item> EVALR </item>- </list>- <list name="evalopcodes6">- <item> RETURN </item>- </list>- <list name="evalopcodes8">- <item> ON-ERROR </item>- </list>- <list name="nonevalopcodes2">- <item> DO </item>- <item> IN </item>- <item> OR </item>- </list>- <list name="nonevalopcodes3">- <item> ACQ </item>- <item> ADD </item>- <item> AND </item>- <item> CAB </item>- <item> CAS </item>- <item> CAT </item>- <item> DIV </item>- <item> DOU </item>- <item> END </item>- <item> MVR </item>- <item> OUT </item>- <item> REL </item>- <item> SUB </item>- <item> TAG </item>- </list>- <list name="nonevalopcodes4">- <item> CALL </item>- <item> COMP </item>- <item> DUMP </item>- <item> ELSE </item>- <item> EXSR </item>- <item> FEOD </item>- <item> GOTO </item>- <item> IFGT </item>- <item> IFLT </item>- <item> IFEQ </item>- <item> IFNE </item>- <item> IFGE </item>- <item> IFLE </item>- <item> ITER </item>- <item> KFLD </item>- <item> MOVE </item>- <item> MULT </item>- <item> NEXT </item>- <item> OPEN </item>- <item> ORGT </item>- <item> ORLT </item>- <item> OREQ </item>- <item> ORNE </item>- <item> ORGE </item>- <item> ORLE </item>- <item> PARM </item>- <item> POST </item>- <item> READ </item>- <item> SCAN </item>- <item> SQRT </item>- <item> TEST </item>- <item> TIME </item>- </list>- <list name="nonevalopcodes5">- <item> ALLOC </item>- <item> ANDGT </item>- <item> ANDLT </item>- <item> ANDEQ </item>- <item> ANDNE </item>- <item> ANDGE </item>- <item> ANDLE </item>- <item> BEGSR </item>- <item> BITON </item>- <item> CABGT </item>- <item> CABLT </item>- <item> CABEQ </item>- <item> CABNE </item>- <item> CABGE </item>- <item> CABLE </item>- <item> CALLB </item>- <item> CALLP </item>- <item> CASGT </item>- <item> CASLT </item>- <item> CASEQ </item>- <item> CASNE </item>- <item> CASGE </item>- <item> CASLE </item>- <item> CHAIN </item>- <item> CHECK </item>- <item> CLEAR </item>- <item> CLOSE </item>- <item> CHECK </item>- <item> CLEAR </item>- <item> CLOSE </item>- <item> DOWGT </item>- <item> DOWLT </item>- <item> DOWEQ </item>- <item> DOWNE </item>- <item> DOWGE </item>- <item> DOWLE </item>- <item> DOUGT </item>- <item> DOULT </item>- <item> DOUEQ </item>- <item> DOUNE </item>- <item> DOUGE </item>- <item> DOULE </item>- <item> DSPLY </item>- <item> ENDCS </item>- <item> ENDDO </item>- <item> ENDIF </item>- <item> ENDSL </item>- <item> ENDSR </item>- <item> EXFMT </item>- <item> FORCE </item>- <item> KLIST </item>- <item> LEAVE </item>- <item> MHHZO </item>- <item> MHLZO </item>- <item> MLHZO </item>- <item> MLLZO </item>- <item> MOVEA </item>- <item> MOVEL </item>- <item> OCCUR </item>- <item> OTHER </item>- <item> PLIST </item>- <item> READC </item>- <item> READE </item>- <item> READP </item>- <item> RESET </item>- <item> ROLBK </item>- <item> SETGT </item>- <item> SETLL </item>- <item> SETON </item>- <item> SHTDN </item>- <item> SORTA </item>- <item> SUBST </item>- <item> TESTB </item>- <item> TESTN </item>- <item> TESTZ </item>- <item> WRITE </item>- <item> XFOOT </item>- <item> XLATE </item>- </list>- <list name="nonevalopcodes6">- <item> ADDDUR </item>- <item> BITOFF </item>- <item> CHECKR </item>- <item> COMMIT </item>- <item> DEFINE </item>- <item> DELETE </item>- <item> EXCEPT </item>- <item> EXTRCT </item>- <item> LOOKUP </item>- <item> READPE </item>- <item> RETURN </item>- <item> SELECT </item>- <item> SETOFF </item>- <item> SUBDUR </item>- <item> UNLOCK </item>- <item> UPDATE </item>- <item> WHENGT </item>- <item> WHENLT </item>- <item> WHENEQ </item>- <item> WHENNR </item>- <item> WHENGE </item>- <item> WHENLE </item>- </list>- <list name="nonevalopcodes7">- <item> DEALLOC </item>- <item> REALLOC </item>- </list>- <list name="freeopcodes">- <item> ACQ </item>- <item> BEGSR </item>- <item> CALLP </item>- <item> CHAIN </item>- <item> CLEAR </item>- <item> CLOSE </item>- <item> COMMIT </item>- <item> DEALLOC </item>- <item> DELETE </item>- <item> DOU </item>- <item> DOW </item>- <item> DSPLY </item>- <item> DUMP </item>- <item> ELSE </item>- <item> ELSEIF</item>- <item> ENDDO </item>- <item> ENDFOR </item>- <item> ENDIF </item>- <item> ENDMON </item>- <item> ENDSL </item>- <item> ENDSR </item>- <item> EVAL </item>- <item> EVALR </item>- <item> EXCEPT </item>- <item> EXFMT </item>- <item> EXSR </item>- <item> FEOD </item>- <item> FOR </item>- <item> FORCE </item>- <item> IF </item>- <item> IN </item>- <item> ITER </item>- <item> LEAVE </item>- <item> LEAVESR</item>- <item> MONITOR </item>- <item> NEXT </item>- <item> ON-ERROR </item>- <item> OPEN </item>- <item> OTHER </item>- <item> OUT </item>- <item> POST </item>- <item> READ </item>- <item> READC </item>- <item> READE </item>- <item> READP </item>- <item> READPE </item>- <item> REL </item>- <item> RESET </item>- <item> RETURN </item>- <item> ROLBK </item>- <item> SELECT </item>- <item> SETGT </item>- <item> SETLL </item>- <item> SORTA </item>- <item> TEST </item>- <item> UNLOCK </item>- <item> UPDATE </item>- <item> WHEN </item>- <item> WRITE </item>- </list>-- <contexts>- -<!-- Start here -->- <!-- Form Type -->- <context name="Default" attribute="Normal Text" lineEndContext="#stay">- <RegExpr attribute="Comment" context="Comments" String="[PpOoIiHhFfDdCc ]?\*"/>- <RegExpr attribute="Directive" context="Directives" String="[PpOoIiHhFfDdCc ]?/"/>- <AnyChar attribute="Keyword" context="AnyCode" String="OoIiHhFf"/>- <AnyChar attribute="Keyword" context="D" String="Dd"/>- <AnyChar attribute="Keyword" context="P" String="Pp"/>- <AnyChar attribute="Keyword" context="CControlLevel" String="Cc"/>- </context>- -<!-- Calculation Specifications -->- <!-- Control Level -->- <context name="CControlLevel" attribute="Normal Text" lineEndContext="#pop">- <RegExpr attribute="Indicator" context="CIndicators" String="\ {2}"/>- <RegExpr attribute="Indicator" context="CIndicators" String="[L|l][0-9]"/>- <RegExpr attribute="Indicator" context="CIndicators" String="[O|o|L|l|S|s][R|r]"/>- <RegExpr attribute="Indicator" context="CIndicators" String="[A|a][N|n]"/>- <RegExpr attribute="Indicator" context="CIndicators" String="[L|l|S|s][R|r]"/>- <RegExpr attribute="Alert" context="CIndicators" String=".{2}"/>- </context>- - <!-- Indicators -->- <context name="CIndicators" attribute="Normal Text" lineEndContext="#pop#pop">- <RegExpr attribute="Indicator" context="CFactor1" String="\ {3}"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][0-9]{2}"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][K|k][A-N|p-y]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][K|k][P-Y|p-y]}"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][L|l][1-9]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][L|l|M|m][R|r]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][R|r][T|t]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][U|u][1-8]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][O|o][A-G|a-g]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][O|o][V|v]"/>- <RegExpr attribute="Indicator" context="CFactor1" String="[\ |N|n][H|h][1-9]"/>- <RegExpr attribute="Alert" context="CFactor1" String=".{3}"/>- </context>- - <!-- Factor1 -->- <context name="CFactor1" attribute="Normal Text" lineEndContext="#pop#pop#pop">- <!-- TODO -->- <RegExpr attribute="Normal Text" context="FindOC" String=".{14}"/>- </context>- - <!-- FindOpcode -->- <context name="FindOC" attribute="Normal Text" lineEndContext="#pop#pop#pop#pop">- <keyword attribute="Keyword" context="NonEvalOC2" String="nonevalopcodes2"/>- <keyword attribute="Keyword" context="NonEvalOC3" String="nonevalopcodes3"/>- <keyword attribute="Keyword" context="NonEvalOC4" String="nonevalopcodes4"/>- <keyword attribute="Keyword" context="NonEvalOC5" String="nonevalopcodes5"/>- <keyword attribute="Keyword" context="NonEvalOC6" String="nonevalopcodes6"/>- <keyword attribute="Keyword" context="NonEvalOC7" String="nonevalopcodes7"/>- <RegExpr attribute="Keyword" context="NonEvalOC5" String="[Z|z]-([A|a][D|d]{2}|[S|s][U|u][B|b])"/>- <keyword attribute="Keyword" context="EvalOC2" String="evalopcodes2"/>- <keyword attribute="Keyword" context="EvalOC3" String="evalopcodes3"/>- <keyword attribute="Keyword" context="EvalOC4" String="evalopcodes4"/>- <keyword attribute="Keyword" context="EvalOC5" String="evalopcodes5"/>- <keyword attribute="Keyword" context="EvalOC6" String="evalopcodes6"/>- <RegExpr attribute="Keyword" context="EvalOC8" String="[O|o][N|n]-([E|e][R|r]{2}|[O|o][R|r])"/>- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {10}"/>- <RegExpr attribute="Alert" context="CFactor2" String=".{10}"/>- </context>-- <!-- Opcodes that can NOT be followed by evaluation expressions -->- <context name="NonEvalOC2" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {8}"/>- </context>- <context name="NonEvalOC3" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {7}"/>- </context>- <context name="NonEvalOC4" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {6}"/>- </context>- <context name="NonEvalOC5" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {5}"/>- </context>- <context name="NonEvalOC6" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {4}"/>- </context>- <context name="NonEvalOC7" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CFactor2" String="\ {3}"/>- </context>-- <context name="CFactor2" attribute="Normal Text" lineEndContext="Default">- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <IncludeRules context="CommonCode" />- </context>-- <!-- Opcodes that can be followed by evaluation expressions -->- <context name="EvalOC2" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {8}"/>- </context>- <context name="EvalOC3" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {7}"/>- </context>- <context name="EvalOC4" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {6}"/>- </context>- <context name="EvalOC5" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {5}"/>- </context>- <context name="EvalOC6" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {4}"/>- </context>- <context name="EvalOC8" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Normal Text" context="CExFactor2" String="\ {2}"/>- </context>- - <context name="CExFactor2" attribute="Normal Text" lineEndContext="Default">- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <IncludeRules context="CommonCode" />- </context>- - <!-- Check for continuation of eval -->- <context name="EvalOCCont" attribute="Normal Text" lineEndContext="#stay">- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <IncludeRules context="CommonCode" />- </context>-- <!-- Comments -->- <context name="Comments" attribute="Comment" lineEndContext="#pop">- <RegExpr attribute="BoldComment" context="#stay" String="\(*(FIXME|TODO)\)*" />- <RegExpr attribute="BoldComment" context="#stay" String="\(*(NOTE:)\)*" />- <RegExpr attribute="DivideComment" context="#stay" String="-|="/>- </context>-- <!-- String Constants -->- <context name="StringConstants" attribute="ConstantChar" lineEndContext="#pop">- <DetectChar attribute="ConstantChar" context="#pop" char="'"/>- </context>-- <!-- Compiler Directives -->- <context name="Directives" attribute="Normal Text" lineEndContext="Default">- <RegExpr attribute="Directive" context="Free" String="[F|f][R|r][E|e][E|e]"/>- <RegExpr attribute="Directive" context="Exec" String="[E|e][X|x][E|e][C|c]"/>- <keyword attribute="Directive" context="Directives2" String="directives"/>- </context>- <context name="Directives2" attribute="Normal Text" lineEndContext="Default">- <keyword attribute="Directive" context="Directives3" String="directives2"/>- </context>- <context name="Directives3" attribute="Normal Text" lineEndContext="Default">- <keyword attribute="Directive" context="#stay" String="directives3"/>- </context>-- <!-- Free -->- <context name="Free" attribute="Normal Text" lineEndContext="#stay">- <RegExpr attribute="Directive" context="#pop" String="[POIHFDC ]?/[E|e][N|n][D|d]-[F|f][R|r][E|e][E|e]"/>- <IncludeRules context="CommonCode" />- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <RegExpr attribute="Comment" context="Comments" String="//"/>- <keyword attribute="Keyword" context="#stay" String="freeopcodes"/>- </context>- - <!-- Exec -->- <context name="Exec" attribute="Normal Text" lineEndContext="#stay">- <RegExpr attribute="Directive" context="#pop" String="[POIHFDC ]?/[E|e][N|n][D|d]-[E|e][X|x][E|e][C|c]"/>- </context>- - <context name="Biffs" attribute="Biff" lineEndContext="#pop">- <keyword attribute="Biff" context="#pop" String="biffs"/>- <RegExpr attribute="Normal Text" context="#pop" String="."/>- </context>-- <!-- Stuff common to all code Use as Include -->- <context name="CommonCode" attribute="Normal Text" lineEndContext="#stay">- <IncludeRules context="ReservedWords" />- <IncludeRules context="Indicators" />- <DetectChar attribute="ConstantChar" context="StringConstants" char="'"/>- <Float attribute="Float" context="#stay"/>- <RegExpr attribute="Hex" context="#stay" String="[Xx]'[0-9a-fA-F]{2,}'"/>- <Int attribute="Decimal" context="#stay">- <StringDetect attribute="Decimal" context="#stay" String="ULL" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="LUL" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="LLU" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="UL" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="LU" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="LL" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="U" insensitive="TRUE"/>- <StringDetect attribute="Decimal" context="#stay" String="L" insensitive="TRUE"/>- </Int>- </context>- - <!-- Reserved words - Use as include -->- <context name="Indicators" attribute="Normal Text" lineEndContext="#stay">- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[0-9][0-9]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?1[P|p]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[H|h|L|l][1-9]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[L|l|M|m][R|r]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[O|o][A-G|a-g|V|v]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[U|u][1-8]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[K|k][A-N|a-n|P-Y|p-y]\)?"/>- <RegExpr attribute="Indicator" context="#stay" String="\*[I|i][N|n]\(?[R|r][T|t]\)?"/>- </context>- - <!-- Reserved words - Use as include -->- <context name="ReservedWords" attribute="Normal Text" lineEndContext="#stay">- <RegExpr attribute="Reserved" context="#stay" String="[\*|U|u][D|d][A|a][T|t][E|e]"/>- <RegExpr attribute="Reserved" context="#stay" String="[\*|U|u][M|m][O|o][N|n][T|t][H|h]"/>- <RegExpr attribute="Reserved" context="#stay" String="[\*|U|u][Y|y][E|e][A|a][R|r]"/>- <RegExpr attribute="Reserved" context="#stay" String="[\*|U|u][D|d][A|a][Y|y]"/>- <RegExpr attribute="Reserved" context="#stay" String="\ [P|p][A|a][G|g][E|e][1-7]?"/>- <!-- *ALL(X/G) *BLANKS *ON *OFF *NULL *ZERO(s) *HIVAL *LOVAL *PSSR *END *START-->- <RegExpr attribute="Constant" context="#stay" String="\*([A|a][A|l]{2}[X|x|G|g]?|[B|b][L|l][A|a][N|n][K|k][S|s]?|[O|o][N|n]|[O|o][F|f]{2}|[N|n][U|u][L|l]{2}|[Z|z][E|e][R|r][O|o][S|s]?|[H|h][I|i][V|v][A|a][L|l]|[L|l][O|o][V|v][A|a][L|l]|[P|p][S|s]{2}[R|r]|[E|e][N|n][D|d]|[S|s][T|t][A|a][R|r][T|t])"/>- <!-- Date stuff -->- <RegExpr attribute="Reserved" context="#stay" String="\*[C|c][D|d][M|m][Y|y]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[C|c][M|m][D|d][Y|y]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[C|c][Y|y][M|m][D|d]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[D|d][M|m][Y|y]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[E|e][U|u][R|r]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[H|h][M|m][S|s]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[I|i][S|s][O|o]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[J|j][I|i][S|s]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[J|j][O|o][B|b]([R|r][U|u][N|n])?"/>- <RegExpr attribute="Reserved" context="#stay" String="\*([L|l][O|o][N|n][G|g])?[J|j][U|u][L|l]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[M|m][D|d][Y|y]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[S|s][Y|y][S|s]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[U|u][S|s][A|a]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[Y|y][M|m][D|d]"/>- - <RegExpr attribute="Reserved" context="#stay" String="\*[A|a][L|l][T|t][S|s][E|e][Q|q]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[E|e][Q|q][U|u][A|a][T|t][E|e]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[F|f][I|i][L|l][E|e]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[F|f][T|t][R|r][A|a][N|n][S|s]"/>-- <RegExpr attribute="Reserved" context="#stay" String="\*[I|i][L|l][E|e][R|r][P|p][G|g]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[C|c][R|r][T|t][B|b][N|n][D|d][R|r][P|p][G|g]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[C|c][R|r][T|t][R|r][P|p][G|g][M|m][O|o][D|d]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[V|v][0-9][R|r][0-9][M|m][0-9]"/>- - </context>-- <!-- AnyCode -->- <context name="AnyCode" attribute="Normal Text" lineEndContext="#pop">- <IncludeRules context="CommonCode" />- </context>- - <!-- D -->- <context name="D" attribute="Normal Text" lineEndContext="#pop">- <keyword attribute="Keyword" context="#stay" String="dkeywords"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[N|n][O|o][P|p][A|a][S|s]{2}"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[O|o][M|m][I|i][T|t]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[V|v][A|a][R|r][S|s][I|i][Z|z][E|e]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[R|r][I|i][G|g][H|h][T|t][A|a][D|d][J|j]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[S|s][T|t][R|r][I|i][N|n][G|g]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[T|t][R|r][I|i][M|m]"/>- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <IncludeRules context="CommonCode" />- </context>- - <!-- P -->- <context name="P" attribute="Normal Text" lineEndContext="#pop">- <keyword attribute="Keyword" context="#stay" String="dkeywords"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[N|n][O|o][P|p][A|a][S|s]{2}"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[O|o][M|m][I|i][T|t]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[V|v][A|a][R|r][S|s][I|i][Z|z][E|e]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[R|r][I|i][G|g][H|h][T|t][A|a][D|d][J|j]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[S|s][T|t][R|r][I|i][N|n][G|g]"/>- <RegExpr attribute="Reserved" context="#stay" String="\*[T|t][R|r][I|i][M|m]"/>- <DetectChar attribute="Biff" context="Biffs" char="%"/>- <IncludeRules context="CommonCode" />- </context>- - - </contexts>- <itemDatas>- <itemData name="Alert" defStyleNum="dsAlert" />- <itemData name="Normal Text" defStyleNum="dsNormal" />- <itemData name="Keyword" defStyleNum="dsKeyword" />- <itemData name="Biff" defStyleNum="dsKeyword" />- <itemData name="RegExpr" defStyleNum="dsBaseN" />- <itemData name="Symbol" defStyleNum="dsNormal"/>- <itemData name="Decimal" defStyleNum="dsDecVal" />- <itemData name="Float" defStyleNum="dsFloat"/>- <itemData name="Octal" defStyleNum="dsBaseN"/>- <itemData name="Hex" defStyleNum="dsBaseN"/>- <itemData name="Float" defStyleNum="dsFloat"/>- <itemData name="Base-N" defStyleNum="dsBaseN" />- <itemData name="Float" defStyleNum="dsFloat" />- <itemData name="Char" defStyleNum="dsChar" />- <itemData name="ConstantChar" defStyleNum="dsNormal" color="#DD0022" selColor="#000000" bold="0" italic="0"/>- <itemData name="Constant" defStyleNum="dsNormal" color="#CC2222" selColor="#000000" bold="0" italic="0"/>- <itemData name="Reserved" defStyleNum="dsNormal" color="#BB1133" selColor="#000000" bold="0" italic="0"/>- <itemData name="Indicator" defStyleNum="dsNormal" color="#CC0000" selColor="#000000" bold="0" italic="0"/>- <itemData name="Fill" defStyleNum="dsNormal" color="#FF6347" selColor="#000000" bold="0" italic="0"/>- <itemData name="Comment" defStyleNum="dsComment"/>- <itemData name="BoldComment" defStyleNum="dsNormal" color="#CD853F" selColor="#808080" bold="1" italic="1"/>- <itemData name="DivideComment" defStyleNum="dsComment" bold="1"/>- <itemData name="Directive" defStyleNum="dsOthers"/>- </itemDatas>- </highlighting>- <general>- <keywords casesensitive="0" />- </general>-</language>-
xml/lua.xml view
@@ -213,12 +213,11 @@ </list> <contexts>- <context name="Base" attribute="Comment" lineEndContext="Normal">+ <context name="Base" attribute="Comment" lineEndContext="Normal" fallthrough="true" fallthroughContext="Normal"> <RegExpr attribute="Comment" context="Normal" String="#!.*$" column="0" />- <RegExpr attribute="Comment" context="Normal" String="^.*$" lookAhead="true" /> </context> <context name="Normal" attribute="Normal Text" lineEndContext="#stay">- <IncludeRules context="##DoxygenLua" />+ <!-- <IncludeRules context="##DoxygenLua" /> --> <keyword attribute="Error" context="#stay" String="deprecated" /> <DetectSpaces /> <RegExpr attribute="Comment" context="Block Comment" beginRegion="block comment" String="--\[(=*)\[" dynamic="true" />
+ xml/lua.xml.bkp view
@@ -0,0 +1,304 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE language SYSTEM "language.dtd">+<!--+ LUA (www.lua.org) syntax highlighting for Kate++ CHANGES++ [ Version 1.03 (2007-09-12) by Bruno Massa ]++ - [=[ ]=] comment and string style is now working (thanks to Dominik and Sebastian)+ - it uses DoxygenLua.xml to format the comments in a Doxygen style++ [ Version 1.02 (2007-07-15) by Bruno Massa ]++ - based on Lua 5.1+ - highlight the Kepler function (cgilua, luasql, lfs, luazip)+ - true, false and nil are highlighted in black+ - table.foreach and foreachi are marked as alerts++ [ Version 1.01 (2007-01-01) by Bruno Massa ]++ - highlighting similar to PHP+ - error detection on one-line strings and common mistakes from other languages like using "!=" "++"+ - uppercase-only variables are highlighted as constants+ - { } now is collapsable++ [ Version 1.00 (2006-12-05) by Bruno Massa ]++ - based on Lua 5.0.2 syntax+ - strings "[[ ]]" and single quoted strings+ - block comments+ - function, if/elseif/else, do-end chunks, comment blocks, strings using [[ ]] collapsable+ - nil, false and true consided pseudo-variables (displayed as numbers)+ - NOTE, FIXME, TODO alerts added on comments+ - improved highlighting++ -->+<language name="Lua" version="1.04" indenter="lua" kateversion="2.4" section="Scripts" extensions="*.lua" mimetype="text/x-lua">+ <highlighting>+ <list name="keywords">+ <item> and </item>+ <item> function </item>+ <item> in </item>+ <item> local </item>+ <item> not </item>+ <item> or </item>+ </list>+ <list name="control">+ <item> break </item>+ <item> do </item>+ <item> else </item>+ <item> elseif </item>+ <item> end </item>+ <item> for </item>+ <item> if </item>+ <item> repeat </item>+ <item> return </item>+ <item> then </item>+ <item> until </item>+ <item> while </item>+ </list>+ <list name="pseudo-variables">+ <item> nil </item>+ <item> false </item>+ <item> true </item>+ </list>+ <list name="basefunc">+ <item> string.byte </item> <item> string.char </item>+ <item> string.find </item> <item> string.len </item>+ <item> string.lower </item> <item> string.rep </item>+ <item> string.sub </item> <item> string.upper </item>+ <item> string.format </item><item> string.gfind </item>+ <item> string.gsub </item> <item> table.concat </item>+ <item> table.getn </item> <item> table.sort </item>+ <item> table.insert </item> <item> table.remove </item>+ <item> table.setn </item> <item> math.abs </item>+ <item> math.sin </item> <item> math.cos </item>+ <item> math.tan </item> <item> math.asin </item>+ <item> math.acos </item> <item> math.atan </item>+ <item> math.atan2 </item> <item> math.ceil </item>+ <item> math.floor </item> <item> math.mod </item>+ <item> math.frexp </item> <item> math.ldexp </item>+ <item> math.squrt </item> <item> math.min </item>+ <item> math.max </item> <item> math.log </item>+ <item> math.log10 </item> <item> math.exp </item>+ <item> math.deg </item> <item> math.rad </item>+ <item> math.random </item> <item> math.randomseed </item>+ <item> io.close </item> <item> io.flush </item>+ <item> io.input </item> <item> io.lines </item>+ <item> io.open </item> <item> io.output </item>+ <item> io.read </item> <item> io.stderr </item>+ <item> io.stdin </item> <item> io.stdout </item>+ <item> io.tmpfile </item> <item> io.write </item>+ <item> os.clock </item> <item> os.date </item>+ <item> os.difftime </item> <item> os.execute </item>+ <item> os.exit </item> <item> os.getenv </item>+ <item> os.remove </item> <item> os.rename </item>+ <item> os.setlocale </item> <item> os.time </item>+ <item> os.tmpname </item> <item> debug.getinfo </item>+ <item> debug.getlocal </item><item> debug.setlocal </item>+ <item> debug.sethook </item><item> debug.gethook </item>+ <item> assert </item> <item> collectgarbage </item>+ <item> dofile </item> <item> error </item>+ <item> next </item> <item> print </item>+ <item> rawget </item> <item> rawset </item>+ <item> tonumber </item> <item> tostring </item>+ <item> type </item> <item> _ALERT </item>+ <item> _ERRORMESSAGE </item><item> call </item>+ <item> getmetatable </item><item> gcinfo </item>+ <item> ipairs </item> <item> loadfile </item>+ <item> loadstring </item> <item> pairs </item>+ <item> pcall </item> <item> require </item>+ <item> LUA_PATH </item> <item> setmetatable </item>+ <item> _LOADED </item> <item> _VERSION </item>+ <item> gettagmethod </item><item> globals </item>+ <item> newtag </item> <item> setglobal </item>+ <item> settag </item> <item> settagmethod </item>+ <item> setlinehook </item> <item> getglobals </item>+ <item> copytagmethods </item><item> dostring </item>+ <item> getglobal </item> <item> tag </item>+ <item> setglobals </item> <item> unpack </item>+ <item> exit </item> <item> readfrom </item>+ <item> writeto </item> <item> appendto </item>+ <item> read </item> <item> write </item>+ <item> getinfo </item> <item> getlocal </item>+ <item> setlocal </item> <item> setcallhook </item>+ <item> tinsert </item> <item> tremove </item>+ <item> flush </item> <item> seek </item>+ <item> setlocale </item> <item> execute </item>+ <item> remove </item> <item> rename </item>+ <item> tmpname </item> <item> getenv </item>+ <item> getn </item> <item> sort </item>+ <item> table.foreach </item> <item> table.foreachi </item>+ <item> foreach </item> <item> foreachi </item>+ <item> abs </item> <item> sin </item>+ <item> cos </item> <item> tan </item>+ <item> asin </item> <item> acos </item>+ <item> atan </item> <item> atan2 </item>+ <item> ceil </item> <item> floor </item>+ <item> mod </item> <item> frexp </item>+ <item> ldexp </item> <item> squrt </item>+ <item> min </item> <item> max </item>+ <item> log </item> <item> log10 </item>+ <item> exp </item> <item> deg </item>+ <item> rad </item> <item> random </item>+ <item> randomseed </item> <item> strlen </item>+ <item> strsub </item> <item> strlower </item>+ <item> strupper </item> <item> strchar </item>+ <item> strrep </item> <item> ascii </item>+ <item> strbyte </item> <item> format </item>+ <item> strfind </item> <item> gsub </item>+ <item> openfile </item> <item> closefile </item>+ <item> date </item> <item> clock </item>+++ <item> cgilua </item> <item> cgilua.lp.translate </item>+ <item> cgilua.contentheader </item> <item> cgilua.script_file </item>+ <item> cgilua.header </item> <item> cgilua.script_path </item>+ <item> cgilua.htmlheader </item> <item> cgilua.script_pdir </item>+ <item> cgilua.redirect </item> <item> cgilua.script_vdir </item>+ <item> cgilua.mkabsoluteurl </item> <item> cgilua.script_vpath </item>+ <item> cgilua.mkurlpath </item> <item> cgilua.servervariable </item>+ <item> cgilua.put </item> <item> cgilua.urlpath </item>+ <item> cgilua.handlelp </item> <item> cgilua.errorlog </item>+ <item> cgilua.lp.compile </item> <item> cgilua.seterrorhandler </item>+ <item> cgilua.lp.include </item> <item> cgilua.seterroroutput </item>+ <item> cgilua.lp.setcompatmode </item> <item> cgilua.addclosefunction </item>+ <item> cgilua.lp.setoutfunc </item> <item> cgilua.addopenfunction </item>+ <item> cgilua.addscripthandler </item> <item> cgilua.addscripthandler </item>+ <item> cgilua.buildprocesshandler </item> <item> cgilua.setmaxfilesize </item>+ <item> cgilua.setmaxinput </item> <item> cgilua.urlcode.encodetable </item>+ <item> cgilua.urlcode.escape </item> <item> cgilua.urlcode.parsequery </item>+ <item> cgilua.urlcode.unescape </item> <item> cgilua.urlcode.insertfield </item>+ <item> cgilua.setoutfunc </item> <item> cgilua.addopenfunction </item>+ <item> cgilua.doif </item> <item> cgilua.doscript </item>+ <item> cgilua.pack </item> <item> cgilua.splitpath </item>+ <item> cgilua.cookies.get </item> <item> cgilua.cookies.set </item>+ <item> cgilua.cookies.sethtml </item> <item> cgilua.cookies.delete </item>+ <item> cgilua.serialize </item> <item> cgilua.session.close </item>+ <item> cgilua.session.data </item> <item> cgilua.session.load </item>+ <item> cgilua.session.new </item> <item> cgilua.session.open </item>+ <item> cgilua.session.save </item> <item> cgilua.session.setsessiondir </item>+ <item> cgilua.session.delete </item> <item> cgilua.session </item>+ <item> cgilua.cookies </item>++ <item> numrows </item> <item> connect </item>+ <item> close </item> <item> fetch </item>+ <item> getcolnames </item> <item> getcoltypes </item>+ <item> commit </item> <item> rollback </item>+ <item> setautocommit </item>++ <item> lfs </item> <item> lfs.attributes </item>+ <item> lfs.chdir </item> <item> lfs.currentdir </item>+ <item> lfs.dir </item> <item> lfs.lock </item>+ <item> lfs.mkdir </item> <item> lfs.rmdir </item>+ <item> lfs.touch </item> <item> lfs.unlock </item>++ <item> zip </item> <item> zip.open </item>+ <item> zip.openfile </item> <item> files </item>+ <item> seek </item> <item> close </item>+ <item> lines </item>+++ </list>+ <list name="attention">+ <item> TODO </item>+ <item> FIXME </item>+ <item> NOTE </item>+ </list>+ <list name="deprecated">+ <item> table.foreach </item> <item> table.foreachi </item>+ <item> foreach </item> <item> foreachi </item>+ </list>++ <contexts>+ <context name="Base" attribute="Comment" lineEndContext="Normal">+ <RegExpr attribute="Comment" context="Normal" String="#!.*$" column="0" />+ <RegExpr attribute="Comment" context="Normal" String="^.*$" lookAhead="true" />+ </context>+ <context name="Normal" attribute="Normal Text" lineEndContext="#stay">+ <IncludeRules context="##DoxygenLua" />+ <keyword attribute="Error" context="#stay" String="deprecated" />+ <DetectSpaces />+ <RegExpr attribute="Comment" context="Block Comment" beginRegion="block comment" String="--\[(=*)\[" dynamic="true" />+ <Detect2Chars attribute="Comment" context="Comment" char="-" char1="-"/>+ <RegExpr attribute="Strings" context="String_block" String="\[(=*)\[" dynamic="true" />+ <DetectChar attribute="Strings" context="String_single" char="'"/>+ <DetectChar attribute="Strings" context="String_double" char="""/>+ <keyword attribute="BFunc" context="#stay" String="basefunc"/>++ <RegExpr attribute="Keyword" context="#stay" beginRegion="chunk" String="\bfunction\b" />+ <keyword attribute="Keyword" context="#stay" String="keywords" />+ <keyword attribute="Keyword" context="#stay" String="pseudo-variables" />+ <RegExpr attribute="Control" context="#stay" endRegion="chunk" beginRegion="chunk" String="\belse\b" />+ <RegExpr attribute="Control" context="#stay" endRegion="chunk" beginRegion="chunk" String="\belseif\b" />+ <RegExpr attribute="Control" context="#stay" beginRegion="chunk" String="\bdo\b" />+ <RegExpr attribute="Control" context="#stay" beginRegion="chunk" String="\bif\b" />+ <RegExpr attribute="Control" context="#stay" endRegion="chunk" String="\bend\b" />+ <keyword attribute="Control" context="#stay" String="control" />++ <DetectChar attribute="Symbols" context="#stay" beginRegion="table" char="{" />+ <DetectChar attribute="Symbols" context="#stay" endRegion="table" char="}" />++ <RegExpr attribute="Numbers" context="#stay" String="\b\d*\.?\d*(e|e\-|e\+)?\d+\b"/>+ <RegExpr attribute="Numbers" context="#stay" String="\b-?0[xX][0-9a-fA-F]+\b"/>++ <RegExpr attribute="Normal Text" context="#stay" String="\b[a-zA-Z_][a-zA-Z0-9_]*(?=\s*([({'"]|\[\[))\b" />+ <RegExpr attribute="Constant" context="#stay" String="\b[A-Z_][A-Z0-9_]*\b" />+ <RegExpr attribute="Variable" context="#stay" String="\b[a-zA-Z_][a-zA-Z0-9_]*\b" />++ <Detect2Chars attribute="Error" context="#stay" char="!" char1="="/>+ <Detect2Chars attribute="Error" context="#stay" char="-" char1="="/>+ <Detect2Chars attribute="Error" context="#stay" char="+" char1="="/>+ <Detect2Chars attribute="Error" context="#stay" char="+" char1="+"/>+ <Detect2Chars attribute="Error" context="#stay" char="." char1="="/>+ <AnyChar attribute="Symbols" context="#stay" String="[]().=~+-*/^><#;" />+ </context>+ <context name="Comment" attribute="Comment" lineEndContext="#pop">+ <Detect2Chars attribute="Alerts" context="#stay" char="-" char1="-" />+ <keyword attribute="Alerts" context="#stay" String="attention"/>+ </context>+ <context name="Block Comment" attribute="Comment" lineEndContext="#stay" dynamic="true" >+ <RegExpr attribute="Comment" context="#pop" endRegion="block comment" String="\]%1\]" dynamic="true" />+ <Detect2Chars attribute="Alerts" context="#stay" char="-" char1="-" />+ <keyword attribute="Alerts" context="#stay" String="attention" />+ </context>+ <context name="String_single" attribute="Strings" lineEndContext="Error">+ <RegExpr attribute="Symbols" context="#stay" String="\\(a|b|f|n|r|t|v|\\|"|\'|[|])" />+ <DetectChar attribute="Strings" context="#pop" char="'"/>+ </context>+ <context name="String_double" attribute="Strings" lineEndContext="Error">+ <RegExpr attribute="Symbols" context="#stay" String="\\[abfnrtv'"\\\[\]]" />+ <DetectChar attribute="Strings" context="#pop" char="""/>+ </context>+ <context name="String_block" attribute="Strings" lineEndContext="#stay" dynamic="true">+ <RegExpr attribute="Symbols" context="#stay" String="\\(a|b|f|n|r|t|v|\\|"|\'|[|])" />+ <RegExpr attribute="Strings" context="#pop" String="\]%1\]" dynamic="true" />+ </context>+ <context name="Error" attribute="Error" lineEndContext="#stay">+ </context>+ </contexts>+ <itemDatas>+ <itemData name="Alerts" defStyleNum="dsAlert" />+ <itemData name="BFunc" defStyleNum="dsFunction"/>+ <itemData name="Comment" defStyleNum="dsComment"/>+ <itemData name="Constant" defStyleNum="dsKeyword"/>+ <itemData name="Control" defStyleNum="dsKeyword" color="#A1A100" selColor="#ffffff" bold="0" italic="0"/>+ <itemData name="Error" defStyleNum="dsError"/>+ <itemData name="Keyword" defStyleNum="dsKeyword"/>+ <itemData name="Normal Text" defStyleNum="dsNormal"/>+ <itemData name="Numbers" defStyleNum="dsDecVal"/>+ <itemData name="Strings" defStyleNum="dsString"/>+ <itemData name="Symbols" defStyleNum="dsOthers"/>+ <itemData name="Variable" defStyleNum="dsKeyword" color="#5555FF" selColor="#ffffff" bold="0" italic="0" />+ </itemDatas>+ </highlighting>+ <general>+ <comments>+ <comment name="singleLine" start="--" />+ <comment name="multiLine" start="--[[" end="]]" />+ </comments>+ <keywords casesensitive="1" weakDeliminator="." additionalDeliminator="""/>+ </general>+</language>
− xml/mediawiki.xml
@@ -1,98 +0,0 @@-<?xml version = '1.0' encoding = 'UTF-8'?>-<!DOCTYPE language SYSTEM "language.dtd">-<language name="MediaWiki" section="Markup" version="1.02" kateversion="2.4" extensions="" mimetype="" license="FDL" >- <highlighting>- <contexts>- <context attribute="Normal" lineEndContext="#stay" name="normal" >- <StringDetect String="<!--" context="comment" attribute="Comment" beginRegion="comment" />- <RegExpr String="([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})" attribute="Section" column="0" />- <RegExpr String="[~]{3,4}" attribute="Wiki-Tag" context="#stay" />- <RegExpr String="[*#;:\s]*[*#:]+" attribute="Wiki-Tag" context="#stay" column="0" />- <RegExpr String="[[](?![[])" attribute="Wiki-Tag" context="URL" />- <RegExpr String="(http:|ftp:|mailto:)[\S]*($|[\s])" attribute="URL" context="#stay" />- <RegExpr String="[']{2,}" attribute="Wiki-Tag" context="#stay" />- <Detect2Chars char="{" char1="|" context="Table" attribute="Wiki-Tag" column="0" beginRegion="table" />- <Detect2Chars char="{" char1="{" context="Template" attribute="Wiki-Tag" />- <Detect2Chars char="[" char1="[" context="WikiLink" attribute="Wiki-Tag" />- <RangeDetect char="&" char1=";" attribute="HTML-Entity" context="#stay" />- <StringDetect String="<nowiki>" context="NoWiki" attribute="Wiki-Tag" />- <StringDetect String="<pre>" context="Pre" attribute="HTML-Tag" />- <RegExpr String="[<][^>]+[>]" attribute="HTML-Tag" context="#stay" />- <RegExpr String="[\s]" context="Unformatted" column="0" />- </context>- <context attribute="Normal" lineEndContext="#stay" name="Table" >- <StringDetect String="<!--" context="comment" attribute="Comment" />- <RegExpr String="([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})" attribute="Section" context="#stay" column="0" />- <RegExpr String="[*#;:\s]*[*#:]+" attribute="Wiki-Tag" context="#stay" column="0" />- <RegExpr String="[[](?![[])" context="URL" attribute="Wiki-Tag" />- <RegExpr String="(http:|ftp:|mailto:)[\S]*($|[\s])" attribute="URL" context="#stay" />- <RegExpr String="[']{2,}" attribute="Wiki-Tag" context="#stay" />- <Detect2Chars char="|" char1="}" context="#pop" attribute="Wiki-Tag" column="0" endRegion="table" />- <DetectChar char="|" attribute="Wiki-Tag" context="#stay"/>- <Detect2Chars char="{" char1="{" context="Template" attribute="Wiki-Tag" />- <Detect2Chars char="[" char1="[" context="WikiLink" attribute="Wiki-Tag" />- <RangeDetect char="&" char1=";" attribute="HTML-Entity" context="#stay" />- <StringDetect String="<nowiki>" context="NoWiki" attribute="Wiki-Tag" />- <StringDetect String="<pre>" context="Pre" attribute="HTML-Tag" />- <RegExpr String="[<][^>]+[>]" attribute="HTML-Tag" context="#stay" />- <RegExpr String="[\s]" context="Unformatted" column="0" />- <RegExpr String="[~]{3,4}" attribute="Wiki-Tag" context="#stay" />- <RegExpr String="[-]{4,}" attribute="Wiki-Tag" context="#stay" />- <DetectChar char="!" attribute="Wiki-Tag" context="#stay" column="0" />- </context>- <context attribute="Comment" lineEndContext="#stay" name="comment" >- <StringDetect String="-->" context="#pop" attribute="Comment" endRegion="comment" />- </context>- <context attribute="Link" lineEndContext="#stay" name="URL" >- <DetectChar char="]" context="#pop" attribute="Wiki-Tag" />- <DetectChar char="'" context="Error" attribute="Error" />- </context>- <context attribute="Link" lineEndContext="#stay" name="WikiLink" >- <DetectChar char="|" attribute="Wiki-Tag" context="WikiLinkDescription" />- <Detect2Chars char="]" char1="]" context="#pop" attribute="Wiki-Tag" />- <DetectChar char="'" context="Error" attribute="Error" />- </context>- <context attribute="Link" lineEndContext="#stay" name="WikiLinkDescription" >- <Detect2Chars char="]" char1="]" context="#pop" attribute="Wiki-Tag" lookAhead="true" />- </context>- <context attribute="Template" lineEndContext="#stay" name="Link" >- <Detect2Chars char="}" char1="}" context="#pop" attribute="Wiki-Tag" />- <AnyChar String="'[]" context="Error" attribute="Error" />- </context>- <context attribute="Error" lineEndContext="#pop" name="Error" />- <context attribute="Link" lineEndContext="#stay" name="Template" >- <Detect2Chars char="}" char1="}" context="#pop" attribute="Wiki-Tag" />- <DetectChar char="'" context="Error" attribute="Error" />- </context>- <context attribute="NoWiki" lineEndContext="#stay" name="NoWiki" >- <RegExpr String="<!--[^-]*-->" attribute="NoWiki" />- <StringDetect String="</nowiki>" context="#pop" attribute="Wiki-Tag" />- <RegExpr String="[<][^>]+[>]" attribute="HTML-Tag" context="#stay" />- <StringDetect String="<pre>" context="Pre" attribute="HTML-Tag" />- </context>- <context attribute="Unformatted" lineEndContext="#pop" name="Unformatted" />- <context attribute="NoWiki" lineEndContext="#stay" name="Pre" >- <StringDetect String="</pre>" context="#pop" attribute="Wiki-Tag" />- </context>- </contexts>- <itemDatas>- <itemData name="Normal" defStyleNum="dsNormal" />- <itemData name="Link" defStyleNum="dsOthers" />- <itemData name="URL" defStyleNum="dsOthers" />- <itemData name="Comment" defStyleNum="dsComment" />- <itemData name="Section" defStyleNum="dsKeyword" />- <itemData name="HTML-Entity" defStyleNum="dsDecVal" />- <itemData name="HTML-Tag" defStyleNum="dsKeyword" />- <itemData name="Wiki-Tag" defStyleNum="dsDecVal" bold="true" />- <itemData name="Error" defStyleNum="dsError" />- <itemData name="NoWiki" defStyleNum="dsNormal" />- <itemData name="Unformatted" defStyleNum="dsNormal" />- </itemDatas>- </highlighting>- <general>- <comments>- <comment end="//-->" start="<!--" name="multiLine" />- </comments>- <keywords casesensitive="0" />- </general>-</language>
− xml/xharbour.xml
@@ -1,543 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE language SYSTEM "language.dtd">-<language name="xHarbour" version="1.04" kateversion="2.4" section="Sources" extensions="*.prg;*.PRG;*.ch" mimetype="text/x-xharbour-src" priority="5" author="Giancarlo Niccolai (giancarlo@niccolai.ws)" license="GPL">-<highlighting>-- <list name="keywords">- <item> local </item>- <item> global </item>- <item> extern </item>- <item> field </item>- <item> each </item>- <item> as </item>- <item> set </item>- <item> clear </item>- <item> screen </item>- <item> databases </item>- <item> all </item>- <item> close </item>- <item> color </item>- <item> date </item>- <item> else </item>- <item> elseif </item>- <item> in </item>- <item> to </item>- <item> do </item>- <item> loop </item>- <item> catch </item>- <item> exit </item>- <item> box </item>- <item> say </item>- <item> case </item>- <item> switch </item>- <item> self </item>- <item> super </item>- <item> say </item>- <item> get </item>- <item> read </item>- <item> use </item>- <item> select </item>- <item> otherwise</item>- <item> index </item>- <item> alias </item>- <item> like </item>- <item> has </item>- <item> return </item>- <item> static </item>- <item> on </item>- <item> off </item>- <item> nil </item>- <item> ? </item>- <item> class </item>- <item> external</item>- </list>-- <list name="context_beginners">- <item> FOR </item>- <item> IF </item>- <item> SWITCH </item>- <item> WHILE </item>- <item> TRY </item>- <item> BEGIN </item>- <item> PROCEDURE </item>- <item> FUNCTION </item>- <item> METHOD </item>- </list>-- <list name="context_terminators">- <item> NEXT </item>- <item> END </item>- <item> ENDIF </item>- <item> ENDDO </item>- <item> ENDCASE </item>- </list>-- <list name="class_keywords">- <item> data </item>- <item> inline </item>- <item> method </item>- <item> classdata </item>- <item> init </item>- <item> from </item>- <item> hidden </item>- </list>-- <list name="set_commands">- <item> INVALID </item>- <item> EXACT </item>- <item> FIXED </item>- <item> DECIMALS </item>- <item> DATEFORMAT </item>- <item> EPOCH </item>- <item> PATH </item>- <item> DEFAULT </item>- <item> EXCLUSIVE </item>- <item> SOFTSEEK </item>- <item> UNIQUE </item>- <item> DELETED </item>- <item> CANCEL </item>- <item> DEBUG </item>- <item> TYPEAHEAD </item>- <item> COLOR </item>- <item> CURSOR </item>- <item> CONSOLE </item>- <item> ALTERNATE </item>- <item> ALTFILE </item>- <item> DEVICE </item>- <item> EXTRA </item>- <item> EXTRAFILE </item>- <item> PRINTER </item>- <item> PRINTFILE </item>- <item> MARGIN </item>- <item> BELL </item>- <item> CONFIRM </item>- <item> ESCAPE </item>- <item> INSERT </item>- <item> EXIT </item>- <item> INTENSITY </item>- <item> SCOREBOARD </item>- <item> DELIMITERS </item>- <item> DELIMCHARS </item>- <item> WRAP </item>- <item> MESSAGE </item>- <item> MCENTER </item>- <item> SCROLLBREAK </item>- <item> EVENTMASK </item>- <item> VIDEOMODE </item>- <item> MBLOCKSIZE </item>- <item> MFILEEXT </item>- <item> STRICTREAD </item>- <item> OPTIMIZE </item>- <item> AUTOPEN </item>- <item> AUTORDER </item>- <item> AUTOSHARE </item>- <item> LANGUAGE </item>- <item> IDLEREPEAT </item>- <item> TRACE </item>- <item> TRACEFILE </item>- <item> TRACESTACK </item>- <item> FILECASE </item>- <item> DIRCASE </item>- <item> DIRSEPARATOR </item>- </list>-- <list name="functions">- <item> aadd </item>- <item> adel </item>- <item> achoice </item>- <item> aclone </item>- <item> aeval </item>- <item> ains </item>- <item> ascan </item>- <item> asize </item>- <item> adir </item>- <item> afill </item>- <item> atail </item>- <item> asort </item>- <item> array </item>- <item> TAssociativeArray </item>-- <item> bin21 </item>- <item> bin2l </item>- <item> bin2u </item>- <item> bin2w </item>- <item> i2bin </item>- <item> l2bin </item>- <item> u2bin </item>- <item> w2bin </item>-- <item> eval </item>- <item> fieldblock </item>- <item> fieldwblock </item>-- <item> inkey </item>- <item> lastkey </item>- <item> mcol </item>- <item> mrow </item>- <item> nextkey </item>-- <item> empty </item>- <item> word </item>- <item> descend </item>- <item> __dbdelim </item>- <item> __dbsdf </item>-- <item> os </item>- <item> __run </item>-- <item> alert </item>- <item> browse </item>- <item> dbedit </item>- <item> outerr </item>- <item> outstd </item>- <item> readkey </item>- <item> readvar </item>- <item> __atprompt </item>- <item> __input </item>- <item> __menuto </item>- <item> __nonoallert </item>- <item> __typefile </item>- <item> __xrestscreen </item>- <item> __xsavescreen </item>-- <item> DBAPPEND </item>- <item> DBCLEARFILTER </item>- <item> DBCLOSEALL </item>- <item> DBCLOSEAREA </item>- <item> DBCOMMIT </item>- <item> DBCOMMITALL </item>- <item> DBCREATE </item>- <item> DBDELETE </item>- <item> DBEVAL </item>- <item> DBF </item>- <item> DBFILTER </item>- <item> DBGOBOTTOM </item>- <item> DBGOTO </item>- <item> DBGOTOP </item>- <item> DBRECALL </item>- <item> DBRLOCK </item>- <item> DBRLOCKLIST </item>- <item> DBRUNLOCK </item>- <item> DBSEEK </item>- <item> DBSELECTAREA </item>- <item> DBSETDRIVER </item>- <item> DBSETFILTER </item>- <item> DBSKIP </item>- <item> DBSTRUCT </item>- <item> DBUNLOCK </item>- <item> DBUNLOCKALL </item>- <item> DBUSEAREA </item>- <item> INDEXEXT </item>- <item> INDEXKEY </item>- <item> INDEXORD </item>- <item> ORDBAGEXT </item>- <item> ORDBAGNAME </item>- <item> ORDCONDSET </item>- <item> ORDCREATE </item>- <item> ORDDESTROY </item>- <item> ORDFOR </item>- <item> ORDKEY </item>- <item> ORDLISTADD </item>- <item> ORDLISTCLEAR </item>- <item> ORDLISTREBUILD </item>- <item> ORDNAME </item>- <item> ORDNUMBER </item>- <item> ORDSETFOCUS </item>- <item> RDDLIST </item>- <item> RDDNAME </item>- <item> RDDSETDEFAULT </item>- <item> __DBCONTINUE </item>- <item> __DBZAP </item>- <item> __FLEDIT </item>- <item> __RDDSETDEFAULT </item>- <item> __dbCopyStruct </item>- <item> __dbCopyXStruct </item>- <item> __dbCreate </item>- <item> __dbStructFilter </item>- <item> dbSkipper </item>- <item> CDOW </item>- <item> CMONTH </item>- <item> CTOD </item>- <item> DATE </item>- <item> DAY </item>- <item> DAYS </item>- <item> DOW </item>- <item> DTOC </item>- <item> DTOS </item>- <item> MONTH </item>- <item> YEAR </item>-- <item> GETENV </item>- <item> SET </item>- <item> SETMODE </item>- <item> SETTYPEAHEAD </item>- <item> VERSION </item>- <item> __SETCENTURY </item>- <item> __SetFunction </item>-- <item> break </item>- <item> errorsys </item>- <item> throw </item>- <item> errornew </item>-- <item> HB_SETKEYSAVE </item>- <item> HB_SetKeyCheck </item>- <item> HB_SetKeyGet </item>- <item> SETKEY </item>- <item> __QUIT </item>- <item> __WAIT </item>-- <item> file </item>- <item> frename </item>- <item> __dir </item>-- <item> col </item>- <item> maxcol </item>- <item> maxrow </item>- <item> row </item>- <item> hb_colorindex </item>-- <item> CURDIR </item>- <item> DIRCHANGE </item>- <item> DIRREMOVE </item>- <item> DISKSPACE </item>- <item> FCLOSE </item>- <item> FCREATE </item>- <item> FERASE </item>- <item> FERROR </item>- <item> FOPEN </item>- <item> FREAD </item>- <item> FREADSTR </item>- <item> FSEEK </item>- <item> FWRITE </item>- <item> HB_DISKSPACE </item>- <item> HB_FEOF </item>- <item> ISDISK </item>- <item> MAKEDIR </item>-- <item> ABS </item>- <item> EXP </item>- <item> INT </item>- <item> LOG </item>- <item> MAX </item>- <item> MIN </item>- <item> MOD </item>- <item> ROUND </item>- <item> SQRT </item>-- <item> HB_ISBYREF </item>- <item> PROCFILE </item>- <item> PROCLINE </item>- <item> PROCNAME </item>- <item> TYPE </item>- <item> VALTYPE </item>- <item> valtoprg </item>- <item> tone </item>-- <item> HB_LANGNAME </item>- <item> HB_LANGSELECT </item>- <item> ISAFFIRM </item>- <item> ISNEGATIVE </item>- <item> NATIONMSG </item>-- <item> pcount </item>- <item> HB_pvalue </item>-- <item> ALLTRIM </item>- <item> ASC </item>- <item> AT </item>- <item> CHR </item>- <item> HARDCR </item>- <item> HB_ANSITOOEM </item>- <item> HB_OEMTOANSI </item>- <item> HB_VALTOSTR </item>- <item> ISALPHA </item>- <item> ISDIGIT </item>- <item> ISLOWER </item>- <item> ISUPPER </item>- <item> LEFT </item>- <item> LEN </item>- <item> LOWER </item>- <item> LTRIM </item>- <item> MEMOTRAN </item>- <item> PADC </item>- <item> PADL </item>- <item> PADR </item>- <item> RAT </item>- <item> REPLICATE </item>- <item> RIGHT </item>- <item> RTRIM </item>- <item> SPACE </item>- <item> STR </item>- <item> STRTRAN </item>- <item> STRZERO </item>- <item> SUBSTR </item>- <item> TRANSFORM </item>- <item> TRIM </item>- <item> UPPER </item>- <item> VAL </item>-- <item> devoutpict </item>-- <item> elaptime </item>- <item> seconds </item>- <item> secs </item>- <item> time </item>-- <item> do </item>-- <item> ThreadStart </item>- <item> ThreadStop </item>- <item> ThreadSleep </item>- <item> ThreadKill </item>- <item> ThreadJoin </item>- <item> CreateMutex </item>- <item> DestroyMutex </item>- <item> MutexLock </item>- <item> MutexUnlock </item>- <item> Subscribe </item>- <item> SubscribeNow </item>- <item> Notify </item>- <item> NotifyAll </item>- <item> WaitForThreads </item>- <item> KillAllThreads </item>-- <item> InetInit </item>- <item> InetCleanup </item>- <item> InetCreate </item>- <item> InetDestroy </item>- <item> InetConnect </item>- <item> InetServer </item>- <item> InetAccept </item>- <item> InetSetTimeout </item>- <item> InetGetTimeout </item>- <item> InetClearTimeout </item>- <item> InetRecv </item>- <item> InetRecvAll </item>- <item> InetSend </item>- <item> InetSendAll </item>- <item> InetDGram </item>- <item> InetDGramRecv </item>- <item> InetDGramSend </item>- <item> InetAddress </item>- <item> InetPort </item>- <item> InetError </item>- <item> InetErrorDesc </item>- <item> InetGetHosts </item>- <item> InetConnectIP </item>-- <item> hb_regex </item>- <item> hb_regexmatch </item>- <item> hb_regexsplit </item>- <item> hb_regexcomp </item>- <item> hb_readini </item>- <item> hb_writeini </item>- <item> hb_random </item>- <item> hb_chechsum </item>- <item> hb_crypt </item>- <item> hb_decrypt </item>- <item> hb_hextonum </item>- <item> hb_numtohex </item>- <item> hb_exec </item>- <item> hb_execfromarray </item>-- <item> hb_class </item>- <item> hb_keyput </item>- <item> hb_osnewline </item>-- </list>-- <list name="pragma">- <item> #include </item>- <item> #if </item>- <item> #ifdef </item>- <item> #ifndef </item>- <item> #endif </item>- <item> #else </item>- <item> #define </item>- </list>-- <contexts>- <context attribute="Normal Text" lineEndContext="#stay" name="TopLevel">-- <Detect2Chars attribute="Comment" context="ml_comment" char="/" char1="*" beginRegion="comment_region"/>- <DetectChar attribute="Comment" context="comment" char="*" firstNonSpace="true"/>- <Detect2Chars attribute="Comment" context="comment" char="/" char1="/" />-- <DetectChar attribute="String" context="string" char=""" />- <DetectChar attribute="String" context="stringc" char="'" />-- <StringDetect attribute="Operator" context="#stay" String=".and." insensitive="TRUE"/>- <StringDetect attribute="Operator" context="#stay" String=".or." insensitive="TRUE"/>- <StringDetect attribute="Operator" context="#stay" String=".not." insensitive="TRUE"/>- <StringDetect attribute="Operator" context="#stay" String=".f." insensitive="TRUE"/>- <StringDetect attribute="Operator" context="#stay" String=".t." insensitive="TRUE"/>-- <AnyChar attribute="Operator" context="#stay" String=":=!" />- <DetectChar attribute="Keyword" context="#stay" char="@"/>-- <RegExpr String="CLASS[\t ]+" attribute="Keyword" context="ClassContext" insensitive="TRUE" beginRegion="ClassDeclRegion" firstNonSpace="true"/>-- <RegExpr String="DO[\t ]+CASE[\t ]*$" attribute="Keyword" context="#stay" insensitive="TRUE" beginRegion="IndentRegion" firstNonSpace="true"/>- <keyword attribute="Keyword" context="#stay" String="context_beginners" beginRegion="IndentRegion" />- <keyword attribute="Keyword" context="#stay" String="context_terminators" endRegion="IndentRegion" />- <RegExpr String="return ?" attribute="Keyword" context="#stay" insensitive="TRUE" endRegion="IndentRegion" column="0"/>-- <keyword attribute="Keyword" context="#stay" String="keywords" />- <keyword attribute="Keyword" context="#stay" String="set_commands" />- <keyword attribute="Function" context="#stay" String="functions" />- <keyword attribute="Preprocessor" context="#stay" String="pragma" />- <Detect2Chars attribute="Operator" context="#stay" char="-" char1=">" />- <RegExpr attribute="Number" context="#stay" String="\d+" />- </context>-- <context attribute="Comment" lineEndContext="#pop" name="comment"/>-- <context attribute="Comment" lineEndContext="#stay" name="ml_comment">- <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="comment_region"/>- </context>-- <context attribute="String" lineEndContext="#pop" name="string">- <DetectChar attribute="String" context="#pop" char=""" />- </context>- <context attribute="String" lineEndContext="#pop" name="stringc">- <DetectChar attribute="String" context="#pop" char="'" />- </context>-- <context attribute="Operator" lineEndContext="#pop" name="logic">- <DetectChar attribute="Operator" context="#pop" char="." />- </context>-- <context attribute="Normal Text" lineEndContext="#stay" name="ClassContext">-- <Detect2Chars attribute="Comment" context="ml_comment" char="/" char1="*" beginRegion="comment_region"/>- <DetectChar attribute="Comment" context="comment" char="*" firstNonSpace="true"/>- <Detect2Chars attribute="Comment" context="comment" char="/" char1="/" />-- <keyword attribute="Keyword" context="#stay" String="class_keywords" />- <RegExpr String="END(CLASS)? *$" attribute="Keyword" context="#pop" insensitive="TRUE" endRegion="ClassDeclRegion" firstNonSpace="true"/>- </context>-- </contexts>-- <itemDatas>- <itemData name="Normal Text" defStyleNum="dsNormal"/>- <itemData name="Keyword" defStyleNum="dsKeyword"/>- <itemData name="Comment" defStyleNum="dsComment"/>- <itemData name="Operator" defStyleNum="dsBaseN" color="#A01060" selColor="#400040" bold="0" italic="0"/>- <itemData name="Number" defStyleNum="dsDecVal" color="#5050C0" selColor="#000000" bold="0" italic="0"/>- <itemData name="Function" defStyleNum="dsFunction" />- <itemData name="String" defStyleNum="dsString"/>- <itemData name="Preprocessor" defStyleNum="dsOthers"/>- </itemDatas>-</highlighting>--<general>- <comments>- <comment name="singleLine" start="*" />- <comment name="singleLine" start="//" />- <comment name="multiLine" start="/*" end="*/" />- </comments>- <keywords casesensitive="0" />-</general>-</language>