選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1312 行
28 KiB

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