source: trunk/src/gpu/lolfx-parser.y @ 1687

Last change on this file since 1687 was 1590, checked in by sam, 9 years ago

core: start working on a higher level LolFx compiler based on the latest
GLSL grammar and some personal attempts at writing an HLSL grammar.

File size: 28.8 KB
Line 
1%{
2//
3// Lol Engine
4//
5// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
6//   This program is free software; you can redistribute it and/or
7//   modify it under the terms of the Do What The Fuck You Want To
8//   Public License, Version 2, as published by Sam Hocevar. See
9//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
10//
11
12#if defined HAVE_CONFIG_H
13#   include "config.h"
14#endif
15
16#include "core.h"
17
18#include <string>
19
20%}
21
22%require "2.3"
23%debug
24%defines
25%skeleton "lalr1.cc"
26%name-prefix="lol"
27%define parser_class_name "LolFxParser"
28%locations
29%parse-param { class LolFxCompiler& mc }
30%error-verbose
31
32/* The classic Bison union trick */
33%union
34{
35    int ival;
36    unsigned uval;
37    float fval;
38    char *sval;
39}
40
41/* %type <sval> lolfx_shader_name */
42
43 /*
44  * GLSL and HLSL generic tokens
45  */
46
47%token <ival> BOOLCONSTANT
48%token <ival> INTCONSTANT
49%token <uval> UINTCONSTANT
50%token <fval> FLOATCONSTANT
51%token /* TODO */ FIELDSELECTION
52%token <sval> IDENTIFIER
53%token <sval> TYPENAME
54
55 /*
56  * GLSL keywords
57  * FIXME: unsorted
58  */
59
60%token GT_SUBROUTINE GT_PATCH GT_SAMPLE GT_FLAT GT_SMOOTH GT_LAYOUT
61%token GT_INVARIANT GT_HIGHP GT_MEDIUMP GT_LOWP GT_PRECISION
62
63 /*
64  * Deprecated GLSL keywords
65  */
66
67%token GT_ATTRIBUTE
68
69 /*
70  * GLSL types
71  */
72
73%token GT_VEC2 GT_VEC3 GT_VEC4
74%token GT_BVEC2 GT_BVEC3 GT_BVEC4
75%token GT_DVEC2 GT_DVEC3 GT_DVEC4
76%token GT_IVEC2 GT_IVEC3 GT_IVEC4
77%token GT_UVEC2 GT_UVEC3 GT_UVEC4
78
79%token GT_MAT2 GT_MAT2X2 GT_MAT2X3 GT_MAT2X4
80%token GT_MAT3 GT_MAT3X2 GT_MAT3X3 GT_MAT3X4
81%token GT_MAT4 GT_MAT4X2 GT_MAT4X3 GT_MAT4X4
82%token GT_DMAT2 GT_DMAT2X2 GT_DMAT2X3 GT_DMAT2X4
83%token GT_DMAT3 GT_DMAT3X2 GT_DMAT3X3 GT_DMAT3X4
84%token GT_DMAT4 GT_DMAT4X2 GT_DMAT4X3 GT_DMAT4X4
85
86%token GT_SAMPLER1DSHADOW GT_SAMPLER1DARRAY GT_SAMPLER1DARRAYSHADOW
87%token GT_SAMPLER2DSHADOW GT_SAMPLER2DARRAY GT_SAMPLER2DARRAYSHADOW
88%token GT_SAMPLER2DRECT GT_SAMPLER2DRECTSHADOW
89%token GT_SAMPLER2DMS GT_SAMPLER2DMSARRAY
90%token GT_SAMPLERCUBESHADOW GT_SAMPLERCUBEARRAY GT_SAMPLERCUBEARRAYSHADOW
91%token GT_SAMPLERBUFFER
92
93%token GT_ISAMPLER1D GT_ISAMPLER1DARRAY
94%token GT_ISAMPLER2D GT_ISAMPLER2DARRAY
95%token GT_ISAMPLER2DRECT
96%token GT_ISAMPLER2DMS GT_ISAMPLER2DMSARRAY
97%token GT_ISAMPLER3D
98%token GT_ISAMPLERCUBE GT_ISAMPLERCUBEARRAY
99%token GT_ISAMPLERBUFFER
100
101%token GT_USAMPLER1D GT_USAMPLER1DARRAY
102%token GT_USAMPLER2D GT_USAMPLER2DARRAY
103%token GT_USAMPLER2DRECT
104%token GT_USAMPLER2DMS GT_USAMPLER2DMSARRAY
105%token GT_USAMPLER3D
106%token GT_USAMPLERCUBE GT_USAMPLERCUBEARRAY
107%token GT_USAMPLERBUFFER
108
109 /*
110  * GLSL keywords that are also in HLSL
111  */
112
113%token GHT_BOOL GHT_BREAK GHT_CASE GHT_CENTROID GHT_CONST GHT_CONTINUE
114%token GHT_DEFAULT GHT_DISCARD GHT_DO GHT_DOUBLE GHT_ELSE GHT_FLOAT GHT_FOR
115%token GHT_IF GHT_IN GHT_INOUT GHT_INT GHT_NOPERSPECTIVE GHT_OUT GHT_RETURN
116%token GHT_SAMPLER1D GHT_SAMPLER2D GHT_SAMPLER3D GHT_SAMPLERCUBE GHT_STRUCT
117%token GHT_SWITCH GHT_UINT GHT_UNIFORM GHT_VOID GHT_WHILE
118
119 /*
120  * HLSL keywords that are also in GLSL
121  */
122
123%token HGT_BOOL HGT_BREAK HGT_CASE HGT_CENTROID HGT_CONST HGT_CONTINUE
124%token HGT_DEFAULT HGT_DISCARD HGT_DO HGT_DOUBLE HGT_ELSE HGT_FLOAT HGT_FOR
125%token HGT_IF HGT_IN HGT_INOUT HGT_INT HGT_NOPERSPECTIVE HGT_OUT HGT_RETURN
126%token HGT_SAMPLER1D HGT_SAMPLER2D HGT_SAMPLER3D HGT_SAMPLERCUBE HGT_STRUCT
127%token HGT_SWITCH HGT_UINT HGT_UNIFORM HGT_VOID HGT_WHILE
128
129 /*
130  * HLSL keywords
131  */
132
133%token HT_APPENDSTRUCTUREDBUFFER HT_ASM HT_ASM_FRAGMENT HT_BLENDSTATE
134%token HT_BUFFER HT_BYTEADDRESSBUFFER HT_CBUFFER
135%token HT_COLUMN_MAJOR HT_COMPILE HT_COMPILE_FRAGMENT HT_COMPILESHADER
136%token HT_COMPUTESHADER HT_CONSUMESTRUCTUREDBUFFER
137%token HT_DEPTHSTENCILSTATE HT_DEPTHSTENCILVIEW
138%token HT_DOMAINSHADER HT_DWORD HT_EXTERN HT_FALSE
139%token HT_FXGROUP HT_GEOMETRYSHADER HT_GROUPSHARED HT_HALF HT_HULLSHADER
140%token HT_INLINE HT_INPUTPATCH HT_INTERFACE HT_LINE
141%token HT_LINEADJ HT_LINEAR HT_LINESTREAM HT_MATRIX HT_NAMESPACE
142%token HT_NOINTERPOLATION HT_NULL HT_OUTPUTPATCH
143%token HT_PACKOFFSET HT_PASS HT_PIXELFRAGMENT HT_PIXELSHADER HT_POINT
144%token HT_POINTSTREAM HT_PRECISE HT_RASTERIZERSTATE HT_RENDERTARGETVIEW
145%token HT_REGISTER HT_ROW_MAJOR HT_RWBUFFER HT_RWBYTEADDRESSBUFFER
146%token HT_RWSTRUCTUREDBUFFER HT_RWTEXTURE1D HT_RWTEXTURE1DARRAY HT_RWTEXTURE2D
147%token HT_RWTEXTURE2DARRAY HT_RWTEXTURE3D HT_SAMPLER
148%token HT_SAMPLER_STATE HT_SAMPLERSTATE
149%token HT_SAMPLERCOMPARISONSTATE HT_SHARED HT_SNORM HT_STATEBLOCK
150%token HT_STATEBLOCK_STATE HT_STATIC HT_STRING
151%token HT_STRUCTUREDBUFFER HT_TBUFFER HT_TECHNIQUE HT_TECHNIQUE10
152%token HT_TECHNIQUE11XZ HT_TEXTURE HT_TEXTURE1D HT_TEXTURE1DARRAY HT_TEXTURE2D
153%token HT_TEXTURE2DARRAY HT_TEXTURE2DMS HT_TEXTURE2DMSARRAY HT_TEXTURE3D
154%token HT_TEXTURECUBE HT_TEXTURECUBEARRAY HT_TRUE HT_TYPEDEF HT_TRIANGLE
155%token HT_TRIANGLEADJ HT_TRIANGLESTREAM HT_UNORM HT_VECTOR
156%token HT_VERTEXFRAGMENT HT_VERTEXSHADER HT_VOLATILE
157
158 /*
159  * HLSL types
160  */
161
162%token HT_BOOL1 HT_BOOL1x1 HT_BOOL2x1 HT_BOOL3x1 HT_BOOL4x1
163%token HT_BOOL2 HT_BOOL1x2 HT_BOOL2x2 HT_BOOL3x2 HT_BOOL4x2
164%token HT_BOOL3 HT_BOOL1x3 HT_BOOL2x3 HT_BOOL3x3 HT_BOOL4x3
165%token HT_BOOL4 HT_BOOL1x4 HT_BOOL2x4 HT_BOOL3x4 HT_BOOL4x4
166
167%token HT_FLOAT1 HT_FLOAT1x1 HT_FLOAT2x1 HT_FLOAT3x1 HT_FLOAT4x1
168%token HT_FLOAT2 HT_FLOAT1x2 HT_FLOAT2x2 HT_FLOAT3x2 HT_FLOAT4x2
169%token HT_FLOAT3 HT_FLOAT1x3 HT_FLOAT2x3 HT_FLOAT3x3 HT_FLOAT4x3
170%token HT_FLOAT4 HT_FLOAT1x4 HT_FLOAT2x4 HT_FLOAT3x4 HT_FLOAT4x4
171
172%token HT_DOUBLE1 HT_DOUBLE1x1 HT_DOUBLE2x1 HT_DOUBLE3x1 HT_DOUBLE4x1
173%token HT_DOUBLE2 HT_DOUBLE1x2 HT_DOUBLE2x2 HT_DOUBLE3x2 HT_DOUBLE4x2
174%token HT_DOUBLE3 HT_DOUBLE1x3 HT_DOUBLE2x3 HT_DOUBLE3x3 HT_DOUBLE4x3
175%token HT_DOUBLE4 HT_DOUBLE1x4 HT_DOUBLE2x4 HT_DOUBLE3x4 HT_DOUBLE4x4
176
177%token HT_DWORD1 HT_DWORD1x1 HT_DWORD2x1 HT_DWORD3x1 HT_DWORD4x1
178%token HT_DWORD2 HT_DWORD1x2 HT_DWORD2x2 HT_DWORD3x2 HT_DWORD4x2
179%token HT_DWORD3 HT_DWORD1x3 HT_DWORD2x3 HT_DWORD3x3 HT_DWORD4x3
180%token HT_DWORD4 HT_DWORD1x4 HT_DWORD2x4 HT_DWORD3x4 HT_DWORD4x4
181
182%token HT_INT1 HT_INT1x1 HT_INT2x1 HT_INT3x1 HT_INT4x1
183%token HT_INT2 HT_INT1x2 HT_INT2x2 HT_INT3x2 HT_INT4x2
184%token HT_INT3 HT_INT1x3 HT_INT2x3 HT_INT3x3 HT_INT4x3
185%token HT_INT4 HT_INT1x4 HT_INT2x4 HT_INT3x4 HT_INT4x4
186
187%token HT_UINT1 HT_UINT1x1 HT_UINT2x1 HT_UINT3x1 HT_UINT4x1
188%token HT_UINT2 HT_UINT1x2 HT_UINT2x2 HT_UINT3x2 HT_UINT4x2
189%token HT_UINT3 HT_UINT1x3 HT_UINT2x3 HT_UINT3x3 HT_UINT4x3
190%token HT_UINT4 HT_UINT1x4 HT_UINT2x4 HT_UINT3x4 HT_UINT4x4
191
192 /*
193  * HLSL preprocessor directives
194  */
195
196%token PREPROCESSOR_DEFINE PREPROCESSOR_ELIF PREPROCESSOR_ELSE
197%token PREPROCESSOR_ENDIF PREPROCESSOR_ERROR PREPROCESSOR_IF
198%token PREPROCESSOR_IFDEF PREPROCESSOR_IFNDEF PREPROCESSOR_INCLUDE
199%token PREPROCESSOR_LINE PREPROCESSOR_PRAGMA PREPROCESSOR_UNDEF
200%token PREPROCESSOR_REGION
201
202%token PRAGMA_LOLFX
203
204 /*
205  * HLSL reserved keywords
206  */
207
208%token HT_AUTO HT_CATCH HT_CHAR HT_CLASS HT_CONST_CAST
209%token HT_DELETE HT_DYNAMIC_CAST HT_ENUM HT_EXPLICIT HT_FRIEND HT_GOTO HT_LONG
210%token HT_MUTABLE HT_NEW HT_OPERATOR HT_PRIVATE HT_PROTECTED HT_PUBLIC
211%token HT_REINTERPRET_CAST HT_SHORT HT_SIGNED HT_SIZEOF HT_STATIC_CAST
212%token HT_TEMPLATE HT_THIS HT_THROW HT_TRY HT_TYPENAME HT_UNION HT_UNSIGNED
213%token HT_USING HT_VIRTUAL
214
215 /*
216  * Language symbols
217  */
218
219%token T_INC T_DEC T_LE T_GE T_EQ T_NE T_LEFT T_RIGHT T_AND T_OR T_XOR
220%token T_MULEQ T_DIVEQ T_MODEQ T_ADDEQ T_SUBEQ T_LEFTEQ T_RIGHTEQ T_ANDEQ
221%token T_XOREQ T_OREQ
222
223 /*
224  * Temporary shit
225  */
226
227%token <fval> FLOAT
228%token <sval> STRING NAME
229
230 /*
231  * Special tokens
232  */
233
234%token T_END 0
235%token T_ERROR
236
237 /*
238  * Our entry point
239  */
240
241%start lolfx_file
242
243%{
244#include "gpu/lolfx-compiler.h"
245
246#undef yylex
247#define yylex mc.m_lexer->lex
248%}
249
250%%
251
252 /*
253  * Shortcuts for token groups
254  */
255
256group_glsl_keyword:
257    GT_SUBROUTINE
258  | GT_PATCH
259  | GT_SAMPLE
260  | GT_FLAT
261  | GT_SMOOTH
262  | GT_LAYOUT
263  | GT_INVARIANT
264  | GT_HIGHP
265  | GT_MEDIUMP
266  | GT_LOWP
267  | GT_PRECISION
268  | GT_ATTRIBUTE
269    ;
270
271group_glsl_type:
272    GT_VEC2
273  | GT_VEC3
274  | GT_VEC4
275  | GT_BVEC2
276  | GT_BVEC3
277  | GT_BVEC4
278  | GT_DVEC2
279  | GT_DVEC3
280  | GT_DVEC4
281  | GT_IVEC2
282  | GT_IVEC3
283  | GT_IVEC4
284  | GT_UVEC2
285  | GT_UVEC3
286  | GT_UVEC4
287  | GT_MAT2
288  | GT_MAT2X2
289  | GT_MAT2X3
290  | GT_MAT2X4
291  | GT_MAT3
292  | GT_MAT3X2
293  | GT_MAT3X3
294  | GT_MAT3X4
295  | GT_MAT4
296  | GT_MAT4X2
297  | GT_MAT4X3
298  | GT_MAT4X4
299  | GT_DMAT2
300  | GT_DMAT2X2
301  | GT_DMAT2X3
302  | GT_DMAT2X4
303  | GT_DMAT3
304  | GT_DMAT3X2
305  | GT_DMAT3X3
306  | GT_DMAT3X4
307  | GT_DMAT4
308  | GT_DMAT4X2
309  | GT_DMAT4X3
310  | GT_DMAT4X4
311  | GT_SAMPLER1DSHADOW
312  | GT_SAMPLER1DARRAY
313  | GT_SAMPLER1DARRAYSHADOW
314  | GT_SAMPLER2DSHADOW
315  | GT_SAMPLER2DARRAY
316  | GT_SAMPLER2DARRAYSHADOW
317  | GT_SAMPLER2DRECT
318  | GT_SAMPLER2DRECTSHADOW
319  | GT_SAMPLER2DMS
320  | GT_SAMPLER2DMSARRAY
321  | GT_SAMPLERCUBESHADOW
322  | GT_SAMPLERCUBEARRAY
323  | GT_SAMPLERCUBEARRAYSHADOW
324  | GT_SAMPLERBUFFER
325  | GT_ISAMPLER1D
326  | GT_ISAMPLER1DARRAY
327  | GT_ISAMPLER2D
328  | GT_ISAMPLER2DARRAY
329  | GT_ISAMPLER2DRECT
330  | GT_ISAMPLER2DMS
331  | GT_ISAMPLER2DMSARRAY
332  | GT_ISAMPLER3D
333  | GT_ISAMPLERCUBE
334  | GT_ISAMPLERCUBEARRAY
335  | GT_ISAMPLERBUFFER
336  | GT_USAMPLER1D
337  | GT_USAMPLER1DARRAY
338  | GT_USAMPLER2D
339  | GT_USAMPLER2DARRAY
340  | GT_USAMPLER2DRECT
341  | GT_USAMPLER2DMS
342  | GT_USAMPLER2DMSARRAY
343  | GT_USAMPLER3D
344  | GT_USAMPLERCUBE
345  | GT_USAMPLERCUBEARRAY
346  | GT_USAMPLERBUFFER
347    ;
348
349group_glsl_keyword_in_hlsl:
350    GHT_BOOL
351  | GHT_BREAK
352  | GHT_CASE
353  | GHT_CENTROID
354  | GHT_CONST
355  | GHT_CONTINUE
356  | GHT_DEFAULT
357  | GHT_DISCARD
358  | GHT_DO
359  | GHT_DOUBLE
360  | GHT_ELSE
361  | GHT_FLOAT
362  | GHT_FOR
363  | GHT_IF
364  | GHT_IN
365  | GHT_INOUT
366  | GHT_INT
367  | GHT_NOPERSPECTIVE
368  | GHT_OUT
369  | GHT_RETURN
370  | GHT_SAMPLER1D
371  | GHT_SAMPLER2D
372  | GHT_SAMPLER3D
373  | GHT_SAMPLERCUBE
374  | GHT_STRUCT
375  | GHT_SWITCH
376  | GHT_UINT
377  | GHT_UNIFORM
378  | GHT_VOID
379  | GHT_WHILE
380    ;
381
382group_hlsl_keyword_in_glsl:
383    HGT_BOOL
384  | HGT_BREAK
385  | HGT_CASE
386  | HGT_CENTROID
387  | HGT_CONST
388  | HGT_CONTINUE
389  | HGT_DEFAULT
390  | HGT_DISCARD
391  | HGT_DO
392  | HGT_DOUBLE
393  | HGT_ELSE
394  | HGT_FLOAT
395  | HGT_FOR
396  | HGT_IF
397  | HGT_IN
398  | HGT_INOUT
399  | HGT_INT
400  | HGT_NOPERSPECTIVE
401  | HGT_OUT
402  | HGT_RETURN
403  | HGT_SAMPLER1D
404  | HGT_SAMPLER2D
405  | HGT_SAMPLER3D
406  | HGT_SAMPLERCUBE
407  | HGT_STRUCT
408  | HGT_SWITCH
409  | HGT_UINT
410  | HGT_UNIFORM
411  | HGT_VOID
412  | HGT_WHILE
413    ;
414
415group_hlsl_keyword:
416    HT_APPENDSTRUCTUREDBUFFER
417  | HT_ASM
418  | HT_ASM_FRAGMENT
419  | HT_BLENDSTATE
420  | HT_BUFFER
421  | HT_BYTEADDRESSBUFFER
422  | HT_CBUFFER
423  | HT_COLUMN_MAJOR
424  | HT_COMPILE
425  | HT_COMPILE_FRAGMENT
426  | HT_COMPILESHADER
427  | HT_COMPUTESHADER
428  | HT_CONSUMESTRUCTUREDBUFFER
429  | HT_DEPTHSTENCILSTATE
430  | HT_DEPTHSTENCILVIEW
431  | HT_DOMAINSHADER
432  | HT_DWORD
433  | HT_EXTERN
434  | HT_FALSE
435  | HT_FXGROUP
436  | HT_GEOMETRYSHADER
437  | HT_GROUPSHARED
438  | HT_HALF
439  | HT_HULLSHADER
440  | HT_INLINE
441  | HT_INPUTPATCH
442  | HT_INTERFACE
443  | HT_LINE
444  | HT_LINEADJ
445  | HT_LINEAR
446  | HT_LINESTREAM
447  | HT_MATRIX
448  | HT_NAMESPACE
449  | HT_NOINTERPOLATION
450  | HT_NULL
451  | HT_OUTPUTPATCH
452  | HT_PACKOFFSET
453  | HT_PASS
454  | HT_PIXELFRAGMENT
455  | HT_PIXELSHADER
456  | HT_POINT
457  | HT_POINTSTREAM
458  | HT_PRECISE
459  | HT_RASTERIZERSTATE
460  | HT_RENDERTARGETVIEW
461  | HT_REGISTER
462  | HT_ROW_MAJOR
463  | HT_RWBUFFER
464  | HT_RWBYTEADDRESSBUFFER
465  | HT_RWSTRUCTUREDBUFFER
466  | HT_RWTEXTURE1D
467  | HT_RWTEXTURE1DARRAY
468  | HT_RWTEXTURE2D
469  | HT_RWTEXTURE2DARRAY
470  | HT_RWTEXTURE3D
471  | HT_SAMPLER
472  | HT_SAMPLER_STATE
473  | HT_SAMPLERSTATE
474  | HT_SAMPLERCOMPARISONSTATE
475  | HT_SHARED
476  | HT_SNORM
477  | HT_STATEBLOCK
478  | HT_STATEBLOCK_STATE
479  | HT_STATIC
480  | HT_STRING
481  | HT_STRUCTUREDBUFFER
482  | HT_TBUFFER
483  | HT_TECHNIQUE
484  | HT_TECHNIQUE10
485  | HT_TECHNIQUE11XZ
486  | HT_TEXTURE
487  | HT_TEXTURE1D
488  | HT_TEXTURE1DARRAY
489  | HT_TEXTURE2D
490  | HT_TEXTURE2DARRAY
491  | HT_TEXTURE2DMS
492  | HT_TEXTURE2DMSARRAY
493  | HT_TEXTURE3D
494  | HT_TEXTURECUBE
495  | HT_TEXTURECUBEARRAY
496  | HT_TRUE
497  | HT_TYPEDEF
498  | HT_TRIANGLE
499  | HT_TRIANGLEADJ
500  | HT_TRIANGLESTREAM
501  | HT_UNORM
502  | HT_VECTOR
503  | HT_VERTEXFRAGMENT
504  | HT_VERTEXSHADER
505  | HT_VOLATILE
506    ;
507
508group_hlsl_type:
509    HT_BOOL1
510  | HT_BOOL1x1
511  | HT_BOOL2x1
512  | HT_BOOL3x1
513  | HT_BOOL4x1
514  | HT_BOOL2
515  | HT_BOOL1x2
516  | HT_BOOL2x2
517  | HT_BOOL3x2
518  | HT_BOOL4x2
519  | HT_BOOL3
520  | HT_BOOL1x3
521  | HT_BOOL2x3
522  | HT_BOOL3x3
523  | HT_BOOL4x3
524  | HT_BOOL4
525  | HT_BOOL1x4
526  | HT_BOOL2x4
527  | HT_BOOL3x4
528  | HT_BOOL4x4
529  | HT_FLOAT1
530  | HT_FLOAT1x1
531  | HT_FLOAT2x1
532  | HT_FLOAT3x1
533  | HT_FLOAT4x1
534  | HT_FLOAT2
535  | HT_FLOAT1x2
536  | HT_FLOAT2x2
537  | HT_FLOAT3x2
538  | HT_FLOAT4x2
539  | HT_FLOAT3
540  | HT_FLOAT1x3
541  | HT_FLOAT2x3
542  | HT_FLOAT3x3
543  | HT_FLOAT4x3
544  | HT_FLOAT4
545  | HT_FLOAT1x4
546  | HT_FLOAT2x4
547  | HT_FLOAT3x4
548  | HT_FLOAT4x4
549  | HT_DOUBLE1
550  | HT_DOUBLE1x1
551  | HT_DOUBLE2x1
552  | HT_DOUBLE3x1
553  | HT_DOUBLE4x1
554  | HT_DOUBLE2
555  | HT_DOUBLE1x2
556  | HT_DOUBLE2x2
557  | HT_DOUBLE3x2
558  | HT_DOUBLE4x2
559  | HT_DOUBLE3
560  | HT_DOUBLE1x3
561  | HT_DOUBLE2x3
562  | HT_DOUBLE3x3
563  | HT_DOUBLE4x3
564  | HT_DOUBLE4
565  | HT_DOUBLE1x4
566  | HT_DOUBLE2x4
567  | HT_DOUBLE3x4
568  | HT_DOUBLE4x4
569  | HT_DWORD1
570  | HT_DWORD1x1
571  | HT_DWORD2x1
572  | HT_DWORD3x1
573  | HT_DWORD4x1
574  | HT_DWORD2
575  | HT_DWORD1x2
576  | HT_DWORD2x2
577  | HT_DWORD3x2
578  | HT_DWORD4x2
579  | HT_DWORD3
580  | HT_DWORD1x3
581  | HT_DWORD2x3
582  | HT_DWORD3x3
583  | HT_DWORD4x3
584  | HT_DWORD4
585  | HT_DWORD1x4
586  | HT_DWORD2x4
587  | HT_DWORD3x4
588  | HT_DWORD4x4
589  | HT_INT1
590  | HT_INT1x1
591  | HT_INT2x1
592  | HT_INT3x1
593  | HT_INT4x1
594  | HT_INT2
595  | HT_INT1x2
596  | HT_INT2x2
597  | HT_INT3x2
598  | HT_INT4x2
599  | HT_INT3
600  | HT_INT1x3
601  | HT_INT2x3
602  | HT_INT3x3
603  | HT_INT4x3
604  | HT_INT4
605  | HT_INT1x4
606  | HT_INT2x4
607  | HT_INT3x4
608  | HT_INT4x4
609  | HT_UINT1
610  | HT_UINT1x1
611  | HT_UINT2x1
612  | HT_UINT3x1
613  | HT_UINT4x1
614  | HT_UINT2
615  | HT_UINT1x2
616  | HT_UINT2x2
617  | HT_UINT3x2
618  | HT_UINT4x2
619  | HT_UINT3
620  | HT_UINT1x3
621  | HT_UINT2x3
622  | HT_UINT3x3
623  | HT_UINT4x3
624  | HT_UINT4
625  | HT_UINT1x4
626  | HT_UINT2x4
627  | HT_UINT3x4
628  | HT_UINT4x4
629    ;
630
631group_hlsl_preprocessor:
632    PREPROCESSOR_DEFINE
633  | PREPROCESSOR_ELIF
634  | PREPROCESSOR_ELSE
635  | PREPROCESSOR_ENDIF
636  | PREPROCESSOR_ERROR
637  | PREPROCESSOR_IF
638  | PREPROCESSOR_IFDEF
639  | PREPROCESSOR_IFNDEF
640  | PREPROCESSOR_INCLUDE
641  | PREPROCESSOR_LINE
642  | PREPROCESSOR_PRAGMA
643  | PREPROCESSOR_UNDEF
644  | PREPROCESSOR_REGION
645    ;
646
647group_hlsl_reserved:
648    HT_AUTO
649  | HT_CATCH
650  | HT_CHAR
651  | HT_CLASS
652  | HT_CONST_CAST
653  | HT_DELETE
654  | HT_DYNAMIC_CAST
655  | HT_ENUM
656  | HT_EXPLICIT
657  | HT_FRIEND
658  | HT_GOTO
659  | HT_LONG
660  | HT_MUTABLE
661  | HT_NEW
662  | HT_OPERATOR
663  | HT_PRIVATE
664  | HT_PROTECTED
665  | HT_PUBLIC
666  | HT_REINTERPRET_CAST
667  | HT_SHORT
668  | HT_SIGNED
669  | HT_SIZEOF
670  | HT_STATIC_CAST
671  | HT_TEMPLATE
672  | HT_THIS
673  | HT_THROW
674  | HT_TRY
675  | HT_TYPENAME
676  | HT_UNION
677  | HT_UNSIGNED
678  | HT_USING
679  | HT_VIRTUAL
680    ;
681
682group_language_symbols:
683    T_INC
684  | T_DEC
685  | T_LE
686  | T_GE
687  | T_EQ
688  | T_NE
689  | T_LEFT
690  | T_RIGHT
691  | T_AND
692  | T_OR
693  | T_XOR
694  | T_MULEQ
695  | T_DIVEQ
696  | T_MODEQ
697  | T_ADDEQ
698  | T_SUBEQ
699  | T_LEFTEQ
700  | T_RIGHTEQ
701  | T_ANDEQ
702  | T_XOREQ
703  | T_OREQ
704    ;
705
706 /*
707  * Grammar for LolFx files
708  */
709
710lolfx_file:
711    lolfx_section_list
712    ;
713
714lolfx_section_list:
715    lolfx_section
716  | lolfx_section lolfx_section_list
717    ;
718
719lolfx_section:
720    lolfx_technique
721  | lolfx_shader
722    ;
723
724 /*
725  * Grammar for techniques
726  */
727
728lolfx_technique:
729    HT_TECHNIQUE IDENTIFIER '{' pass_list '}' { std::cout << "New tech " << $2 << std::endl; }
730    ;
731
732 /*
733  * Grammar for passes
734  */
735
736pass_list:
737    pass
738  | pass pass_list
739    ;
740
741pass:
742    HT_PASS IDENTIFIER '{' pass_stmt_list '}' { std::cout << "New pass " << $2 << std::endl; }
743    ;
744
745pass_stmt_list:
746    pass_stmt
747  | pass_stmt pass_stmt_list
748    ;
749
750 /* Shitty shit */
751pass_stmt:
752    ';'
753  | IDENTIFIER '=' IDENTIFIER ';'
754  | IDENTIFIER '=' INTCONSTANT ';'
755  | IDENTIFIER '=' BOOLCONSTANT ';'
756  | IDENTIFIER '=' HT_FALSE ';'
757  | IDENTIFIER '=' HT_TRUE ';'
758  | IDENTIFIER '[' INTCONSTANT ']' '=' IDENTIFIER ';'
759  | IDENTIFIER '[' INTCONSTANT ']' '=' INTCONSTANT ';'
760  | HT_TEXTURE '[' INTCONSTANT ']' '=' IDENTIFIER ';'
761  | HT_TEXTURE '[' INTCONSTANT ']' '=' HT_NULL ';'
762  | HT_DOMAINSHADER '=' IDENTIFIER ';'
763  | HT_GEOMETRYSHADER '=' IDENTIFIER ';'
764  | HT_HULLSHADER '=' IDENTIFIER ';'
765  | HT_PIXELSHADER '=' IDENTIFIER ';'
766  | HT_VERTEXSHADER '=' IDENTIFIER ';'
767    ;
768
769 /*
770  * Grammar for shaders
771  */
772
773lolfx_shader:
774    lolfx_shader_declaration glsl_translation_unit
775    ;
776
777lolfx_shader_declaration:
778    PRAGMA_LOLFX lolfx_shader_type '(' lolfx_shader_description_list ')' { std::cout << "new shader" << std::endl; }
779    ;
780
781lolfx_shader_type:
782    HT_VERTEXSHADER
783  | HT_PIXELSHADER
784    ;
785
786lolfx_shader_description_list:
787    lolfx_shader_description ',' lolfx_shader_description
788  | lolfx_shader_description
789    ;
790
791lolfx_shader_description:
792    IDENTIFIER '=' IDENTIFIER FLOATCONSTANT
793  | IDENTIFIER '=' IDENTIFIER
794    ;
795
796 /*
797  * Grammar for GLSL
798  */
799
800glsl_variable_identifier:
801    IDENTIFIER
802    ;
803
804glsl_primary_expression:
805    glsl_variable_identifier
806  | INTCONSTANT
807  | UINTCONSTANT
808  | FLOATCONSTANT
809  | BOOLCONSTANT
810  | '(' glsl_expression ')'
811    ;
812
813glsl_postfix_expression:
814    glsl_primary_expression
815  | glsl_postfix_expression '[' glsl_integer_expression ']'
816  | glsl_function_call
817  | glsl_postfix_expression '.' FIELDSELECTION
818  | glsl_postfix_expression T_INC
819  | glsl_postfix_expression T_DEC
820    ;
821
822glsl_integer_expression:
823    glsl_expression
824    ;
825
826glsl_function_call:
827    glsl_function_call_or_method
828    ;
829
830glsl_function_call_or_method:
831    glsl_function_call_generic
832  | glsl_postfix_expression '.' glsl_function_call_generic
833    ;
834
835glsl_function_call_generic:
836    glsl_function_call_header_with_parameters ')'
837  | glsl_function_call_header_no_parameters ')'
838    ;
839
840glsl_function_call_header_no_parameters:
841    glsl_function_call_header GHT_VOID
842  | glsl_function_call_header
843    ;
844
845glsl_function_call_header_with_parameters:
846    glsl_function_call_header glsl_assignment_expression
847  | glsl_function_call_header_with_parameters ',' glsl_assignment_expression
848    ;
849
850glsl_function_call_header:
851    glsl_function_identifier '('
852    ;
853
854glsl_function_identifier:
855    glsl_type_specifier
856  | IDENTIFIER
857  | FIELDSELECTION
858    ;
859
860glsl_unary_expression:
861    glsl_postfix_expression
862  | T_INC glsl_unary_expression
863  | T_DEC glsl_unary_expression
864  | glsl_unary_operator glsl_unary_expression
865    ;
866
867glsl_unary_operator:
868    '+'
869  | '-'
870  | '!'
871  | '~'
872    ;
873
874glsl_multiplicative_expression:
875    glsl_unary_expression
876  | glsl_multiplicative_expression '*' glsl_unary_expression
877  | glsl_multiplicative_expression '/' glsl_unary_expression
878  | glsl_multiplicative_expression '%' glsl_unary_expression
879    ;
880
881glsl_additive_expression:
882    glsl_multiplicative_expression
883  | glsl_additive_expression '+' glsl_multiplicative_expression
884  | glsl_additive_expression '-' glsl_multiplicative_expression
885    ;
886
887glsl_shift_expression:
888    glsl_additive_expression
889  | glsl_shift_expression T_LEFT glsl_additive_expression
890  | glsl_shift_expression T_RIGHT glsl_additive_expression
891    ;
892
893glsl_relational_expression:
894    glsl_shift_expression
895  | glsl_relational_expression '<' glsl_shift_expression
896  | glsl_relational_expression '>' glsl_shift_expression
897  | glsl_relational_expression T_LE glsl_shift_expression
898  | glsl_relational_expression T_GE glsl_shift_expression
899    ;
900
901glsl_equality_expression:
902    glsl_relational_expression
903  | glsl_equality_expression T_EQ glsl_relational_expression
904  | glsl_equality_expression T_NE glsl_relational_expression
905    ;
906
907glsl_and_expression:
908    glsl_equality_expression
909  | glsl_and_expression '&' glsl_equality_expression
910    ;
911
912glsl_exclusive_or_expression:
913    glsl_and_expression
914  | glsl_exclusive_or_expression '^' glsl_and_expression
915    ;
916
917glsl_inclusive_or_expression:
918    glsl_exclusive_or_expression
919  | glsl_inclusive_or_expression '|' glsl_exclusive_or_expression
920    ;
921
922glsl_logical_and_expression:
923    glsl_inclusive_or_expression
924  | glsl_logical_and_expression T_AND glsl_inclusive_or_expression
925    ;
926
927glsl_logical_xor_expression:
928    glsl_logical_and_expression
929  | glsl_logical_xor_expression T_XOR glsl_logical_and_expression
930    ;
931
932glsl_logical_or_expression:
933    glsl_logical_xor_expression
934  | glsl_logical_or_expression T_OR glsl_logical_xor_expression
935    ;
936
937glsl_conditional_expression:
938    glsl_logical_or_expression
939  | glsl_logical_or_expression '?' glsl_expression ':' glsl_assignment_expression
940    ;
941
942glsl_assignment_expression:
943    glsl_conditional_expression
944  | glsl_unary_expression glsl_assignment_operator glsl_assignment_expression
945    ;
946
947glsl_assignment_operator:
948    '='
949  | T_MULEQ
950  | T_DIVEQ
951  | T_MODEQ
952  | T_ADDEQ
953  | T_SUBEQ
954  | T_LEFTEQ
955  | T_RIGHTEQ
956  | T_ANDEQ
957  | T_XOREQ
958  | T_OREQ
959    ;
960
961glsl_expression:
962    glsl_assignment_expression
963  | glsl_expression ',' glsl_assignment_expression
964    ;
965
966glsl_constant_expression:
967    glsl_conditional_expression
968    ;
969
970glsl_declaration:
971    glsl_function_prototype ';'
972  | glsl_init_declarator_list ';'
973  | GT_PRECISION glsl_precision_qualifier glsl_type_specifier_no_prec ';'
974  | glsl_type_qualifier IDENTIFIER '{' glsl_struct_declaration_list '}' ';'
975  | glsl_type_qualifier IDENTIFIER '{' glsl_struct_declaration_list '}' IDENTIFIER ';'
976  | glsl_type_qualifier IDENTIFIER '{' glsl_struct_declaration_list '}' IDENTIFIER '[' ']' ';'
977  | glsl_type_qualifier IDENTIFIER '{' glsl_struct_declaration_list '}' IDENTIFIER '[' glsl_constant_expression ']' ';'
978  | glsl_type_qualifier ';'
979    ;
980
981glsl_function_prototype:
982    glsl_function_declarator ')'
983    ;
984
985glsl_function_declarator:
986    glsl_function_header
987  | glsl_function_header_with_parameters
988    ;
989
990glsl_function_header_with_parameters:
991    glsl_function_header glsl_parameter_declaration
992  | glsl_function_header_with_parameters ',' glsl_parameter_declaration
993    ;
994
995glsl_function_header:
996    glsl_fully_specified_type IDENTIFIER '('
997    ;
998
999glsl_parameter_declarator:
1000    glsl_type_specifier IDENTIFIER
1001  | glsl_type_specifier IDENTIFIER '[' glsl_constant_expression ']'
1002    ;
1003
1004glsl_parameter_declaration:
1005    glsl_parameter_type_qualifier glsl_parameter_qualifier glsl_parameter_declarator
1006  | glsl_parameter_qualifier glsl_parameter_declarator
1007  | glsl_parameter_type_qualifier glsl_parameter_qualifier glsl_parameter_type_specifier
1008  | glsl_parameter_qualifier glsl_parameter_type_specifier
1009    ;
1010
1011glsl_parameter_qualifier:
1012    /* empty */
1013  | GHT_IN
1014  | GHT_OUT
1015  | GHT_INOUT
1016  | GT_ATTRIBUTE /* deprecated */
1017    ;
1018
1019glsl_parameter_type_specifier:
1020    glsl_type_specifier
1021    ;
1022
1023glsl_init_declarator_list:
1024    glsl_single_declaration
1025  | glsl_init_declarator_list ',' IDENTIFIER
1026  | glsl_init_declarator_list ',' IDENTIFIER '[' ']'
1027  | glsl_init_declarator_list ',' IDENTIFIER '[' glsl_constant_expression ']'
1028  | glsl_init_declarator_list ',' IDENTIFIER '[' ']' '=' glsl_initializer
1029  | glsl_init_declarator_list ',' IDENTIFIER '[' glsl_constant_expression ']' '=' glsl_initializer
1030  | glsl_init_declarator_list ',' IDENTIFIER '=' glsl_initializer
1031    ;
1032
1033glsl_single_declaration:
1034    glsl_fully_specified_type
1035  | glsl_fully_specified_type IDENTIFIER
1036  | glsl_fully_specified_type IDENTIFIER '[' ']'
1037  | glsl_fully_specified_type IDENTIFIER '[' glsl_constant_expression ']'
1038  | glsl_fully_specified_type IDENTIFIER '[' ']' '=' glsl_initializer
1039  | glsl_fully_specified_type IDENTIFIER '[' glsl_constant_expression ']' '=' glsl_initializer
1040  | glsl_fully_specified_type IDENTIFIER '=' glsl_initializer
1041  | GT_INVARIANT IDENTIFIER
1042    ;
1043
1044glsl_fully_specified_type:
1045    glsl_type_specifier
1046  | glsl_type_qualifier glsl_type_specifier
1047    ;
1048
1049glsl_invariant_qualifier:
1050    GT_INVARIANT
1051    ;
1052
1053glsl_interpolation_qualifier:
1054    GT_SMOOTH
1055  | GT_FLAT
1056  | GHT_NOPERSPECTIVE
1057    ;
1058
1059glsl_layout_qualifier:
1060    GT_LAYOUT '(' glsl_layout_qualifier_id_list ')'
1061    ;
1062
1063glsl_layout_qualifier_id_list:
1064    glsl_layout_qualifier_id
1065  | glsl_layout_qualifier_id_list ',' glsl_layout_qualifier_id
1066    ;
1067
1068glsl_layout_qualifier_id:
1069    IDENTIFIER
1070  | IDENTIFIER '=' INTCONSTANT
1071    ;
1072
1073glsl_parameter_type_qualifier:
1074    GHT_CONST
1075    ;
1076
1077glsl_type_qualifier:
1078    glsl_storage_qualifier
1079  | glsl_layout_qualifier
1080  | glsl_layout_qualifier glsl_storage_qualifier
1081  | glsl_interpolation_qualifier glsl_storage_qualifier
1082  | glsl_interpolation_qualifier
1083  | glsl_invariant_qualifier glsl_storage_qualifier
1084  | glsl_invariant_qualifier glsl_interpolation_qualifier glsl_storage_qualifier
1085  | glsl_invariant_qualifier
1086    ;
1087
1088glsl_storage_qualifier:
1089    GHT_CONST
1090  | GHT_IN
1091  | GHT_OUT
1092  | GHT_CENTROID GHT_IN
1093  | GHT_CENTROID GHT_OUT
1094  | GT_PATCH GHT_IN
1095  | GT_PATCH GHT_OUT
1096  | GT_SAMPLE GHT_IN
1097  | GT_SAMPLE GHT_OUT
1098  | GHT_UNIFORM
1099  | GT_ATTRIBUTE /* deprecated */
1100    ;
1101
1102glsl_type_specifier:
1103    glsl_type_specifier_no_prec
1104  | glsl_precision_qualifier glsl_type_specifier_no_prec
1105    ;
1106
1107glsl_type_specifier_no_prec:
1108    glsl_type_specifier_nonarray
1109  | glsl_type_specifier_nonarray '[' ']'
1110  | glsl_type_specifier_nonarray '[' glsl_constant_expression ']'
1111
1112glsl_type_specifier_nonarray:
1113    GHT_VOID
1114  | GHT_FLOAT
1115  | GHT_DOUBLE
1116  | GHT_INT
1117  | GHT_UINT
1118  | GHT_BOOL
1119  | GT_VEC2
1120  | GT_VEC3
1121  | GT_VEC4
1122  | GT_DVEC2
1123  | GT_DVEC3
1124  | GT_DVEC4
1125  | GT_BVEC2
1126  | GT_BVEC3
1127  | GT_BVEC4
1128  | GT_IVEC2
1129  | GT_IVEC3
1130  | GT_IVEC4
1131  | GT_UVEC2
1132  | GT_UVEC3
1133  | GT_UVEC4
1134  | GT_MAT2
1135  | GT_MAT3
1136  | GT_MAT4
1137  | GT_MAT2X2
1138  | GT_MAT2X3
1139  | GT_MAT2X4
1140  | GT_MAT3X2
1141  | GT_MAT3X3
1142  | GT_MAT3X4
1143  | GT_MAT4X2
1144  | GT_MAT4X3
1145  | GT_MAT4X4
1146  | GT_DMAT2
1147  | GT_DMAT3
1148  | GT_DMAT4
1149  | GT_DMAT2X2
1150  | GT_DMAT2X3
1151  | GT_DMAT2X4
1152  | GT_DMAT3X2
1153  | GT_DMAT3X3
1154  | GT_DMAT3X4
1155  | GT_DMAT4X2
1156  | GT_DMAT4X3
1157  | GT_DMAT4X4
1158  | GHT_SAMPLER1D
1159  | GHT_SAMPLER2D
1160  | GHT_SAMPLER3D
1161  | GHT_SAMPLERCUBE
1162  | GT_SAMPLER1DSHADOW
1163  | GT_SAMPLER2DSHADOW
1164  | GT_SAMPLERCUBESHADOW
1165  | GT_SAMPLER1DARRAY
1166  | GT_SAMPLER2DARRAY
1167  | GT_SAMPLER1DARRAYSHADOW
1168  | GT_SAMPLER2DARRAYSHADOW
1169  | GT_SAMPLERCUBEARRAY
1170  | GT_SAMPLERCUBEARRAYSHADOW
1171  | GT_ISAMPLER1D
1172  | GT_ISAMPLER2D
1173  | GT_ISAMPLER3D
1174  | GT_ISAMPLERCUBE
1175  | GT_ISAMPLER1DARRAY
1176  | GT_ISAMPLER2DARRAY
1177  | GT_ISAMPLERCUBEARRAY
1178  | GT_USAMPLER1D
1179  | GT_USAMPLER2D
1180  | GT_USAMPLER3D
1181  | GT_USAMPLERCUBE
1182  | GT_USAMPLER1DARRAY
1183  | GT_USAMPLER2DARRAY
1184  | GT_USAMPLERCUBEARRAY
1185  | GT_SAMPLER2DRECT
1186  | GT_SAMPLER2DRECTSHADOW
1187  | GT_ISAMPLER2DRECT
1188  | GT_USAMPLER2DRECT
1189  | GT_SAMPLERBUFFER
1190  | GT_ISAMPLERBUFFER
1191  | GT_USAMPLERBUFFER
1192  | GT_SAMPLER2DMS
1193  | GT_ISAMPLER2DMS
1194  | GT_USAMPLER2DMS
1195  | GT_SAMPLER2DMSARRAY
1196  | GT_ISAMPLER2DMSARRAY
1197  | GT_USAMPLER2DMSARRAY
1198  | glsl_struct_specifier
1199  | TYPENAME
1200    ;
1201
1202glsl_precision_qualifier:
1203    GT_HIGHP
1204  | GT_MEDIUMP
1205  | GT_LOWP
1206    ;
1207
1208glsl_struct_specifier:
1209    GHT_STRUCT IDENTIFIER '{' glsl_struct_declaration_list '}'
1210  | GHT_STRUCT '{' glsl_struct_declaration_list '}'
1211    ;
1212
1213glsl_struct_declaration_list:
1214    glsl_struct_declaration
1215  | glsl_struct_declaration_list glsl_struct_declaration
1216    ;
1217
1218glsl_struct_declaration:
1219    glsl_type_specifier glsl_struct_declarator_list ';'
1220  | glsl_type_qualifier glsl_type_specifier glsl_struct_declarator_list ';'
1221    ;
1222
1223glsl_struct_declarator_list:
1224    glsl_struct_declarator
1225  | glsl_struct_declarator_list ',' glsl_struct_declarator
1226    ;
1227
1228glsl_struct_declarator:
1229    IDENTIFIER
1230  | IDENTIFIER '[' ']'
1231  | IDENTIFIER '[' glsl_constant_expression ']'
1232    ;
1233
1234glsl_initializer:
1235    glsl_assignment_expression
1236    ;
1237
1238glsl_declaration_statement:
1239    glsl_declaration
1240    ;
1241
1242glsl_statement:
1243    glsl_compound_statement
1244  | glsl_simple_statement
1245    ;
1246
1247glsl_simple_statement:
1248    glsl_declaration_statement
1249  | glsl_expression_statement
1250  | glsl_selection_statement
1251  | glsl_switch_statement
1252  | glsl_case_label
1253  | glsl_iteration_statement
1254  | glsl_jump_statement
1255    ;
1256
1257glsl_compound_statement:
1258    '{' '}'
1259  | '{' glsl_statement_list '}'
1260    ;
1261
1262glsl_statement_no_new_scope:
1263    glsl_compound_statement_no_new_scope
1264  | glsl_simple_statement
1265    ;
1266
1267glsl_compound_statement_no_new_scope:
1268    '{' '}'
1269  | '{' glsl_statement_list '}'
1270    ;
1271
1272glsl_statement_list:
1273    glsl_statement
1274  | glsl_statement_list glsl_statement
1275    ;
1276
1277glsl_expression_statement:
1278    ';'
1279  | glsl_expression ';'
1280    ;
1281
1282glsl_selection_statement:
1283    GHT_IF '(' glsl_expression ')' glsl_selection_rest_statement
1284    ;
1285
1286glsl_selection_rest_statement:
1287    glsl_statement GHT_ELSE glsl_statement
1288  | glsl_statement
1289    ;
1290
1291glsl_condition:
1292    glsl_expression
1293  | glsl_fully_specified_type IDENTIFIER '=' glsl_initializer
1294    ;
1295
1296glsl_switch_statement:
1297    GHT_SWITCH '(' glsl_expression ')' '{' glsl_switch_statement_list '}'
1298    ;
1299
1300glsl_switch_statement_list:
1301    /* nothing */
1302  | glsl_statement_list
1303    ;
1304
1305glsl_case_label:
1306    GHT_CASE glsl_expression ':'
1307  | GHT_DEFAULT ':'
1308    ;
1309
1310glsl_iteration_statement:
1311    GHT_WHILE '(' glsl_condition ')' glsl_statement_no_new_scope
1312  | GHT_DO glsl_statement GHT_WHILE '(' glsl_expression ')' ';'
1313  | GHT_FOR '(' glsl_for_init_statement glsl_for_rest_statement ')' glsl_statement_no_new_scope
1314    ;
1315
1316glsl_for_init_statement:
1317    glsl_expression_statement
1318  | glsl_declaration_statement
1319    ;
1320
1321glsl_conditionopt:
1322    glsl_condition
1323  | /* empty */
1324    ;
1325
1326glsl_for_rest_statement:
1327    glsl_conditionopt ';'
1328  | glsl_conditionopt ';' glsl_expression
1329    ;
1330
1331glsl_jump_statement:
1332    GHT_CONTINUE ';'
1333  | GHT_BREAK ';'
1334  | GHT_RETURN ';'
1335  | GHT_RETURN glsl_expression ';'
1336  | GHT_DISCARD ';'
1337    ;
1338
1339glsl_translation_unit:
1340    glsl_external_declaration
1341  | glsl_translation_unit glsl_external_declaration
1342    ;
1343
1344glsl_external_declaration:
1345    glsl_function_definition
1346  | glsl_declaration
1347    ;
1348
1349glsl_function_definition:
1350    glsl_function_prototype glsl_compound_statement_no_new_scope
1351    ;
1352
1353%%
1354
1355void lol::LolFxParser::error(const LolFxParser::location_type& l,
1356                             const std::string& m)
1357{
1358    mc.Error(l, m);
1359}
1360
Note: See TracBrowser for help on using the repository browser.