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 'python.xml' file of the syntax highlight
6 # engine of the kate text editor (http://www.kate-editor.org
10 #kate author Per Wigren
11 #generated: Sun Feb 3 22:02:06 2008, localtime
13 package Syntax::Highlight::Engine::Kate::Python;
15 our $VERSION = '0.06';
19 use base('Syntax::Highlight::Engine::Kate::Template');
23 my $class = ref($proto) || $proto;
24 my $self = $class->SUPER::new(@_);
26 'Builtin Function' => 'DataType',
27 'Comment' => 'Comment',
28 'Complex' => 'Others',
32 'Keyword' => 'Keyword',
34 'Normal Text' => 'Normal',
37 'Preprocessor' => 'Char',
38 'Raw String' => 'String',
39 'Special Variable' => 'Others',
42 $self->listAdd('builtinfuncs',
104 $self->listAdd('prep',
109 $self->listAdd('specialvars',
117 $self->listAdd('statements',
148 callback => \&parseNormal,
149 attribute => 'Normal Text',
152 callback => \&parseRawAstring,
153 attribute => 'Raw String',
156 callback => \&parseRawQstring,
157 attribute => 'Raw String',
159 'Single A-comment' => {
160 callback => \&parseSingleAcomment,
161 attribute => 'Comment',
163 'Single A-string' => {
164 callback => \&parseSingleAstring,
165 attribute => 'String',
167 'Single Q-comment' => {
168 callback => \&parseSingleQcomment,
169 attribute => 'Comment',
171 'Single Q-string' => {
172 callback => \&parseSingleQstring,
173 attribute => 'String',
175 'Tripple A-comment' => {
176 callback => \&parseTrippleAcomment,
177 attribute => 'Comment',
179 'Tripple A-string' => {
180 callback => \&parseTrippleAstring,
181 attribute => 'String',
183 'Tripple Q-comment' => {
184 callback => \&parseTrippleQcomment,
185 attribute => 'Comment',
187 'Tripple Q-string' => {
188 callback => \&parseTrippleQstring,
189 attribute => 'String',
192 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
193 $self->basecontext('Normal');
194 $self->keywordscase(0);
196 bless ($self, $class);
205 my ($self, $text) = @_;
207 # attribute => 'Preprocessor'
210 if ($self->testKeyword($text, 'prep', 0, undef, 0, '#stay', 'Preprocessor')) {
213 # String => 'statements'
214 # attribute => 'Keyword'
217 if ($self->testKeyword($text, 'statements', 0, undef, 0, '#stay', 'Keyword')) {
220 # String => 'builtinfuncs'
221 # attribute => 'Builtin Function'
224 if ($self->testKeyword($text, 'builtinfuncs', 0, undef, 0, '#stay', 'Builtin Function')) {
227 # String => 'specialvars'
228 # attribute => 'Special Variable'
231 if ($self->testKeyword($text, 'specialvars', 0, undef, 0, '#stay', 'Special Variable')) {
234 # String => '[a-zA-Z_]\w+'
235 # attribute => 'Normal'
238 if ($self->testRegExpr($text, '[a-zA-Z_]\\w+', 0, 0, 0, undef, 0, '#stay', 'Normal')) {
241 # String => ' (((\d*\.\d+|\d+\.)|(\d+|(\d*\.\d+|\d+\.))[eE][+-]?\d+)|\d+)[jJ]'
242 # attribute => 'Complex'
245 if ($self->testRegExpr($text, ' (((\\d*\\.\\d+|\\d+\\.)|(\\d+|(\\d*\\.\\d+|\\d+\\.))[eE][+-]?\\d+)|\\d+)[jJ]', 0, 0, 0, undef, 0, '#stay', 'Complex')) {
248 # String => '(\d+\.\d*|\.\d+)([eE]\d+)?'
249 # attribute => 'Float'
252 if ($self->testRegExpr($text, '(\\d+\\.\\d*|\\.\\d+)([eE]\\d+)?', 0, 0, 0, undef, 0, '#stay', 'Float')) {
255 # String => '([1-9]\d*([eE]\d+)?|0)'
259 if ($self->testRegExpr($text, '([1-9]\\d*([eE]\\d+)?|0)', 0, 0, 0, undef, 0, '#stay', 'Int')) {
262 # String => '[1-9]\d*([eE][\d.]+)?[Ll]'
263 # attribute => 'Long'
266 if ($self->testRegExpr($text, '[1-9]\\d*([eE][\\d.]+)?[Ll]', 0, 0, 0, undef, 0, '#stay', 'Long')) {
269 # String => '0[Xx][\da-fA-F]+'
273 if ($self->testRegExpr($text, '0[Xx][\\da-fA-F]+', 0, 0, 0, undef, 0, '#stay', 'Hex')) {
276 # String => '0[1-9]\d*'
277 # attribute => 'Octal'
280 if ($self->testRegExpr($text, '0[1-9]\\d*', 0, 0, 0, undef, 0, '#stay', 'Octal')) {
284 # attribute => 'Raw String'
285 # context => 'Raw A-string'
287 if ($self->testRegExpr($text, '[rR]\'', 0, 0, 0, undef, 0, 'Raw A-string', 'Raw String')) {
291 # attribute => 'Raw String'
292 # context => 'Raw Q-string'
294 if ($self->testRegExpr($text, '[rR]"', 0, 0, 0, undef, 0, 'Raw Q-string', 'Raw String')) {
298 # attribute => 'Comment'
301 if ($self->testRegExpr($text, '#.*$', 0, 0, 0, undef, 0, '#stay', 'Comment')) {
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')) {
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')) {
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')) {
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')) {
334 # attribute => 'String'
336 # context => 'Single A-string'
337 # type => 'DetectChar'
338 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Single A-string', 'String')) {
341 # attribute => 'String'
343 # context => 'Single Q-string'
344 # type => 'DetectChar'
345 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'Single Q-string', 'String')) {
348 # String => '[+*/\(\)%\|\[\]\{\}:=;\!<>!^&~-]'
349 # attribute => 'Operator'
352 if ($self->testRegExpr($text, '[+*/\\(\\)%\\|\\[\\]\\{\\}:=;\\!<>!^&~-]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
358 sub parseRawAstring {
359 my ($self, $text) = @_;
360 # attribute => 'Raw String'
362 # type => 'HlCStringChar'
363 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Raw String')) {
366 # attribute => 'Raw String'
369 # type => 'DetectChar'
370 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Raw String')) {
376 sub parseRawQstring {
377 my ($self, $text) = @_;
378 # attribute => 'Raw String'
380 # type => 'HlCStringChar'
381 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Raw String')) {
384 # attribute => 'Raw String'
387 # type => 'DetectChar'
388 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Raw String')) {
394 sub parseSingleAcomment {
395 my ($self, $text) = @_;
396 # attribute => 'Comment'
398 # type => 'HlCStringChar'
399 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Comment')) {
402 # attribute => 'Comment'
405 # type => 'DetectChar'
406 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
412 sub parseSingleAstring {
413 my ($self, $text) = @_;
414 # attribute => 'String'
416 # type => 'HlCStringChar'
417 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
420 # String => '%[a-zA-Z]'
421 # attribute => 'Operator'
424 if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
427 # attribute => 'String'
430 # type => 'DetectChar'
431 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'String')) {
437 sub parseSingleQcomment {
438 my ($self, $text) = @_;
439 # attribute => 'Comment'
441 # type => 'HlCStringChar'
442 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'Comment')) {
445 # attribute => 'Comment'
448 # type => 'DetectChar'
449 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
455 sub parseSingleQstring {
456 my ($self, $text) = @_;
457 # attribute => 'String'
459 # type => 'HlCStringChar'
460 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
463 # String => '%[a-zA-Z]'
464 # attribute => 'Operator'
467 if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
470 # attribute => 'String'
473 # type => 'DetectChar'
474 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) {
480 sub parseTrippleAcomment {
481 my ($self, $text) = @_;
482 # attribute => 'Comment'
485 if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Comment')) {
489 # attribute => 'Comment'
491 # type => 'StringDetect'
492 if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
498 sub parseTrippleAstring {
499 my ($self, $text) = @_;
500 # attribute => 'String'
503 if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'String')) {
506 # String => '%[a-zA-Z]'
507 # attribute => 'Operator'
510 if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
514 # attribute => 'String'
516 # type => 'StringDetect'
517 if ($self->testStringDetect($text, '\'\'\'', 0, 0, 0, undef, 0, '#pop', 'String')) {
523 sub parseTrippleQcomment {
524 my ($self, $text) = @_;
525 # attribute => 'Comment'
528 if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Comment')) {
532 # attribute => 'Comment'
534 # type => 'StringDetect'
535 if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
541 sub parseTrippleQstring {
542 my ($self, $text) = @_;
543 # attribute => 'String'
545 # type => 'HlCStringChar'
546 if ($self->testHlCStringChar($text, 0, undef, 0, '#stay', 'String')) {
549 # String => '%[a-zA-Z]'
550 # attribute => 'Operator'
553 if ($self->testRegExpr($text, '%[a-zA-Z]', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
557 # attribute => 'String'
559 # type => 'StringDetect'
560 if ($self->testStringDetect($text, '"""', 0, 0, 0, undef, 0, '#pop', 'String')) {
573 Syntax::Highlight::Engine::Kate::Python - a Plugin for Python syntax highlighting
577 require Syntax::Highlight::Engine::Kate::Python;
578 my $sh = new Syntax::Highlight::Engine::Kate::Python([
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.
586 This code is generated from the syntax definition files used
588 It works quite fine, but can use refinement and optimization.
590 It inherits Syntax::Higlight::Engine::Kate::Template. See also there.
596 Hans Jeuken (haje <at> toneel <dot> demon <dot> nl)
602 Unknown. If you find any, please contact the author