You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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