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 'yacc.xml' file of the syntax highlight |
6 | # engine of the kate text editor (http://www.kate-editor.org |
7 | |
8 | #kate xml version 1.03 |
9 | #kate version 2.4 |
10 | #kate author Jan Villat (jan.villat@net2000.ch) |
11 | #generated: Sun Feb 3 22:02:06 2008, localtime |
12 | |
13 | package Syntax::Highlight::Engine::Kate::Yacc_Bison; |
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 | 'Alert' => 'Alert', |
27 | 'Backslash Code' => 'String', |
28 | 'Comment' => 'Comment', |
29 | 'Content-Type Delimiter' => 'BaseN', |
30 | 'Data Type' => 'DataType', |
31 | 'Definition' => 'Normal', |
32 | 'Directive' => 'Keyword', |
33 | 'Normal Text' => 'Normal', |
34 | 'Rule' => 'String', |
35 | 'String' => 'String', |
36 | 'String Char' => 'Char', |
37 | }); |
38 | $self->contextdata({ |
39 | 'C Declarations' => { |
40 | callback => \&parseCDeclarations, |
41 | attribute => 'Normal Text', |
42 | }, |
43 | 'Char' => { |
44 | callback => \&parseChar, |
45 | attribute => 'String Char', |
46 | lineending => '#pop', |
47 | }, |
48 | 'Comment' => { |
49 | callback => \&parseComment, |
50 | attribute => 'Comment', |
51 | }, |
52 | 'CommentSlash' => { |
53 | callback => \&parseCommentSlash, |
54 | attribute => 'Comment', |
55 | }, |
56 | 'CommentStar' => { |
57 | callback => \&parseCommentStar, |
58 | attribute => 'Comment', |
59 | }, |
60 | 'Declarations' => { |
61 | callback => \&parseDeclarations, |
62 | attribute => 'Normal Text', |
63 | }, |
64 | 'Dol' => { |
65 | callback => \&parseDol, |
66 | attribute => 'Normal Text', |
67 | fallthrough => 'DolEnd', |
68 | }, |
69 | 'DolEnd' => { |
70 | callback => \&parseDolEnd, |
71 | attribute => 'Normal Text', |
72 | }, |
73 | 'Normal C Bloc' => { |
74 | callback => \&parseNormalCBloc, |
75 | attribute => 'Normal Text', |
76 | }, |
77 | 'PC type' => { |
78 | callback => \&parsePCtype, |
79 | attribute => 'Data Type', |
80 | lineending => '#pop#pop#pop', |
81 | }, |
82 | 'Percent Command' => { |
83 | callback => \&parsePercentCommand, |
84 | attribute => 'Directive', |
85 | lineending => '#pop', |
86 | }, |
87 | 'Percent Command In' => { |
88 | callback => \&parsePercentCommandIn, |
89 | attribute => 'NormalText', |
90 | lineending => '#pop#pop', |
91 | }, |
92 | 'Pre Start' => { |
93 | callback => \&parsePreStart, |
94 | attribute => 'Normal Text', |
95 | }, |
96 | 'Rule In' => { |
97 | callback => \&parseRuleIn, |
98 | attribute => 'Definition', |
99 | }, |
100 | 'Rules' => { |
101 | callback => \&parseRules, |
102 | attribute => 'Rule', |
103 | }, |
104 | 'String' => { |
105 | callback => \&parseString, |
106 | attribute => 'String', |
107 | lineending => '#pop', |
108 | }, |
109 | 'StringOrChar' => { |
110 | callback => \&parseStringOrChar, |
111 | attribute => 'NormalText', |
112 | }, |
113 | 'Union In' => { |
114 | callback => \&parseUnionIn, |
115 | attribute => 'Normal Text', |
116 | }, |
117 | 'Union InIn' => { |
118 | callback => \&parseUnionInIn, |
119 | attribute => 'Normal Text', |
120 | }, |
121 | 'Union Start' => { |
122 | callback => \&parseUnionStart, |
123 | attribute => 'Normal Text', |
124 | }, |
125 | 'User Code' => { |
126 | callback => \&parseUserCode, |
127 | attribute => 'Normal Text', |
128 | }, |
129 | }); |
130 | $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\'); |
131 | $self->basecontext('Pre Start'); |
132 | $self->keywordscase(1); |
133 | $self->initialize; |
134 | bless ($self, $class); |
135 | return $self; |
136 | } |
137 | |
138 | sub language { |
139 | return 'Yacc/Bison'; |
140 | } |
141 | |
142 | sub parseCDeclarations { |
143 | my ($self, $text) = @_; |
144 | # context => 'Comment' |
145 | # type => 'IncludeRules' |
146 | if ($self->includeRules('Comment', $text)) { |
147 | return 1 |
148 | } |
149 | # attribute => 'Content-Type Delimiter' |
150 | # char => '%' |
151 | # char1 => '}' |
152 | # column => '0' |
153 | # context => '#pop' |
154 | # endRegion => 'cdeclarations' |
155 | # type => 'Detect2Chars' |
156 | if ($self->testDetect2Chars($text, '%', '}', 0, 0, 0, 0, 0, '#pop', 'Content-Type Delimiter')) { |
157 | return 1 |
158 | } |
159 | # context => '##C++' |
160 | # type => 'IncludeRules' |
161 | if ($self->includePlugin('C++', $text)) { |
162 | return 1 |
163 | } |
164 | return 0; |
165 | }; |
166 | |
167 | sub parseChar { |
168 | my ($self, $text) = @_; |
169 | # String => '\\.' |
170 | # attribute => 'Backslash Code' |
171 | # context => '#stay' |
172 | # type => 'RegExpr' |
173 | if ($self->testRegExpr($text, '\\\\.', 0, 0, 0, undef, 0, '#stay', 'Backslash Code')) { |
174 | return 1 |
175 | } |
176 | # attribute => 'String Char' |
177 | # char => ''' |
178 | # context => '#pop' |
179 | # type => 'DetectChar' |
180 | if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'String Char')) { |
181 | return 1 |
182 | } |
183 | return 0; |
184 | }; |
185 | |
186 | sub parseComment { |
187 | my ($self, $text) = @_; |
188 | # attribute => 'Comment' |
189 | # char => '/' |
190 | # char1 => '*' |
191 | # context => 'CommentStar' |
192 | # type => 'Detect2Chars' |
193 | if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'CommentStar', 'Comment')) { |
194 | return 1 |
195 | } |
196 | # attribute => 'Comment' |
197 | # char => '/' |
198 | # char1 => '/' |
199 | # context => 'CommentSlash' |
200 | # type => 'Detect2Chars' |
201 | if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'CommentSlash', 'Comment')) { |
202 | return 1 |
203 | } |
204 | return 0; |
205 | }; |
206 | |
207 | sub parseCommentSlash { |
208 | my ($self, $text) = @_; |
209 | # String => '[^\\]$' |
210 | # attribute => 'Comment' |
211 | # context => '#pop' |
212 | # type => 'RegExpr' |
213 | if ($self->testRegExpr($text, '[^\\\\]$', 0, 0, 0, undef, 0, '#pop', 'Comment')) { |
214 | return 1 |
215 | } |
216 | return 0; |
217 | }; |
218 | |
219 | sub parseCommentStar { |
220 | my ($self, $text) = @_; |
221 | # attribute => 'Comment' |
222 | # char => '*' |
223 | # char1 => '/' |
224 | # context => '#pop' |
225 | # type => 'Detect2Chars' |
226 | if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) { |
227 | return 1 |
228 | } |
229 | return 0; |
230 | }; |
231 | |
232 | sub parseDeclarations { |
233 | my ($self, $text) = @_; |
234 | # context => 'Comment' |
235 | # type => 'IncludeRules' |
236 | if ($self->includeRules('Comment', $text)) { |
237 | return 1 |
238 | } |
239 | # String => '%union' |
240 | # attribute => 'Directive' |
241 | # context => 'Union Start' |
242 | # type => 'StringDetect' |
243 | if ($self->testStringDetect($text, '%union', 0, 0, 0, undef, 0, 'Union Start', 'Directive')) { |
244 | return 1 |
245 | } |
246 | # attribute => 'Content-Type Delimiter' |
247 | # beginRegion => 'rules' |
248 | # char => '%' |
249 | # char1 => '%' |
250 | # context => 'Rules' |
251 | # endRegion => 'declarations' |
252 | # type => 'Detect2Chars' |
253 | if ($self->testDetect2Chars($text, '%', '%', 0, 0, 0, undef, 0, 'Rules', 'Content-Type Delimiter')) { |
254 | return 1 |
255 | } |
256 | # attribute => 'Content-Type Delimiter' |
257 | # beginRegion => 'cdeclarations' |
258 | # char => '%' |
259 | # char1 => '{' |
260 | # column => '0' |
261 | # context => 'C Declarations' |
262 | # type => 'Detect2Chars' |
263 | if ($self->testDetect2Chars($text, '%', '{', 0, 0, 0, 0, 0, 'C Declarations', 'Content-Type Delimiter')) { |
264 | return 1 |
265 | } |
266 | # attribute => 'Directive' |
267 | # char => '%' |
268 | # context => 'Percent Command' |
269 | # type => 'DetectChar' |
270 | if ($self->testDetectChar($text, '%', 0, 0, 0, undef, 0, 'Percent Command', 'Directive')) { |
271 | return 1 |
272 | } |
273 | return 0; |
274 | }; |
275 | |
276 | sub parseDol { |
277 | my ($self, $text) = @_; |
278 | # String => '<[^>]+>' |
279 | # attribute => 'Data Type' |
280 | # context => 'DolEnd' |
281 | # type => 'RegExpr' |
282 | if ($self->testRegExpr($text, '<[^>]+>', 0, 0, 0, undef, 0, 'DolEnd', 'Data Type')) { |
283 | return 1 |
284 | } |
285 | return 0; |
286 | }; |
287 | |
288 | sub parseDolEnd { |
289 | my ($self, $text) = @_; |
290 | # String => '\d+' |
291 | # attribute => 'Directive' |
292 | # context => '#pop#pop' |
293 | # type => 'RegExpr' |
294 | if ($self->testRegExpr($text, '\\d+', 0, 0, 0, undef, 0, '#pop#pop', 'Directive')) { |
295 | return 1 |
296 | } |
297 | # attribute => 'Directive' |
298 | # char => '$' |
299 | # context => '#pop#pop' |
300 | # type => 'DetectChar' |
301 | if ($self->testDetectChar($text, '$', 0, 0, 0, undef, 0, '#pop#pop', 'Directive')) { |
302 | return 1 |
303 | } |
304 | return 0; |
305 | }; |
306 | |
307 | sub parseNormalCBloc { |
308 | my ($self, $text) = @_; |
309 | # attribute => 'Normal Text' |
310 | # beginRegion => 'bloc' |
311 | # char => '{' |
312 | # context => 'Normal C Bloc' |
313 | # type => 'DetectChar' |
314 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, 'Normal C Bloc', 'Normal Text')) { |
315 | return 1 |
316 | } |
317 | # attribute => 'Normal Text' |
318 | # char => '}' |
319 | # context => '#pop' |
320 | # endRegion => 'bloc' |
321 | # type => 'DetectChar' |
322 | if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#pop', 'Normal Text')) { |
323 | return 1 |
324 | } |
325 | # context => '##C++' |
326 | # type => 'IncludeRules' |
327 | if ($self->includePlugin('C++', $text)) { |
328 | return 1 |
329 | } |
330 | # attribute => 'Directive' |
331 | # char => '$' |
332 | # context => 'Dol' |
333 | # type => 'DetectChar' |
334 | if ($self->testDetectChar($text, '$', 0, 0, 0, undef, 0, 'Dol', 'Directive')) { |
335 | return 1 |
336 | } |
337 | return 0; |
338 | }; |
339 | |
340 | sub parsePCtype { |
341 | my ($self, $text) = @_; |
342 | # attribute => 'Data Type' |
343 | # char => '>' |
344 | # context => '#pop' |
345 | # type => 'DetectChar' |
346 | if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop', 'Data Type')) { |
347 | return 1 |
348 | } |
349 | return 0; |
350 | }; |
351 | |
352 | sub parsePercentCommand { |
353 | my ($self, $text) = @_; |
354 | # context => 'Comment' |
355 | # type => 'IncludeRules' |
356 | if ($self->includeRules('Comment', $text)) { |
357 | return 1 |
358 | } |
359 | # String => '\W' |
360 | # attribute => 'Normal Text' |
361 | # context => 'Percent Command In' |
362 | # lookAhead => 'true' |
363 | # type => 'RegExpr' |
364 | if ($self->testRegExpr($text, '\\W', 0, 0, 1, undef, 0, 'Percent Command In', 'Normal Text')) { |
365 | return 1 |
366 | } |
367 | return 0; |
368 | }; |
369 | |
370 | sub parsePercentCommandIn { |
371 | my ($self, $text) = @_; |
372 | # context => 'StringOrChar' |
373 | # type => 'IncludeRules' |
374 | if ($self->includeRules('StringOrChar', $text)) { |
375 | return 1 |
376 | } |
377 | # attribute => 'Data Type' |
378 | # char => '<' |
379 | # context => 'PC type' |
380 | # type => 'DetectChar' |
381 | if ($self->testDetectChar($text, '<', 0, 0, 0, undef, 0, 'PC type', 'Data Type')) { |
382 | return 1 |
383 | } |
384 | return 0; |
385 | }; |
386 | |
387 | sub parsePreStart { |
388 | my ($self, $text) = @_; |
389 | # context => 'Comment' |
390 | # type => 'IncludeRules' |
391 | if ($self->includeRules('Comment', $text)) { |
392 | return 1 |
393 | } |
394 | # type => 'DetectSpaces' |
395 | if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) { |
396 | return 1 |
397 | } |
398 | # attribute => 'Content-Type Delimiter' |
399 | # beginRegion => 'cdeclarations' |
400 | # char => '%' |
401 | # char1 => '{' |
402 | # column => '0' |
403 | # context => 'C Declarations' |
404 | # type => 'Detect2Chars' |
405 | if ($self->testDetect2Chars($text, '%', '{', 0, 0, 0, 0, 0, 'C Declarations', 'Content-Type Delimiter')) { |
406 | return 1 |
407 | } |
408 | # String => '.' |
409 | # attribute => 'Normal Text' |
410 | # beginRegion => 'declarations' |
411 | # context => 'Declarations' |
412 | # lookAhead => 'true' |
413 | # type => 'RegExpr' |
414 | if ($self->testRegExpr($text, '.', 0, 0, 1, undef, 0, 'Declarations', 'Normal Text')) { |
415 | return 1 |
416 | } |
417 | return 0; |
418 | }; |
419 | |
420 | sub parseRuleIn { |
421 | my ($self, $text) = @_; |
422 | # context => 'Comment' |
423 | # type => 'IncludeRules' |
424 | if ($self->includeRules('Comment', $text)) { |
425 | return 1 |
426 | } |
427 | # attribute => 'Normal Text' |
428 | # char => ';' |
429 | # context => '#pop' |
430 | # endRegion => 'rule' |
431 | # type => 'DetectChar' |
432 | if ($self->testDetectChar($text, ';', 0, 0, 0, undef, 0, '#pop', 'Normal Text')) { |
433 | return 1 |
434 | } |
435 | # attribute => 'Normal Text' |
436 | # beginRegion => 'bloc' |
437 | # char => '{' |
438 | # context => 'Normal C Bloc' |
439 | # type => 'DetectChar' |
440 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, 'Normal C Bloc', 'Normal Text')) { |
441 | return 1 |
442 | } |
443 | # attribute => 'Normal Text' |
444 | # char => '|' |
445 | # context => '#stay' |
446 | # type => 'DetectChar' |
447 | if ($self->testDetectChar($text, '|', 0, 0, 0, undef, 0, '#stay', 'Normal Text')) { |
448 | return 1 |
449 | } |
450 | # context => 'StringOrChar' |
451 | # type => 'IncludeRules' |
452 | if ($self->includeRules('StringOrChar', $text)) { |
453 | return 1 |
454 | } |
455 | return 0; |
456 | }; |
457 | |
458 | sub parseRules { |
459 | my ($self, $text) = @_; |
460 | # context => 'Comment' |
461 | # type => 'IncludeRules' |
462 | if ($self->includeRules('Comment', $text)) { |
463 | return 1 |
464 | } |
465 | # attribute => 'Content-Type Delimiter' |
466 | # beginRegion => 'code' |
467 | # char => '%' |
468 | # char1 => '%' |
469 | # context => 'User Code' |
470 | # endRegion => 'rules' |
471 | # type => 'Detect2Chars' |
472 | if ($self->testDetect2Chars($text, '%', '%', 0, 0, 0, undef, 0, 'User Code', 'Content-Type Delimiter')) { |
473 | return 1 |
474 | } |
475 | # attribute => 'Normal Text' |
476 | # beginRegion => 'rule' |
477 | # char => ':' |
478 | # context => 'Rule In' |
479 | # type => 'DetectChar' |
480 | if ($self->testDetectChar($text, ':', 0, 0, 0, undef, 0, 'Rule In', 'Normal Text')) { |
481 | return 1 |
482 | } |
483 | return 0; |
484 | }; |
485 | |
486 | sub parseString { |
487 | my ($self, $text) = @_; |
488 | # String => '\\.' |
489 | # attribute => 'Backslash Code' |
490 | # context => '#stay' |
491 | # type => 'RegExpr' |
492 | if ($self->testRegExpr($text, '\\\\.', 0, 0, 0, undef, 0, '#stay', 'Backslash Code')) { |
493 | return 1 |
494 | } |
495 | # attribute => 'String' |
496 | # char => '"' |
497 | # context => '#pop' |
498 | # type => 'DetectChar' |
499 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) { |
500 | return 1 |
501 | } |
502 | return 0; |
503 | }; |
504 | |
505 | sub parseStringOrChar { |
506 | my ($self, $text) = @_; |
507 | # attribute => 'String Char' |
508 | # char => ''' |
509 | # context => 'Char' |
510 | # type => 'DetectChar' |
511 | if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Char', 'String Char')) { |
512 | return 1 |
513 | } |
514 | # attribute => 'String' |
515 | # char => '"' |
516 | # context => 'String' |
517 | # type => 'DetectChar' |
518 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'String', 'String')) { |
519 | return 1 |
520 | } |
521 | return 0; |
522 | }; |
523 | |
524 | sub parseUnionIn { |
525 | my ($self, $text) = @_; |
526 | # attribute => 'Normal Text' |
527 | # char => '{' |
528 | # context => 'Union InIn' |
529 | # type => 'DetectChar' |
530 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, 'Union InIn', 'Normal Text')) { |
531 | return 1 |
532 | } |
533 | # attribute => 'Normal Text' |
534 | # char => '}' |
535 | # context => '#pop#pop' |
536 | # endRegion => 'union' |
537 | # type => 'DetectChar' |
538 | if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#pop#pop', 'Normal Text')) { |
539 | return 1 |
540 | } |
541 | # context => '##C++' |
542 | # type => 'IncludeRules' |
543 | if ($self->includePlugin('C++', $text)) { |
544 | return 1 |
545 | } |
546 | return 0; |
547 | }; |
548 | |
549 | sub parseUnionInIn { |
550 | my ($self, $text) = @_; |
551 | # attribute => 'Normal Text' |
552 | # char => '{' |
553 | # context => 'Union InIn' |
554 | # type => 'DetectChar' |
555 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, 'Union InIn', 'Normal Text')) { |
556 | return 1 |
557 | } |
558 | # attribute => 'Normal Text' |
559 | # char => '}' |
560 | # context => '#pop' |
561 | # type => 'DetectChar' |
562 | if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#pop', 'Normal Text')) { |
563 | return 1 |
564 | } |
565 | # context => '##C++' |
566 | # type => 'IncludeRules' |
567 | if ($self->includePlugin('C++', $text)) { |
568 | return 1 |
569 | } |
570 | return 0; |
571 | }; |
572 | |
573 | sub parseUnionStart { |
574 | my ($self, $text) = @_; |
575 | # context => 'Comment' |
576 | # type => 'IncludeRules' |
577 | if ($self->includeRules('Comment', $text)) { |
578 | return 1 |
579 | } |
580 | # type => 'DetectSpaces' |
581 | if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) { |
582 | return 1 |
583 | } |
584 | # attribute => 'Normal Text' |
585 | # beginRegion => 'union' |
586 | # char => '{' |
587 | # context => 'Union In' |
588 | # type => 'DetectChar' |
589 | if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, 'Union In', 'Normal Text')) { |
590 | return 1 |
591 | } |
592 | # String => '.' |
593 | # attribute => 'Alert' |
594 | # context => '#pop' |
595 | # type => 'RegExpr' |
596 | if ($self->testRegExpr($text, '.', 0, 0, 0, undef, 0, '#pop', 'Alert')) { |
597 | return 1 |
598 | } |
599 | return 0; |
600 | }; |
601 | |
602 | sub parseUserCode { |
603 | my ($self, $text) = @_; |
604 | # context => '##C++' |
605 | # type => 'IncludeRules' |
606 | if ($self->includePlugin('C++', $text)) { |
607 | return 1 |
608 | } |
609 | return 0; |
610 | }; |
611 | |
612 | |
613 | 1; |
614 | |
615 | __END__ |
616 | |
617 | =head1 NAME |
618 | |
619 | Syntax::Highlight::Engine::Kate::Yacc_Bison - a Plugin for Yacc/Bison syntax highlighting |
620 | |
621 | =head1 SYNOPSIS |
622 | |
623 | require Syntax::Highlight::Engine::Kate::Yacc_Bison; |
624 | my $sh = new Syntax::Highlight::Engine::Kate::Yacc_Bison([ |
625 | ]); |
626 | |
627 | =head1 DESCRIPTION |
628 | |
629 | Syntax::Highlight::Engine::Kate::Yacc_Bison is a plugin module that provides syntax highlighting |
630 | for Yacc/Bison to the Syntax::Haghlight::Engine::Kate highlighting engine. |
631 | |
632 | This code is generated from the syntax definition files used |
633 | by the Kate project. |
634 | It works quite fine, but can use refinement and optimization. |
635 | |
636 | It inherits Syntax::Higlight::Engine::Kate::Template. See also there. |
637 | |
638 | =cut |
639 | |
640 | =head1 AUTHOR |
641 | |
642 | Hans Jeuken (haje <at> toneel <dot> demon <dot> nl) |
643 | |
644 | =cut |
645 | |
646 | =head1 BUGS |
647 | |
648 | Unknown. If you find any, please contact the author |
649 | |
650 | =cut |
651 | |