File Coverage

blib/lib/Syntax/Highlight/Engine/Kate/LPC.pm
Criterion Covered Total %
statement 95 112 84.8
branch 60 76 78.9
condition 1 3 33.3
subroutine 10 11 90.9
pod 0 8 0.0
total 166 210 79.0


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 'lpc.xml' file of the syntax highlight
6             # engine of the kate text editor (http://www.kate-editor.org
7              
8             #kate xml version 0.76
9             #kate version 2.4
10             #kate author Andreas Klauer (Andreas.Klauer@metamorpher.de)
11             #generated: Sun Feb 3 22:02:05 2008, localtime
12              
13             package Syntax::Highlight::Engine::Kate::LPC;
14              
15             our $VERSION = '0.14';
16              
17 1     1   509 use strict;
  1         2  
  1         26  
18 1     1   4 use warnings;
  1         3  
  1         32  
19 1     1   6 use base('Syntax::Highlight::Engine::Kate::Template');
  1         1  
  1         1071  
20              
21             sub new {
22 2     2 0 640 my $proto = shift;
23 2   33     8 my $class = ref($proto) || $proto;
24 2         9 my $self = $class->SUPER::new(@_);
25 2         25 $self->attributes({
26             'Alert' => 'Alert',
27             'Binary' => 'BaseN',
28             'Char' => 'Char',
29             'Closure' => 'Others',
30             'Datatype' => 'DataType',
31             'Default' => 'Normal',
32             'Floats' => 'Float',
33             'Hexadecimal' => 'BaseN',
34             'Integer' => 'DecVal',
35             'Keywords' => 'Keyword',
36             'Modifier' => 'DataType',
37             'Multi-Line comments' => 'Comment',
38             'Octal' => 'BaseN',
39             'Preprocessor' => 'Others',
40             'Preprocessor-Strings' => 'String',
41             'Region Marker' => 'RegionMarker',
42             'Single-Line comments' => 'Comment',
43             'Strings' => 'String',
44             });
45 2         8 $self->listAdd('attention',
46             '###',
47             'FIXME',
48             'HACK',
49             'NOTE',
50             'NOTICE',
51             'TODO',
52             'WARNING',
53             );
54 2         7 $self->listAdd('keywords',
55             'break',
56             'case',
57             'continue',
58             'default',
59             'do',
60             'else',
61             'for',
62             'foreach',
63             'functions',
64             'if',
65             'inherit',
66             'nolog',
67             'publish',
68             'return',
69             'switch',
70             'variables',
71             'while',
72             );
73 2         5 $self->listAdd('modifiers',
74             'nomask',
75             'nosave',
76             'private',
77             'protected',
78             'public',
79             'static',
80             'varargs',
81             'virtual',
82             );
83 2         6 $self->listAdd('types',
84             'array',
85             'closure',
86             'float',
87             'int',
88             'mapping',
89             'mixed',
90             'object',
91             'status',
92             'string',
93             'symbol',
94             'void',
95             );
96 2         19 $self->contextdata({
97             'Comment1' => {
98             callback => \&parseComment1,
99             attribute => 'Single-Line comments',
100             lineending => '#pop',
101             },
102             'Comment2' => {
103             callback => \&parseComment2,
104             attribute => 'Multi-Line comments',
105             },
106             'Normal' => {
107             callback => \&parseNormal,
108             attribute => 'Default',
109             },
110             'Preprocessor' => {
111             callback => \&parsePreprocessor,
112             attribute => 'Preprocessor',
113             lineending => '#pop',
114             },
115             'String1' => {
116             callback => \&parseString1,
117             attribute => 'Strings',
118             lineending => '#pop',
119             },
120             'String2' => {
121             callback => \&parseString2,
122             attribute => 'Preprocessor-Strings',
123             lineending => '#pop',
124             },
125             });
126 2         7 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
127 2         248 $self->basecontext('Normal');
128 2         9 $self->keywordscase(0);
129 2         7 $self->initialize;
130 2         4 bless ($self, $class);
131 2         8 return $self;
132             }
133              
134             sub language {
135 0     0 0 0 return 'LPC';
136             }
137              
138             sub parseComment1 {
139 1038     1038 0 1404 my ($self, $text) = @_;
140             # attribute => 'Single-Line comments'
141             # context => '#stay'
142             # type => 'LineContinue'
143 1038 100       2055 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Single-Line comments')) {
144 4         9 return 1
145             }
146             # String => 'attention'
147             # attribute => 'Alert'
148             # context => '#stay'
149             # type => 'keyword'
150 1034 100       2188 if ($self->testKeyword($text, 'attention', 0, undef, 0, '#stay', 'Alert')) {
151 2         6 return 1
152             }
153 1032         1715 return 0;
154             };
155              
156             sub parseComment2 {
157 690     690 0 1007 my ($self, $text) = @_;
158             # attribute => 'Multi-Line comments'
159             # char => '*'
160             # char1 => '/'
161             # context => '#pop'
162             # endRegion => 'blockComment'
163             # type => 'Detect2Chars'
164 690 100       1436 if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Multi-Line comments')) {
165 8         19 return 1
166             }
167             # String => 'attention'
168             # attribute => 'Alert'
169             # context => '#stay'
170             # type => 'keyword'
171 682 100       1600 if ($self->testKeyword($text, 'attention', 0, undef, 0, '#stay', 'Alert')) {
172 6         14 return 1
173             }
174 676         1097 return 0;
175             };
176              
177             sub parseNormal {
178 664     664 0 1001 my ($self, $text) = @_;
179             # String => '//\s*BEGIN.*$'
180             # attribute => 'Region Marker'
181             # beginRegion => 'regionMarker'
182             # context => '#stay'
183             # firstNonSpace => 'true'
184             # type => 'RegExpr'
185 664 50       1554 if ($self->testRegExpr($text, '//\\s*BEGIN.*$', 0, 0, 0, undef, 1, '#stay', 'Region Marker')) {
186 0         0 return 1
187             }
188             # String => '//\s*END.*$'
189             # attribute => 'Region Marker'
190             # context => '#stay'
191             # endRegion => 'regionMarker'
192             # firstNonSpace => 'true'
193             # type => 'RegExpr'
194 664 50       1558 if ($self->testRegExpr($text, '//\\s*END.*$', 0, 0, 0, undef, 1, '#stay', 'Region Marker')) {
195 0         0 return 1
196             }
197             # attribute => 'Single-Line comments'
198             # char => '/'
199             # char1 => '/'
200             # context => 'Comment1'
201             # type => 'Detect2Chars'
202 664 100       1732 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Comment1', 'Single-Line comments')) {
203 30         64 return 1
204             }
205             # attribute => 'Multi-Line comments'
206             # beginRegion => 'blockComment'
207             # char => '/'
208             # char1 => '*'
209             # context => 'Comment2'
210             # type => 'Detect2Chars'
211 634 100       1306 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Comment2', 'Multi-Line comments')) {
212 8         19 return 1
213             }
214             # String => 'modifiers'
215             # attribute => 'Modifier'
216             # context => '#stay'
217             # type => 'keyword'
218 626 100       1545 if ($self->testKeyword($text, 'modifiers', 0, undef, 0, '#stay', 'Modifier')) {
219 2         6 return 1
220             }
221             # String => 'types'
222             # attribute => 'Datatype'
223             # context => '#stay'
224             # type => 'keyword'
225 624 100       1438 if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Datatype')) {
226 16         35 return 1
227             }
228             # String => 'keywords'
229             # attribute => 'Keywords'
230             # context => '#stay'
231             # type => 'keyword'
232 608 100       1325 if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keywords')) {
233 12         27 return 1
234             }
235             # attribute => 'Preprocessor'
236             # char => '#'
237             # column => '0'
238             # context => 'Preprocessor'
239             # type => 'DetectChar'
240 596 100       1442 if ($self->testDetectChar($text, '#', 0, 0, 0, 0, 0, 'Preprocessor', 'Preprocessor')) {
241 2         4 return 1
242             }
243             # attribute => 'Floats'
244             # context => '#stay'
245             # items => 'ARRAY(0x19c5720)'
246             # type => 'Float'
247 594 100       1279 if ($self->testFloat($text, 0, undef, 0, '#stay', 'Floats')) {
248             # String => 'fFeE'
249             # context => '#stay'
250             # type => 'AnyChar'
251 20 50       65 if ($self->testAnyChar($text, 'fFeE', 0, 0, undef, 0, '#stay', undef)) {
252 0         0 return 1
253             }
254             }
255             # String => '0b[01]+'
256             # attribute => 'Binary'
257             # context => '#stay'
258             # type => 'RegExpr'
259 594 50       1291 if ($self->testRegExpr($text, '0b[01]+', 0, 0, 0, undef, 0, '#stay', 'Binary')) {
260 0         0 return 1
261             }
262             # String => '0x[0-9a-fA-F]+'
263             # attribute => 'Hexadecimal'
264             # context => '#stay'
265             # type => 'RegExpr'
266 594 50       1483 if ($self->testRegExpr($text, '0x[0-9a-fA-F]+', 0, 0, 0, undef, 0, '#stay', 'Hexadecimal')) {
267 0         0 return 1
268             }
269             # String => '0o[0-7]+'
270             # attribute => 'Octal'
271             # context => '#stay'
272             # type => 'RegExpr'
273 594 50       1403 if ($self->testRegExpr($text, '0o[0-7]+', 0, 0, 0, undef, 0, '#stay', 'Octal')) {
274 0         0 return 1
275             }
276             # attribute => 'Integer'
277             # context => '#stay'
278             # type => 'Int'
279 594 50       1449 if ($self->testInt($text, 0, undef, 0, '#stay', 'Integer')) {
280 0         0 return 1
281             }
282             # String => '#'[^\t ][^\t ,);}\]/]*'
283             # attribute => 'Closure'
284             # context => '#stay'
285             # type => 'RegExpr'
286 594 100       1284 if ($self->testRegExpr($text, '#\'[^\\t ][^\\t ,);}\\]/]*', 0, 0, 0, undef, 0, '#stay', 'Closure')) {
287 4         9 return 1
288             }
289             # attribute => 'Strings'
290             # char => '"'
291             # context => 'String1'
292             # type => 'DetectChar'
293 590 100       1381 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String1', 'Strings')) {
294 4         9 return 1
295             }
296             # attribute => 'Char'
297             # context => '#stay'
298             # type => 'HlCStringChar'
299 586 50       1338 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Char')) {
300 0         0 return 1
301             }
302             # attribute => 'Default'
303             # beginRegion => 'brace'
304             # char => '{'
305             # context => '#stay'
306             # type => 'DetectChar'
307 586 100       1235 if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, '#stay', 'Default')) {
308 8         19 return 1
309             }
310             # attribute => 'Default'
311             # char => '}'
312             # context => '#stay'
313             # endRegion => 'brace'
314             # type => 'DetectChar'
315 578 100       1123 if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#stay', 'Default')) {
316 8         16 return 1
317             }
318 570         1012 return 0;
319             };
320              
321             sub parsePreprocessor {
322 210     210 0 298 my ($self, $text) = @_;
323             # attribute => 'Preprocessor'
324             # context => '#stay'
325             # type => 'LineContinue'
326 210 100       446 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Preprocessor')) {
327 6         12 return 1
328             }
329             # attribute => 'Single-Line comments'
330             # char => '/'
331             # char1 => '/'
332             # context => 'Comment1'
333             # type => 'Detect2Chars'
334 204 100       450 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Comment1', 'Single-Line comments')) {
335 2         4 return 1
336             }
337             # attribute => 'Multi-Line comments'
338             # beginRegion => 'blockComment'
339             # char => '/'
340             # char1 => '*'
341             # context => 'Comment2'
342             # type => 'Detect2Chars'
343 202 50       416 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Comment2', 'Multi-Line comments')) {
344 0         0 return 1
345             }
346             # String => 'modifiers'
347             # attribute => 'Modifier'
348             # context => '#stay'
349             # type => 'keyword'
350 202 50       420 if ($self->testKeyword($text, 'modifiers', 0, undef, 0, '#stay', 'Modifier')) {
351 0         0 return 1
352             }
353             # String => 'types'
354             # attribute => 'Datatype'
355             # context => '#stay'
356             # type => 'keyword'
357 202 50       437 if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Datatype')) {
358 0         0 return 1
359             }
360             # String => 'keywords'
361             # attribute => 'Keywords'
362             # context => '#stay'
363             # type => 'keyword'
364 202 100       414 if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keywords')) {
365 2         5 return 1
366             }
367             # attribute => 'Preprocessor-Strings'
368             # char => '"'
369             # context => 'String2'
370             # type => 'DetectChar'
371 200 100       448 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String2', 'Preprocessor-Strings')) {
372 4         18 return 1
373             }
374 196         299 return 0;
375             };
376              
377             sub parseString1 {
378 44     44 0 69 my ($self, $text) = @_;
379             # attribute => 'Default'
380             # context => '#stay'
381             # type => 'LineContinue'
382 44 100       92 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Default')) {
383 2         6 return 1
384             }
385             # attribute => 'Strings'
386             # char => '\'
387             # char1 => '\'
388             # context => '#stay'
389             # type => 'Detect2Chars'
390 42 50       86 if ($self->testDetect2Chars($text, '\\', '\\', 0, 0, 0, undef, 0, '#stay', 'Strings')) {
391 0         0 return 1
392             }
393             # attribute => 'Strings'
394             # char => '\'
395             # char1 => '"'
396             # context => '#stay'
397             # type => 'Detect2Chars'
398 42 50       83 if ($self->testDetect2Chars($text, '\\', '"', 0, 0, 0, undef, 0, '#stay', 'Strings')) {
399 0         0 return 1
400             }
401             # attribute => 'Strings'
402             # char => '"'
403             # context => '#pop'
404             # type => 'DetectChar'
405 42 100       85 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Strings')) {
406 4         8 return 1
407             }
408 38         63 return 0;
409             };
410              
411             sub parseString2 {
412 16     16 0 36 my ($self, $text) = @_;
413             # attribute => 'Default'
414             # context => '#stay'
415             # type => 'LineContinue'
416 16 50       33 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Default')) {
417 0         0 return 1
418             }
419             # attribute => 'Preprocessor-Strings'
420             # char => '\'
421             # char1 => '\'
422             # context => '#stay'
423             # type => 'Detect2Chars'
424 16 50       36 if ($self->testDetect2Chars($text, '\\', '\\', 0, 0, 0, undef, 0, '#stay', 'Preprocessor-Strings')) {
425 0         0 return 1
426             }
427             # attribute => 'Preprocessor-Strings'
428             # char => '\'
429             # char1 => '"'
430             # context => '#stay'
431             # type => 'Detect2Chars'
432 16 50       39 if ($self->testDetect2Chars($text, '\\', '"', 0, 0, 0, undef, 0, '#stay', 'Preprocessor-Strings')) {
433 0         0 return 1
434             }
435             # attribute => 'Preprocessor-Strings'
436             # char => '"'
437             # context => '#pop'
438             # type => 'DetectChar'
439 16 100       36 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Preprocessor-Strings')) {
440 4         10 return 1
441             }
442 12         21 return 0;
443             };
444              
445              
446             1;
447              
448             __END__