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 'r.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.1 |
10 | #kate author E.L. Willighagen |
11 | #generated: Sun Feb 3 22:02:06 2008, localtime |
12 | |
13 | package Syntax::Highlight::Engine::Kate::R_Script; |
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 | 'Comment' => 'Comment', |
27 | 'Control Structure' => 'Normal', |
28 | 'Infix' => 'Others', |
29 | 'Keyword' => 'Keyword', |
30 | 'Normal Text' => 'Normal', |
31 | 'Operators' => 'Operator', |
32 | 'Reserved Words' => 'Reserved', |
33 | 'String' => 'String', |
34 | }); |
35 | $self->listAdd('controls', |
36 | 'break', |
37 | 'else', |
38 | 'for', |
39 | 'function', |
40 | 'if', |
41 | 'in', |
42 | 'next', |
43 | 'repeat', |
44 | 'switch', |
45 | 'while', |
46 | ); |
47 | $self->listAdd('words', |
48 | 'FALSE', |
49 | 'Inf', |
50 | 'NA', |
51 | 'NULL', |
52 | 'NaN', |
53 | 'TRUE', |
54 | ); |
55 | $self->contextdata({ |
56 | 'ctx0' => { |
57 | callback => \&parsectx0, |
58 | attribute => 'Normal Text', |
59 | }, |
60 | 'ctx1' => { |
61 | callback => \&parsectx1, |
62 | attribute => 'String', |
63 | }, |
64 | }); |
65 | $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\'); |
66 | $self->basecontext('ctx0'); |
67 | $self->keywordscase(0); |
68 | $self->initialize; |
69 | bless ($self, $class); |
70 | return $self; |
71 | } |
72 | |
73 | sub language { |
74 | return 'R Script'; |
75 | } |
76 | |
77 | sub parsectx0 { |
78 | my ($self, $text) = @_; |
79 | # String => 'controls' |
80 | # attribute => 'Control Structure' |
81 | # context => '#stay' |
82 | # type => 'keyword' |
83 | if ($self->testKeyword($text, 'controls', 0, undef, 0, '#stay', 'Control Structure')) { |
84 | return 1 |
85 | } |
86 | # String => 'words' |
87 | # attribute => 'Reserved Words' |
88 | # context => '#stay' |
89 | # type => 'keyword' |
90 | if ($self->testKeyword($text, 'words', 0, undef, 0, '#stay', 'Reserved Words')) { |
91 | return 1 |
92 | } |
93 | # attribute => 'String' |
94 | # char => '"' |
95 | # context => 'ctx1' |
96 | # type => 'DetectChar' |
97 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'ctx1', 'String')) { |
98 | return 1 |
99 | } |
100 | # String => '[a-zA-Z_]+ *\(' |
101 | # attribute => 'Keyword' |
102 | # context => '#stay' |
103 | # type => 'RegExpr' |
104 | if ($self->testRegExpr($text, '[a-zA-Z_]+ *\\(', 0, 0, 0, undef, 0, '#stay', 'Keyword')) { |
105 | return 1 |
106 | } |
107 | # attribute => 'Keyword' |
108 | # char => '(' |
109 | # context => '#stay' |
110 | # type => 'DetectChar' |
111 | if ($self->testDetectChar($text, '(', 0, 0, 0, undef, 0, '#stay', 'Keyword')) { |
112 | return 1 |
113 | } |
114 | # attribute => 'Keyword' |
115 | # char => ')' |
116 | # context => '#stay' |
117 | # type => 'DetectChar' |
118 | if ($self->testDetectChar($text, ')', 0, 0, 0, undef, 0, '#stay', 'Keyword')) { |
119 | return 1 |
120 | } |
121 | # String => '#.*$' |
122 | # attribute => 'Comment' |
123 | # context => '#stay' |
124 | # type => 'RegExpr' |
125 | if ($self->testRegExpr($text, '#.*$', 0, 0, 0, undef, 0, '#stay', 'Comment')) { |
126 | return 1 |
127 | } |
128 | # String => '+-*/^:$~!&|=><@' |
129 | # attribute => 'Operators' |
130 | # context => '#stay' |
131 | # type => 'AnyChar' |
132 | if ($self->testAnyChar($text, '+-*/^:$~!&|=><@', 0, 0, undef, 0, '#stay', 'Operators')) { |
133 | return 1 |
134 | } |
135 | # String => '%[a-zA-Z_]*%' |
136 | # attribute => 'Operators' |
137 | # context => '#stay' |
138 | # type => 'RegExpr' |
139 | if ($self->testRegExpr($text, '%[a-zA-Z_]*%', 0, 0, 0, undef, 0, '#stay', 'Operators')) { |
140 | return 1 |
141 | } |
142 | return 0; |
143 | }; |
144 | |
145 | sub parsectx1 { |
146 | my ($self, $text) = @_; |
147 | # attribute => 'String' |
148 | # char => '"' |
149 | # context => '#pop' |
150 | # type => 'DetectChar' |
151 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) { |
152 | return 1 |
153 | } |
154 | return 0; |
155 | }; |
156 | |
157 | |
158 | 1; |
159 | |
160 | __END__ |
161 | |
162 | =head1 NAME |
163 | |
164 | Syntax::Highlight::Engine::Kate::R_Script - a Plugin for R Script syntax highlighting |
165 | |
166 | =head1 SYNOPSIS |
167 | |
168 | require Syntax::Highlight::Engine::Kate::R_Script; |
169 | my $sh = new Syntax::Highlight::Engine::Kate::R_Script([ |
170 | ]); |
171 | |
172 | =head1 DESCRIPTION |
173 | |
174 | Syntax::Highlight::Engine::Kate::R_Script is a plugin module that provides syntax highlighting |
175 | for R Script to the Syntax::Haghlight::Engine::Kate highlighting engine. |
176 | |
177 | This code is generated from the syntax definition files used |
178 | by the Kate project. |
179 | It works quite fine, but can use refinement and optimization. |
180 | |
181 | It inherits Syntax::Higlight::Engine::Kate::Template. See also there. |
182 | |
183 | =cut |
184 | |
185 | =head1 AUTHOR |
186 | |
187 | Hans Jeuken (haje <at> toneel <dot> demon <dot> nl) |
188 | |
189 | =cut |
190 | |
191 | =head1 BUGS |
192 | |
193 | Unknown. If you find any, please contact the author |
194 | |
195 | =cut |
196 | |