Commit | Line | Data |
3fea05b9 |
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 'ansic89.xml' file of the syntax highlight |
6 | # engine of the kate text editor (http://www.kate-editor.org |
7 | |
8 | #kate xml version 1.09 |
9 | #kate version 2.4 |
10 | #kate author Dominik Haumann (dhdev@gmx.de) |
11 | #generated: Sun Feb 3 22:02:04 2008, localtime |
12 | |
13 | package Syntax::Highlight::Engine::Kate::ANSI_C89; |
14 | |
15 | our $VERSION = '0.06'; |
16 | |
17 | use strict; |
18 | use warnings; |
19 | use base('Syntax::Highlight::Engine::Kate::Template'); |
20 | |
21 | sub new { |
22 | my $proto = shift; |
23 | my $class = ref($proto) || $proto; |
24 | my $self = $class->SUPER::new(@_); |
25 | $self->attributes({ |
26 | 'Char' => 'Char', |
27 | 'Comment' => 'Comment', |
28 | 'Data Type' => 'DataType', |
29 | 'Decimal' => 'DecVal', |
30 | 'Float' => 'Float', |
31 | 'Hex' => 'BaseN', |
32 | 'Keyword' => 'Keyword', |
33 | 'Normal Text' => 'Normal', |
34 | 'Octal' => 'BaseN', |
35 | 'Prep. Lib' => 'Others', |
36 | 'Preprocessor' => 'Others', |
37 | 'String' => 'String', |
38 | 'String Char' => 'Char', |
39 | 'Symbol' => 'Normal', |
40 | }); |
41 | $self->listAdd('keywords', |
42 | 'break', |
43 | 'case', |
44 | 'continue', |
45 | 'default', |
46 | 'do', |
47 | 'else', |
48 | 'enum', |
49 | 'extern', |
50 | 'for', |
51 | 'goto', |
52 | 'if', |
53 | 'return', |
54 | 'sizeof', |
55 | 'struct', |
56 | 'switch', |
57 | 'typedef', |
58 | 'union', |
59 | 'while', |
60 | ); |
61 | $self->listAdd('types', |
62 | 'auto', |
63 | 'char', |
64 | 'const', |
65 | 'double', |
66 | 'float', |
67 | 'int', |
68 | 'long', |
69 | 'register', |
70 | 'short', |
71 | 'signed', |
72 | 'static', |
73 | 'unsigned', |
74 | 'void', |
75 | 'volatile', |
76 | ); |
77 | $self->contextdata({ |
78 | 'Define' => { |
79 | callback => \&parseDefine, |
80 | attribute => 'Preprocessor', |
81 | lineending => '#pop', |
82 | }, |
83 | 'Normal' => { |
84 | callback => \&parseNormal, |
85 | attribute => 'Normal Text', |
86 | }, |
87 | 'Outscoped' => { |
88 | callback => \&parseOutscoped, |
89 | attribute => 'Comment', |
90 | }, |
91 | 'Outscoped intern' => { |
92 | callback => \&parseOutscopedintern, |
93 | attribute => 'Comment', |
94 | }, |
95 | 'Preprocessor' => { |
96 | callback => \&parsePreprocessor, |
97 | attribute => 'Preprocessor', |
98 | lineending => '#pop', |
99 | }, |
100 | 'String' => { |
101 | callback => \&parseString, |
102 | attribute => 'String', |
103 | lineending => '#pop', |
104 | }, |
105 | 'comment' => { |
106 | callback => \&parsecomment, |
107 | attribute => 'Comment', |
108 | }, |
109 | }); |
110 | $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\'); |
111 | $self->basecontext('Normal'); |
112 | $self->keywordscase(0); |
113 | $self->initialize; |
114 | bless ($self, $class); |
115 | return $self; |
116 | } |
117 | |
118 | sub language { |
119 | return 'ANSI C89'; |
120 | } |
121 | |
122 | sub parseDefine { |
123 | my ($self, $text) = @_; |
124 | # attribute => 'Preprocessor' |
125 | # context => '#stay' |
126 | # type => 'LineContinue' |
127 | if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Preprocessor')) { |
128 | return 1 |
129 | } |
130 | return 0; |
131 | }; |
132 | |
133 | sub parseNormal { |
134 | my ($self, $text) = @_; |
135 | # type => 'DetectSpaces' |
136 | if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) { |
137 | return 1 |
138 | } |
139 | # String => '#\s*if\s+0' |
140 | # attribute => 'Preprocessor' |
141 | # beginRegion => 'Outscoped' |
142 | # context => 'Outscoped' |
143 | # firstNonSpace => 'true' |
144 | # type => 'RegExpr' |
145 | if ($self->testRegExpr($text, '#\\s*if\\s+0', 0, 0, 0, undef, 1, 'Outscoped', 'Preprocessor')) { |
146 | return 1 |
147 | } |
148 | # attribute => 'Preprocessor' |
149 | # char => '#' |
150 | # context => 'Preprocessor' |
151 | # firstNonSpace => 'true' |
152 | # type => 'DetectChar' |
153 | if ($self->testDetectChar($text, '#', 0, 0, 0, undef, 1, 'Preprocessor', 'Preprocessor')) { |
154 | return 1 |
155 | } |
156 | # String => 'keywords' |
157 | # attribute => 'Keyword' |
158 | # context => '#stay' |
159 | # type => 'keyword' |
160 | if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) { |
161 | return 1 |
162 | } |
163 | # String => 'types' |
164 | # attribute => 'Data Type' |
165 | # context => '#stay' |
166 | # type => 'keyword' |
167 | if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Data Type')) { |
168 | return 1 |
169 | } |
170 | # type => 'DetectIdentifier' |
171 | if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) { |
172 | return 1 |
173 | } |
174 | # attribute => 'Symbol' |
175 | # beginRegion => 'Brace1' |
176 | # char => '{' |
177 | # context => '#stay' |
178 | # type => 'DetectChar' |
179 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, '#stay', 'Symbol')) { |
180 | return 1 |
181 | } |
182 | # attribute => 'Symbol' |
183 | # char => '}' |
184 | # context => '#stay' |
185 | # endRegion => 'Brace1' |
186 | # type => 'DetectChar' |
187 | if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#stay', 'Symbol')) { |
188 | return 1 |
189 | } |
190 | # attribute => 'Float' |
191 | # context => '#stay' |
192 | # items => 'ARRAY(0xec1180)' |
193 | # type => 'Float' |
194 | if ($self->testFloat($text, 0, undef, 0, '#stay', 'Float')) { |
195 | # String => 'fF' |
196 | # attribute => 'Float' |
197 | # context => '#stay' |
198 | # type => 'AnyChar' |
199 | if ($self->testAnyChar($text, 'fF', 0, 0, undef, 0, '#stay', 'Float')) { |
200 | return 1 |
201 | } |
202 | } |
203 | # attribute => 'Octal' |
204 | # context => '#stay' |
205 | # type => 'HlCOct' |
206 | if ($self->testHlCOct($text, 0, undef, 0, '#stay', 'Octal')) { |
207 | return 1 |
208 | } |
209 | # attribute => 'Hex' |
210 | # context => '#stay' |
211 | # type => 'HlCHex' |
212 | if ($self->testHlCHex($text, 0, undef, 0, '#stay', 'Hex')) { |
213 | return 1 |
214 | } |
215 | # attribute => 'Decimal' |
216 | # context => '#stay' |
217 | # items => 'ARRAY(0xef8f50)' |
218 | # type => 'Int' |
219 | if ($self->testInt($text, 0, undef, 0, '#stay', 'Decimal')) { |
220 | # String => 'ULL' |
221 | # attribute => 'Decimal' |
222 | # context => '#stay' |
223 | # insensitive => 'TRUE' |
224 | # type => 'StringDetect' |
225 | if ($self->testStringDetect($text, 'ULL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
226 | return 1 |
227 | } |
228 | # String => 'LUL' |
229 | # attribute => 'Decimal' |
230 | # context => '#stay' |
231 | # insensitive => 'TRUE' |
232 | # type => 'StringDetect' |
233 | if ($self->testStringDetect($text, 'LUL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
234 | return 1 |
235 | } |
236 | # String => 'LLU' |
237 | # attribute => 'Decimal' |
238 | # context => '#stay' |
239 | # insensitive => 'TRUE' |
240 | # type => 'StringDetect' |
241 | if ($self->testStringDetect($text, 'LLU', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
242 | return 1 |
243 | } |
244 | # String => 'UL' |
245 | # attribute => 'Decimal' |
246 | # context => '#stay' |
247 | # insensitive => 'TRUE' |
248 | # type => 'StringDetect' |
249 | if ($self->testStringDetect($text, 'UL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
250 | return 1 |
251 | } |
252 | # String => 'LU' |
253 | # attribute => 'Decimal' |
254 | # context => '#stay' |
255 | # insensitive => 'TRUE' |
256 | # type => 'StringDetect' |
257 | if ($self->testStringDetect($text, 'LU', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
258 | return 1 |
259 | } |
260 | # String => 'LL' |
261 | # attribute => 'Decimal' |
262 | # context => '#stay' |
263 | # insensitive => 'TRUE' |
264 | # type => 'StringDetect' |
265 | if ($self->testStringDetect($text, 'LL', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
266 | return 1 |
267 | } |
268 | # String => 'U' |
269 | # attribute => 'Decimal' |
270 | # context => '#stay' |
271 | # insensitive => 'TRUE' |
272 | # type => 'StringDetect' |
273 | if ($self->testStringDetect($text, 'U', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
274 | return 1 |
275 | } |
276 | # String => 'L' |
277 | # attribute => 'Decimal' |
278 | # context => '#stay' |
279 | # insensitive => 'TRUE' |
280 | # type => 'StringDetect' |
281 | if ($self->testStringDetect($text, 'L', 1, 0, 0, undef, 0, '#stay', 'Decimal')) { |
282 | return 1 |
283 | } |
284 | } |
285 | # attribute => 'Char' |
286 | # context => '#stay' |
287 | # type => 'HlCChar' |
288 | if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Char')) { |
289 | return 1 |
290 | } |
291 | # attribute => 'String' |
292 | # char => '"' |
293 | # context => 'String' |
294 | # type => 'DetectChar' |
295 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String', 'String')) { |
296 | return 1 |
297 | } |
298 | # attribute => 'Comment' |
299 | # beginRegion => 'blockcomment' |
300 | # char => '/' |
301 | # char1 => '*' |
302 | # context => 'comment' |
303 | # type => 'Detect2Chars' |
304 | if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'comment', 'Comment')) { |
305 | return 1 |
306 | } |
307 | # String => ':!%&()+,-/.*<=>?[]|~^;' |
308 | # attribute => 'Symbol' |
309 | # context => '#stay' |
310 | # type => 'AnyChar' |
311 | if ($self->testAnyChar($text, ':!%&()+,-/.*<=>?[]|~^;', 0, 0, undef, 0, '#stay', 'Symbol')) { |
312 | return 1 |
313 | } |
314 | return 0; |
315 | }; |
316 | |
317 | sub parseOutscoped { |
318 | my ($self, $text) = @_; |
319 | # attribute => 'Comment' |
320 | # beginRegion => 'Comment' |
321 | # char => '/' |
322 | # char1 => '*' |
323 | # context => 'comment' |
324 | # type => 'Detect2Chars' |
325 | if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'comment', 'Comment')) { |
326 | return 1 |
327 | } |
328 | # context => '##Alerts' |
329 | # type => 'IncludeRules' |
330 | if ($self->includePlugin('Alerts', $text)) { |
331 | return 1 |
332 | } |
333 | # String => '#\s*if' |
334 | # attribute => 'Comment' |
335 | # beginRegion => 'Outscoped' |
336 | # context => 'Outscoped intern' |
337 | # firstNonSpace => 'true' |
338 | # type => 'RegExpr' |
339 | if ($self->testRegExpr($text, '#\\s*if', 0, 0, 0, undef, 1, 'Outscoped intern', 'Comment')) { |
340 | return 1 |
341 | } |
342 | # String => '#\s*(endif|else|elif)' |
343 | # attribute => 'Preprocessor' |
344 | # context => '#pop' |
345 | # endRegion => 'Outscoped' |
346 | # firstNonSpace => 'true' |
347 | # type => 'RegExpr' |
348 | if ($self->testRegExpr($text, '#\\s*(endif|else|elif)', 0, 0, 0, undef, 1, '#pop', 'Preprocessor')) { |
349 | return 1 |
350 | } |
351 | return 0; |
352 | }; |
353 | |
354 | sub parseOutscopedintern { |
355 | my ($self, $text) = @_; |
356 | # attribute => 'Comment' |
357 | # beginRegion => 'Comment' |
358 | # char => '/' |
359 | # char1 => '*' |
360 | # context => 'comment' |
361 | # type => 'Detect2Chars' |
362 | if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'comment', 'Comment')) { |
363 | return 1 |
364 | } |
365 | # String => '#\s*if' |
366 | # attribute => 'Comment' |
367 | # beginRegion => 'Outscoped' |
368 | # context => 'Outscoped intern' |
369 | # firstNonSpace => 'true' |
370 | # type => 'RegExpr' |
371 | if ($self->testRegExpr($text, '#\\s*if', 0, 0, 0, undef, 1, 'Outscoped intern', 'Comment')) { |
372 | return 1 |
373 | } |
374 | # String => '#\s*endif' |
375 | # attribute => 'Comment' |
376 | # context => '#pop' |
377 | # endRegion => 'Outscoped' |
378 | # firstNonSpace => 'true' |
379 | # type => 'RegExpr' |
380 | if ($self->testRegExpr($text, '#\\s*endif', 0, 0, 0, undef, 1, '#pop', 'Comment')) { |
381 | return 1 |
382 | } |
383 | return 0; |
384 | }; |
385 | |
386 | sub parsePreprocessor { |
387 | my ($self, $text) = @_; |
388 | # attribute => 'Preprocessor' |
389 | # context => '#stay' |
390 | # type => 'LineContinue' |
391 | if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'Preprocessor')) { |
392 | return 1 |
393 | } |
394 | # String => 'define.*((?=\\))' |
395 | # attribute => 'Preprocessor' |
396 | # context => 'Define' |
397 | # type => 'RegExpr' |
398 | if ($self->testRegExpr($text, 'define.*((?=\\\\))', 0, 0, 0, undef, 0, 'Define', 'Preprocessor')) { |
399 | return 1 |
400 | } |
401 | # String => 'define.*' |
402 | # attribute => 'Preprocessor' |
403 | # context => '#stay' |
404 | # type => 'RegExpr' |
405 | if ($self->testRegExpr($text, 'define.*', 0, 0, 0, undef, 0, '#stay', 'Preprocessor')) { |
406 | return 1 |
407 | } |
408 | # attribute => 'Prep. Lib' |
409 | # char => '"' |
410 | # char1 => '"' |
411 | # context => '#stay' |
412 | # type => 'RangeDetect' |
413 | if ($self->testRangeDetect($text, '"', '"', 0, 0, undef, 0, '#stay', 'Prep. Lib')) { |
414 | return 1 |
415 | } |
416 | # attribute => 'Prep. Lib' |
417 | # char => '<' |
418 | # char1 => '>' |
419 | # context => '#stay' |
420 | # type => 'RangeDetect' |
421 | if ($self->testRangeDetect($text, '<', '>', 0, 0, undef, 0, '#stay', 'Prep. Lib')) { |
422 | return 1 |
423 | } |
424 | # attribute => 'Comment' |
425 | # beginRegion => 'blockcomment' |
426 | # char => '/' |
427 | # char1 => '*' |
428 | # context => 'comment' |
429 | # type => 'Detect2Chars' |
430 | if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'comment', 'Comment')) { |
431 | return 1 |
432 | } |
433 | return 0; |
434 | }; |
435 | |
436 | sub parseString { |
437 | my ($self, $text) = @_; |
438 | # attribute => 'String' |
439 | # context => '#stay' |
440 | # type => 'LineContinue' |
441 | if ($self->testLineContinue($text, 0, undef, 0, '#stay', 'String')) { |
442 | return 1 |
443 | } |
444 | # attribute => 'String Char' |
445 | # context => '#stay' |
446 | # type => 'HlCStringChar' |
447 | if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String Char')) { |
448 | return 1 |
449 | } |
450 | # attribute => 'String' |
451 | # char => '"' |
452 | # context => '#pop' |
453 | # type => 'DetectChar' |
454 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) { |
455 | return 1 |
456 | } |
457 | return 0; |
458 | }; |
459 | |
460 | sub parsecomment { |
461 | my ($self, $text) = @_; |
462 | # attribute => 'Comment' |
463 | # char => '*' |
464 | # char1 => '/' |
465 | # context => '#pop' |
466 | # endRegion => 'blockcomment' |
467 | # type => 'Detect2Chars' |
468 | if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) { |
469 | return 1 |
470 | } |
471 | # context => '##Alerts' |
472 | # type => 'IncludeRules' |
473 | if ($self->includePlugin('Alerts', $text)) { |
474 | return 1 |
475 | } |
476 | return 0; |
477 | }; |
478 | |
479 | |
480 | 1; |
481 | |
482 | __END__ |
483 | |
484 | =head1 NAME |
485 | |
486 | Syntax::Highlight::Engine::Kate::ANSI_C89 - a Plugin for ANSI C89 syntax highlighting |
487 | |
488 | =head1 SYNOPSIS |
489 | |
490 | require Syntax::Highlight::Engine::Kate::ANSI_C89; |
491 | my $sh = new Syntax::Highlight::Engine::Kate::ANSI_C89([ |
492 | ]); |
493 | |
494 | =head1 DESCRIPTION |
495 | |
496 | Syntax::Highlight::Engine::Kate::ANSI_C89 is a plugin module that provides syntax highlighting |
497 | for ANSI C89 to the Syntax::Haghlight::Engine::Kate highlighting engine. |
498 | |
499 | This code is generated from the syntax definition files used |
500 | by the Kate project. |
501 | It works quite fine, but can use refinement and optimization. |
502 | |
503 | It inherits Syntax::Higlight::Engine::Kate::Template. See also there. |
504 | |
505 | =cut |
506 | |
507 | =head1 AUTHOR |
508 | |
509 | Hans Jeuken (haje <at> toneel <dot> demon <dot> nl) |
510 | |
511 | =cut |
512 | |
513 | =head1 BUGS |
514 | |
515 | Unknown. If you find any, please contact the author |
516 | |
517 | =cut |
518 | |