File Coverage

blib/lib/Syntax/Highlight/Engine/Kate/GLSL.pm
Criterion Covered Total %
statement 73 79 92.4
branch 37 42 88.1
condition 1 3 33.3
subroutine 9 10 90.0
pod 0 7 0.0
total 120 141 85.1


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 'glsl.xml' file of the syntax highlight
6             # engine of the kate text editor (http://www.kate-editor.org
7              
8             #kate xml version 1.02
9             #kate version 2.4
10             #kate author Oliver Richers (o.richers@tu-bs.de)
11             #generated: Sun Feb 3 22:02:05 2008, localtime
12              
13             package Syntax::Highlight::Engine::Kate::GLSL;
14              
15             our $VERSION = '0.14';
16              
17 1     1   489 use strict;
  1         2  
  1         23  
18 1     1   5 use warnings;
  1         2  
  1         22  
19 1     1   4 use base('Syntax::Highlight::Engine::Kate::Template');
  1         2  
  1         887  
20              
21             sub new {
22 2     2 0 593 my $proto = shift;
23 2   33     8 my $class = ref($proto) || $proto;
24 2         11 my $self = $class->SUPER::new(@_);
25 2         20 $self->attributes({
26             'Alert' => 'Alert',
27             'Comment' => 'Comment',
28             'Data Type' => 'DataType',
29             'Decimal' => 'DecVal',
30             'Float' => 'Float',
31             'Function' => 'Function',
32             'Hex' => 'BaseN',
33             'Keyword' => 'Keyword',
34             'Normal Text' => 'Normal',
35             'Octal' => 'BaseN',
36             'Preprocessor' => 'Others',
37             'StdFunction' => 'Function',
38             'StdVariable' => 'Function',
39             'Symbol' => 'Normal',
40             'Type Qualifier' => 'DataType',
41             });
42 2         8 $self->listAdd('attention',
43             'BUG',
44             'FIXME',
45             'TODO',
46             );
47 2         6 $self->listAdd('keywords',
48             'break',
49             'continue',
50             'discard',
51             'do',
52             'else',
53             'false',
54             'for',
55             'if',
56             'return',
57             'struct',
58             'true',
59             'while',
60             );
61 2         7 $self->listAdd('stdlib',
62             'abs',
63             'acos',
64             'all',
65             'any',
66             'asin',
67             'atan',
68             'ceil',
69             'clamp',
70             'cos',
71             'cross',
72             'dFdx',
73             'dFdy',
74             'degrees',
75             'distance',
76             'dot',
77             'equal',
78             'exp',
79             'exp2',
80             'faceforward',
81             'floor',
82             'fract',
83             'ftransform',
84             'fwidth',
85             'greaterThan',
86             'greaterThanEqual',
87             'inversesqrt',
88             'length',
89             'lessThan',
90             'lessThenEqual',
91             'log',
92             'log2',
93             'matrixCompMult',
94             'max',
95             'min',
96             'mix',
97             'mod',
98             'noise1',
99             'noise2',
100             'noise3',
101             'noise4',
102             'normalize',
103             'not',
104             'notEqual',
105             'pow',
106             'radians',
107             'reflect',
108             'refract',
109             'shadow1D',
110             'shadow1DLod',
111             'shadow1DProj',
112             'shadow1DProjLod',
113             'shadow2D',
114             'shadow2DLod',
115             'shadow2DProj',
116             'shadow2DProjLod',
117             'sign',
118             'sin',
119             'smoothstep',
120             'sqrt',
121             'step',
122             'tan',
123             'texture1D',
124             'texture1DLod',
125             'texture1DProj',
126             'texture1DProjLod',
127             'texture2D',
128             'texture2DLod',
129             'texture2DProj',
130             'texture2DProjLod',
131             'texture3D',
132             'texture3DLod',
133             'texture3DProj',
134             'texture3DProjLod',
135             'textureCube',
136             'textureCubeLod',
137             );
138 2         7 $self->listAdd('stdvar',
139             'gl_BackColor',
140             'gl_BackLightModelProduct',
141             'gl_BackLightProduct',
142             'gl_BackMaterial',
143             'gl_BackSecondaryColor',
144             'gl_ClipPlane',
145             'gl_ClipVertex',
146             'gl_Color',
147             'gl_Color',
148             'gl_DepthRange',
149             'gl_DepthRangeParameters',
150             'gl_EyePlaneQ',
151             'gl_EyePlaneR',
152             'gl_EyePlaneS',
153             'gl_EyePlaneT',
154             'gl_Fog',
155             'gl_FogColor',
156             'gl_FogFragCoord',
157             'gl_FogParameters',
158             'gl_FragColor',
159             'gl_FragCoord',
160             'gl_FragData',
161             'gl_FragDepth',
162             'gl_FragFacing',
163             'gl_FrontColor',
164             'gl_FrontLightModelProduct',
165             'gl_FrontLightProduct',
166             'gl_FrontMaterial',
167             'gl_FrontSecondaryColor',
168             'gl_LightModel',
169             'gl_LightModelParameters',
170             'gl_LightModelProducts',
171             'gl_LightProducts',
172             'gl_LightSource',
173             'gl_LightSourceParameters',
174             'gl_MaterialParameters',
175             'gl_MaxClipPlanes',
176             'gl_MaxCombinedTextureImageUnits',
177             'gl_MaxDrawBuffers',
178             'gl_MaxFragmentUniformComponents',
179             'gl_MaxLights',
180             'gl_MaxTextureCoords',
181             'gl_MaxTextureImageUnits',
182             'gl_MaxTextureUnits',
183             'gl_MaxVaryingFloats',
184             'gl_MaxVertexAttributes',
185             'gl_MaxVertexTextureImageUnits',
186             'gl_MaxVertexUniformComponents',
187             'gl_ModelViewMatrix',
188             'gl_ModelViewMatrixInverse',
189             'gl_ModelViewMatrixInverseTranspose',
190             'gl_ModelViewMatrixTranspose',
191             'gl_ModelViewProjectionMatrix',
192             'gl_ModelViewProjectionMatrixInverse',
193             'gl_ModelViewProjectionMatrixInverseTranspose',
194             'gl_ModelViewProjectionMatrixTranspose',
195             'gl_MultiTexCoord0',
196             'gl_MultiTexCoord1',
197             'gl_MultiTexCoord2',
198             'gl_MultiTexCoord2',
199             'gl_MultiTexCoord3',
200             'gl_MultiTexCoord4',
201             'gl_MultiTexCoord5',
202             'gl_MultiTexCoord6',
203             'gl_MultiTexCoord7',
204             'gl_NormScale',
205             'gl_Normal',
206             'gl_NormalMatrix',
207             'gl_ObjectPlaneQ',
208             'gl_ObjectPlaneR',
209             'gl_ObjectPlaneS',
210             'gl_ObjectPlaneT',
211             'gl_Point',
212             'gl_PointParameters',
213             'gl_PointSize',
214             'gl_Position',
215             'gl_ProjectionMatrix',
216             'gl_ProjectionMatrixInverse',
217             'gl_ProjectionMatrixInverseTranspose',
218             'gl_ProjectionMatrixTranspose',
219             'gl_SecondaryColor',
220             'gl_SecondaryColor',
221             'gl_TexCoord',
222             'gl_TextureEnvColor',
223             'gl_TextureMatrix',
224             'gl_TextureMatrixInverse',
225             'gl_TextureMatrixInverseTranspose',
226             'gl_TextureMatrixTranspose',
227             'gl_Vertex',
228             );
229 2         6 $self->listAdd('typequal',
230             'attribute',
231             'const',
232             'in',
233             'inout',
234             'out',
235             'uniform',
236             'varying',
237             );
238 2         6 $self->listAdd('types',
239             'bool',
240             'bvec2',
241             'bvec3',
242             'bvec4',
243             'float',
244             'int',
245             'ivec2',
246             'ivec3',
247             'ivec4',
248             'mat2',
249             'mat3',
250             'mat4',
251             'sampler1D',
252             'sampler1DShadow',
253             'sampler2D',
254             'sampler2DShadow',
255             'sampler3D',
256             'samplerCube',
257             'vec2',
258             'vec3',
259             'vec4',
260             'void',
261             );
262 2         28 $self->contextdata({
263             'Commentar 1' => {
264             callback => \&parseCommentar1,
265             attribute => 'Comment',
266             lineending => '#pop',
267             },
268             'Commentar 2' => {
269             callback => \&parseCommentar2,
270             attribute => 'Comment',
271             },
272             'Member' => {
273             callback => \&parseMember,
274             attribute => 'Normal Text',
275             lineending => '#pop',
276             fallthrough => '#pop',
277             },
278             'Normal' => {
279             callback => \&parseNormal,
280             attribute => 'Normal Text',
281             },
282             'Preprocessor' => {
283             callback => \&parsePreprocessor,
284             attribute => 'Preprocessor',
285             lineending => '#pop',
286             },
287             });
288 2         8 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
289 2         7 $self->basecontext('Normal');
290 2         7 $self->keywordscase(0);
291 2         5 $self->initialize;
292 2         4 bless ($self, $class);
293 2         8 return $self;
294             }
295              
296             sub language {
297 0     0 0 0 return 'GLSL';
298             }
299              
300             sub parseCommentar1 {
301 654     654 0 856 my ($self, $text) = @_;
302             # String => 'attention'
303             # attribute => 'Alert'
304             # context => '#stay'
305             # type => 'keyword'
306 654 100       1257 if ($self->testKeyword($text, 'attention', 0, undef, 0, '#stay', 'Alert')) {
307 6         12 return 1
308             }
309 648         1015 return 0;
310             };
311              
312             sub parseCommentar2 {
313 60     60 0 83 my ($self, $text) = @_;
314             # attribute => 'Comment'
315             # char => '*'
316             # char1 => '/'
317             # context => '#pop'
318             # endRegion => 'Comment'
319             # type => 'Detect2Chars'
320 60 100       113 if ($self->testDetect2Chars($text, '*', '/', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
321 2         5 return 1
322             }
323             # String => 'attention'
324             # attribute => 'Alert'
325             # context => '#stay'
326             # type => 'keyword'
327 58 50       118 if ($self->testKeyword($text, 'attention', 0, undef, 0, '#stay', 'Alert')) {
328 0         0 return 1
329             }
330 58         86 return 0;
331             };
332              
333             sub parseMember {
334 4     4 0 9 my ($self, $text) = @_;
335             # String => '\b[_\w][_\w\d]*(?=[\s]*)'
336             # attribute => 'Function'
337             # context => '#pop'
338             # type => 'RegExpr'
339 4 50       11 if ($self->testRegExpr($text, '\\b[_\\w][_\\w\\d]*(?=[\\s]*)', 0, 0, 0, undef, 0, '#pop', 'Function')) {
340 4         9 return 1
341             }
342 0         0 return 0;
343             };
344              
345             sub parseNormal {
346 540     540 0 799 my ($self, $text) = @_;
347             # String => 'keywords'
348             # attribute => 'Keyword'
349             # context => '#stay'
350             # type => 'keyword'
351 540 100       1147 if ($self->testKeyword($text, 'keywords', 0, undef, 0, '#stay', 'Keyword')) {
352 26         52 return 1
353             }
354             # String => 'types'
355             # attribute => 'Data Type'
356             # context => '#stay'
357             # type => 'keyword'
358 514 100       1045 if ($self->testKeyword($text, 'types', 0, undef, 0, '#stay', 'Data Type')) {
359 56         102 return 1
360             }
361             # String => 'typequal'
362             # attribute => 'Type Qualifier'
363             # context => '#stay'
364             # type => 'keyword'
365 458 100       906 if ($self->testKeyword($text, 'typequal', 0, undef, 0, '#stay', 'Type Qualifier')) {
366 14         29 return 1
367             }
368             # String => 'stdlib'
369             # attribute => 'StdFunction'
370             # context => '#stay'
371             # type => 'keyword'
372 444 100       920 if ($self->testKeyword($text, 'stdlib', 0, undef, 0, '#stay', 'StdFunction')) {
373 16         32 return 1
374             }
375             # String => 'stdvar'
376             # attribute => 'StdVariable'
377             # context => '#stay'
378             # type => 'keyword'
379 428 100       914 if ($self->testKeyword($text, 'stdvar', 0, undef, 0, '#stay', 'StdVariable')) {
380 6         12 return 1
381             }
382             # attribute => 'Float'
383             # context => '#stay'
384             # type => 'Float'
385 422 100       970 if ($self->testFloat($text, 0, undef, 0, '#stay', 'Float')) {
386 8         18 return 1
387             }
388             # attribute => 'Octal'
389             # context => '#stay'
390             # type => 'HlCOct'
391 414 50       851 if ($self->testHlCOct($text, 0, undef, 0, '#stay', 'Octal')) {
392 0         0 return 1
393             }
394             # attribute => 'Hex'
395             # context => '#stay'
396             # type => 'HlCHex'
397 414 50       899 if ($self->testHlCHex($text, 0, undef, 0, '#stay', 'Hex')) {
398 0         0 return 1
399             }
400             # attribute => 'Decimal'
401             # context => '#stay'
402             # type => 'Int'
403 414 50       828 if ($self->testInt($text, 0, undef, 0, '#stay', 'Decimal')) {
404 0         0 return 1
405             }
406             # attribute => 'Comment'
407             # char => '/'
408             # char1 => '/'
409             # context => 'Commentar 1'
410             # type => 'Detect2Chars'
411 414 100       880 if ($self->testDetect2Chars($text, '/', '/', 0, 0, 0, undef, 0, 'Commentar 1', 'Comment')) {
412 34         62 return 1
413             }
414             # attribute => 'Comment'
415             # beginRegion => 'Comment'
416             # char => '/'
417             # char1 => '*'
418             # context => 'Commentar 2'
419             # type => 'Detect2Chars'
420 380 100       790 if ($self->testDetect2Chars($text, '/', '*', 0, 0, 0, undef, 0, 'Commentar 2', 'Comment')) {
421 2         6 return 1
422             }
423             # attribute => 'Symbol'
424             # beginRegion => 'Brace1'
425             # char => '{'
426             # context => '#stay'
427             # type => 'DetectChar'
428 378 100       793 if ($self->testDetectChar($text, '{', 0, 0, 0, undef, 0, '#stay', 'Symbol')) {
429 4         8 return 1
430             }
431             # attribute => 'Symbol'
432             # char => '}'
433             # context => '#stay'
434             # endRegion => 'Brace1'
435             # type => 'DetectChar'
436 374 100       702 if ($self->testDetectChar($text, '}', 0, 0, 0, undef, 0, '#stay', 'Symbol')) {
437 4         10 return 1
438             }
439             # attribute => 'Preprocessor'
440             # char => '#'
441             # context => 'Preprocessor'
442             # firstNonSpace => 'true'
443             # type => 'DetectChar'
444 370 100       719 if ($self->testDetectChar($text, '#', 0, 0, 0, undef, 1, 'Preprocessor', 'Preprocessor')) {
445 4         9 return 1
446             }
447             # String => '\b[_\w][_\w\d]*(?=[\s]*[(])'
448             # attribute => 'Function'
449             # context => '#stay'
450             # type => 'RegExpr'
451 366 100       760 if ($self->testRegExpr($text, '\\b[_\\w][_\\w\\d]*(?=[\\s]*[(])', 0, 0, 0, undef, 0, '#stay', 'Function')) {
452 4         11 return 1
453             }
454             # String => '[.]{1,1}'
455             # attribute => 'Symbol'
456             # context => 'Member'
457             # type => 'RegExpr'
458 362 100       844 if ($self->testRegExpr($text, '[.]{1,1}', 0, 0, 0, undef, 0, 'Member', 'Symbol')) {
459 4         9 return 1
460             }
461             # String => '.+-/*%<>[]()^|&~=!:;,?;'
462             # attribute => 'Symbol'
463             # context => '#stay'
464             # type => 'AnyChar'
465 358 100       797 if ($self->testAnyChar($text, '.+-/*%<>[]()^|&~=!:;,?;', 0, 0, undef, 0, '#stay', 'Symbol')) {
466 38         76 return 1
467             }
468 320         544 return 0;
469             };
470              
471             sub parsePreprocessor {
472 52     52 0 65 my ($self, $text) = @_;
473 52         84 return 0;
474             };
475              
476              
477             1;
478              
479             __END__