File Coverage

blib/lib/Syntax/Highlight/Engine/Kate/Literate_Haskell.pm
Criterion Covered Total %
statement 75 87 86.2
branch 37 44 84.0
condition 1 3 33.3
subroutine 10 13 76.9
pod 0 10 0.0
total 123 157 78.3


line stmt bran cond sub pod time code
1             # Copyright (c) 2005 - 2006 Hans Jeuken. All rights reserved.
2             # This program is free software; you can redistribute it and/or
3             # modify it under the same terms as Perl itself.
4              
5             # This file was generated from the 'literate-haskell.xml' file of the syntax highlight
6             # engine of the kate text editor (http://www.kate-editor.org
7              
8             #kate xml version 1.04
9             #kate version 2.4
10             #kate author Marcel Martin (mmar@freenet.de)
11             #generated: Sun Feb 3 22:02:05 2008, localtime
12              
13             package Syntax::Highlight::Engine::Kate::Literate_Haskell;
14              
15             our $VERSION = '0.12';
16              
17 1     1   590 use strict;
  1         3  
  1         31  
18 1     1   6 use warnings;
  1         2  
  1         34  
19 1     1   5 use base('Syntax::Highlight::Engine::Kate::Template');
  1         2  
  1         988  
20              
21             sub new {
22 2     2 0 579 my $proto = shift;
23 2   33     11 my $class = ref($proto) || $proto;
24 2         14 my $self = $class->SUPER::new(@_);
25 2         26 $self->attributes({
26             'Char' => 'Char',
27             'Class' => 'Keyword',
28             'Comment' => 'Comment',
29             'Constructor' => 'Others',
30             'Data Constructor' => 'Keyword',
31             'Decimal' => 'DecVal',
32             'Float' => 'Float',
33             'Function' => 'Function',
34             'Function Definition' => 'Function',
35             'Infix Operator' => 'Others',
36             'Keyword' => 'Keyword',
37             'Normal Text' => 'Normal',
38             'Special' => 'Char',
39             'String' => 'String',
40             'Type Constructor' => 'DataType',
41             });
42 2         10 $self->listAdd('classes',
43             'Bounded',
44             'Enum',
45             'Eq',
46             'Floating',
47             'Fractional',
48             'Functor',
49             'Integral',
50             'Ix',
51             'Monad',
52             'Num',
53             'Ord',
54             'Read',
55             'Real',
56             'RealFloat',
57             'RealFrac',
58             'Show',
59             );
60 2         6 $self->listAdd('data constructors',
61             'EQ',
62             'False',
63             'GT',
64             'Just',
65             'LT',
66             'Left',
67             'Nothing',
68             'Right',
69             'True',
70             );
71 2         12 $self->listAdd('functions',
72             'FilePath',
73             'IOError',
74             'abs',
75             'acos',
76             'acosh',
77             'all',
78             'and',
79             'any',
80             'appendFile',
81             'approxRational',
82             'asTypeOf',
83             'asin',
84             'asinh',
85             'atan',
86             'atan2',
87             'atanh',
88             'basicIORun',
89             'break',
90             'catch',
91             'ceiling',
92             'chr',
93             'compare',
94             'concat',
95             'concatMap',
96             'const',
97             'cos',
98             'cosh',
99             'curry',
100             'cycle',
101             'decodeFloat',
102             'denominator',
103             'digitToInt',
104             'div',
105             'divMod',
106             'drop',
107             'dropWhile',
108             'either',
109             'elem',
110             'encodeFloat',
111             'enumFrom',
112             'enumFromThen',
113             'enumFromThenTo',
114             'enumFromTo',
115             'error',
116             'even',
117             'exp',
118             'exponent',
119             'fail',
120             'filter',
121             'flip',
122             'floatDigits',
123             'floatRadix',
124             'floatRange',
125             'floor',
126             'fmap',
127             'foldl',
128             'foldl1',
129             'foldr',
130             'foldr1',
131             'fromDouble',
132             'fromEnum',
133             'fromInt',
134             'fromInteger',
135             'fromIntegral',
136             'fromRational',
137             'fst',
138             'gcd',
139             'getChar',
140             'getContents',
141             'getLine',
142             'head',
143             'id',
144             'inRange',
145             'index',
146             'init',
147             'intToDigit',
148             'interact',
149             'ioError',
150             'isAlpha',
151             'isAlphaNum',
152             'isAscii',
153             'isControl',
154             'isDenormalized',
155             'isDigit',
156             'isHexDigit',
157             'isIEEE',
158             'isInfinite',
159             'isLower',
160             'isNaN',
161             'isNegativeZero',
162             'isOctDigit',
163             'isPrint',
164             'isSpace',
165             'isUpper',
166             'iterate',
167             'last',
168             'lcm',
169             'length',
170             'lex',
171             'lexDigits',
172             'lexLitChar',
173             'lines',
174             'log',
175             'logBase',
176             'lookup',
177             'map',
178             'mapM',
179             'mapM_',
180             'max',
181             'maxBound',
182             'maximum',
183             'maybe',
184             'min',
185             'minBound',
186             'minimum',
187             'mod',
188             'negate',
189             'not',
190             'notElem',
191             'null',
192             'numerator',
193             'odd',
194             'or',
195             'ord',
196             'otherwise',
197             'pi',
198             'pred',
199             'primExitWith',
200             'print',
201             'product',
202             'properFraction',
203             'putChar',
204             'putStr',
205             'putStrLn',
206             'quot',
207             'quotRem',
208             'range',
209             'rangeSize',
210             'read',
211             'readDec',
212             'readFile',
213             'readFloat',
214             'readHex',
215             'readIO',
216             'readInt',
217             'readList',
218             'readLitChar',
219             'readLn',
220             'readOct',
221             'readParen',
222             'readSigned',
223             'reads',
224             'readsPrec',
225             'realToFrac',
226             'recip',
227             'rem',
228             'repeat',
229             'replicate',
230             'return',
231             'reverse',
232             'round',
233             'scaleFloat',
234             'scanl',
235             'scanl1',
236             'scanr',
237             'scanr1',
238             'seq',
239             'sequence',
240             'sequence_',
241             'show',
242             'showChar',
243             'showInt',
244             'showList',
245             'showLitChar',
246             'showParen',
247             'showSigned',
248             'showString',
249             'shows',
250             'showsPrec',
251             'significand',
252             'signum',
253             'sin',
254             'sinh',
255             'snd',
256             'span',
257             'splitAt',
258             'sqrt',
259             'subtract',
260             'succ',
261             'sum',
262             'tail',
263             'take',
264             'takeWhile',
265             'tan',
266             'tanh',
267             'threadToIOResult',
268             'toEnum',
269             'toInt',
270             'toInteger',
271             'toLower',
272             'toRational',
273             'toUpper',
274             'truncate',
275             'uncurry',
276             'undefined',
277             'unlines',
278             'until',
279             'unwords',
280             'unzip',
281             'unzip3',
282             'userError',
283             'words',
284             'writeFile',
285             'zip',
286             'zip3',
287             'zipWith',
288             'zipWith3',
289             );
290 2         6 $self->listAdd('infix operators',
291             'div',
292             'elem',
293             'mod',
294             'notElem',
295             'quot',
296             'rem',
297             'seq',
298             );
299 2         7 $self->listAdd('keywords',
300             'case',
301             'class',
302             'data',
303             'deriving',
304             'do',
305             'else',
306             'if',
307             'in',
308             'infixl',
309             'infixr',
310             'instance',
311             'let',
312             'module',
313             'of',
314             'primitive',
315             'then',
316             'type',
317             'where',
318             );
319 2         6 $self->listAdd('type constructors',
320             'Bool',
321             'Char',
322             'Double',
323             'Either',
324             'Float',
325             'IO',
326             'Int',
327             'Integer',
328             'Maybe',
329             'Ordering',
330             'Ratio',
331             'Rational',
332             'ReadS',
333             'ShowS',
334             'String',
335             );
336 2         34 $self->contextdata({
337             'comment_multi_line' => {
338             callback => \&parsecomment_multi_line,
339             attribute => 'Comment',
340             },
341             'comment_single_line' => {
342             callback => \&parsecomment_single_line,
343             attribute => 'Comment',
344             lineending => '#pop',
345             },
346             'function_definition' => {
347             callback => \&parsefunction_definition,
348             attribute => 'Function Definition',
349             lineending => '#pop',
350             },
351             'infix' => {
352             callback => \&parseinfix,
353             attribute => 'Infix Operator',
354             },
355             'literate-normal' => {
356             callback => \&parseliteratenormal,
357             attribute => 'Comment',
358             },
359             'normal' => {
360             callback => \&parsenormal,
361             attribute => 'Normal Text',
362             lineending => 'literate-normal',
363             },
364             'single_char' => {
365             callback => \&parsesingle_char,
366             attribute => 'Char',
367             lineending => '#pop',
368             },
369             'string' => {
370             callback => \&parsestring,
371             attribute => 'String',
372             },
373             });
374 2         9 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
375 2         5 $self->basecontext('literate-normal');
376 2         8 $self->keywordscase(0);
377 2         6 $self->initialize;
378 2         5 bless ($self, $class);
379 2         9 return $self;
380             }
381              
382             sub language {
383 0     0 0 0 return 'Literate Haskell';
384             }
385              
386             sub parsecomment_multi_line {
387 0     0 0 0 my ($self, $text) = @_;
388             # attribute => 'Comment'
389             # char => '-'
390             # char1 => '}'
391             # context => '#pop'
392             # type => 'Detect2Chars'
393 0 0       0 if ($self->testDetect2Chars($text, '-', '}', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
394 0         0 return 1
395             }
396 0         0 return 0;
397             };
398              
399             sub parsecomment_single_line {
400 36     36 0 52 my ($self, $text) = @_;
401 36         67 return 0;
402             };
403              
404             sub parsefunction_definition {
405 0     0 0 0 my ($self, $text) = @_;
406             # attribute => 'Function Definition'
407             # char => ';'
408             # context => '#pop'
409             # type => 'DetectChar'
410 0 0       0 if ($self->testDetectChar($text, ';', 0, 0, 0, undef, 0, '#pop', 'Function Definition')) {
411 0         0 return 1
412             }
413 0         0 return 0;
414             };
415              
416             sub parseinfix {
417 42     42 0 67 my ($self, $text) = @_;
418             # attribute => 'Infix Operator'
419             # char => '`'
420             # context => '#pop'
421             # type => 'DetectChar'
422 42 100       92 if ($self->testDetectChar($text, '`', 0, 0, 0, undef, 0, '#pop', 'Infix Operator')) {
423 10         26 return 1
424             }
425 32         62 return 0;
426             };
427              
428             sub parseliteratenormal {
429 2166     2166 0 3393 my ($self, $text) = @_;
430             # attribute => 'Special'
431             # char => '>'
432             # column => '0'
433             # context => 'normal'
434             # type => 'DetectChar'
435 2166 100       4592 if ($self->testDetectChar($text, '>', 0, 0, 0, 0, 0, 'normal', 'Special')) {
436 114         334 return 1
437             }
438 2052         3668 return 0;
439             };
440              
441             sub parsenormal {
442 2898     2898 0 4914 my ($self, $text) = @_;
443             # attribute => 'Comment'
444             # char => '{'
445             # char1 => '-'
446             # context => 'comment_multi_line'
447             # type => 'Detect2Chars'
448 2898 50       6881 if ($self->testDetect2Chars($text, '{', '-', 0, 0, 0, undef, 0, 'comment_multi_line', 'Comment')) {
449 0         0 return 1
450             }
451             # attribute => 'Comment'
452             # char => '-'
453             # char1 => '-'
454             # context => 'comment_single_line'
455             # type => 'Detect2Chars'
456 2898 100       6610 if ($self->testDetect2Chars($text, '-', '-', 0, 0, 0, undef, 0, 'comment_single_line', 'Comment')) {
457 2         8 return 1
458             }
459             # String => 'keywords'
460             # attribute => 'Keyword'
461             # context => '#stay'
462             # type => 'keyword'
463 2896 100       6834 if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) {
464 50         112 return 1
465             }
466             # String => 'classes'
467             # attribute => 'Class'
468             # context => '#stay'
469             # type => 'keyword'
470 2846 100       7319 if ($self->testKeyword($text, 'classes', 0, undef, 0, '#stay', 'Class')) {
471 52         118 return 1
472             }
473             # String => 'type constructors'
474             # attribute => 'Type Constructor'
475             # context => '#stay'
476             # type => 'keyword'
477 2794 100       7162 if ($self->testKeyword($text, 'type constructors', 0, undef, 0, '#stay', 'Type Constructor')) {
478 52         148 return 1
479             }
480             # String => 'functions'
481             # attribute => 'Function'
482             # context => '#stay'
483             # type => 'keyword'
484 2742 100       6601 if ($self->testKeyword($text, 'functions', 0, undef, 0, '#stay', 'Function')) {
485 472         1216 return 1
486             }
487             # String => 'data constructors'
488             # attribute => 'Data Constructor'
489             # context => '#stay'
490             # type => 'keyword'
491 2270 100       5671 if ($self->testKeyword($text, 'data constructors', 0, undef, 0, '#stay', 'Data Constructor')) {
492 16         39 return 1
493             }
494             # attribute => 'String'
495             # char => '"'
496             # context => 'string'
497             # type => 'DetectChar'
498 2254 100       5667 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'string', 'String')) {
499 6         15 return 1
500             }
501             # attribute => 'Infix Operator'
502             # char => '`'
503             # context => 'infix'
504             # type => 'DetectChar'
505 2248 100       5135 if ($self->testDetectChar($text, '`', 0, 0, 0, undef, 0, 'infix', 'Infix Operator')) {
506 10         25 return 1
507             }
508             # String => '\w[']+'
509             # attribute => 'Normal Text'
510             # context => '#stay'
511             # type => 'RegExpr'
512 2238 100       5784 if ($self->testRegExpr($text, '\\w[\']+', 0, 0, 0, undef, 0, '#stay', 'Normal Text')) {
513 8         28 return 1
514             }
515             # attribute => 'Char'
516             # char => '''
517             # context => 'single_char'
518             # type => 'DetectChar'
519 2230 100       6033 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'single_char', 'Char')) {
520 12         30 return 1
521             }
522             # String => '\s*[a-z_]+\w*'*\s*::'
523             # attribute => 'Function Definition'
524             # context => '#stay'
525             # type => 'RegExpr'
526 2218 100       5647 if ($self->testRegExpr($text, '\\s*[a-z_]+\\w*\'*\\s*::', 0, 0, 0, undef, 0, '#stay', 'Function Definition')) {
527 12         39 return 1
528             }
529             # attribute => 'Float'
530             # context => '#stay'
531             # type => 'Float'
532 2206 100       6230 if ($self->testFloat($text, 0, undef, 0, '#stay', 'Float')) {
533 42         100 return 1
534             }
535             # attribute => 'Decimal'
536             # context => '#stay'
537             # type => 'Int'
538 2164 50       5832 if ($self->testInt($text, 0, undef, 0, '#stay', 'Decimal')) {
539 0         0 return 1
540             }
541 2164         4228 return 0;
542             };
543              
544             sub parsesingle_char {
545 50     50 0 85 my ($self, $text) = @_;
546             # String => '\\.'
547             # attribute => 'Char'
548             # context => '#stay'
549             # type => 'RegExpr'
550 50 100       120 if ($self->testRegExpr($text, '\\\\.', 0, 0, 0, undef, 0, '#stay', 'Char')) {
551 4         12 return 1
552             }
553             # attribute => 'Char'
554             # char => '''
555             # context => '#pop'
556             # type => 'DetectChar'
557 46 100       127 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Char')) {
558 12         27 return 1
559             }
560 34         68 return 0;
561             };
562              
563             sub parsestring {
564 38     38 0 68 my ($self, $text) = @_;
565             # String => '\\.'
566             # attribute => 'String'
567             # context => '#stay'
568             # type => 'RegExpr'
569 38 50       111 if ($self->testRegExpr($text, '\\\\.', 0, 0, 0, undef, 0, '#stay', 'String')) {
570 0         0 return 1
571             }
572             # attribute => 'String'
573             # char => '"'
574             # context => '#pop'
575             # type => 'DetectChar'
576 38 100       108 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) {
577 6         14 return 1
578             }
579 32         59 return 0;
580             };
581              
582              
583             1;
584              
585             __END__