Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Syntax / Highlight / Engine / Kate / Python.pm
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 'python.xml' file of the syntax highlight
6 # engine of the kate text editor (http://www.kate-editor.org
7
8 #kate xml version 1.23
9 #kate version 2.4
10 #kate author Per Wigren
11 #generated: Sun Feb  3 22:02:06 2008, localtime
12
13 package Syntax::Highlight::Engine::Kate::Python;
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       'Builtin Function' => 'DataType',
27       'Comment' => 'Comment',
28       'Complex' => 'Others',
29       'Float' => 'Float',
30       'Hex' => 'Others',
31       'Int' => 'DecVal',
32       'Keyword' => 'Keyword',
33       'Long' => 'Others',
34       'Normal Text' => 'Normal',
35       'Octal' => 'Others',
36       'Operator' => 'Char',
37       'Preprocessor' => 'Char',
38       'Raw String' => 'String',
39       'Special Variable' => 'Others',
40       'String' => 'String',
41    });
42    $self->listAdd('builtinfuncs',
43       'abs',
44       'apply',
45       'buffer',
46       'callable',
47       'chr',
48       'cmp',
49       'coerce',
50       'compile',
51       'complex',
52       'copyright',
53       'credits',
54       'delattr',
55       'dir',
56       'divmod',
57       'eval',
58       'execfile',
59       'exit',
60       'filter',
61       'float',
62       'getattr',
63       'globals',
64       'hasattr',
65       'hash',
66       'hex',
67       'id',
68       'input',
69       'int',
70       'intern',
71       'isinstance',
72       'issubclass',
73       'iter',
74       'len',
75       'license',
76       'list',
77       'locals',
78       'long',
79       'map',
80       'max',
81       'min',
82       'oct',
83       'open',
84       'ord',
85       'pow',
86       'quit',
87       'range',
88       'raw_input',
89       'reduce',
90       'reload',
91       'repr',
92       'round',
93       'setattr',
94       'slice',
95       'str',
96       'tuple',
97       'type',
98       'unichr',
99       'unicode',
100       'vars',
101       'xrange',
102       'zip',
103    );
104    $self->listAdd('prep',
105       'as',
106       'from',
107       'import',
108    );
109    $self->listAdd('specialvars',
110       'Ellipsis',
111       'False',
112       'None',
113       'NotImplemented',
114       'True',
115       'self',
116    );
117    $self->listAdd('statements',
118       'and',
119       'assert',
120       'break',
121       'class',
122       'continue',
123       'def',
124       'del',
125       'elif',
126       'else',
127       'except',
128       'exec',
129       'finally',
130       'for',
131       'global',
132       'if',
133       'in',
134       'is',
135       'lambda',
136       'not',
137       'or',
138       'pass',
139       'print',
140       'raise',
141       'return',
142       'try',
143       'while',
144       'yield',
145    );
146    $self->contextdata({
147       'Normal' => {
148          callback => \&parseNormal,
149          attribute => 'Normal Text',
150       },
151       'Raw A-string' => {
152          callback => \&parseRawAstring,
153          attribute => 'Raw String',
154       },
155       'Raw Q-string' => {
156          callback => \&parseRawQstring,
157          attribute => 'Raw String',
158       },
159       'Single A-comment' => {
160          callback => \&parseSingleAcomment,
161          attribute => 'Comment',
162       },
163       'Single A-string' => {
164          callback => \&parseSingleAstring,
165          attribute => 'String',
166       },
167       'Single Q-comment' => {
168          callback => \&parseSingleQcomment,
169          attribute => 'Comment',
170       },
171       'Single Q-string' => {
172          callback => \&parseSingleQstring,
173          attribute => 'String',
174       },
175       'Tripple A-comment' => {
176          callback => \&parseTrippleAcomment,
177          attribute => 'Comment',
178       },
179       'Tripple A-string' => {
180          callback => \&parseTrippleAstring,
181          attribute => 'String',
182       },
183       'Tripple Q-comment' => {
184          callback => \&parseTrippleQcomment,
185          attribute => 'Comment',
186       },
187       'Tripple Q-string' => {
188          callback => \&parseTrippleQstring,
189          attribute => 'String',
190       },
191    });
192    $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
193    $self->basecontext('Normal');
194    $self->keywordscase(0);
195    $self->initialize;
196    bless ($self, $class);
197    return $self;
198 }
199
200 sub language {
201    return 'Python';
202 }
203
204 sub parseNormal {
205    my ($self, $text) = @_;
206    # String => 'prep'
207    # attribute => 'Preprocessor'
208    # context => '#stay'
209    # type => 'keyword'
210    if ($self->testKeyword($text, 'prep', 0, undef, 0, '#stay', 'Preprocessor')) {
211       return 1
212    }
213    # String => 'statements'
214    # attribute => 'Keyword'
215    # context => '#stay'
216    # type => 'keyword'
217    if ($self->testKeyword($text, 'statements', 0, undef, 0, '#stay', 'Keyword')) {
218       return 1
219    }
220    # String => 'builtinfuncs'
221    # attribute => 'Builtin Function'
222    # context => '#stay'
223    # type => 'keyword'
224    if ($self->testKeyword($text, 'builtinfuncs', 0, undef, 0, '#stay', 'Builtin Function')) {
225       return 1
226    }
227    # String => 'specialvars'
228    # attribute => 'Special Variable'
229    # context => '#stay'
230    # type => 'keyword'
231    if ($self->testKeyword($text, 'specialvars', 0, undef, 0, '#stay', 'Special Variable')) {
232       return 1
233    }
234    # String => '[a-zA-Z_]\w+'
235    # attribute => 'Normal'
236    # context => '#stay'
237    # type => 'RegExpr'
238    if ($self->testRegExpr($text, '[a-zA-Z_]\\w+', 0, 0, 0, undef, 0, '#stay', 'Normal')) {
239       return 1
240    }
241    # String => ' (((\d*\.\d+|\d+\.)|(\d+|(\d*\.\d+|\d+\.))[eE][+-]?\d+)|\d+)[jJ]'
242    # attribute => 'Complex'
243    # context => '#stay'
244    # type => 'RegExpr'
245    if ($self->testRegExpr($text, ' (((\\d*\\.\\d+|\\d+\\.)|(\\d+|(\\d*\\.\\d+|\\d+\\.))[eE][+-]?\\d+)|\\d+)[jJ]', 0, 0, 0, undef, 0, '#stay', 'Complex')) {
246       return 1
247    }
248    # String => '(\d+\.\d*|\.\d+)([eE]\d+)?'
249    # attribute => 'Float'
250    # context => '#stay'
251    # type => 'RegExpr'
252    if ($self->testRegExpr($text, '(\\d+\\.\\d*|\\.\\d+)([eE]\\d+)?', 0, 0, 0, undef, 0, '#stay', 'Float')) {
253       return 1
254    }
255    # String => '([1-9]\d*([eE]\d+)?|0)'
256    # attribute => 'Int'
257    # context => '#stay'
258    # type => 'RegExpr'
259    if ($self->testRegExpr($text, '([1-9]\\d*([eE]\\d+)?|0)', 0, 0, 0, undef, 0, '#stay', 'Int')) {
260       return 1
261    }
262    # String => '[1-9]\d*([eE][\d.]+)?[Ll]'
263    # attribute => 'Long'
264    # context => '#stay'
265    # type => 'RegExpr'
266    if ($self->testRegExpr($text, '[1-9]\\d*([eE][\\d.]+)?[Ll]', 0, 0, 0, undef, 0, '#stay', 'Long')) {
267       return 1
268    }
269    # String => '0[Xx][\da-fA-F]+'
270    # attribute => 'Hex'
271    # context => '#stay'
272    # type => 'RegExpr'
273    if ($self->testRegExpr($text, '0[Xx][\\da-fA-F]+', 0, 0, 0, undef, 0, '#stay', 'Hex')) {
274       return 1
275    }
276    # String => '0[1-9]\d*'
277    # attribute => 'Octal'
278    # context => '#stay'
279    # type => 'RegExpr'
280    if ($self->testRegExpr($text, '0[1-9]\\d*', 0, 0, 0, undef, 0, '#stay', 'Octal')) {
281       return 1
282    }
283    # String => '[rR]''
284    # attribute => 'Raw String'
285    # context => 'Raw A-string'
286    # type => 'RegExpr'
287    if ($self->testRegExpr($text, '[rR]\'', 0, 0, 0, undef, 0, 'Raw A-string', 'Raw String')) {
288       return 1
289    }
290    # String => '[rR]"'
291    # attribute => 'Raw String'
292    # context => 'Raw Q-string'
293    # type => 'RegExpr'
294    if ($self->testRegExpr($text, '[rR]"', 0, 0, 0, undef, 0, 'Raw Q-string', 'Raw String')) {
295       return 1
296    }
297    # String => '#.*$'
298    # attribute => 'Comment'
299    # context => '#stay'
300    # type => 'RegExpr'
301    if ($self->testRegExpr($text, '#.*$', 0, 0, 0, undef, 0, '#stay', 'Comment')) {
302       return 1
303    }
304    # String => '''''
305    # attribute => 'Comment'
306    # context => 'Tripple A-comment'
307    # firstNonSpace => 'true'
308    # type => 'StringDetect'
309    if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 1, 'Tripple A-comment', 'Comment')) {
310       return 1
311    }
312    # String => '"""'
313    # attribute => 'Comment'
314    # context => 'Tripple Q-comment'
315    # firstNonSpace => 'true'
316    # type => 'StringDetect'
317    if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 1, 'Tripple Q-comment', 'Comment')) {
318       return 1
319    }
320    # String => '''''
321    # attribute => 'String'
322    # context => 'Tripple A-string'
323    # type => 'StringDetect'
324    if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 0, 'Tripple A-string', 'String')) {
325       return 1
326    }
327    # String => '"""'
328    # attribute => 'String'
329    # context => 'Tripple Q-string'
330    # type => 'StringDetect'
331    if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 0, 'Tripple Q-string', 'String')) {
332       return 1
333    }
334    # attribute => 'String'
335    # char => '''
336    # context => 'Single A-string'
337    # type => 'DetectChar'
338    if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Single A-string', 'String')) {
339       return 1
340    }
341    # attribute => 'String'
342    # char => '"'
343    # context => 'Single Q-string'
344    # type => 'DetectChar'
345    if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'Single Q-string', 'String')) {
346       return 1
347    }
348    # String => '[+*/\(\)%\|\[\]\{\}:=;\!<>!^&~-]'
349    # attribute => 'Operator'
350    # context => '#stay'
351    # type => 'RegExpr'
352    if ($self->testRegExpr($text, '[+*/\\(\\)%\\|\\[\\]\\{\\}:=;\\!<>!^&~-]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
353       return 1
354    }
355    return 0;
356 };
357
358 sub parseRawAstring {
359    my ($self, $text) = @_;
360    # attribute => 'Raw String'
361    # context => '#stay'
362    # type => 'HlCStringChar'
363    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Raw String')) {
364       return 1
365    }
366    # attribute => 'Raw String'
367    # char => '''
368    # context => '#pop'
369    # type => 'DetectChar'
370    if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Raw String')) {
371       return 1
372    }
373    return 0;
374 };
375
376 sub parseRawQstring {
377    my ($self, $text) = @_;
378    # attribute => 'Raw String'
379    # context => '#stay'
380    # type => 'HlCStringChar'
381    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Raw String')) {
382       return 1
383    }
384    # attribute => 'Raw String'
385    # char => '"'
386    # context => '#pop'
387    # type => 'DetectChar'
388    if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Raw String')) {
389       return 1
390    }
391    return 0;
392 };
393
394 sub parseSingleAcomment {
395    my ($self, $text) = @_;
396    # attribute => 'Comment'
397    # context => '#stay'
398    # type => 'HlCStringChar'
399    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Comment')) {
400       return 1
401    }
402    # attribute => 'Comment'
403    # char => '''
404    # context => '#pop'
405    # type => 'DetectChar'
406    if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
407       return 1
408    }
409    return 0;
410 };
411
412 sub parseSingleAstring {
413    my ($self, $text) = @_;
414    # attribute => 'String'
415    # context => '#stay'
416    # type => 'HlCStringChar'
417    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
418       return 1
419    }
420    # String => '%[a-zA-Z]'
421    # attribute => 'Operator'
422    # context => '#stay'
423    # type => 'RegExpr'
424    if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
425       return 1
426    }
427    # attribute => 'String'
428    # char => '''
429    # context => '#pop'
430    # type => 'DetectChar'
431    if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'String')) {
432       return 1
433    }
434    return 0;
435 };
436
437 sub parseSingleQcomment {
438    my ($self, $text) = @_;
439    # attribute => 'Comment'
440    # context => '#stay'
441    # type => 'HlCStringChar'
442    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Comment')) {
443       return 1
444    }
445    # attribute => 'Comment'
446    # char => '"'
447    # context => '#pop'
448    # type => 'DetectChar'
449    if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
450       return 1
451    }
452    return 0;
453 };
454
455 sub parseSingleQstring {
456    my ($self, $text) = @_;
457    # attribute => 'String'
458    # context => '#stay'
459    # type => 'HlCStringChar'
460    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
461       return 1
462    }
463    # String => '%[a-zA-Z]'
464    # attribute => 'Operator'
465    # context => '#stay'
466    # type => 'RegExpr'
467    if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
468       return 1
469    }
470    # attribute => 'String'
471    # char => '"'
472    # context => '#pop'
473    # type => 'DetectChar'
474    if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) {
475       return 1
476    }
477    return 0;
478 };
479
480 sub parseTrippleAcomment {
481    my ($self, $text) = @_;
482    # attribute => 'Comment'
483    # context => '#stay'
484    # type => 'HlCChar'
485    if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Comment')) {
486       return 1
487    }
488    # String => '''''
489    # attribute => 'Comment'
490    # context => '#pop'
491    # type => 'StringDetect'
492    if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
493       return 1
494    }
495    return 0;
496 };
497
498 sub parseTrippleAstring {
499    my ($self, $text) = @_;
500    # attribute => 'String'
501    # context => '#stay'
502    # type => 'HlCChar'
503    if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'String')) {
504       return 1
505    }
506    # String => '%[a-zA-Z]'
507    # attribute => 'Operator'
508    # context => '#stay'
509    # type => 'RegExpr'
510    if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
511       return 1
512    }
513    # String => '''''
514    # attribute => 'String'
515    # context => '#pop'
516    # type => 'StringDetect'
517    if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 0, '#pop', 'String')) {
518       return 1
519    }
520    return 0;
521 };
522
523 sub parseTrippleQcomment {
524    my ($self, $text) = @_;
525    # attribute => 'Comment'
526    # context => '#stay'
527    # type => 'HlCChar'
528    if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Comment')) {
529       return 1
530    }
531    # String => '"""'
532    # attribute => 'Comment'
533    # context => '#pop'
534    # type => 'StringDetect'
535    if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
536       return 1
537    }
538    return 0;
539 };
540
541 sub parseTrippleQstring {
542    my ($self, $text) = @_;
543    # attribute => 'String'
544    # context => '#stay'
545    # type => 'HlCStringChar'
546    if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
547       return 1
548    }
549    # String => '%[a-zA-Z]'
550    # attribute => 'Operator'
551    # context => '#stay'
552    # type => 'RegExpr'
553    if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
554       return 1
555    }
556    # String => '"""'
557    # attribute => 'String'
558    # context => '#pop'
559    # type => 'StringDetect'
560    if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 0, '#pop', 'String')) {
561       return 1
562    }
563    return 0;
564 };
565
566
567 1;
568
569 __END__
570
571 =head1 NAME
572
573 Syntax::Highlight::Engine::Kate::Python - a Plugin for Python syntax highlighting
574
575 =head1 SYNOPSIS
576
577  require Syntax::Highlight::Engine::Kate::Python;
578  my $sh = new Syntax::Highlight::Engine::Kate::Python([
579  ]);
580
581 =head1 DESCRIPTION
582
583 Syntax::Highlight::Engine::Kate::Python is a  plugin module that provides syntax highlighting
584 for Python to the Syntax::Haghlight::Engine::Kate highlighting engine.
585
586 This code is generated from the syntax definition files used
587 by the Kate project.
588 It works quite fine, but can use refinement and optimization.
589
590 It inherits Syntax::Higlight::Engine::Kate::Template. See also there.
591
592 =cut
593
594 =head1 AUTHOR
595
596 Hans Jeuken (haje <at> toneel <dot> demon <dot> nl)
597
598 =cut
599
600 =head1 BUGS
601
602 Unknown. If you find any, please contact the author
603
604 =cut
605