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 'ahdl.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 Dominik Haumann (dhdev@gmx.de) |
11 | #generated: Sun Feb 3 22:02:04 2008, localtime |
12 | |
13 | package Syntax::Highlight::Engine::Kate::AHDL; |
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 | 'Bit' => 'DecVal', |
27 | 'Char' => 'Char', |
28 | 'Comment' => 'Comment', |
29 | 'Data Type' => 'DataType', |
30 | 'Decimal' => 'DecVal', |
31 | 'Hex' => 'BaseN', |
32 | 'Keyword' => 'Keyword', |
33 | 'Normal Text' => 'Normal', |
34 | 'Octal' => 'BaseN', |
35 | 'Operator' => 'Others', |
36 | 'Region Marker' => 'RegionMarker', |
37 | 'String' => 'String', |
38 | }); |
39 | $self->listAdd('keywords', |
40 | 'assert', |
41 | 'bidir', |
42 | 'bits', |
43 | 'buried', |
44 | 'case', |
45 | 'clique', |
46 | 'connected_pins', |
47 | 'constant', |
48 | 'defaults', |
49 | 'define', |
50 | 'design', |
51 | 'device', |
52 | 'else', |
53 | 'elsif', |
54 | 'for', |
55 | 'function', |
56 | 'generate', |
57 | 'gnd', |
58 | 'help_id', |
59 | 'in', |
60 | 'include', |
61 | 'input', |
62 | 'is', |
63 | 'machine', |
64 | 'node', |
65 | 'of', |
66 | 'options', |
67 | 'others', |
68 | 'output', |
69 | 'parameters', |
70 | 'returns', |
71 | 'states', |
72 | 'subdesign', |
73 | 'then', |
74 | 'title', |
75 | 'to', |
76 | 'tri_state_node', |
77 | 'variable', |
78 | 'vcc', |
79 | 'when', |
80 | 'with', |
81 | ); |
82 | $self->listAdd('operator', |
83 | 'and', |
84 | 'ceil', |
85 | 'div', |
86 | 'floor', |
87 | 'log2', |
88 | 'mod', |
89 | 'nand', |
90 | 'nor', |
91 | 'not', |
92 | 'or', |
93 | 'used', |
94 | 'xnor', |
95 | 'xor', |
96 | ); |
97 | $self->listAdd('types', |
98 | 'carry', |
99 | 'cascade', |
100 | 'dff', |
101 | 'dffe', |
102 | 'exp', |
103 | 'global', |
104 | 'jkff', |
105 | 'jkffe', |
106 | 'latch', |
107 | 'lcell', |
108 | 'mcell', |
109 | 'memory', |
110 | 'opendrn', |
111 | 'soft', |
112 | 'srff', |
113 | 'srffe', |
114 | 'tff', |
115 | 'tffe', |
116 | 'tri', |
117 | 'wire', |
118 | 'x', |
119 | ); |
120 | $self->contextdata({ |
121 | 'comment' => { |
122 | callback => \&parsecomment, |
123 | attribute => 'Comment', |
124 | }, |
125 | 'normal' => { |
126 | callback => \&parsenormal, |
127 | attribute => 'Normal Text', |
128 | }, |
129 | 'string' => { |
130 | callback => \&parsestring, |
131 | attribute => 'String', |
132 | }, |
133 | }); |
134 | $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\'); |
135 | $self->basecontext('normal'); |
136 | $self->keywordscase(0); |
137 | $self->initialize; |
138 | bless ($self, $class); |
139 | return $self; |
140 | } |
141 | |
142 | sub language { |
143 | return 'AHDL'; |
144 | } |
145 | |
146 | sub parsecomment { |
147 | my ($self, $text) = @_; |
148 | # attribute => 'Comment' |
149 | # char => '%' |
150 | # context => '#pop' |
151 | # type => 'DetectChar' |
152 | if ($self->testDetectChar($text, '%', 0, 0, 0, undef, 0, '#pop', 'Comment')) { |
153 | return 1 |
154 | } |
155 | return 0; |
156 | }; |
157 | |
158 | sub parsenormal { |
159 | my ($self, $text) = @_; |
160 | # String => '\bdefaults\b' |
161 | # attribute => 'Keyword' |
162 | # beginRegion => 'def' |
163 | # context => '#stay' |
164 | # insensitive => 'true' |
165 | # type => 'RegExpr' |
166 | if ($self->testRegExpr($text, '\\bdefaults\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
167 | return 1 |
168 | } |
169 | # String => '\bend\s+defaults\b' |
170 | # attribute => 'Keyword' |
171 | # context => '#stay' |
172 | # endRegion => 'def' |
173 | # insensitive => 'true' |
174 | # type => 'RegExpr' |
175 | if ($self->testRegExpr($text, '\\bend\\s+defaults\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
176 | return 1 |
177 | } |
178 | # String => '\bif\b' |
179 | # attribute => 'Keyword' |
180 | # beginRegion => 'if' |
181 | # context => '#stay' |
182 | # insensitive => 'true' |
183 | # type => 'RegExpr' |
184 | if ($self->testRegExpr($text, '\\bif\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
185 | return 1 |
186 | } |
187 | # String => '\bend\s+if\b' |
188 | # attribute => 'Keyword' |
189 | # context => '#stay' |
190 | # endRegion => 'if' |
191 | # insensitive => 'true' |
192 | # type => 'RegExpr' |
193 | if ($self->testRegExpr($text, '\\bend\\s+if\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
194 | return 1 |
195 | } |
196 | # String => '\btable\b' |
197 | # attribute => 'Keyword' |
198 | # beginRegion => 'table' |
199 | # context => '#stay' |
200 | # insensitive => 'true' |
201 | # type => 'RegExpr' |
202 | if ($self->testRegExpr($text, '\\btable\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
203 | return 1 |
204 | } |
205 | # String => '\bend\s+table\b' |
206 | # attribute => 'Keyword' |
207 | # context => '#stay' |
208 | # endRegion => 'table' |
209 | # insensitive => 'true' |
210 | # type => 'RegExpr' |
211 | if ($self->testRegExpr($text, '\\bend\\s+table\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
212 | return 1 |
213 | } |
214 | # String => '\bcase\b' |
215 | # attribute => 'Keyword' |
216 | # beginRegion => 'case' |
217 | # context => '#stay' |
218 | # insensitive => 'true' |
219 | # type => 'RegExpr' |
220 | if ($self->testRegExpr($text, '\\bcase\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
221 | return 1 |
222 | } |
223 | # String => '\bend\s+case\b' |
224 | # attribute => 'Keyword' |
225 | # context => '#stay' |
226 | # endRegion => 'case' |
227 | # insensitive => 'true' |
228 | # type => 'RegExpr' |
229 | if ($self->testRegExpr($text, '\\bend\\s+case\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
230 | return 1 |
231 | } |
232 | # String => '\bbegin\b' |
233 | # attribute => 'Keyword' |
234 | # beginRegion => 'block' |
235 | # context => '#stay' |
236 | # insensitive => 'true' |
237 | # type => 'RegExpr' |
238 | if ($self->testRegExpr($text, '\\bbegin\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
239 | return 1 |
240 | } |
241 | # String => '\bend\b' |
242 | # attribute => 'Keyword' |
243 | # context => '#stay' |
244 | # endRegion => 'block' |
245 | # insensitive => 'true' |
246 | # type => 'RegExpr' |
247 | if ($self->testRegExpr($text, '\\bend\\b', 1, 0, 0, undef, 0, '#stay', 'Keyword')) { |
248 | return 1 |
249 | } |
250 | # attribute => 'Normal Text' |
251 | # beginRegion => 'bracket' |
252 | # char => '(' |
253 | # context => '#stay' |
254 | # type => 'DetectChar' |
255 | if ($self->testDetectChar($text, '(', 0, 0, 0, undef, 0, '#stay', 'Normal Text')) { |
256 | return 1 |
257 | } |
258 | # attribute => 'Normal Text' |
259 | # char => ')' |
260 | # context => '#stay' |
261 | # endRegion => 'bracket' |
262 | # type => 'DetectChar' |
263 | if ($self->testDetectChar($text, ')', 0, 0, 0, undef, 0, '#stay', 'Normal Text')) { |
264 | return 1 |
265 | } |
266 | # String => 'keywords' |
267 | # attribute => 'Keyword' |
268 | # context => '#stay' |
269 | # type => 'keyword' |
270 | if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) { |
271 | return 1 |
272 | } |
273 | # String => 'types' |
274 | # attribute => 'Data Type' |
275 | # context => '#stay' |
276 | # type => 'keyword' |
277 | if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Data Type')) { |
278 | return 1 |
279 | } |
280 | # String => 'operator' |
281 | # attribute => 'Operator' |
282 | # context => '#stay' |
283 | # type => 'keyword' |
284 | if ($self->testKeyword($text, 'operator', 0, undef, 0, '#stay', 'Operator')) { |
285 | return 1 |
286 | } |
287 | # String => '\b(\d+)\b' |
288 | # attribute => 'Decimal' |
289 | # context => '#stay' |
290 | # type => 'RegExpr' |
291 | if ($self->testRegExpr($text, '\\b(\\d+)\\b', 0, 0, 0, undef, 0, '#stay', 'Decimal')) { |
292 | return 1 |
293 | } |
294 | # String => '\bb"(0|1|x)+"' |
295 | # attribute => 'Bit' |
296 | # context => '#stay' |
297 | # insensitive => 'true' |
298 | # type => 'RegExpr' |
299 | if ($self->testRegExpr($text, '\\bb"(0|1|x)+"', 1, 0, 0, undef, 0, '#stay', 'Bit')) { |
300 | return 1 |
301 | } |
302 | # String => '\b(o|q)"[0-7*]"' |
303 | # attribute => 'Octal' |
304 | # context => '#stay' |
305 | # insensitive => 'true' |
306 | # type => 'RegExpr' |
307 | if ($self->testRegExpr($text, '\\b(o|q)"[0-7*]"', 1, 0, 0, undef, 0, '#stay', 'Octal')) { |
308 | return 1 |
309 | } |
310 | # String => '\b(h|x)"[0-9a-f]*"' |
311 | # attribute => 'Hex' |
312 | # context => '#stay' |
313 | # insensitive => 'true' |
314 | # type => 'RegExpr' |
315 | if ($self->testRegExpr($text, '\\b(h|x)"[0-9a-f]*"', 1, 0, 0, undef, 0, '#stay', 'Hex')) { |
316 | return 1 |
317 | } |
318 | # attribute => 'String' |
319 | # char => '"' |
320 | # context => 'string' |
321 | # type => 'DetectChar' |
322 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'string', 'String')) { |
323 | return 1 |
324 | } |
325 | # String => '--\s*BEGIN.*$' |
326 | # attribute => 'Region Marker' |
327 | # beginRegion => 'region' |
328 | # context => '#stay' |
329 | # firstNonSpace => 'true' |
330 | # type => 'RegExpr' |
331 | if ($self->testRegExpr($text, '--\\s*BEGIN.*$', 0, 0, 0, undef, 1, '#stay', 'Region Marker')) { |
332 | return 1 |
333 | } |
334 | # String => '--\s*END.*$' |
335 | # attribute => 'Region Marker' |
336 | # context => '#stay' |
337 | # endRegion => 'region' |
338 | # firstNonSpace => 'true' |
339 | # type => 'RegExpr' |
340 | if ($self->testRegExpr($text, '--\\s*END.*$', 0, 0, 0, undef, 1, '#stay', 'Region Marker')) { |
341 | return 1 |
342 | } |
343 | # String => '--.*$' |
344 | # attribute => 'Comment' |
345 | # context => '#stay' |
346 | # type => 'RegExpr' |
347 | if ($self->testRegExpr($text, '--.*$', 0, 0, 0, undef, 0, '#stay', 'Comment')) { |
348 | return 1 |
349 | } |
350 | # attribute => 'Comment' |
351 | # char => '%' |
352 | # context => 'comment' |
353 | # type => 'DetectChar' |
354 | if ($self->testDetectChar($text, '%', 0, 0, 0, undef, 0, 'comment', 'Comment')) { |
355 | return 1 |
356 | } |
357 | # attribute => 'Char' |
358 | # context => '#stay' |
359 | # type => 'HlCChar' |
360 | if ($self->testHlCChar($text, 0, undef, 0, '#stay', 'Char')) { |
361 | return 1 |
362 | } |
363 | return 0; |
364 | }; |
365 | |
366 | sub parsestring { |
367 | my ($self, $text) = @_; |
368 | # attribute => 'Char' |
369 | # char => '\' |
370 | # char1 => '"' |
371 | # context => '#stay' |
372 | # type => 'Detect2Chars' |
373 | if ($self->testDetect2Chars($text, '\\', '"', 0, 0, 0, undef, 0, '#stay', 'Char')) { |
374 | return 1 |
375 | } |
376 | # attribute => 'String' |
377 | # char => '"' |
378 | # context => '#pop' |
379 | # type => 'DetectChar' |
380 | if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'String')) { |
381 | return 1 |
382 | } |
383 | return 0; |
384 | }; |
385 | |
386 | |
387 | 1; |
388 | |
389 | __END__ |
390 | |
391 | =head1 NAME |
392 | |
393 | Syntax::Highlight::Engine::Kate::AHDL - a Plugin for AHDL syntax highlighting |
394 | |
395 | =head1 SYNOPSIS |
396 | |
397 | require Syntax::Highlight::Engine::Kate::AHDL; |
398 | my $sh = new Syntax::Highlight::Engine::Kate::AHDL([ |
399 | ]); |
400 | |
401 | =head1 DESCRIPTION |
402 | |
403 | Syntax::Highlight::Engine::Kate::AHDL is a plugin module that provides syntax highlighting |
404 | for AHDL to the Syntax::Haghlight::Engine::Kate highlighting engine. |
405 | |
406 | This code is generated from the syntax definition files used |
407 | by the Kate project. |
408 | It works quite fine, but can use refinement and optimization. |
409 | |
410 | It inherits Syntax::Higlight::Engine::Kate::Template. See also there. |
411 | |
412 | =cut |
413 | |
414 | =head1 AUTHOR |
415 | |
416 | Hans Jeuken (haje <at> toneel <dot> demon <dot> nl) |
417 | |
418 | =cut |
419 | |
420 | =head1 BUGS |
421 | |
422 | Unknown. If you find any, please contact the author |
423 | |
424 | =cut |
425 | |