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.
 
 
 

551 rivejä
24 KiB

  1. %{
  2. #include <iostream>
  3. #define YY_DECL extern "C" int yylex()
  4. #include "lolfx.tab.h"
  5. %}
  6. %x C_COMMENT
  7. %x CPP_COMMENT
  8. %%
  9. /*
  10. * GLSL keywords
  11. */
  12. "subroutine" { return GT_SUBROUTINE; }
  13. "patch" { return GT_PATCH; }
  14. "sample" { return GT_SAMPLE; }
  15. "flat" { return GT_FLAT; }
  16. "smooth" { return GT_SMOOTH; }
  17. "layout" { return GT_LAYOUT; }
  18. "sampler1dshadow" { return GT_SAMPLER1DSHADOW; }
  19. "sampler2dshadow" { return GT_SAMPLER2DSHADOW; }
  20. "samplercubeshadow" { return GT_SAMPLERCUBESHADOW; }
  21. "sampler1darray" { return GT_SAMPLER1DARRAY; }
  22. "sampler2darray" { return GT_SAMPLER2DARRAY; }
  23. "sampler1darrayshadow" { return GT_SAMPLER1DARRAYSHADOW; }
  24. "sampler2darrayshadow" { return GT_SAMPLER2DARRAYSHADOW; }
  25. "isampler1d" { return GT_ISAMPLER1D; }
  26. "isampler2d" { return GT_ISAMPLER2D; }
  27. "isampler3d" { return GT_ISAMPLER3D; }
  28. "isamplercube" { return GT_ISAMPLERCUBE; }
  29. "isampler1darray" { return GT_ISAMPLER1DARRAY; }
  30. "isampler2darray" { return GT_ISAMPLER2DARRAY; }
  31. "usampler1d" { return GT_USAMPLER1D; }
  32. "usampler2d" { return GT_USAMPLER2D; }
  33. "usampler3d" { return GT_USAMPLER3D; }
  34. "usamplercube" { return GT_USAMPLERCUBE; }
  35. "usampler1darray" { return GT_USAMPLER1DARRAY; }
  36. "usampler2darray" { return GT_USAMPLER2DARRAY; }
  37. "sampler2drect" { return GT_SAMPLER2DRECT; }
  38. "sampler2drectshadow" { return GT_SAMPLER2DRECTSHADOW; }
  39. "isampler2drect" { return GT_ISAMPLER2DRECT; }
  40. "usampler2drect" { return GT_USAMPLER2DRECT; }
  41. "samplerbuffer" { return GT_SAMPLERBUFFER; }
  42. "isamplerbuffer" { return GT_ISAMPLERBUFFER; }
  43. "usamplerbuffer" { return GT_USAMPLERBUFFER; }
  44. "samplercubearray" { return GT_SAMPLERCUBEARRAY; }
  45. "samplercubearrayshadow" { return GT_SAMPLERCUBEARRAYSHADOW; }
  46. "isamplercubearray" { return GT_ISAMPLERCUBEARRAY; }
  47. "usamplercubearray" { return GT_USAMPLERCUBEARRAY; }
  48. "sampler2dms" { return GT_SAMPLER2DMS; }
  49. "isampler2dms" { return GT_ISAMPLER2DMS; }
  50. "usampler2dms" { return GT_USAMPLER2DMS; }
  51. "sampler2dmsarray" { return GT_SAMPLER2DMSARRAY; }
  52. "isampler2dmsarray" { return GT_ISAMPLER2DMSARRAY; }
  53. "usampler2dmsarray" { return GT_USAMPLER2DMSARRAY; }
  54. "highp" { return GT_HIGHP; }
  55. "mediump" { return GT_MEDIUMP; }
  56. "lowp" { return GT_LOWP; }
  57. "precision" { return GT_PRECISION; }
  58. "invariant" { return GT_INVARIANT; }
  59. /*
  60. * Deprecated GLSL keywords
  61. */
  62. "attribute" { return GT_ATTRIBUTE; }
  63. /*
  64. * GLSL vector types
  65. */
  66. "bvec2" { return GT_BVEC2; }
  67. "bvec3" { return GT_BVEC3; }
  68. "bvec4" { return GT_BVEC4; }
  69. "ivec2" { return GT_IVEC2; }
  70. "ivec3" { return GT_IVEC3; }
  71. "ivec4" { return GT_IVEC4; }
  72. "uvec2" { return GT_UVEC2; }
  73. "uvec3" { return GT_UVEC3; }
  74. "uvec4" { return GT_UVEC4; }
  75. "vec2" { return GT_VEC2; }
  76. "vec3" { return GT_VEC3; }
  77. "vec4" { return GT_VEC4; }
  78. "mat2" { return GT_MAT2; }
  79. "mat2x2" { return GT_MAT2X2; }
  80. "mat2x3" { return GT_MAT2X3; }
  81. "mat2x4" { return GT_MAT2X4; }
  82. "mat3" { return GT_MAT3; }
  83. "mat3x2" { return GT_MAT3X2; }
  84. "mat3x3" { return GT_MAT3X3; }
  85. "mat3x4" { return GT_MAT3X4; }
  86. "mat4" { return GT_MAT4; }
  87. "mat4x2" { return GT_MAT4X2; }
  88. "mat4x3" { return GT_MAT4X3; }
  89. "mat4x4" { return GT_MAT4X4; }
  90. "dvec2" { return GT_DVEC2; }
  91. "dvec3" { return GT_DVEC3; }
  92. "dvec4" { return GT_DVEC4; }
  93. "dmat2" { return GT_DMAT2; }
  94. "dmat2x2" { return GT_DMAT2X2; }
  95. "dmat2x3" { return GT_DMAT2X3; }
  96. "dmat2x4" { return GT_DMAT2X4; }
  97. "dmat3" { return GT_DMAT3; }
  98. "dmat3x2" { return GT_DMAT3X2; }
  99. "dmat3x3" { return GT_DMAT3X3; }
  100. "dmat3x4" { return GT_DMAT3X4; }
  101. "dmat4" { return GT_DMAT4; }
  102. "dmat4x2" { return GT_DMAT4X2; }
  103. "dmat4x3" { return GT_DMAT4X3; }
  104. "dmat4x4" { return GT_DMAT4X4; }
  105. /*
  106. * GLSL constant values
  107. */
  108. "true" { yylval.ival = 1; return BOOLCONSTANT; }
  109. "false" { yylval.ival = 0; return BOOLCONSTANT; }
  110. [xyzw]{1,4} { return FIELDSELECTION; }
  111. [rgba]{1,4} { return FIELDSELECTION; }
  112. [stpq]{1,4} { return FIELDSELECTION; }
  113. /*
  114. * GLSL keywords that are also valid or reserved in HLSL
  115. * and HLSL keywords that are also valid or reserved in GLSL.
  116. */
  117. "bool" { return GHT_BOOL; }
  118. "break" { return GHT_BREAK; }
  119. "case" { return GHT_CASE; }
  120. "centroid" { return GHT_CENTROID; }
  121. "const" { return GHT_CONST; }
  122. "continue" { return GHT_CONTINUE; }
  123. "default" { return GHT_DEFAULT; }
  124. "discard" { return GHT_DISCARD; }
  125. "do" { return GHT_DO; }
  126. "double" { return GHT_DOUBLE; }
  127. "else" { return GHT_ELSE; }
  128. "float" { return GHT_FLOAT; }
  129. "for" { return GHT_FOR; }
  130. "if" { return GHT_IF; }
  131. "in" { return GHT_IN; }
  132. "inout" { return GHT_INOUT; }
  133. "int" { return GHT_INT; }
  134. "noperspective" { return GHT_NOPERSPECTIVE; }
  135. "out" { return GHT_OUT; }
  136. "return" { return GHT_RETURN; }
  137. "sampler1d" { return GHT_SAMPLER1D; }
  138. "sampler2d" { return GHT_SAMPLER2D; }
  139. "sampler3d" { return GHT_SAMPLER3D; }
  140. "samplercube" { return GHT_SAMPLERCUBE; }
  141. "struct" { return GHT_STRUCT; }
  142. "switch" { return GHT_SWITCH; }
  143. "uint" { return GHT_UINT; }
  144. "uniform" { return GHT_UNIFORM; }
  145. "void" { return GHT_VOID; }
  146. "while" { return GHT_WHILE; }
  147. (?i:bool) { return HGT_BOOL; }
  148. (?i:break) { return HGT_BREAK; }
  149. (?i:case) { return HGT_CASE; }
  150. (?i:centroid) { return HGT_CENTROID; }
  151. (?i:const) { return HGT_CONST; }
  152. (?i:continue) { return HGT_CONTINUE; }
  153. (?i:default) { return HGT_DEFAULT; }
  154. (?i:discard) { return HGT_DISCARD; }
  155. (?i:do) { return HGT_DO; }
  156. (?i:double) { return HGT_DOUBLE; }
  157. (?i:else) { return HGT_ELSE; }
  158. (?i:float) { return HGT_FLOAT; }
  159. (?i:for) { return HGT_FOR; }
  160. (?i:if) { return HGT_IF; }
  161. (?i:in) { return HGT_IN; }
  162. (?i:inout) { return HGT_INOUT; }
  163. (?i:int) { return HGT_INT; }
  164. (?i:noperspective) { return HGT_NOPERSPECTIVE; }
  165. (?i:out) { return HGT_OUT; }
  166. (?i:return) { return HGT_RETURN; }
  167. (?i:sampler1d) { return HGT_SAMPLER1D; }
  168. (?i:sampler2d) { return HGT_SAMPLER2D; }
  169. (?i:sampler3d) { return HGT_SAMPLER3D; }
  170. (?i:samplercube) { return HGT_SAMPLERCUBE; }
  171. (?i:struct) { return HGT_STRUCT; }
  172. (?i:switch) { return HGT_SWITCH; }
  173. (?i:uint) { return HGT_UINT; }
  174. (?i:uniform) { return HGT_UNIFORM; }
  175. (?i:void) { return HGT_VOID; }
  176. (?i:while) { return HGT_WHILE; }
  177. /*
  178. * HLSL keywords
  179. * Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509568%28v=vs.85%29.aspx
  180. */
  181. (?i:appendstructuredbuffer) { return HT_APPENDSTRUCTUREDBUFFER; }
  182. (?i:asm) { return HT_ASM; }
  183. (?i:asm_fragment) { return HT_ASM_FRAGMENT; }
  184. (?i:blendstate) { return HT_BLENDSTATE; }
  185. (?i:buffer) { return HT_BUFFER; }
  186. (?i:byteaddressbuffer) { return HT_BYTEADDRESSBUFFER; }
  187. (?i:cbuffer) { return HT_CBUFFER; }
  188. (?i:column_major) { return HT_COLUMN_MAJOR; }
  189. (?i:compile) { return HT_COMPILE; }
  190. (?i:compile_fragment) { return HT_COMPILE_FRAGMENT; }
  191. (?i:compileshader) { return HT_COMPILESHADER; }
  192. (?i:computeshader) { return HT_COMPUTESHADER; }
  193. (?i:consumestructuredbuffer) { return HT_CONSUMESTRUCTUREDBUFFER; }
  194. (?i:depthstencilstate) { return HT_DEPTHSTENCILSTATE; }
  195. (?i:depthstencilview) { return HT_DEPTHSTENCILVIEW; }
  196. (?i:domainshader) { return HT_DOMAINSHADER; }
  197. (?i:dword) { return HT_DWORD; }
  198. (?i:extern) { return HT_EXTERN; }
  199. (?i:false) { return HT_FALSE; }
  200. (?i:fxgroup) { return HT_FXGROUP; }
  201. (?i:geometryshader) { return HT_GEOMETRYSHADER; }
  202. (?i:groupshared) { return HT_GROUPSHARED; }
  203. (?i:half) { return HT_HALF; }
  204. (?i:hullshader) { return HT_HULLSHADER; }
  205. (?i:inline) { return HT_INLINE; }
  206. (?i:inputpatch) { return HT_INPUTPATCH; }
  207. (?i:interface) { return HT_INTERFACE; }
  208. (?i:line) { return HT_LINE; }
  209. (?i:lineadj) { return HT_LINEADJ; }
  210. (?i:linear) { return HT_LINEAR; }
  211. (?i:linestream) { return HT_LINESTREAM; }
  212. (?i:matrix) { return HT_MATRIX; }
  213. (?i:namespace) { return HT_NAMESPACE; }
  214. (?i:nointerpolation) { return HT_NOINTERPOLATION; }
  215. (?i:null) { return HT_NULL; }
  216. (?i:outputpatch) { return HT_OUTPUTPATCH; }
  217. (?i:packoffset) { return HT_PACKOFFSET; }
  218. (?i:pass) { return HT_PASS; }
  219. (?i:pixelfragment) { return HT_PIXELFRAGMENT; }
  220. (?i:pixelshader) { return HT_PIXELSHADER; }
  221. (?i:point) { return HT_POINT; }
  222. (?i:pointstream) { return HT_POINTSTREAM; }
  223. (?i:precise) { return HT_PRECISE; }
  224. (?i:rasterizerstate) { return HT_RASTERIZERSTATE; }
  225. (?i:rendertargetview) { return HT_RENDERTARGETVIEW; }
  226. (?i:register) { return HT_REGISTER; }
  227. (?i:row_major) { return HT_ROW_MAJOR; }
  228. (?i:rwbuffer) { return HT_RWBUFFER; }
  229. (?i:rwbyteaddressbuffer) { return HT_RWBYTEADDRESSBUFFER; }
  230. (?i:rwstructuredbuffer) { return HT_RWSTRUCTUREDBUFFER; }
  231. (?i:rwtexture1d) { return HT_RWTEXTURE1D; }
  232. (?i:rwtexture1darray) { return HT_RWTEXTURE1DARRAY; }
  233. (?i:rwtexture2d) { return HT_RWTEXTURE2D; }
  234. (?i:rwtexture2darray) { return HT_RWTEXTURE2DARRAY; }
  235. (?i:rwtexture3d) { return HT_RWTEXTURE3D; }
  236. (?i:sampler) { return HT_SAMPLER; }
  237. (?i:sampler_state) { return HT_SAMPLER_STATE; }
  238. (?i:samplerstate) { return HT_SAMPLERSTATE; }
  239. (?i:samplercomparisonstate) { return HT_SAMPLERCOMPARISONSTATE; }
  240. (?i:shared) { return HT_SHARED; }
  241. (?i:snorm) { return HT_SNORM; }
  242. (?i:stateblock) { return HT_STATEBLOCK; }
  243. (?i:stateblock_state) { return HT_STATEBLOCK_STATE; }
  244. (?i:static) { return HT_STATIC; }
  245. (?i:string) { return HT_STRING; }
  246. (?i:structuredbuffer) { return HT_STRUCTUREDBUFFER; }
  247. (?i:tbuffer) { return HT_TBUFFER; }
  248. (?i:technique) { return HT_TECHNIQUE; }
  249. (?i:technique10) { return HT_TECHNIQUE10; }
  250. (?i:technique11xz) { return HT_TECHNIQUE11XZ; }
  251. "texture" { return HT_TEXTURE; }
  252. (?i:texture1d) { return HT_TEXTURE1D; }
  253. (?i:texture1darray) { return HT_TEXTURE1DARRAY; }
  254. (?i:texture2d) { return HT_TEXTURE2D; }
  255. (?i:texture2darray) { return HT_TEXTURE2DARRAY; }
  256. (?i:texture2dms) { return HT_TEXTURE2DMS; }
  257. (?i:texture2dmsarray) { return HT_TEXTURE2DMSARRAY; }
  258. (?i:texture3d) { return HT_TEXTURE3D; }
  259. (?i:texturecube) { return HT_TEXTURECUBE; }
  260. (?i:texturecubearray) { return HT_TEXTURECUBEARRAY; }
  261. (?i:true) { return HT_TRUE; }
  262. (?i:typedef) { return HT_TYPEDEF; }
  263. (?i:triangle) { return HT_TRIANGLE; }
  264. (?i:triangleadj) { return HT_TRIANGLEADJ; }
  265. (?i:trianglestream) { return HT_TRIANGLESTREAM; }
  266. (?i:unorm) { return HT_UNORM; }
  267. (?i:vector) { return HT_VECTOR; }
  268. (?i:vertexfragment) { return HT_VERTEXFRAGMENT; }
  269. (?i:vertexshader) { return HT_VERTEXSHADER; }
  270. (?i:volatile) { return HT_VOLATILE; }
  271. /*
  272. * HLSL vector types
  273. * TODO: this can probably be factored somehow
  274. */
  275. (?i:bool1) { return HT_BOOL1; }
  276. (?i:bool1x1) { return HT_BOOL1x1; }
  277. (?i:bool2x1) { return HT_BOOL2x1; }
  278. (?i:bool3x1) { return HT_BOOL3x1; }
  279. (?i:bool4x1) { return HT_BOOL4x1; }
  280. (?i:bool2) { return HT_BOOL2; }
  281. (?i:bool1x2) { return HT_BOOL1x2; }
  282. (?i:bool2x2) { return HT_BOOL2x2; }
  283. (?i:bool3x2) { return HT_BOOL3x2; }
  284. (?i:bool4x2) { return HT_BOOL4x2; }
  285. (?i:bool3) { return HT_BOOL3; }
  286. (?i:bool1x3) { return HT_BOOL1x3; }
  287. (?i:bool2x3) { return HT_BOOL2x3; }
  288. (?i:bool3x3) { return HT_BOOL3x3; }
  289. (?i:bool4x3) { return HT_BOOL4x3; }
  290. (?i:bool4) { return HT_BOOL4; }
  291. (?i:bool1x4) { return HT_BOOL1x4; }
  292. (?i:bool2x4) { return HT_BOOL2x4; }
  293. (?i:bool3x4) { return HT_BOOL3x4; }
  294. (?i:bool4x4) { return HT_BOOL4x4; }
  295. (?i:float1) { return HT_FLOAT1; }
  296. (?i:float1x1) { return HT_FLOAT1x1; }
  297. (?i:float2x1) { return HT_FLOAT2x1; }
  298. (?i:float3x1) { return HT_FLOAT3x1; }
  299. (?i:float4x1) { return HT_FLOAT4x1; }
  300. (?i:float2) { return HT_FLOAT2; }
  301. (?i:float1x2) { return HT_FLOAT1x2; }
  302. (?i:float2x2) { return HT_FLOAT2x2; }
  303. (?i:float3x2) { return HT_FLOAT3x2; }
  304. (?i:float4x2) { return HT_FLOAT4x2; }
  305. (?i:float3) { return HT_FLOAT3; }
  306. (?i:float1x3) { return HT_FLOAT1x3; }
  307. (?i:float2x3) { return HT_FLOAT2x3; }
  308. (?i:float3x3) { return HT_FLOAT3x3; }
  309. (?i:float4x3) { return HT_FLOAT4x3; }
  310. (?i:float4) { return HT_FLOAT4; }
  311. (?i:float1x4) { return HT_FLOAT1x4; }
  312. (?i:float2x4) { return HT_FLOAT2x4; }
  313. (?i:float3x4) { return HT_FLOAT3x4; }
  314. (?i:float4x4) { return HT_FLOAT4x4; }
  315. (?i:double1) { return HT_DOUBLE1; }
  316. (?i:double1x1) { return HT_DOUBLE1x1; }
  317. (?i:double2x1) { return HT_DOUBLE2x1; }
  318. (?i:double3x1) { return HT_DOUBLE3x1; }
  319. (?i:double4x1) { return HT_DOUBLE4x1; }
  320. (?i:double2) { return HT_DOUBLE2; }
  321. (?i:double1x2) { return HT_DOUBLE1x2; }
  322. (?i:double2x2) { return HT_DOUBLE2x2; }
  323. (?i:double3x2) { return HT_DOUBLE3x2; }
  324. (?i:double4x2) { return HT_DOUBLE4x2; }
  325. (?i:double3) { return HT_DOUBLE3; }
  326. (?i:double1x3) { return HT_DOUBLE1x3; }
  327. (?i:double2x3) { return HT_DOUBLE2x3; }
  328. (?i:double3x3) { return HT_DOUBLE3x3; }
  329. (?i:double4x3) { return HT_DOUBLE4x3; }
  330. (?i:double4) { return HT_DOUBLE4; }
  331. (?i:double1x4) { return HT_DOUBLE1x4; }
  332. (?i:double2x4) { return HT_DOUBLE2x4; }
  333. (?i:double3x4) { return HT_DOUBLE3x4; }
  334. (?i:double4x4) { return HT_DOUBLE4x4; }
  335. (?i:dword1) { return HT_DWORD1; }
  336. (?i:dword1x1) { return HT_DWORD1x1; }
  337. (?i:dword2x1) { return HT_DWORD2x1; }
  338. (?i:dword3x1) { return HT_DWORD3x1; }
  339. (?i:dword4x1) { return HT_DWORD4x1; }
  340. (?i:dword2) { return HT_DWORD2; }
  341. (?i:dword1x2) { return HT_DWORD1x2; }
  342. (?i:dword2x2) { return HT_DWORD2x2; }
  343. (?i:dword3x2) { return HT_DWORD3x2; }
  344. (?i:dword4x2) { return HT_DWORD4x2; }
  345. (?i:dword3) { return HT_DWORD3; }
  346. (?i:dword1x3) { return HT_DWORD1x3; }
  347. (?i:dword2x3) { return HT_DWORD2x3; }
  348. (?i:dword3x3) { return HT_DWORD3x3; }
  349. (?i:dword4x3) { return HT_DWORD4x3; }
  350. (?i:dword4) { return HT_DWORD4; }
  351. (?i:dword1x4) { return HT_DWORD1x4; }
  352. (?i:dword2x4) { return HT_DWORD2x4; }
  353. (?i:dword3x4) { return HT_DWORD3x4; }
  354. (?i:dword4x4) { return HT_DWORD4x4; }
  355. (?i:int1) { return HT_INT1; }
  356. (?i:int1x1) { return HT_INT1x1; }
  357. (?i:int2x1) { return HT_INT2x1; }
  358. (?i:int3x1) { return HT_INT3x1; }
  359. (?i:int4x1) { return HT_INT4x1; }
  360. (?i:int2) { return HT_INT2; }
  361. (?i:int1x2) { return HT_INT1x2; }
  362. (?i:int2x2) { return HT_INT2x2; }
  363. (?i:int3x2) { return HT_INT3x2; }
  364. (?i:int4x2) { return HT_INT4x2; }
  365. (?i:int3) { return HT_INT3; }
  366. (?i:int1x3) { return HT_INT1x3; }
  367. (?i:int2x3) { return HT_INT2x3; }
  368. (?i:int3x3) { return HT_INT3x3; }
  369. (?i:int4x3) { return HT_INT4x3; }
  370. (?i:int4) { return HT_INT4; }
  371. (?i:int1x4) { return HT_INT1x4; }
  372. (?i:int2x4) { return HT_INT2x4; }
  373. (?i:int3x4) { return HT_INT3x4; }
  374. (?i:int4x4) { return HT_INT4x4; }
  375. (?i:uint1) { return HT_UINT1; }
  376. (?i:uint1x1) { return HT_UINT1x1; }
  377. (?i:uint2x1) { return HT_UINT2x1; }
  378. (?i:uint3x1) { return HT_UINT3x1; }
  379. (?i:uint4x1) { return HT_UINT4x1; }
  380. (?i:uint2) { return HT_UINT2; }
  381. (?i:uint1x2) { return HT_UINT1x2; }
  382. (?i:uint2x2) { return HT_UINT2x2; }
  383. (?i:uint3x2) { return HT_UINT3x2; }
  384. (?i:uint4x2) { return HT_UINT4x2; }
  385. (?i:uint3) { return HT_UINT3; }
  386. (?i:uint1x3) { return HT_UINT1x3; }
  387. (?i:uint2x3) { return HT_UINT2x3; }
  388. (?i:uint3x3) { return HT_UINT3x3; }
  389. (?i:uint4x3) { return HT_UINT4x3; }
  390. (?i:uint4) { return HT_UINT4; }
  391. (?i:uint1x4) { return HT_UINT1x4; }
  392. (?i:uint2x4) { return HT_UINT2x4; }
  393. (?i:uint3x4) { return HT_UINT3x4; }
  394. (?i:uint4x4) { return HT_UINT4x4; }
  395. /*
  396. * HLSL preprocessor directives
  397. * Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb943993%28v=vs.85%29.aspx
  398. */
  399. "#"[ \t]*"define" { return PREPROCESSOR_DEFINE; }
  400. "#"[ \t]*"elif" { return PREPROCESSOR_ELIF; }
  401. "#"[ \t]*"else" { return PREPROCESSOR_ELSE; }
  402. "#"[ \t]*"endif" { return PREPROCESSOR_ENDIF; }
  403. "#"[ \t]*"error" { return PREPROCESSOR_ERROR; }
  404. "#"[ \t]*"if" { return PREPROCESSOR_IF; }
  405. "#"[ \t]*"ifdef" { return PREPROCESSOR_IFDEF; }
  406. "#"[ \t]*"ifndef" { return PREPROCESSOR_IFNDEF; }
  407. "#"[ \t]*"include" { return PREPROCESSOR_INCLUDE; }
  408. "#"[ \t]*"line" { return PREPROCESSOR_LINE; }
  409. "#"[ \t]*"pragma" { return PREPROCESSOR_PRAGMA; }
  410. "#"[ \t]*"undef" { return PREPROCESSOR_UNDEF; }
  411. /*
  412. * GLSL preprocessor directives
  413. */
  414. "#"[ \t]*"version".* { /* ignore for now */ }
  415. /*
  416. * LolFx preprocessor directives
  417. */
  418. "#"[ \t]*"region" { return PREPROCESSOR_REGION; }
  419. "#"[ \t]*"pragma"[ \t]*"lolfx".* { /* ignore for now */ }
  420. /*
  421. * HLSL reserved keywords
  422. * Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509569%28v=vs.85%29.aspx
  423. */
  424. (?i:auto) { return HT_AUTO; }
  425. (?i:catch) { return HT_CATCH; }
  426. (?i:char) { return HT_CHAR; }
  427. (?i:class) { return HT_CLASS; }
  428. (?i:const_cast) { return HT_CONST_CAST; }
  429. (?i:delete) { return HT_DELETE; }
  430. (?i:dynamic_cast) { return HT_DYNAMIC_CAST; }
  431. (?i:enum) { return HT_ENUM; }
  432. (?i:explicit) { return HT_EXPLICIT; }
  433. (?i:friend) { return HT_FRIEND; }
  434. (?i:goto) { return HT_GOTO; }
  435. (?i:long) { return HT_LONG; }
  436. (?i:mutable) { return HT_MUTABLE; }
  437. (?i:new) { return HT_NEW; }
  438. (?i:operator) { return HT_OPERATOR; }
  439. (?i:private) { return HT_PRIVATE; }
  440. (?i:protected) { return HT_PROTECTED; }
  441. (?i:public) { return HT_PUBLIC; }
  442. (?i:reinterpret_cast) { return HT_REINTERPRET_CAST; }
  443. (?i:short) { return HT_SHORT; }
  444. (?i:signed) { return HT_SIGNED; }
  445. (?i:sizeof) { return HT_SIZEOF; }
  446. (?i:static_cast) { return HT_STATIC_CAST; }
  447. (?i:template) { return HT_TEMPLATE; }
  448. (?i:this) { return HT_THIS; }
  449. (?i:throw) { return HT_THROW; }
  450. (?i:try) { return HT_TRY; }
  451. (?i:typename) { return HT_TYPENAME; }
  452. (?i:union) { return HT_UNION; }
  453. (?i:unsigned) { return HT_UNSIGNED; }
  454. (?i:using) { return HT_USING; }
  455. (?i:virtual) { return HT_VIRTUAL; }
  456. /*
  457. * Various tokens
  458. */
  459. "++" { return T_INC; }
  460. "--" { return T_DEC; }
  461. "<=" { return T_LE; }
  462. ">=" { return T_GE; }
  463. "==" { return T_EQ; }
  464. "!=" { return T_NE; }
  465. "<<" { return T_LEFT; }
  466. ">>" { return T_RIGHT; }
  467. "&&" { return T_AND; }
  468. "||" { return T_OR; }
  469. "^^" { return T_XOR; }
  470. "*=" { return T_MULEQ; }
  471. "/=" { return T_DIVEQ; }
  472. "%=" { return T_MODEQ; }
  473. "+=" { return T_ADDEQ; }
  474. "-=" { return T_SUBEQ; }
  475. "<<=" { return T_LEFTEQ; }
  476. ">>=" { return T_RIGHTEQ; }
  477. "&=" { return T_ANDEQ; }
  478. "^=" { return T_XOREQ; }
  479. "|=" { return T_OREQ; }
  480. (0|[1-9][0-9]*)\.[0-9]+ { yylval.fval = atof(yytext); return FLOATCONSTANT; }
  481. (0|[1-9][0-9]*)[uU] { yylval.uval = atoi(yytext); return UINTCONSTANT; }
  482. (0|[1-9][0-9]*) { yylval.ival = atoi(yytext); return INTCONSTANT; }
  483. [a-zA-Z][a-zA-Z0-9_]* {
  484. /* Copy token for now */
  485. yylval.sval = strdup(yytext);
  486. return IDENTIFIER;
  487. }
  488. [ \t\n]+ { /* ignore whitespace */ }
  489. . { return *yytext; }
  490. /*
  491. * Ignore C comments
  492. */
  493. "/*" { BEGIN(C_COMMENT); }
  494. <C_COMMENT>"*/" { BEGIN(INITIAL); }
  495. <C_COMMENT>[^*]* { }
  496. <C_COMMENT>. { }
  497. /*
  498. * Ignore C++ comments
  499. */
  500. "//" { BEGIN(CPP_COMMENT); }
  501. <CPP_COMMENT>\n { BEGIN(INITIAL); }
  502. <CPP_COMMENT>.* { }
  503. %%