File Coverage

blib/lib/Syntax/Highlight/Engine/Kate/XHarbour.pm
Criterion Covered Total %
statement 27 106 25.4
branch 0 64 0.0
condition 1 3 33.3
subroutine 4 12 33.3
pod 0 9 0.0
total 32 194 16.4


line stmt bran cond sub pod time code
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 'xharbour.xml' file of the syntax highlight
6             # engine of the kate text editor (http://www.kate-editor.org
7              
8             #kate xml version 1.04
9             #kate version 2.4
10             #kate author Giancarlo Niccolai (giancarlo@niccolai.ws)
11             #generated: Sun Feb 3 22:02:06 2008, localtime
12              
13             package Syntax::Highlight::Engine::Kate::XHarbour;
14              
15             our $VERSION = '0.14';
16              
17 1     1   708 use strict;
  1         2  
  1         29  
18 1     1   5 use warnings;
  1         3  
  1         33  
19 1     1   5 use base('Syntax::Highlight::Engine::Kate::Template');
  1         1  
  1         1324  
20              
21             sub new {
22 1     1 0 584 my $proto = shift;
23 1   33     6 my $class = ref($proto) || $proto;
24 1         9 my $self = $class->SUPER::new(@_);
25 1         10 $self->attributes({
26             'Comment' => 'Comment',
27             'Function' => 'Function',
28             'Keyword' => 'Keyword',
29             'Normal Text' => 'Normal',
30             'Number' => 'DecVal',
31             'Operator' => 'BaseN',
32             'Preprocessor' => 'Others',
33             'String' => 'String',
34             });
35 1         6 $self->listAdd('class_keywords',
36             'classdata',
37             'data',
38             'from',
39             'hidden',
40             'init',
41             'inline',
42             'method',
43             );
44 1         3 $self->listAdd('context_beginners',
45             'BEGIN',
46             'FOR',
47             'FUNCTION',
48             'IF',
49             'METHOD',
50             'PROCEDURE',
51             'SWITCH',
52             'TRY',
53             'WHILE',
54             );
55 1         3 $self->listAdd('context_terminators',
56             'END',
57             'ENDCASE',
58             'ENDDO',
59             'ENDIF',
60             'NEXT',
61             );
62 1         15 $self->listAdd('functions',
63             'ABS',
64             'ALLTRIM',
65             'ASC',
66             'AT',
67             'CDOW',
68             'CHR',
69             'CMONTH',
70             'CTOD',
71             'CURDIR',
72             'CreateMutex',
73             'DATE',
74             'DAY',
75             'DAYS',
76             'DBAPPEND',
77             'DBCLEARFILTER',
78             'DBCLOSEALL',
79             'DBCLOSEAREA',
80             'DBCOMMIT',
81             'DBCOMMITALL',
82             'DBCREATE',
83             'DBDELETE',
84             'DBEVAL',
85             'DBF',
86             'DBFILTER',
87             'DBGOBOTTOM',
88             'DBGOTO',
89             'DBGOTOP',
90             'DBRECALL',
91             'DBRLOCK',
92             'DBRLOCKLIST',
93             'DBRUNLOCK',
94             'DBSEEK',
95             'DBSELECTAREA',
96             'DBSETDRIVER',
97             'DBSETFILTER',
98             'DBSKIP',
99             'DBSTRUCT',
100             'DBUNLOCK',
101             'DBUNLOCKALL',
102             'DBUSEAREA',
103             'DIRCHANGE',
104             'DIRREMOVE',
105             'DISKSPACE',
106             'DOW',
107             'DTOC',
108             'DTOS',
109             'DestroyMutex',
110             'EXP',
111             'FCLOSE',
112             'FCREATE',
113             'FERASE',
114             'FERROR',
115             'FOPEN',
116             'FREAD',
117             'FREADSTR',
118             'FSEEK',
119             'FWRITE',
120             'GETENV',
121             'HARDCR',
122             'HB_ANSITOOEM',
123             'HB_DISKSPACE',
124             'HB_FEOF',
125             'HB_ISBYREF',
126             'HB_LANGNAME',
127             'HB_LANGSELECT',
128             'HB_OEMTOANSI',
129             'HB_SETKEYSAVE',
130             'HB_SetKeyCheck',
131             'HB_SetKeyGet',
132             'HB_VALTOSTR',
133             'HB_pvalue',
134             'INDEXEXT',
135             'INDEXKEY',
136             'INDEXORD',
137             'INT',
138             'ISAFFIRM',
139             'ISALPHA',
140             'ISDIGIT',
141             'ISDISK',
142             'ISLOWER',
143             'ISNEGATIVE',
144             'ISUPPER',
145             'InetAccept',
146             'InetAddress',
147             'InetCleanup',
148             'InetClearTimeout',
149             'InetConnect',
150             'InetConnectIP',
151             'InetCreate',
152             'InetDGram',
153             'InetDGramRecv',
154             'InetDGramSend',
155             'InetDestroy',
156             'InetError',
157             'InetErrorDesc',
158             'InetGetHosts',
159             'InetGetTimeout',
160             'InetInit',
161             'InetPort',
162             'InetRecv',
163             'InetRecvAll',
164             'InetSend',
165             'InetSendAll',
166             'InetServer',
167             'InetSetTimeout',
168             'KillAllThreads',
169             'LEFT',
170             'LEN',
171             'LOG',
172             'LOWER',
173             'LTRIM',
174             'MAKEDIR',
175             'MAX',
176             'MEMOTRAN',
177             'MIN',
178             'MOD',
179             'MONTH',
180             'MutexLock',
181             'MutexUnlock',
182             'NATIONMSG',
183             'Notify',
184             'NotifyAll',
185             'ORDBAGEXT',
186             'ORDBAGNAME',
187             'ORDCONDSET',
188             'ORDCREATE',
189             'ORDDESTROY',
190             'ORDFOR',
191             'ORDKEY',
192             'ORDLISTADD',
193             'ORDLISTCLEAR',
194             'ORDLISTREBUILD',
195             'ORDNAME',
196             'ORDNUMBER',
197             'ORDSETFOCUS',
198             'PADC',
199             'PADL',
200             'PADR',
201             'PROCFILE',
202             'PROCLINE',
203             'PROCNAME',
204             'RAT',
205             'RDDLIST',
206             'RDDNAME',
207             'RDDSETDEFAULT',
208             'REPLICATE',
209             'RIGHT',
210             'ROUND',
211             'RTRIM',
212             'SET',
213             'SETKEY',
214             'SETMODE',
215             'SETTYPEAHEAD',
216             'SPACE',
217             'SQRT',
218             'STR',
219             'STRTRAN',
220             'STRZERO',
221             'SUBSTR',
222             'Subscribe',
223             'SubscribeNow',
224             'TAssociativeArray',
225             'TRANSFORM',
226             'TRIM',
227             'TYPE',
228             'ThreadJoin',
229             'ThreadKill',
230             'ThreadSleep',
231             'ThreadStart',
232             'ThreadStop',
233             'UPPER',
234             'VAL',
235             'VALTYPE',
236             'VERSION',
237             'WaitForThreads',
238             'YEAR',
239             '__DBCONTINUE',
240             '__DBZAP',
241             '__FLEDIT',
242             '__QUIT',
243             '__RDDSETDEFAULT',
244             '__SETCENTURY',
245             '__SetFunction',
246             '__WAIT',
247             '__atprompt',
248             '__dbCopyStruct',
249             '__dbCopyXStruct',
250             '__dbCreate',
251             '__dbStructFilter',
252             '__dbdelim',
253             '__dbsdf',
254             '__dir',
255             '__input',
256             '__menuto',
257             '__nonoallert',
258             '__run',
259             '__typefile',
260             '__xrestscreen',
261             '__xsavescreen',
262             'aadd',
263             'achoice',
264             'aclone',
265             'adel',
266             'adir',
267             'aeval',
268             'afill',
269             'ains',
270             'alert',
271             'array',
272             'ascan',
273             'asize',
274             'asort',
275             'atail',
276             'bin21',
277             'bin2l',
278             'bin2u',
279             'bin2w',
280             'break',
281             'browse',
282             'col',
283             'dbSkipper',
284             'dbedit',
285             'descend',
286             'devoutpict',
287             'do',
288             'elaptime',
289             'empty',
290             'errornew',
291             'errorsys',
292             'eval',
293             'fieldblock',
294             'fieldwblock',
295             'file',
296             'frename',
297             'hb_chechsum',
298             'hb_class',
299             'hb_colorindex',
300             'hb_crypt',
301             'hb_decrypt',
302             'hb_exec',
303             'hb_execfromarray',
304             'hb_hextonum',
305             'hb_keyput',
306             'hb_numtohex',
307             'hb_osnewline',
308             'hb_random',
309             'hb_readini',
310             'hb_regex',
311             'hb_regexcomp',
312             'hb_regexmatch',
313             'hb_regexsplit',
314             'hb_writeini',
315             'i2bin',
316             'inkey',
317             'l2bin',
318             'lastkey',
319             'maxcol',
320             'maxrow',
321             'mcol',
322             'mrow',
323             'nextkey',
324             'os',
325             'outerr',
326             'outstd',
327             'pcount',
328             'readkey',
329             'readvar',
330             'row',
331             'seconds',
332             'secs',
333             'throw',
334             'time',
335             'tone',
336             'u2bin',
337             'valtoprg',
338             'w2bin',
339             'word',
340             );
341 1         4 $self->listAdd('keywords',
342             '?',
343             'alias',
344             'all',
345             'as',
346             'box',
347             'case',
348             'catch',
349             'class',
350             'clear',
351             'close',
352             'color',
353             'databases',
354             'date',
355             'do',
356             'each',
357             'else',
358             'elseif',
359             'exit',
360             'extern',
361             'external',
362             'field',
363             'get',
364             'global',
365             'has',
366             'in',
367             'index',
368             'like',
369             'local',
370             'loop',
371             'nil',
372             'off',
373             'on',
374             'otherwise',
375             'read',
376             'return',
377             'say',
378             'say',
379             'screen',
380             'select',
381             'self',
382             'set',
383             'static',
384             'super',
385             'switch',
386             'to',
387             'use',
388             );
389 1         3 $self->listAdd('pragma',
390             '#define',
391             '#else',
392             '#endif',
393             '#if',
394             '#ifdef',
395             '#ifndef',
396             '#include',
397             );
398 1         4 $self->listAdd('set_commands',
399             'ALTERNATE',
400             'ALTFILE',
401             'AUTOPEN',
402             'AUTORDER',
403             'AUTOSHARE',
404             'BELL',
405             'CANCEL',
406             'COLOR',
407             'CONFIRM',
408             'CONSOLE',
409             'CURSOR',
410             'DATEFORMAT',
411             'DEBUG',
412             'DECIMALS',
413             'DEFAULT',
414             'DELETED',
415             'DELIMCHARS',
416             'DELIMITERS',
417             'DEVICE',
418             'DIRCASE',
419             'DIRSEPARATOR',
420             'EPOCH',
421             'ESCAPE',
422             'EVENTMASK',
423             'EXACT',
424             'EXCLUSIVE',
425             'EXIT',
426             'EXTRA',
427             'EXTRAFILE',
428             'FILECASE',
429             'FIXED',
430             'IDLEREPEAT',
431             'INSERT',
432             'INTENSITY',
433             'INVALID',
434             'LANGUAGE',
435             'MARGIN',
436             'MBLOCKSIZE',
437             'MCENTER',
438             'MESSAGE',
439             'MFILEEXT',
440             'OPTIMIZE',
441             'PATH',
442             'PRINTER',
443             'PRINTFILE',
444             'SCOREBOARD',
445             'SCROLLBREAK',
446             'SOFTSEEK',
447             'STRICTREAD',
448             'TRACE',
449             'TRACEFILE',
450             'TRACESTACK',
451             'TYPEAHEAD',
452             'UNIQUE',
453             'VIDEOMODE',
454             'WRAP',
455             );
456 1         16 $self->contextdata({
457             'ClassContext' => {
458             callback => \&parseClassContext,
459             attribute => 'Normal Text',
460             },
461             'TopLevel' => {
462             callback => \&parseTopLevel,
463             attribute => 'Normal Text',
464             },
465             'comment' => {
466             callback => \&parsecomment,
467             attribute => 'Comment',
468             lineending => '#pop',
469             },
470             'logic' => {
471             callback => \&parselogic,
472             attribute => 'Operator',
473             lineending => '#pop',
474             },
475             'ml_comment' => {
476             callback => \&parseml_comment,
477             attribute => 'Comment',
478             },
479             'string' => {
480             callback => \&parsestring,
481             attribute => 'String',
482             lineending => '#pop',
483             },
484             'stringc' => {
485             callback => \&parsestringc,
486             attribute => 'String',
487             lineending => '#pop',
488             },
489             });
490 1         6 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
491 1         6 $self->basecontext('TopLevel');
492 1         5 $self->keywordscase(0);
493 1         3 $self->initialize;
494 1         2 bless ($self, $class);
495 1         3 return $self;
496             }
497              
498             sub language {
499 0     0 0   return 'xHarbour';
500             }
501              
502             sub parseClassContext {
503 0     0 0   my ($self, $text) = @_;
504             # attribute => 'Comment'
505             # beginRegion => 'comment_region'
506             # char => '/'
507             # char1 => '*'
508             # context => 'ml_comment'
509             # type => 'Detect2Chars'
510 0 0         if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'ml_comment', 'Comment')) {
511 0           return 1
512             }
513             # attribute => 'Comment'
514             # char => '*'
515             # context => 'comment'
516             # firstNonSpace => 'true'
517             # type => 'DetectChar'
518 0 0         if ($self->testDetectChar($text, '*', 0, 0, 0, undef, 1, 'comment', 'Comment')) {
519 0           return 1
520             }
521             # attribute => 'Comment'
522             # char => '/'
523             # char1 => '/'
524             # context => 'comment'
525             # type => 'Detect2Chars'
526 0 0         if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'comment', 'Comment')) {
527 0           return 1
528             }
529             # String => 'class_keywords'
530             # attribute => 'Keyword'
531             # context => '#stay'
532             # type => 'keyword'
533 0 0         if ($self->testKeyword($text, 'class_keywords', 0, undef, 0, '#stay', 'Keyword')) {
534 0           return 1
535             }
536             # String => 'END(CLASS)? *$'
537             # attribute => 'Keyword'
538             # context => '#pop'
539             # endRegion => 'ClassDeclRegion'
540             # firstNonSpace => 'true'
541             # insensitive => 'TRUE'
542             # type => 'RegExpr'
543 0 0         if ($self->testRegExpr($text, 'END(CLASS)? *$', 1, 0, 0, undef, 1, '#pop', 'Keyword')) {
544 0           return 1
545             }
546 0           return 0;
547             };
548              
549             sub parseTopLevel {
550 0     0 0   my ($self, $text) = @_;
551             # attribute => 'Comment'
552             # beginRegion => 'comment_region'
553             # char => '/'
554             # char1 => '*'
555             # context => 'ml_comment'
556             # type => 'Detect2Chars'
557 0 0         if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'ml_comment', 'Comment')) {
558 0           return 1
559             }
560             # attribute => 'Comment'
561             # char => '*'
562             # context => 'comment'
563             # firstNonSpace => 'true'
564             # type => 'DetectChar'
565 0 0         if ($self->testDetectChar($text, '*', 0, 0, 0, undef, 1, 'comment', 'Comment')) {
566 0           return 1
567             }
568             # attribute => 'Comment'
569             # char => '/'
570             # char1 => '/'
571             # context => 'comment'
572             # type => 'Detect2Chars'
573 0 0         if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'comment', 'Comment')) {
574 0           return 1
575             }
576             # attribute => 'String'
577             # char => '"'
578             # context => 'string'
579             # type => 'DetectChar'
580 0 0         if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'string', 'String')) {
581 0           return 1
582             }
583             # attribute => 'String'
584             # char => '''
585             # context => 'stringc'
586             # type => 'DetectChar'
587 0 0         if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'stringc', 'String')) {
588 0           return 1
589             }
590             # String => '.and.'
591             # attribute => 'Operator'
592             # context => '#stay'
593             # insensitive => 'TRUE'
594             # type => 'StringDetect'
595 0 0         if ($self->testStringDetect($text, '.and.', 1, 0, 0, undef, 0, '#stay', 'Operator')) {
596 0           return 1
597             }
598             # String => '.or.'
599             # attribute => 'Operator'
600             # context => '#stay'
601             # insensitive => 'TRUE'
602             # type => 'StringDetect'
603 0 0         if ($self->testStringDetect($text, '.or.', 1, 0, 0, undef, 0, '#stay', 'Operator')) {
604 0           return 1
605             }
606             # String => '.not.'
607             # attribute => 'Operator'
608             # context => '#stay'
609             # insensitive => 'TRUE'
610             # type => 'StringDetect'
611 0 0         if ($self->testStringDetect($text, '.not.', 1, 0, 0, undef, 0, '#stay', 'Operator')) {
612 0           return 1
613             }
614             # String => '.f.'
615             # attribute => 'Operator'
616             # context => '#stay'
617             # insensitive => 'TRUE'
618             # type => 'StringDetect'
619 0 0         if ($self->testStringDetect($text, '.f.', 1, 0, 0, undef, 0, '#stay', 'Operator')) {
620 0           return 1
621             }
622             # String => '.t.'
623             # attribute => 'Operator'
624             # context => '#stay'
625             # insensitive => 'TRUE'
626             # type => 'StringDetect'
627 0 0         if ($self->testStringDetect($text, '.t.', 1, 0, 0, undef, 0, '#stay', 'Operator')) {
628 0           return 1
629             }
630             # String => ':=!'
631             # attribute => 'Operator'
632             # context => '#stay'
633             # type => 'AnyChar'
634 0 0         if ($self->testAnyChar($text, ':=!', 0, 0, undef, 0, '#stay', 'Operator')) {
635 0           return 1
636             }
637             # attribute => 'Keyword'
638             # char => '@'
639             # context => '#stay'
640             # type => 'DetectChar'
641 0 0         if ($self->testDetectChar($text, '@', 0, 0, 0, undef, 0, '#stay', 'Keyword')) {
642 0           return 1
643             }
644             # String => 'CLASS[\t ]+'
645             # attribute => 'Keyword'
646             # beginRegion => 'ClassDeclRegion'
647             # context => 'ClassContext'
648             # firstNonSpace => 'true'
649             # insensitive => 'TRUE'
650             # type => 'RegExpr'
651 0 0         if ($self->testRegExpr($text, 'CLASS[\\t ]+', 1, 0, 0, undef, 1, 'ClassContext', 'Keyword')) {
652 0           return 1
653             }
654             # String => 'DO[\t ]+CASE[\t ]*$'
655             # attribute => 'Keyword'
656             # beginRegion => 'IndentRegion'
657             # context => '#stay'
658             # firstNonSpace => 'true'
659             # insensitive => 'TRUE'
660             # type => 'RegExpr'
661 0 0         if ($self->testRegExpr($text, 'DO[\\t ]+CASE[\\t ]*$', 1, 0, 0, undef, 1, '#stay', 'Keyword')) {
662 0           return 1
663             }
664             # String => 'context_beginners'
665             # attribute => 'Keyword'
666             # beginRegion => 'IndentRegion'
667             # context => '#stay'
668             # type => 'keyword'
669 0 0         if ($self->testKeyword($text, 'context_beginners', 0, undef, 0, '#stay', 'Keyword')) {
670 0           return 1
671             }
672             # String => 'context_terminators'
673             # attribute => 'Keyword'
674             # context => '#stay'
675             # endRegion => 'IndentRegion'
676             # type => 'keyword'
677 0 0         if ($self->testKeyword($text, 'context_terminators', 0, undef, 0, '#stay', 'Keyword')) {
678 0           return 1
679             }
680             # String => 'return ?'
681             # attribute => 'Keyword'
682             # column => '0'
683             # context => '#stay'
684             # endRegion => 'IndentRegion'
685             # insensitive => 'TRUE'
686             # type => 'RegExpr'
687 0 0         if ($self->testRegExpr($text, 'return ?', 1, 0, 0, 0, 0, '#stay', 'Keyword')) {
688 0           return 1
689             }
690             # String => 'keywords'
691             # attribute => 'Keyword'
692             # context => '#stay'
693             # type => 'keyword'
694 0 0         if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) {
695 0           return 1
696             }
697             # String => 'set_commands'
698             # attribute => 'Keyword'
699             # context => '#stay'
700             # type => 'keyword'
701 0 0         if ($self->testKeyword($text, 'set_commands', 0, undef, 0, '#stay', 'Keyword')) {
702 0           return 1
703             }
704             # String => 'functions'
705             # attribute => 'Function'
706             # context => '#stay'
707             # type => 'keyword'
708 0 0         if ($self->testKeyword($text, 'functions', 0, undef, 0, '#stay', 'Function')) {
709 0           return 1
710             }
711             # String => 'pragma'
712             # attribute => 'Preprocessor'
713             # context => '#stay'
714             # type => 'keyword'
715 0 0         if ($self->testKeyword($text, 'pragma', 0, undef, 0, '#stay', 'Preprocessor')) {
716 0           return 1
717             }
718             # attribute => 'Operator'
719             # char => '-'
720             # char1 => '>'
721             # context => '#stay'
722             # type => 'Detect2Chars'
723 0 0         if ($self->testDetect2Chars($text, '-', '>', 0, 0, 0, undef, 0, '#stay', 'Operator')) {
724 0           return 1
725             }
726             # String => '\d+'
727             # attribute => 'Number'
728             # context => '#stay'
729             # type => 'RegExpr'
730 0 0         if ($self->testRegExpr($text, '\\d+', 0, 0, 0, undef, 0, '#stay', 'Number')) {
731 0           return 1
732             }
733 0           return 0;
734             };
735              
736             sub parsecomment {
737 0     0 0   my ($self, $text) = @_;
738 0           return 0;
739             };
740              
741             sub parselogic {
742 0     0 0   my ($self, $text) = @_;
743             # attribute => 'Operator'
744             # char => '.'
745             # context => '#pop'
746             # type => 'DetectChar'
747 0 0         if ($self->testDetectChar($text, '.', 0, 0, 0, undef, 0, '#pop', 'Operator')) {
748 0           return 1
749             }
750 0           return 0;
751             };
752              
753             sub parseml_comment {
754 0     0 0   my ($self, $text) = @_;
755             # attribute => 'Comment'
756             # char => '*'
757             # char1 => '/'
758             # context => '#pop'
759             # endRegion => 'comment_region'
760             # type => 'Detect2Chars'
761 0 0         if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
762 0           return 1
763             }
764 0           return 0;
765             };
766              
767             sub parsestring {
768 0     0 0   my ($self, $text) = @_;
769             # attribute => 'String'
770             # char => '"'
771             # context => '#pop'
772             # type => 'DetectChar'
773 0 0         if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) {
774 0           return 1
775             }
776 0           return 0;
777             };
778              
779             sub parsestringc {
780 0     0 0   my ($self, $text) = @_;
781             # attribute => 'String'
782             # char => '''
783             # context => '#pop'
784             # type => 'DetectChar'
785 0 0         if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'String')) {
786 0           return 1
787             }
788 0           return 0;
789             };
790              
791              
792             1;
793              
794             __END__