~ubuntu-branches/ubuntu/trusty/highlighting-kate/trusty

« back to all changes in this revision

Viewing changes to Text/Highlighting/Kate/Syntax/Pascal.hs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2010-08-02 16:42:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100802164227-hlexp5w850rpfizp
Tags: 0.2.7.1-1
* Priority: extra
* New upstream version (Closes: #591168)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import Text.Highlighting.Kate.Definitions
6
6
import Text.Highlighting.Kate.Common
7
7
import Text.ParserCombinators.Parsec
8
 
import Data.List (nub)
 
8
import Control.Monad (when)
 
9
import Data.Map (fromList)
 
10
import Data.Maybe (fromMaybe, maybeToList)
 
11
 
9
12
import qualified Data.Set as Set
10
 
import Data.Map (fromList)
11
 
import Data.Maybe (fromMaybe)
12
 
 
13
13
-- | Full name of language.
14
14
syntaxName :: String
15
15
syntaxName = "Pascal"
62
62
  updateState $ \st -> st { synStCurrentLine = lineContents, synStCharsParsedInLine = 0, synStPrevChar = '\n' }
63
63
 
64
64
withAttribute attr txt = do
65
 
  if null txt
66
 
     then fail "Parser matched no text"
67
 
     else return ()
68
 
  let style = fromMaybe "" $ lookup attr styles
 
65
  when (null txt) $ fail "Parser matched no text"
 
66
  let labs = attr : maybeToList (lookup attr styles)
69
67
  st <- getState
70
68
  let oldCharsParsed = synStCharsParsedInLine st
71
69
  let prevchar = if null txt then '\n' else last txt
72
70
  updateState $ \st -> st { synStCharsParsedInLine = oldCharsParsed + length txt, synStPrevChar = prevchar } 
73
 
  return (nub [style, attr], txt)
 
71
  return (labs, txt)
74
72
 
75
 
styles = [("Normal Text","Normal"),("Keyword","Keyword"),("ISO/Delphi Extended","Keyword"),("Type","DataType"),("Number","DecVal"),("String","String"),("Directive","Others"),("Comment","Comment"),("Alert","Alert")]
 
73
styles = [("Keyword","kw"),("ISO/Delphi Extended","kw"),("Type","dt"),("Number","dv"),("String","st"),("Directive","ot"),("Comment","co"),("Alert","al")]
76
74
 
77
75
parseExpressionInternal = do
78
76
  context <- currentContext