(file) Return to haskell.st CVS log (file) (dir) Up to [RizwankCVS] / testProject / states / hl

  1 rizwank 1.1 /**
  2              * Name: haskell
  3              * Description: Haskell programming language.
  4              *
  5              * Simple highlighting treating keywords, comments, strings and type
  6              * expressions specially.
  7              *
  8              * Author: Hans-Wolfgang Loidl <hwloidl@dcs.gla.ac.uk>
  9              * Date: 27/2/97
 10              */
 11             
 12             state haskell extends HighlightEntry
 13             {
 14               /* Comments. */
 15               /\{\-/ {
 16                 comment_face (true);
 17                 language_print ($0);
 18                 call (haskell_comment);
 19                 comment_face (false);
 20               }
 21             
 22 rizwank 1.1   /* One line comments. */
 23               /\-\-/ {
 24                 comment_face (true);
 25                 language_print ($0);
 26                 call (eat_one_line);
 27                 comment_face (false);
 28               }
 29             
 30               /* Built-in beasts (GHC specific). */
 31               /\b\_/ {
 32                 keyword_face (true);
 33                 language_print ($0);
 34                 call (haskell_builtin);
 35                 keyword_face (false);
 36               }
 37             
 38               /* Type declarations. */
 39               /::/ {
 40                 type_face (true);
 41                 language_print ($0);
 42                 call (eat_one_line);
 43 rizwank 1.1     /* call (haskell_type); */
 44                 type_face (false);
 45               }
 46             
 47               /* String constants. */
 48               /\"/ {
 49                 string_face (true);
 50                 language_print ($0);
 51                 call (haskell_string);
 52                 string_face (false);
 53               }
 54             
 55               /* Pre-processor lines. */
 56               /^#/ {
 57                 reference_face (true);
 58                 language_print ($0);
 59                 call (eat_one_line);
 60                 /* call (haskell_ppline); */
 61                 reference_face (false);
 62               }
 63             
 64 rizwank 1.1   /* Character constants. */
 65               /'.'|'\\.'/ {
 66                 string_face (true);
 67                 language_print ($0);
 68                 string_face (false);
 69               }
 70             
 71               /* Keywords.
 72                  I took that from haskell.el. The True Way to do it would be to grab it
 73                  out of the on-line haskell report (actually, The Real True Way would
 74                  be to write a Haskell program that extracts different kinds of
 75                  keywords and to partially evaluate it wrt the Haskell report; but that
 76                  might be a wee overkill).
 77                  (let ((strings
 78             	'("case" "class" "data" "default" "deriving" "else" "hiding" "if" "import" "in" "\
 79             	  infix" "infixl" "infixr" "instance" "interface" "let" "module" "of" "renaming" "\
 80             	  then" "to" "type" "where" )))
 81                   (make-regexp strings)
 82                  )
 83                  ==>
 84                  \(infix\|then\)\|c\(ase\|lass\)\|d\(ata\|e\(fault\|riving\)\)\|else\|hiding\|i\([fn]\|mport\|n\(fix[lr]\|stance\|terface\)\)\|let\|module\|of\|renaming\|t\(o\|ype\)\|where
 85 rizwank 1.1    */
 86               /\b((infix|then)|c(ase|lass)|d(ata|e(fault|riving))|else|hiding|i([fn]|mport|n(fix[lr]|stance|terface))|let|module|of|renaming|t(o|ype)|where)\b/ {
 87                 keyword_face (true);
 88                 language_print ($0);
 89                 keyword_face (false);
 90               }
 91             }
 92             
 93             state haskell_comment extends Highlight
 94             {
 95               /\-\}/ {
 96                 language_print ($0);
 97                 return;
 98               }
 99             }
100             
101             /* HWL: for GHC builtin objects like _parGlobal_ i.e. not std Haskell */
102             state haskell_builtin extends Highlight
103             {
104               /(\_\b)| / {
105                 language_print ($0);
106 rizwank 1.1     return;
107               }
108             }
109             
110             state haskell_type extends Highlight
111             {
112               /* ToDo: Implement type continuation lines:
113             	   If the line ends in a -> or the next starts with a -> then we
114             	   are still in a type expression
115               */
116               /\n/ {
117                 language_print ($0);
118                 return;
119               }
120             }
121             
122             state haskell_string extends Highlight
123             {
124               /\\\\./ {
125                 language_print ($0);
126               }
127 rizwank 1.1   /\"/ {
128                 language_print ($0);
129                 return;
130               }
131             }
132             
133             state haskell_ppline extends Highlight
134             {
135               /\/\*/ {
136                 /* Comment within a pre-processor line. */
137                 reference_face (false);
138                 comment_face (true);
139                 language_print ($0);
140                 call (c_comment);
141                 comment_face (false);
142                 reference_face (true);
143               }
144               /\n/ {
145                 language_print ($0);
146                 return;
147               }
148 rizwank 1.1 }
149             
150             
151             /*
152             Local variables:
153             mode: c
154             End:
155             */

Rizwan Kassim
Powered by
ViewCVS 0.9.2