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.
5 # This file was generated from the 'c.xml' file of the syntax highlight
6 # engine of the kate text editor (http://www.kate-editor.org
10 #generated: Sun Feb 3 22:02:04 2008, localtime
12 package Syntax::Highlight::Engine::Kate::C;
14 our $VERSION = '0.06';
18 use base('Syntax::Highlight::Engine::Kate::Template');
22 my $class = ref($proto) || $proto;
23 my $self = $class->SUPER::new(@_);
27 'Comment' => 'Comment',
28 'Data Type' => 'DataType',
29 'Decimal' => 'DecVal',
32 'Keyword' => 'Keyword',
33 'Normal Text' => 'Normal',
35 'Prep. Lib' => 'Others',
36 'Preprocessor' => 'Others',
37 'Region Marker' => 'RegionMarker',
39 'String Char' => 'Char',
42 $self->listAdd('keywords',
63 $self->listAdd('types',
85 callback => \&parseCommentar1,
86 attribute => 'Comment',
90 callback => \&parseCommentar2,
91 attribute => 'Comment',
93 'Commentar/Preprocessor' => {
94 callback => \&parseCommentarPreprocessor,
95 attribute => 'Comment',
98 callback => \&parseDefine,
99 attribute => 'Preprocessor',
100 lineending => '#pop',
103 callback => \&parseNormal,
104 attribute => 'Normal Text',
107 callback => \&parseOutscoped,
108 attribute => 'Comment',
110 'Outscoped intern' => {
111 callback => \&parseOutscopedintern,
112 attribute => 'Comment',
115 callback => \&parsePreprocessor,
116 attribute => 'Preprocessor',
117 lineending => '#pop',
120 callback => \&parseRegionMarker,
121 attribute => 'Region Marker',
122 lineending => '#pop',
125 callback => \&parseString,
126 attribute => 'String',
127 lineending => '#pop',
130 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
131 $self->basecontext('Normal');
132 $self->keywordscase(0);
134 bless ($self, $class);
142 sub parseCommentar1 {
143 my ($self, $text) = @_;
144 # context => '##Alerts'
145 # type => 'IncludeRules'
146 if ($self->includePlugin('Alerts', $text)) {
152 sub parseCommentar2 {
153 my ($self, $text) = @_;
154 # attribute => 'Comment'
158 # endRegion => 'Comment'
159 # type => 'Detect2Chars'
160 if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
163 # context => '##Alerts'
164 # type => 'IncludeRules'
165 if ($self->includePlugin('Alerts', $text)) {
171 sub parseCommentarPreprocessor {
172 my ($self, $text) = @_;
173 # attribute => 'Comment'
177 # endRegion => 'Comment2'
178 # type => 'Detect2Chars'
179 if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
186 my ($self, $text) = @_;
187 # attribute => 'Preprocessor'
189 # type => 'LineContinue'
190 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Preprocessor')) {
197 my ($self, $text) = @_;
198 # type => 'DetectSpaces'
199 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
202 # String => '#\s*if\s+0'
203 # attribute => 'Preprocessor'
204 # beginRegion => 'Outscoped'
205 # context => 'Outscoped'
206 # firstNonSpace => 'true'
208 if ($self->testRegExpr($text, '#\\s*if\\s+0', 0, 0, 0, undef, 1, 'Outscoped', 'Preprocessor')) {
211 # attribute => 'Preprocessor'
213 # context => 'Preprocessor'
214 # firstNonSpace => 'true'
215 # type => 'DetectChar'
216 if ($self->testDetectChar($text, '#', 0, 0, 0, undef, 1, 'Preprocessor', 'Preprocessor')) {
219 # String => '//BEGIN'
220 # attribute => 'Region Marker'
221 # beginRegion => 'Region1'
222 # context => 'Region Marker'
223 # firstNonSpace => 'true'
224 # type => 'StringDetect'
225 if ($self->testStringDetect($text, '//BEGIN', 0, 0, 0, undef, 1, 'Region Marker', 'Region Marker')) {
229 # attribute => 'Region Marker'
230 # context => 'Region Marker'
231 # endRegion => 'Region1'
232 # firstNonSpace => 'true'
233 # type => 'StringDetect'
234 if ($self->testStringDetect($text, '//END', 0, 0, 0, undef, 1, 'Region Marker', 'Region Marker')) {
237 # String => 'keywords'
238 # attribute => 'Keyword'
241 if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) {
245 # attribute => 'Data Type'
248 if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Data Type')) {
251 # type => 'DetectIdentifier'
252 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
255 # attribute => 'Symbol'
256 # beginRegion => 'Brace1'
259 # type => 'DetectChar'
260 if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, '#stay', 'Symbol')) {
263 # attribute => 'Symbol'
266 # endRegion => 'Brace1'
267 # type => 'DetectChar'
268 if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#stay', 'Symbol')) {
271 # attribute => 'Float'
273 # items => 'ARRAY(0x12df8b0)'
275 if ($self->testFloat($text, 0, undef, 0, '#stay', 'Float')) {
277 # attribute => 'Float'
280 if ($self->testAnyChar($text, 'fF', 0, 0, undef, 0, '#stay', 'Float')) {
284 # attribute => 'Octal'
287 if ($self->testHlCOct($text, 0, undef, 0, '#stay', 'Octal')) {
293 if ($self->testHlCHex($text, 0, undef, 0, '#stay', 'Hex')) {
296 # attribute => 'Decimal'
298 # items => 'ARRAY(0x12207d0)'
300 if ($self->testInt($text, 0, undef, 0, '#stay', 'Decimal')) {
302 # attribute => 'Decimal'
304 # insensitive => 'TRUE'
305 # type => 'StringDetect'
306 if ($self->testStringDetect($text, 'ULL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
310 # attribute => 'Decimal'
312 # insensitive => 'TRUE'
313 # type => 'StringDetect'
314 if ($self->testStringDetect($text, 'LUL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
318 # attribute => 'Decimal'
320 # insensitive => 'TRUE'
321 # type => 'StringDetect'
322 if ($self->testStringDetect($text, 'LLU', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
326 # attribute => 'Decimal'
328 # insensitive => 'TRUE'
329 # type => 'StringDetect'
330 if ($self->testStringDetect($text, 'UL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
334 # attribute => 'Decimal'
336 # insensitive => 'TRUE'
337 # type => 'StringDetect'
338 if ($self->testStringDetect($text, 'LU', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
342 # attribute => 'Decimal'
344 # insensitive => 'TRUE'
345 # type => 'StringDetect'
346 if ($self->testStringDetect($text, 'LL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
350 # attribute => 'Decimal'
352 # insensitive => 'TRUE'
353 # type => 'StringDetect'
354 if ($self->testStringDetect($text, 'U', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
358 # attribute => 'Decimal'
360 # insensitive => 'TRUE'
361 # type => 'StringDetect'
362 if ($self->testStringDetect($text, 'L', 1, 0, 0, undef, 0, '#stay', 'Decimal')) {
366 # attribute => 'Char'
369 if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Char')) {
372 # attribute => 'String'
374 # context => 'String'
375 # type => 'DetectChar'
376 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String', 'String')) {
379 # context => '##Doxygen'
380 # type => 'IncludeRules'
381 if ($self->includePlugin('Doxygen', $text)) {
384 # attribute => 'Comment'
387 # context => 'Commentar 1'
388 # type => 'Detect2Chars'
389 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Commentar 1', 'Comment')) {
392 # attribute => 'Comment'
393 # beginRegion => 'Comment'
396 # context => 'Commentar 2'
397 # type => 'Detect2Chars'
398 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Commentar 2', 'Comment')) {
401 # String => ':!%&()+,-/.*<=>?[]|~^;'
402 # attribute => 'Symbol'
405 if ($self->testAnyChar($text, ':!%&()+,-/.*<=>?[]|~^;', 0, 0, undef, 0, '#stay', 'Symbol')) {
412 my ($self, $text) = @_;
413 # type => 'DetectSpaces'
414 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
417 # context => '##Alerts'
418 # type => 'IncludeRules'
419 if ($self->includePlugin('Alerts', $text)) {
422 # type => 'DetectIdentifier'
423 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
426 # attribute => 'String'
428 # context => 'String'
429 # type => 'DetectChar'
430 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String', 'String')) {
433 # context => '##Doxygen'
434 # type => 'IncludeRules'
435 if ($self->includePlugin('Doxygen', $text)) {
438 # attribute => 'Comment'
441 # context => 'Commentar 1'
442 # type => 'Detect2Chars'
443 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Commentar 1', 'Comment')) {
446 # attribute => 'Comment'
447 # beginRegion => 'Comment'
450 # context => 'Commentar 2'
451 # type => 'Detect2Chars'
452 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Commentar 2', 'Comment')) {
456 # attribute => 'Comment'
457 # beginRegion => 'Outscoped'
458 # context => 'Outscoped intern'
459 # firstNonSpace => 'true'
461 if ($self->testRegExpr($text, '#\\s*if', 0, 0, 0, undef, 1, 'Outscoped intern', 'Comment')) {
464 # String => '#\s*(endif|else|elif)'
465 # attribute => 'Preprocessor'
467 # endRegion => 'Outscoped'
468 # firstNonSpace => 'true'
470 if ($self->testRegExpr($text, '#\\s*(endif|else|elif)', 0, 0, 0, undef, 1, '#pop', 'Preprocessor')) {
476 sub parseOutscopedintern {
477 my ($self, $text) = @_;
478 # type => 'DetectSpaces'
479 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
482 # context => '##Alerts'
483 # type => 'IncludeRules'
484 if ($self->includePlugin('Alerts', $text)) {
487 # type => 'DetectIdentifier'
488 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
491 # attribute => 'String'
493 # context => 'String'
494 # type => 'DetectChar'
495 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String', 'String')) {
498 # context => '##Doxygen'
499 # type => 'IncludeRules'
500 if ($self->includePlugin('Doxygen', $text)) {
503 # attribute => 'Comment'
506 # context => 'Commentar 1'
507 # type => 'Detect2Chars'
508 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Commentar 1', 'Comment')) {
511 # attribute => 'Comment'
512 # beginRegion => 'Comment'
515 # context => 'Commentar 2'
516 # type => 'Detect2Chars'
517 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Commentar 2', 'Comment')) {
521 # attribute => 'Comment'
522 # beginRegion => 'Outscoped'
523 # context => 'Outscoped intern'
524 # firstNonSpace => 'true'
526 if ($self->testRegExpr($text, '#\\s*if', 0, 0, 0, undef, 1, 'Outscoped intern', 'Comment')) {
529 # String => '#\s*endif'
530 # attribute => 'Comment'
532 # endRegion => 'Outscoped'
533 # firstNonSpace => 'true'
535 if ($self->testRegExpr($text, '#\\s*endif', 0, 0, 0, undef, 1, '#pop', 'Comment')) {
541 sub parsePreprocessor {
542 my ($self, $text) = @_;
543 # attribute => 'Preprocessor'
545 # type => 'LineContinue'
546 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Preprocessor')) {
549 # String => 'define.*((?=\\))'
550 # attribute => 'Preprocessor'
551 # context => 'Define'
553 if ($self->testRegExpr($text, 'define.*((?=\\\\))', 0, 0, 0, undef, 0, 'Define', 'Preprocessor')) {
556 # String => 'define.*'
557 # attribute => 'Preprocessor'
560 if ($self->testRegExpr($text, 'define.*', 0, 0, 0, undef, 0, '#stay', 'Preprocessor')) {
563 # attribute => 'Prep. Lib'
567 # type => 'RangeDetect'
568 if ($self->testRangeDetect($text, '"', '"', 0, 0, undef, 0, '#stay', 'Prep. Lib')) {
571 # attribute => 'Prep. Lib'
575 # type => 'RangeDetect'
576 if ($self->testRangeDetect($text, '<', '>', 0, 0, undef, 0, '#stay', 'Prep. Lib')) {
579 # context => '##Doxygen'
580 # type => 'IncludeRules'
581 if ($self->includePlugin('Doxygen', $text)) {
584 # attribute => 'Comment'
585 # beginRegion => 'Comment2'
588 # context => 'Commentar/Preprocessor'
589 # type => 'Detect2Chars'
590 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Commentar/Preprocessor', 'Comment')) {
596 sub parseRegionMarker {
597 my ($self, $text) = @_;
602 my ($self, $text) = @_;
603 # attribute => 'String'
605 # type => 'LineContinue'
606 if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'String')) {
609 # attribute => 'String Char'
611 # type => 'HlCStringChar'
612 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String Char')) {
615 # attribute => 'String'
618 # type => 'DetectChar'
619 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) {
632 Syntax::Highlight::Engine::Kate::C - a Plugin for C syntax highlighting
636 require Syntax::Highlight::Engine::Kate::C;
637 my $sh = new Syntax::Highlight::Engine::Kate::C([
642 Syntax::Highlight::Engine::Kate::C is a plugin module that provides syntax highlighting
643 for C to the Syntax::Haghlight::Engine::Kate highlighting engine.
645 This code is generated from the syntax definition files used
647 It works quite fine, but can use refinement and optimization.
649 It inherits Syntax::Higlight::Engine::Kate::Template. See also there.
655 Hans Jeuken (haje <at> toneel <dot> demon <dot> nl)
661 Unknown. If you find any, please contact the author