source: trunk/test/sandbox/lex/lolfx.y @ 1427

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

test: a better GLSL parser in the LolFx test parser.

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