GLSL grammar and some personal attempts at writing an HLSL grammar.legacy
@@ -48,10 +48,15 @@ liblol_a_SOURCES = \ | |||||
gpu/indexbuffer.cpp gpu/indexbuffer.h \ | gpu/indexbuffer.cpp gpu/indexbuffer.h \ | ||||
gpu/vertexbuffer.cpp gpu/vertexbuffer.h \ | gpu/vertexbuffer.cpp gpu/vertexbuffer.h \ | ||||
gpu/framebuffer.cpp gpu/framebuffer.h \ | gpu/framebuffer.cpp gpu/framebuffer.h \ | ||||
\ | |||||
gpu/defaultmaterial.lolfx \ | gpu/defaultmaterial.lolfx \ | ||||
gpu/emptymaterial.lolfx \ | gpu/emptymaterial.lolfx \ | ||||
gpu/testmaterial.lolfx \ | gpu/testmaterial.lolfx \ | ||||
\ | \ | ||||
gpu/lolfx-compiler.cpp gpu/lolfx-compiler.h \ | |||||
generated/lolfx-parser.cpp generated/lolfx-parser.h \ | |||||
generated/lolfx-scanner.cpp \ | |||||
\ | |||||
image/image.cpp image/image.h image/image-private.h \ | image/image.cpp image/image.h image/image-private.h \ | ||||
image/codec/gdiplus-image.cpp \ | image/codec/gdiplus-image.cpp \ | ||||
image/codec/ios-image.cpp \ | image/codec/ios-image.cpp \ | ||||
@@ -74,10 +79,14 @@ generated: .FORCE | |||||
flex -o generated/easymesh-scanner.cpp easymesh/easymesh-scanner.l | flex -o generated/easymesh-scanner.cpp easymesh/easymesh-scanner.l | ||||
bison -o generated/easymesh-parser.cpp --defines=generated/easymesh-parser.h \ | bison -o generated/easymesh-parser.cpp --defines=generated/easymesh-parser.h \ | ||||
-d -b generated/easymesh easymesh/easymesh-parser.y | -d -b generated/easymesh easymesh/easymesh-parser.y | ||||
flex -o generated/lolfx-scanner.cpp gpu/lolfx-scanner.l | |||||
bison -o generated/lolfx-parser.cpp --defines=generated/lolfx-parser.h \ | |||||
-d -b generated/lolfx gpu/lolfx-parser.y | |||||
.FORCE: | .FORCE: | ||||
endif | endif | ||||
EXTRA_DIST = easymesh/easymesh-scanner.l easymesh/easymesh-parser.y | |||||
EXTRA_DIST = easymesh/easymesh-scanner.l easymesh/easymesh-parser.y \ | |||||
gpu/lolfx-scanner.l gpu/lolfx-parser.y | |||||
sdl_sources = \ | sdl_sources = \ | ||||
image/codec/sdl-image.cpp \ | image/codec/sdl-image.cpp \ | ||||
@@ -0,0 +1,720 @@ | |||||
/* A Bison parser, made by GNU Bison 2.5. */ | |||||
/* Skeleton interface for Bison LALR(1) parsers in C++ | |||||
Copyright (C) 2002-2011 Free Software Foundation, Inc. | |||||
This program is free software: you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation, either version 3 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |||||
/* As a special exception, you may create a larger work that contains | |||||
part or all of the Bison parser skeleton and distribute that work | |||||
under terms of your choice, so long as that work isn't itself a | |||||
parser generator using the skeleton or a modified version thereof | |||||
as a parser skeleton. Alternatively, if you modify or redistribute | |||||
the parser skeleton itself, you may (at your option) remove this | |||||
special exception, which will cause the skeleton and the resulting | |||||
Bison output files to be licensed under the GNU General Public | |||||
License without this special exception. | |||||
This special exception was added by the Free Software Foundation in | |||||
version 2.2 of Bison. */ | |||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */ | |||||
#ifndef PARSER_HEADER_H | |||||
# define PARSER_HEADER_H | |||||
#include <string> | |||||
#include <iostream> | |||||
#include "stack.hh" | |||||
#include "location.hh" | |||||
/* Enabling traces. */ | |||||
#ifndef YYDEBUG | |||||
# define YYDEBUG 1 | |||||
#endif | |||||
/* Enabling verbose error messages. */ | |||||
#ifdef YYERROR_VERBOSE | |||||
# undef YYERROR_VERBOSE | |||||
# define YYERROR_VERBOSE 1 | |||||
#else | |||||
# define YYERROR_VERBOSE 1 | |||||
#endif | |||||
/* Enabling the token table. */ | |||||
#ifndef YYTOKEN_TABLE | |||||
# define YYTOKEN_TABLE 0 | |||||
#endif | |||||
namespace lol { | |||||
/* Line 35 of lalr1.cc */ | |||||
#line 68 "generated/lolfx-parser.h" | |||||
/// A Bison parser. | |||||
class LolFxParser | |||||
{ | |||||
public: | |||||
/// Symbol semantic values. | |||||
#ifndef YYSTYPE | |||||
union semantic_type | |||||
{ | |||||
/* Line 35 of lalr1.cc */ | |||||
#line 34 "gpu/lolfx-parser.y" | |||||
int ival; | |||||
unsigned uval; | |||||
float fval; | |||||
char *sval; | |||||
/* Line 35 of lalr1.cc */ | |||||
#line 90 "generated/lolfx-parser.h" | |||||
}; | |||||
#else | |||||
typedef YYSTYPE semantic_type; | |||||
#endif | |||||
/// Symbol locations. | |||||
typedef location location_type; | |||||
/// Tokens. | |||||
struct token | |||||
{ | |||||
/* Tokens. */ | |||||
enum yytokentype { | |||||
T_END = 0, | |||||
BOOLCONSTANT = 258, | |||||
INTCONSTANT = 259, | |||||
UINTCONSTANT = 260, | |||||
FLOATCONSTANT = 261, | |||||
FIELDSELECTION = 262, | |||||
IDENTIFIER = 263, | |||||
TYPENAME = 264, | |||||
GT_SUBROUTINE = 265, | |||||
GT_PATCH = 266, | |||||
GT_SAMPLE = 267, | |||||
GT_FLAT = 268, | |||||
GT_SMOOTH = 269, | |||||
GT_LAYOUT = 270, | |||||
GT_INVARIANT = 271, | |||||
GT_HIGHP = 272, | |||||
GT_MEDIUMP = 273, | |||||
GT_LOWP = 274, | |||||
GT_PRECISION = 275, | |||||
GT_ATTRIBUTE = 276, | |||||
GT_VEC2 = 277, | |||||
GT_VEC3 = 278, | |||||
GT_VEC4 = 279, | |||||
GT_BVEC2 = 280, | |||||
GT_BVEC3 = 281, | |||||
GT_BVEC4 = 282, | |||||
GT_DVEC2 = 283, | |||||
GT_DVEC3 = 284, | |||||
GT_DVEC4 = 285, | |||||
GT_IVEC2 = 286, | |||||
GT_IVEC3 = 287, | |||||
GT_IVEC4 = 288, | |||||
GT_UVEC2 = 289, | |||||
GT_UVEC3 = 290, | |||||
GT_UVEC4 = 291, | |||||
GT_MAT2 = 292, | |||||
GT_MAT2X2 = 293, | |||||
GT_MAT2X3 = 294, | |||||
GT_MAT2X4 = 295, | |||||
GT_MAT3 = 296, | |||||
GT_MAT3X2 = 297, | |||||
GT_MAT3X3 = 298, | |||||
GT_MAT3X4 = 299, | |||||
GT_MAT4 = 300, | |||||
GT_MAT4X2 = 301, | |||||
GT_MAT4X3 = 302, | |||||
GT_MAT4X4 = 303, | |||||
GT_DMAT2 = 304, | |||||
GT_DMAT2X2 = 305, | |||||
GT_DMAT2X3 = 306, | |||||
GT_DMAT2X4 = 307, | |||||
GT_DMAT3 = 308, | |||||
GT_DMAT3X2 = 309, | |||||
GT_DMAT3X3 = 310, | |||||
GT_DMAT3X4 = 311, | |||||
GT_DMAT4 = 312, | |||||
GT_DMAT4X2 = 313, | |||||
GT_DMAT4X3 = 314, | |||||
GT_DMAT4X4 = 315, | |||||
GT_SAMPLER1DSHADOW = 316, | |||||
GT_SAMPLER1DARRAY = 317, | |||||
GT_SAMPLER1DARRAYSHADOW = 318, | |||||
GT_SAMPLER2DSHADOW = 319, | |||||
GT_SAMPLER2DARRAY = 320, | |||||
GT_SAMPLER2DARRAYSHADOW = 321, | |||||
GT_SAMPLER2DRECT = 322, | |||||
GT_SAMPLER2DRECTSHADOW = 323, | |||||
GT_SAMPLER2DMS = 324, | |||||
GT_SAMPLER2DMSARRAY = 325, | |||||
GT_SAMPLERCUBESHADOW = 326, | |||||
GT_SAMPLERCUBEARRAY = 327, | |||||
GT_SAMPLERCUBEARRAYSHADOW = 328, | |||||
GT_SAMPLERBUFFER = 329, | |||||
GT_ISAMPLER1D = 330, | |||||
GT_ISAMPLER1DARRAY = 331, | |||||
GT_ISAMPLER2D = 332, | |||||
GT_ISAMPLER2DARRAY = 333, | |||||
GT_ISAMPLER2DRECT = 334, | |||||
GT_ISAMPLER2DMS = 335, | |||||
GT_ISAMPLER2DMSARRAY = 336, | |||||
GT_ISAMPLER3D = 337, | |||||
GT_ISAMPLERCUBE = 338, | |||||
GT_ISAMPLERCUBEARRAY = 339, | |||||
GT_ISAMPLERBUFFER = 340, | |||||
GT_USAMPLER1D = 341, | |||||
GT_USAMPLER1DARRAY = 342, | |||||
GT_USAMPLER2D = 343, | |||||
GT_USAMPLER2DARRAY = 344, | |||||
GT_USAMPLER2DRECT = 345, | |||||
GT_USAMPLER2DMS = 346, | |||||
GT_USAMPLER2DMSARRAY = 347, | |||||
GT_USAMPLER3D = 348, | |||||
GT_USAMPLERCUBE = 349, | |||||
GT_USAMPLERCUBEARRAY = 350, | |||||
GT_USAMPLERBUFFER = 351, | |||||
GHT_BOOL = 352, | |||||
GHT_BREAK = 353, | |||||
GHT_CASE = 354, | |||||
GHT_CENTROID = 355, | |||||
GHT_CONST = 356, | |||||
GHT_CONTINUE = 357, | |||||
GHT_DEFAULT = 358, | |||||
GHT_DISCARD = 359, | |||||
GHT_DO = 360, | |||||
GHT_DOUBLE = 361, | |||||
GHT_ELSE = 362, | |||||
GHT_FLOAT = 363, | |||||
GHT_FOR = 364, | |||||
GHT_IF = 365, | |||||
GHT_IN = 366, | |||||
GHT_INOUT = 367, | |||||
GHT_INT = 368, | |||||
GHT_NOPERSPECTIVE = 369, | |||||
GHT_OUT = 370, | |||||
GHT_RETURN = 371, | |||||
GHT_SAMPLER1D = 372, | |||||
GHT_SAMPLER2D = 373, | |||||
GHT_SAMPLER3D = 374, | |||||
GHT_SAMPLERCUBE = 375, | |||||
GHT_STRUCT = 376, | |||||
GHT_SWITCH = 377, | |||||
GHT_UINT = 378, | |||||
GHT_UNIFORM = 379, | |||||
GHT_VOID = 380, | |||||
GHT_WHILE = 381, | |||||
HGT_BOOL = 382, | |||||
HGT_BREAK = 383, | |||||
HGT_CASE = 384, | |||||
HGT_CENTROID = 385, | |||||
HGT_CONST = 386, | |||||
HGT_CONTINUE = 387, | |||||
HGT_DEFAULT = 388, | |||||
HGT_DISCARD = 389, | |||||
HGT_DO = 390, | |||||
HGT_DOUBLE = 391, | |||||
HGT_ELSE = 392, | |||||
HGT_FLOAT = 393, | |||||
HGT_FOR = 394, | |||||
HGT_IF = 395, | |||||
HGT_IN = 396, | |||||
HGT_INOUT = 397, | |||||
HGT_INT = 398, | |||||
HGT_NOPERSPECTIVE = 399, | |||||
HGT_OUT = 400, | |||||
HGT_RETURN = 401, | |||||
HGT_SAMPLER1D = 402, | |||||
HGT_SAMPLER2D = 403, | |||||
HGT_SAMPLER3D = 404, | |||||
HGT_SAMPLERCUBE = 405, | |||||
HGT_STRUCT = 406, | |||||
HGT_SWITCH = 407, | |||||
HGT_UINT = 408, | |||||
HGT_UNIFORM = 409, | |||||
HGT_VOID = 410, | |||||
HGT_WHILE = 411, | |||||
HT_APPENDSTRUCTUREDBUFFER = 412, | |||||
HT_ASM = 413, | |||||
HT_ASM_FRAGMENT = 414, | |||||
HT_BLENDSTATE = 415, | |||||
HT_BUFFER = 416, | |||||
HT_BYTEADDRESSBUFFER = 417, | |||||
HT_CBUFFER = 418, | |||||
HT_COLUMN_MAJOR = 419, | |||||
HT_COMPILE = 420, | |||||
HT_COMPILE_FRAGMENT = 421, | |||||
HT_COMPILESHADER = 422, | |||||
HT_COMPUTESHADER = 423, | |||||
HT_CONSUMESTRUCTUREDBUFFER = 424, | |||||
HT_DEPTHSTENCILSTATE = 425, | |||||
HT_DEPTHSTENCILVIEW = 426, | |||||
HT_DOMAINSHADER = 427, | |||||
HT_DWORD = 428, | |||||
HT_EXTERN = 429, | |||||
HT_FALSE = 430, | |||||
HT_FXGROUP = 431, | |||||
HT_GEOMETRYSHADER = 432, | |||||
HT_GROUPSHARED = 433, | |||||
HT_HALF = 434, | |||||
HT_HULLSHADER = 435, | |||||
HT_INLINE = 436, | |||||
HT_INPUTPATCH = 437, | |||||
HT_INTERFACE = 438, | |||||
HT_LINE = 439, | |||||
HT_LINEADJ = 440, | |||||
HT_LINEAR = 441, | |||||
HT_LINESTREAM = 442, | |||||
HT_MATRIX = 443, | |||||
HT_NAMESPACE = 444, | |||||
HT_NOINTERPOLATION = 445, | |||||
HT_NULL = 446, | |||||
HT_OUTPUTPATCH = 447, | |||||
HT_PACKOFFSET = 448, | |||||
HT_PASS = 449, | |||||
HT_PIXELFRAGMENT = 450, | |||||
HT_PIXELSHADER = 451, | |||||
HT_POINT = 452, | |||||
HT_POINTSTREAM = 453, | |||||
HT_PRECISE = 454, | |||||
HT_RASTERIZERSTATE = 455, | |||||
HT_RENDERTARGETVIEW = 456, | |||||
HT_REGISTER = 457, | |||||
HT_ROW_MAJOR = 458, | |||||
HT_RWBUFFER = 459, | |||||
HT_RWBYTEADDRESSBUFFER = 460, | |||||
HT_RWSTRUCTUREDBUFFER = 461, | |||||
HT_RWTEXTURE1D = 462, | |||||
HT_RWTEXTURE1DARRAY = 463, | |||||
HT_RWTEXTURE2D = 464, | |||||
HT_RWTEXTURE2DARRAY = 465, | |||||
HT_RWTEXTURE3D = 466, | |||||
HT_SAMPLER = 467, | |||||
HT_SAMPLER_STATE = 468, | |||||
HT_SAMPLERSTATE = 469, | |||||
HT_SAMPLERCOMPARISONSTATE = 470, | |||||
HT_SHARED = 471, | |||||
HT_SNORM = 472, | |||||
HT_STATEBLOCK = 473, | |||||
HT_STATEBLOCK_STATE = 474, | |||||
HT_STATIC = 475, | |||||
HT_STRING = 476, | |||||
HT_STRUCTUREDBUFFER = 477, | |||||
HT_TBUFFER = 478, | |||||
HT_TECHNIQUE = 479, | |||||
HT_TECHNIQUE10 = 480, | |||||
HT_TECHNIQUE11XZ = 481, | |||||
HT_TEXTURE = 482, | |||||
HT_TEXTURE1D = 483, | |||||
HT_TEXTURE1DARRAY = 484, | |||||
HT_TEXTURE2D = 485, | |||||
HT_TEXTURE2DARRAY = 486, | |||||
HT_TEXTURE2DMS = 487, | |||||
HT_TEXTURE2DMSARRAY = 488, | |||||
HT_TEXTURE3D = 489, | |||||
HT_TEXTURECUBE = 490, | |||||
HT_TEXTURECUBEARRAY = 491, | |||||
HT_TRUE = 492, | |||||
HT_TYPEDEF = 493, | |||||
HT_TRIANGLE = 494, | |||||
HT_TRIANGLEADJ = 495, | |||||
HT_TRIANGLESTREAM = 496, | |||||
HT_UNORM = 497, | |||||
HT_VECTOR = 498, | |||||
HT_VERTEXFRAGMENT = 499, | |||||
HT_VERTEXSHADER = 500, | |||||
HT_VOLATILE = 501, | |||||
HT_BOOL1 = 502, | |||||
HT_BOOL1x1 = 503, | |||||
HT_BOOL2x1 = 504, | |||||
HT_BOOL3x1 = 505, | |||||
HT_BOOL4x1 = 506, | |||||
HT_BOOL2 = 507, | |||||
HT_BOOL1x2 = 508, | |||||
HT_BOOL2x2 = 509, | |||||
HT_BOOL3x2 = 510, | |||||
HT_BOOL4x2 = 511, | |||||
HT_BOOL3 = 512, | |||||
HT_BOOL1x3 = 513, | |||||
HT_BOOL2x3 = 514, | |||||
HT_BOOL3x3 = 515, | |||||
HT_BOOL4x3 = 516, | |||||
HT_BOOL4 = 517, | |||||
HT_BOOL1x4 = 518, | |||||
HT_BOOL2x4 = 519, | |||||
HT_BOOL3x4 = 520, | |||||
HT_BOOL4x4 = 521, | |||||
HT_FLOAT1 = 522, | |||||
HT_FLOAT1x1 = 523, | |||||
HT_FLOAT2x1 = 524, | |||||
HT_FLOAT3x1 = 525, | |||||
HT_FLOAT4x1 = 526, | |||||
HT_FLOAT2 = 527, | |||||
HT_FLOAT1x2 = 528, | |||||
HT_FLOAT2x2 = 529, | |||||
HT_FLOAT3x2 = 530, | |||||
HT_FLOAT4x2 = 531, | |||||
HT_FLOAT3 = 532, | |||||
HT_FLOAT1x3 = 533, | |||||
HT_FLOAT2x3 = 534, | |||||
HT_FLOAT3x3 = 535, | |||||
HT_FLOAT4x3 = 536, | |||||
HT_FLOAT4 = 537, | |||||
HT_FLOAT1x4 = 538, | |||||
HT_FLOAT2x4 = 539, | |||||
HT_FLOAT3x4 = 540, | |||||
HT_FLOAT4x4 = 541, | |||||
HT_DOUBLE1 = 542, | |||||
HT_DOUBLE1x1 = 543, | |||||
HT_DOUBLE2x1 = 544, | |||||
HT_DOUBLE3x1 = 545, | |||||
HT_DOUBLE4x1 = 546, | |||||
HT_DOUBLE2 = 547, | |||||
HT_DOUBLE1x2 = 548, | |||||
HT_DOUBLE2x2 = 549, | |||||
HT_DOUBLE3x2 = 550, | |||||
HT_DOUBLE4x2 = 551, | |||||
HT_DOUBLE3 = 552, | |||||
HT_DOUBLE1x3 = 553, | |||||
HT_DOUBLE2x3 = 554, | |||||
HT_DOUBLE3x3 = 555, | |||||
HT_DOUBLE4x3 = 556, | |||||
HT_DOUBLE4 = 557, | |||||
HT_DOUBLE1x4 = 558, | |||||
HT_DOUBLE2x4 = 559, | |||||
HT_DOUBLE3x4 = 560, | |||||
HT_DOUBLE4x4 = 561, | |||||
HT_DWORD1 = 562, | |||||
HT_DWORD1x1 = 563, | |||||
HT_DWORD2x1 = 564, | |||||
HT_DWORD3x1 = 565, | |||||
HT_DWORD4x1 = 566, | |||||
HT_DWORD2 = 567, | |||||
HT_DWORD1x2 = 568, | |||||
HT_DWORD2x2 = 569, | |||||
HT_DWORD3x2 = 570, | |||||
HT_DWORD4x2 = 571, | |||||
HT_DWORD3 = 572, | |||||
HT_DWORD1x3 = 573, | |||||
HT_DWORD2x3 = 574, | |||||
HT_DWORD3x3 = 575, | |||||
HT_DWORD4x3 = 576, | |||||
HT_DWORD4 = 577, | |||||
HT_DWORD1x4 = 578, | |||||
HT_DWORD2x4 = 579, | |||||
HT_DWORD3x4 = 580, | |||||
HT_DWORD4x4 = 581, | |||||
HT_INT1 = 582, | |||||
HT_INT1x1 = 583, | |||||
HT_INT2x1 = 584, | |||||
HT_INT3x1 = 585, | |||||
HT_INT4x1 = 586, | |||||
HT_INT2 = 587, | |||||
HT_INT1x2 = 588, | |||||
HT_INT2x2 = 589, | |||||
HT_INT3x2 = 590, | |||||
HT_INT4x2 = 591, | |||||
HT_INT3 = 592, | |||||
HT_INT1x3 = 593, | |||||
HT_INT2x3 = 594, | |||||
HT_INT3x3 = 595, | |||||
HT_INT4x3 = 596, | |||||
HT_INT4 = 597, | |||||
HT_INT1x4 = 598, | |||||
HT_INT2x4 = 599, | |||||
HT_INT3x4 = 600, | |||||
HT_INT4x4 = 601, | |||||
HT_UINT1 = 602, | |||||
HT_UINT1x1 = 603, | |||||
HT_UINT2x1 = 604, | |||||
HT_UINT3x1 = 605, | |||||
HT_UINT4x1 = 606, | |||||
HT_UINT2 = 607, | |||||
HT_UINT1x2 = 608, | |||||
HT_UINT2x2 = 609, | |||||
HT_UINT3x2 = 610, | |||||
HT_UINT4x2 = 611, | |||||
HT_UINT3 = 612, | |||||
HT_UINT1x3 = 613, | |||||
HT_UINT2x3 = 614, | |||||
HT_UINT3x3 = 615, | |||||
HT_UINT4x3 = 616, | |||||
HT_UINT4 = 617, | |||||
HT_UINT1x4 = 618, | |||||
HT_UINT2x4 = 619, | |||||
HT_UINT3x4 = 620, | |||||
HT_UINT4x4 = 621, | |||||
PREPROCESSOR_DEFINE = 622, | |||||
PREPROCESSOR_ELIF = 623, | |||||
PREPROCESSOR_ELSE = 624, | |||||
PREPROCESSOR_ENDIF = 625, | |||||
PREPROCESSOR_ERROR = 626, | |||||
PREPROCESSOR_IF = 627, | |||||
PREPROCESSOR_IFDEF = 628, | |||||
PREPROCESSOR_IFNDEF = 629, | |||||
PREPROCESSOR_INCLUDE = 630, | |||||
PREPROCESSOR_LINE = 631, | |||||
PREPROCESSOR_PRAGMA = 632, | |||||
PREPROCESSOR_UNDEF = 633, | |||||
PREPROCESSOR_REGION = 634, | |||||
PRAGMA_LOLFX = 635, | |||||
HT_AUTO = 636, | |||||
HT_CATCH = 637, | |||||
HT_CHAR = 638, | |||||
HT_CLASS = 639, | |||||
HT_CONST_CAST = 640, | |||||
HT_DELETE = 641, | |||||
HT_DYNAMIC_CAST = 642, | |||||
HT_ENUM = 643, | |||||
HT_EXPLICIT = 644, | |||||
HT_FRIEND = 645, | |||||
HT_GOTO = 646, | |||||
HT_LONG = 647, | |||||
HT_MUTABLE = 648, | |||||
HT_NEW = 649, | |||||
HT_OPERATOR = 650, | |||||
HT_PRIVATE = 651, | |||||
HT_PROTECTED = 652, | |||||
HT_PUBLIC = 653, | |||||
HT_REINTERPRET_CAST = 654, | |||||
HT_SHORT = 655, | |||||
HT_SIGNED = 656, | |||||
HT_SIZEOF = 657, | |||||
HT_STATIC_CAST = 658, | |||||
HT_TEMPLATE = 659, | |||||
HT_THIS = 660, | |||||
HT_THROW = 661, | |||||
HT_TRY = 662, | |||||
HT_TYPENAME = 663, | |||||
HT_UNION = 664, | |||||
HT_UNSIGNED = 665, | |||||
HT_USING = 666, | |||||
HT_VIRTUAL = 667, | |||||
T_INC = 668, | |||||
T_DEC = 669, | |||||
T_LE = 670, | |||||
T_GE = 671, | |||||
T_EQ = 672, | |||||
T_NE = 673, | |||||
T_LEFT = 674, | |||||
T_RIGHT = 675, | |||||
T_AND = 676, | |||||
T_OR = 677, | |||||
T_XOR = 678, | |||||
T_MULEQ = 679, | |||||
T_DIVEQ = 680, | |||||
T_MODEQ = 681, | |||||
T_ADDEQ = 682, | |||||
T_SUBEQ = 683, | |||||
T_LEFTEQ = 684, | |||||
T_RIGHTEQ = 685, | |||||
T_ANDEQ = 686, | |||||
T_XOREQ = 687, | |||||
T_OREQ = 688, | |||||
FLOAT = 689, | |||||
STRING = 690, | |||||
NAME = 691, | |||||
T_ERROR = 692 | |||||
}; | |||||
}; | |||||
/// Token type. | |||||
typedef token::yytokentype token_type; | |||||
/// Build a parser object. | |||||
LolFxParser (class LolFxCompiler& mc_yyarg); | |||||
virtual ~LolFxParser (); | |||||
/// Parse. | |||||
/// \returns 0 iff parsing succeeded. | |||||
virtual int parse (); | |||||
#if YYDEBUG | |||||
/// The current debugging stream. | |||||
std::ostream& debug_stream () const; | |||||
/// Set the current debugging stream. | |||||
void set_debug_stream (std::ostream &); | |||||
/// Type for debugging levels. | |||||
typedef int debug_level_type; | |||||
/// The current debugging level. | |||||
debug_level_type debug_level () const; | |||||
/// Set the current debugging level. | |||||
void set_debug_level (debug_level_type l); | |||||
#endif | |||||
private: | |||||
/// Report a syntax error. | |||||
/// \param loc where the syntax error is found. | |||||
/// \param msg a description of the syntax error. | |||||
virtual void error (const location_type& loc, const std::string& msg); | |||||
/// Generate an error message. | |||||
/// \param state the state where the error occurred. | |||||
/// \param tok the lookahead token. | |||||
virtual std::string yysyntax_error_ (int yystate, int tok); | |||||
#if YYDEBUG | |||||
/// \brief Report a symbol value on the debug stream. | |||||
/// \param yytype The token type. | |||||
/// \param yyvaluep Its semantic value. | |||||
/// \param yylocationp Its location. | |||||
virtual void yy_symbol_value_print_ (int yytype, | |||||
const semantic_type* yyvaluep, | |||||
const location_type* yylocationp); | |||||
/// \brief Report a symbol on the debug stream. | |||||
/// \param yytype The token type. | |||||
/// \param yyvaluep Its semantic value. | |||||
/// \param yylocationp Its location. | |||||
virtual void yy_symbol_print_ (int yytype, | |||||
const semantic_type* yyvaluep, | |||||
const location_type* yylocationp); | |||||
#endif | |||||
/// State numbers. | |||||
typedef int state_type; | |||||
/// State stack type. | |||||
typedef stack<state_type> state_stack_type; | |||||
/// Semantic value stack type. | |||||
typedef stack<semantic_type> semantic_stack_type; | |||||
/// location stack type. | |||||
typedef stack<location_type> location_stack_type; | |||||
/// The state stack. | |||||
state_stack_type yystate_stack_; | |||||
/// The semantic value stack. | |||||
semantic_stack_type yysemantic_stack_; | |||||
/// The location stack. | |||||
location_stack_type yylocation_stack_; | |||||
/// Whether the given \c yypact_ value indicates a defaulted state. | |||||
/// \param yyvalue the value to check | |||||
static bool yy_pact_value_is_default_ (int yyvalue); | |||||
/// Whether the given \c yytable_ value indicates a syntax error. | |||||
/// \param yyvalue the value to check | |||||
static bool yy_table_value_is_error_ (int yyvalue); | |||||
/// Internal symbol numbers. | |||||
typedef unsigned short int token_number_type; | |||||
/* Tables. */ | |||||
/// For a state, the index in \a yytable_ of its portion. | |||||
static const short int yypact_[]; | |||||
static const short int yypact_ninf_; | |||||
/// For a state, default reduction number. | |||||
/// Unless\a yytable_ specifies something else to do. | |||||
/// Zero means the default is an error. | |||||
static const unsigned short int yydefact_[]; | |||||
static const short int yypgoto_[]; | |||||
static const short int yydefgoto_[]; | |||||
/// What to do in a state. | |||||
/// \a yytable_[yypact_[s]]: what to do in state \a s. | |||||
/// - if positive, shift that token. | |||||
/// - if negative, reduce the rule which number is the opposite. | |||||
/// - if zero, do what YYDEFACT says. | |||||
static const short int yytable_[]; | |||||
static const short int yytable_ninf_; | |||||
static const short int yycheck_[]; | |||||
/// For a state, its accessing symbol. | |||||
static const unsigned short int yystos_[]; | |||||
/// For a rule, its LHS. | |||||
static const unsigned short int yyr1_[]; | |||||
/// For a rule, its RHS length. | |||||
static const unsigned char yyr2_[]; | |||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE | |||||
/// For a symbol, its name in clear. | |||||
static const char* const yytname_[]; | |||||
#endif | |||||
/// Convert the symbol name \a n to a form suitable for a diagnostic. | |||||
static std::string yytnamerr_ (const char *n); | |||||
#if YYDEBUG | |||||
/// A type to store symbol numbers and -1. | |||||
typedef short int rhs_number_type; | |||||
/// A `-1'-separated list of the rules' RHS. | |||||
static const rhs_number_type yyrhs_[]; | |||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_. | |||||
static const unsigned short int yyprhs_[]; | |||||
/// For each rule, its source line number. | |||||
static const unsigned short int yyrline_[]; | |||||
/// For each scanner token number, its symbol number. | |||||
static const unsigned short int yytoken_number_[]; | |||||
/// Report on the debug stream that the rule \a r is going to be reduced. | |||||
virtual void yy_reduce_print_ (int r); | |||||
/// Print the state stack on the debug stream. | |||||
virtual void yystack_print_ (); | |||||
/* Debugging. */ | |||||
int yydebug_; | |||||
std::ostream* yycdebug_; | |||||
#endif | |||||
/// Convert a scanner token number \a t to a symbol number. | |||||
token_number_type yytranslate_ (int t); | |||||
/// \brief Reclaim the memory associated to a symbol. | |||||
/// \param yymsg Why this token is reclaimed. | |||||
/// \param yytype The symbol type. | |||||
/// \param yyvaluep Its semantic value. | |||||
/// \param yylocationp Its location. | |||||
inline void yydestruct_ (const char* yymsg, | |||||
int yytype, | |||||
semantic_type* yyvaluep, | |||||
location_type* yylocationp); | |||||
/// Pop \a n symbols the three stacks. | |||||
inline void yypop_ (unsigned int n = 1); | |||||
/* Constants. */ | |||||
static const int yyeof_; | |||||
/* LAST_ -- Last index in TABLE_. */ | |||||
static const int yylast_; | |||||
static const int yynnts_; | |||||
static const int yyempty_; | |||||
static const int yyfinal_; | |||||
static const int yyterror_; | |||||
static const int yyerrcode_; | |||||
static const int yyntokens_; | |||||
static const unsigned int yyuser_token_number_max_; | |||||
static const token_number_type yyundef_token_; | |||||
/* User arguments. */ | |||||
class LolFxCompiler& mc; | |||||
}; | |||||
} // lol | |||||
/* Line 35 of lalr1.cc */ | |||||
#line 717 "generated/lolfx-parser.h" | |||||
#endif /* ! defined PARSER_HEADER_H */ |
@@ -0,0 +1,50 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <string> | |||||
#include "core.h" | |||||
#include "gpu/lolfx-compiler.h" | |||||
namespace lol | |||||
{ | |||||
LolFxCompiler::LolFxCompiler(LolFx &lolfx) | |||||
: m_lolfx(lolfx) | |||||
{ | |||||
} | |||||
bool LolFxCompiler::ParseString(char const *command) | |||||
{ | |||||
LolFxScanner scanner(command); | |||||
m_lexer = &scanner; | |||||
LolFxParser parser(*this); | |||||
if (parser.parse() != 0) | |||||
return false; | |||||
return true; | |||||
} | |||||
void LolFxCompiler::Error(const class location& l, const std::string& m) | |||||
{ | |||||
Log::Error("Syntax error line %d column %d: %s", | |||||
l.begin.line, l.begin.column, m.c_str()); | |||||
} | |||||
void LolFxCompiler::Error(const std::string& m) | |||||
{ | |||||
Log::Error("Syntax error: %s", m.c_str()); | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -0,0 +1,59 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#ifndef __LOLFX_COMPILER_H__ | |||||
#define __LOLFX_COMPILER_H__ | |||||
#include <string> | |||||
#ifndef __FLEX_LEXER_H | |||||
# define yyFlexLexer LolFxFlexLexer | |||||
# include "FlexLexer.h" | |||||
# undef yyFlexLexer | |||||
#endif | |||||
#include "generated/lolfx-parser.h" | |||||
class LolFx; | |||||
namespace lol | |||||
{ | |||||
class LolFxScanner : public LolFxFlexLexer | |||||
{ | |||||
public: | |||||
LolFxScanner(char const *command); | |||||
virtual ~LolFxScanner(); | |||||
virtual int LexerInput(char* buf, int max_size); | |||||
virtual LolFxParser::token_type lex(LolFxParser::semantic_type* yylval, | |||||
LolFxParser::location_type* yylloc); | |||||
private: | |||||
char const *m_input; | |||||
}; | |||||
class LolFxCompiler | |||||
{ | |||||
public: | |||||
LolFxCompiler(class LolFx &lolfx); | |||||
bool ParseString(char const *command); | |||||
void Error(const class location& l, const std::string& m); | |||||
void Error(const std::string& m); | |||||
class LolFxScanner *m_lexer; | |||||
class LolFx &m_lolfx; | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif /* __LOLFX_COMPILER_H__ */ | |||||
@@ -1,15 +1,34 @@ | |||||
%{ | %{ | ||||
#include <cstdio> | |||||
#include <iostream> | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
extern "C" int yylex(); | |||||
extern "C" int yyparse(); | |||||
extern "C" FILE *yyin; | |||||
extern "C" int yylineno; | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include "core.h" | |||||
#include <string> | |||||
void yyerror(const char *s); | |||||
%} | %} | ||||
%require "2.3" | |||||
%debug | |||||
%defines | |||||
%skeleton "lalr1.cc" | |||||
%name-prefix="lol" | |||||
%define parser_class_name "LolFxParser" | |||||
%locations | |||||
%parse-param { class LolFxCompiler& mc } | |||||
%error-verbose | |||||
/* The classic Bison union trick */ | /* The classic Bison union trick */ | ||||
%union | %union | ||||
{ | { | ||||
@@ -19,7 +38,7 @@ void yyerror(const char *s); | |||||
char *sval; | char *sval; | ||||
} | } | ||||
%type <sval> lolfx_shader_name | |||||
/* %type <sval> lolfx_shader_name */ | |||||
/* | /* | ||||
* GLSL and HLSL generic tokens | * GLSL and HLSL generic tokens | ||||
@@ -180,6 +199,8 @@ void yyerror(const char *s); | |||||
%token PREPROCESSOR_LINE PREPROCESSOR_PRAGMA PREPROCESSOR_UNDEF | %token PREPROCESSOR_LINE PREPROCESSOR_PRAGMA PREPROCESSOR_UNDEF | ||||
%token PREPROCESSOR_REGION | %token PREPROCESSOR_REGION | ||||
%token PRAGMA_LOLFX | |||||
/* | /* | ||||
* HLSL reserved keywords | * HLSL reserved keywords | ||||
*/ | */ | ||||
@@ -206,12 +227,26 @@ void yyerror(const char *s); | |||||
%token <fval> FLOAT | %token <fval> FLOAT | ||||
%token <sval> STRING NAME | %token <sval> STRING NAME | ||||
/* | |||||
* Special tokens | |||||
*/ | |||||
%token T_END 0 | |||||
%token T_ERROR | |||||
/* | /* | ||||
* Our entry point | * Our entry point | ||||
*/ | */ | ||||
%start lolfx_file | %start lolfx_file | ||||
%{ | |||||
#include "gpu/lolfx-compiler.h" | |||||
#undef yylex | |||||
#define yylex mc.m_lexer->lex | |||||
%} | |||||
%% | %% | ||||
/* | /* | ||||
@@ -691,7 +726,7 @@ lolfx_section: | |||||
*/ | */ | ||||
lolfx_technique: | lolfx_technique: | ||||
HT_TECHNIQUE IDENTIFIER '{' pass_list '}' { std::cout << "New tech" << std::endl; } | |||||
HT_TECHNIQUE IDENTIFIER '{' pass_list '}' { std::cout << "New tech " << $2 << std::endl; } | |||||
; | ; | ||||
/* | /* | ||||
@@ -704,7 +739,7 @@ pass_list: | |||||
; | ; | ||||
pass: | pass: | ||||
HT_PASS IDENTIFIER '{' pass_stmt_list '}' { std::cout << "New pass" << std::endl; } | |||||
HT_PASS IDENTIFIER '{' pass_stmt_list '}' { std::cout << "New pass " << $2 << std::endl; } | |||||
; | ; | ||||
pass_stmt_list: | pass_stmt_list: | ||||
@@ -736,17 +771,26 @@ pass_stmt: | |||||
*/ | */ | ||||
lolfx_shader: | lolfx_shader: | ||||
lolfx_shader_region glsl_translation_unit | |||||
| lolfx_shader_region | |||||
lolfx_shader_declaration glsl_translation_unit | |||||
; | |||||
lolfx_shader_declaration: | |||||
PRAGMA_LOLFX lolfx_shader_type '(' lolfx_shader_description_list ')' { std::cout << "new shader" << std::endl; } | |||||
; | |||||
lolfx_shader_type: | |||||
HT_VERTEXSHADER | |||||
| HT_PIXELSHADER | |||||
; | ; | ||||
lolfx_shader_region: | |||||
PREPROCESSOR_REGION lolfx_shader_name { std::cout << "new shader " << $2 << std::endl; } | |||||
lolfx_shader_description_list: | |||||
lolfx_shader_description ',' lolfx_shader_description | |||||
| lolfx_shader_description | |||||
; | ; | ||||
lolfx_shader_name: | |||||
IDENTIFIER { $$ = $1; } | |||||
| lolfx_shader_name '.' IDENTIFIER { $$ = $3; } /* FIXME: concatenate */ | |||||
lolfx_shader_description: | |||||
IDENTIFIER '=' IDENTIFIER FLOATCONSTANT | |||||
| IDENTIFIER '=' IDENTIFIER | |||||
; | ; | ||||
/* | /* | ||||
@@ -1308,21 +1352,9 @@ glsl_function_definition: | |||||
%% | %% | ||||
main() | |||||
{ | |||||
yyin = stdin;//fopen("test.lolfx", "r"); | |||||
do | |||||
{ | |||||
yyparse(); | |||||
} | |||||
while (!feof(yyin)); | |||||
fclose(yyin); | |||||
} | |||||
void yyerror(const char *s) | |||||
void lol::LolFxParser::error(const LolFxParser::location_type& l, | |||||
const std::string& m) | |||||
{ | { | ||||
std::cout << "Parse error line " << yylineno << ": " << s << std::endl; | |||||
exit(-1); | |||||
mc.Error(l, m); | |||||
} | } | ||||
@@ -0,0 +1,636 @@ | |||||
%{ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstdlib> | |||||
using std::exit; | |||||
using std::malloc; | |||||
using std::realloc; | |||||
using std::free; | |||||
#include <iostream> | |||||
#include "core.h" | |||||
#include "gpu/lolfx-compiler.h" | |||||
typedef lol::LolFxParser::token token; | |||||
typedef lol::LolFxParser::token_type token_type; | |||||
#ifndef YY_DECL | |||||
# define YY_DECL lol::LolFxParser::token_type \ | |||||
lol::LolFxScanner::lex(lol::LolFxParser::semantic_type* yylval, \ | |||||
lol::LolFxParser::location_type* yylloc) | |||||
#endif | |||||
#define yyterminate() return token::T_END | |||||
#define YY_NO_UNISTD_H | |||||
#define YY_USER_ACTION yylloc->columns(yyleng); | |||||
%} | |||||
%option c++ prefix="LolFx" | |||||
%option batch yywrap nounput stack | |||||
%x C_COMMENT | |||||
%x CPP_COMMENT | |||||
%% | |||||
%{ | |||||
/* reset location at the beginning of yylex() */ | |||||
yylloc->step(); | |||||
int language_guess = INITIAL; | |||||
%} | |||||
/* | |||||
* GLSL keywords | |||||
*/ | |||||
"subroutine" { return token::GT_SUBROUTINE; } | |||||
"patch" { return token::GT_PATCH; } | |||||
"sample" { return token::GT_SAMPLE; } | |||||
"flat" { return token::GT_FLAT; } | |||||
"smooth" { return token::GT_SMOOTH; } | |||||
"layout" { return token::GT_LAYOUT; } | |||||
"sampler1dshadow" { return token::GT_SAMPLER1DSHADOW; } | |||||
"sampler2dshadow" { return token::GT_SAMPLER2DSHADOW; } | |||||
"samplercubeshadow" { return token::GT_SAMPLERCUBESHADOW; } | |||||
"sampler1darray" { return token::GT_SAMPLER1DARRAY; } | |||||
"sampler2darray" { return token::GT_SAMPLER2DARRAY; } | |||||
"sampler1darrayshadow" { return token::GT_SAMPLER1DARRAYSHADOW; } | |||||
"sampler2darrayshadow" { return token::GT_SAMPLER2DARRAYSHADOW; } | |||||
"isampler1d" { return token::GT_ISAMPLER1D; } | |||||
"isampler2d" { return token::GT_ISAMPLER2D; } | |||||
"isampler3d" { return token::GT_ISAMPLER3D; } | |||||
"isamplercube" { return token::GT_ISAMPLERCUBE; } | |||||
"isampler1darray" { return token::GT_ISAMPLER1DARRAY; } | |||||
"isampler2darray" { return token::GT_ISAMPLER2DARRAY; } | |||||
"usampler1d" { return token::GT_USAMPLER1D; } | |||||
"usampler2d" { return token::GT_USAMPLER2D; } | |||||
"usampler3d" { return token::GT_USAMPLER3D; } | |||||
"usamplercube" { return token::GT_USAMPLERCUBE; } | |||||
"usampler1darray" { return token::GT_USAMPLER1DARRAY; } | |||||
"usampler2darray" { return token::GT_USAMPLER2DARRAY; } | |||||
"sampler2drect" { return token::GT_SAMPLER2DRECT; } | |||||
"sampler2drectshadow" { return token::GT_SAMPLER2DRECTSHADOW; } | |||||
"isampler2drect" { return token::GT_ISAMPLER2DRECT; } | |||||
"usampler2drect" { return token::GT_USAMPLER2DRECT; } | |||||
"samplerbuffer" { return token::GT_SAMPLERBUFFER; } | |||||
"isamplerbuffer" { return token::GT_ISAMPLERBUFFER; } | |||||
"usamplerbuffer" { return token::GT_USAMPLERBUFFER; } | |||||
"samplercubearray" { return token::GT_SAMPLERCUBEARRAY; } | |||||
"samplercubearrayshadow" { return token::GT_SAMPLERCUBEARRAYSHADOW; } | |||||
"isamplercubearray" { return token::GT_ISAMPLERCUBEARRAY; } | |||||
"usamplercubearray" { return token::GT_USAMPLERCUBEARRAY; } | |||||
"sampler2dms" { return token::GT_SAMPLER2DMS; } | |||||
"isampler2dms" { return token::GT_ISAMPLER2DMS; } | |||||
"usampler2dms" { return token::GT_USAMPLER2DMS; } | |||||
"sampler2dmsarray" { return token::GT_SAMPLER2DMSARRAY; } | |||||
"isampler2dmsarray" { return token::GT_ISAMPLER2DMSARRAY; } | |||||
"usampler2dmsarray" { return token::GT_USAMPLER2DMSARRAY; } | |||||
"highp" { return token::GT_HIGHP; } | |||||
"mediump" { return token::GT_MEDIUMP; } | |||||
"lowp" { return token::GT_LOWP; } | |||||
"precision" { return token::GT_PRECISION; } | |||||
"invariant" { return token::GT_INVARIANT; } | |||||
/* | |||||
* Deprecated GLSL keywords | |||||
*/ | |||||
"attribute" { return token::GT_ATTRIBUTE; } | |||||
/* | |||||
* GLSL vector types | |||||
*/ | |||||
"bvec2" { return token::GT_BVEC2; } | |||||
"bvec3" { return token::GT_BVEC3; } | |||||
"bvec4" { return token::GT_BVEC4; } | |||||
"ivec2" { return token::GT_IVEC2; } | |||||
"ivec3" { return token::GT_IVEC3; } | |||||
"ivec4" { return token::GT_IVEC4; } | |||||
"uvec2" { return token::GT_UVEC2; } | |||||
"uvec3" { return token::GT_UVEC3; } | |||||
"uvec4" { return token::GT_UVEC4; } | |||||
"vec2" { return token::GT_VEC2; } | |||||
"vec3" { return token::GT_VEC3; } | |||||
"vec4" { return token::GT_VEC4; } | |||||
"mat2" { return token::GT_MAT2; } | |||||
"mat2x2" { return token::GT_MAT2X2; } | |||||
"mat2x3" { return token::GT_MAT2X3; } | |||||
"mat2x4" { return token::GT_MAT2X4; } | |||||
"mat3" { return token::GT_MAT3; } | |||||
"mat3x2" { return token::GT_MAT3X2; } | |||||
"mat3x3" { return token::GT_MAT3X3; } | |||||
"mat3x4" { return token::GT_MAT3X4; } | |||||
"mat4" { return token::GT_MAT4; } | |||||
"mat4x2" { return token::GT_MAT4X2; } | |||||
"mat4x3" { return token::GT_MAT4X3; } | |||||
"mat4x4" { return token::GT_MAT4X4; } | |||||
"dvec2" { return token::GT_DVEC2; } | |||||
"dvec3" { return token::GT_DVEC3; } | |||||
"dvec4" { return token::GT_DVEC4; } | |||||
"dmat2" { return token::GT_DMAT2; } | |||||
"dmat2x2" { return token::GT_DMAT2X2; } | |||||
"dmat2x3" { return token::GT_DMAT2X3; } | |||||
"dmat2x4" { return token::GT_DMAT2X4; } | |||||
"dmat3" { return token::GT_DMAT3; } | |||||
"dmat3x2" { return token::GT_DMAT3X2; } | |||||
"dmat3x3" { return token::GT_DMAT3X3; } | |||||
"dmat3x4" { return token::GT_DMAT3X4; } | |||||
"dmat4" { return token::GT_DMAT4; } | |||||
"dmat4x2" { return token::GT_DMAT4X2; } | |||||
"dmat4x3" { return token::GT_DMAT4X3; } | |||||
"dmat4x4" { return token::GT_DMAT4X4; } | |||||
/* | |||||
* GLSL constant values | |||||
*/ | |||||
"true" { yylval->ival = 1; return token::BOOLCONSTANT; } | |||||
"false" { yylval->ival = 0; return token::BOOLCONSTANT; } | |||||
[xyzw]{1,4} { return token::FIELDSELECTION; } | |||||
[rgba]{1,4} { return token::FIELDSELECTION; } | |||||
[stpq]{1,4} { return token::FIELDSELECTION; } | |||||
/* | |||||
* GLSL keywords that are also valid or reserved in HLSL | |||||
* and HLSL keywords that are also valid or reserved in GLSL. | |||||
*/ | |||||
"bool" { return token::GHT_BOOL; } | |||||
"break" { return token::GHT_BREAK; } | |||||
"case" { return token::GHT_CASE; } | |||||
"centroid" { return token::GHT_CENTROID; } | |||||
"const" { return token::GHT_CONST; } | |||||
"continue" { return token::GHT_CONTINUE; } | |||||
"default" { return token::GHT_DEFAULT; } | |||||
"discard" { return token::GHT_DISCARD; } | |||||
"do" { return token::GHT_DO; } | |||||
"double" { return token::GHT_DOUBLE; } | |||||
"else" { return token::GHT_ELSE; } | |||||
"float" { return token::GHT_FLOAT; } | |||||
"for" { return token::GHT_FOR; } | |||||
"if" { return token::GHT_IF; } | |||||
"in" { return token::GHT_IN; } | |||||
"inout" { return token::GHT_INOUT; } | |||||
"int" { return token::GHT_INT; } | |||||
"noperspective" { return token::GHT_NOPERSPECTIVE; } | |||||
"out" { return token::GHT_OUT; } | |||||
"return" { return token::GHT_RETURN; } | |||||
"sampler1d" { return token::GHT_SAMPLER1D; } | |||||
"sampler2d" { return token::GHT_SAMPLER2D; } | |||||
"sampler3d" { return token::GHT_SAMPLER3D; } | |||||
"samplercube" { return token::GHT_SAMPLERCUBE; } | |||||
"struct" { return token::GHT_STRUCT; } | |||||
"switch" { return token::GHT_SWITCH; } | |||||
"uint" { return token::GHT_UINT; } | |||||
"uniform" { return token::GHT_UNIFORM; } | |||||
"void" { return token::GHT_VOID; } | |||||
"while" { return token::GHT_WHILE; } | |||||
(?i:bool) { return token::HGT_BOOL; } | |||||
(?i:break) { return token::HGT_BREAK; } | |||||
(?i:case) { return token::HGT_CASE; } | |||||
(?i:centroid) { return token::HGT_CENTROID; } | |||||
(?i:const) { return token::HGT_CONST; } | |||||
(?i:continue) { return token::HGT_CONTINUE; } | |||||
(?i:default) { return token::HGT_DEFAULT; } | |||||
(?i:discard) { return token::HGT_DISCARD; } | |||||
(?i:do) { return token::HGT_DO; } | |||||
(?i:double) { return token::HGT_DOUBLE; } | |||||
(?i:else) { return token::HGT_ELSE; } | |||||
(?i:float) { return token::HGT_FLOAT; } | |||||
(?i:for) { return token::HGT_FOR; } | |||||
(?i:if) { return token::HGT_IF; } | |||||
(?i:in) { return token::HGT_IN; } | |||||
(?i:inout) { return token::HGT_INOUT; } | |||||
(?i:int) { return token::HGT_INT; } | |||||
(?i:noperspective) { return token::HGT_NOPERSPECTIVE; } | |||||
(?i:out) { return token::HGT_OUT; } | |||||
(?i:return) { return token::HGT_RETURN; } | |||||
(?i:sampler1d) { return token::HGT_SAMPLER1D; } | |||||
(?i:sampler2d) { return token::HGT_SAMPLER2D; } | |||||
(?i:sampler3d) { return token::HGT_SAMPLER3D; } | |||||
(?i:samplercube) { return token::HGT_SAMPLERCUBE; } | |||||
(?i:struct) { return token::HGT_STRUCT; } | |||||
(?i:switch) { return token::HGT_SWITCH; } | |||||
(?i:uint) { return token::HGT_UINT; } | |||||
(?i:uniform) { return token::HGT_UNIFORM; } | |||||
(?i:void) { return token::HGT_VOID; } | |||||
(?i:while) { return token::HGT_WHILE; } | |||||
/* | |||||
* HLSL keywords | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509568%28v=vs.85%29.aspx | |||||
*/ | |||||
(?i:appendstructuredbuffer) { return token::HT_APPENDSTRUCTUREDBUFFER; } | |||||
(?i:asm) { return token::HT_ASM; } | |||||
(?i:asm_fragment) { return token::HT_ASM_FRAGMENT; } | |||||
(?i:blendstate) { return token::HT_BLENDSTATE; } | |||||
(?i:buffer) { return token::HT_BUFFER; } | |||||
(?i:byteaddressbuffer) { return token::HT_BYTEADDRESSBUFFER; } | |||||
(?i:cbuffer) { return token::HT_CBUFFER; } | |||||
(?i:column_major) { return token::HT_COLUMN_MAJOR; } | |||||
(?i:compile) { return token::HT_COMPILE; } | |||||
(?i:compile_fragment) { return token::HT_COMPILE_FRAGMENT; } | |||||
(?i:compileshader) { return token::HT_COMPILESHADER; } | |||||
(?i:computeshader) { return token::HT_COMPUTESHADER; } | |||||
(?i:consumestructuredbuffer) { return token::HT_CONSUMESTRUCTUREDBUFFER; } | |||||
(?i:depthstencilstate) { return token::HT_DEPTHSTENCILSTATE; } | |||||
(?i:depthstencilview) { return token::HT_DEPTHSTENCILVIEW; } | |||||
(?i:domainshader) { return token::HT_DOMAINSHADER; } | |||||
(?i:dword) { return token::HT_DWORD; } | |||||
(?i:extern) { return token::HT_EXTERN; } | |||||
(?i:false) { return token::HT_FALSE; } | |||||
(?i:fxgroup) { return token::HT_FXGROUP; } | |||||
(?i:geometryshader) { return token::HT_GEOMETRYSHADER; } | |||||
(?i:groupshared) { return token::HT_GROUPSHARED; } | |||||
(?i:half) { return token::HT_HALF; } | |||||
(?i:hullshader) { return token::HT_HULLSHADER; } | |||||
(?i:inline) { return token::HT_INLINE; } | |||||
(?i:inputpatch) { return token::HT_INPUTPATCH; } | |||||
(?i:interface) { return token::HT_INTERFACE; } | |||||
(?i:line) { return token::HT_LINE; } | |||||
(?i:lineadj) { return token::HT_LINEADJ; } | |||||
(?i:linear) { return token::HT_LINEAR; } | |||||
(?i:linestream) { return token::HT_LINESTREAM; } | |||||
(?i:matrix) { return token::HT_MATRIX; } | |||||
(?i:namespace) { return token::HT_NAMESPACE; } | |||||
(?i:nointerpolation) { return token::HT_NOINTERPOLATION; } | |||||
(?i:null) { return token::HT_NULL; } | |||||
(?i:outputpatch) { return token::HT_OUTPUTPATCH; } | |||||
(?i:packoffset) { return token::HT_PACKOFFSET; } | |||||
(?i:pass) { return token::HT_PASS; } | |||||
(?i:pixelfragment) { return token::HT_PIXELFRAGMENT; } | |||||
(?i:pixelshader) { return token::HT_PIXELSHADER; } | |||||
(?i:point) { return token::HT_POINT; } | |||||
(?i:pointstream) { return token::HT_POINTSTREAM; } | |||||
(?i:precise) { return token::HT_PRECISE; } | |||||
(?i:rasterizerstate) { return token::HT_RASTERIZERSTATE; } | |||||
(?i:rendertargetview) { return token::HT_RENDERTARGETVIEW; } | |||||
(?i:register) { return token::HT_REGISTER; } | |||||
(?i:row_major) { return token::HT_ROW_MAJOR; } | |||||
(?i:rwbuffer) { return token::HT_RWBUFFER; } | |||||
(?i:rwbyteaddressbuffer) { return token::HT_RWBYTEADDRESSBUFFER; } | |||||
(?i:rwstructuredbuffer) { return token::HT_RWSTRUCTUREDBUFFER; } | |||||
(?i:rwtexture1d) { return token::HT_RWTEXTURE1D; } | |||||
(?i:rwtexture1darray) { return token::HT_RWTEXTURE1DARRAY; } | |||||
(?i:rwtexture2d) { return token::HT_RWTEXTURE2D; } | |||||
(?i:rwtexture2darray) { return token::HT_RWTEXTURE2DARRAY; } | |||||
(?i:rwtexture3d) { return token::HT_RWTEXTURE3D; } | |||||
(?i:sampler) { return token::HT_SAMPLER; } | |||||
(?i:sampler_state) { return token::HT_SAMPLER_STATE; } | |||||
(?i:samplerstate) { return token::HT_SAMPLERSTATE; } | |||||
(?i:samplercomparisonstate) { return token::HT_SAMPLERCOMPARISONSTATE; } | |||||
(?i:shared) { return token::HT_SHARED; } | |||||
(?i:snorm) { return token::HT_SNORM; } | |||||
(?i:stateblock) { return token::HT_STATEBLOCK; } | |||||
(?i:stateblock_state) { return token::HT_STATEBLOCK_STATE; } | |||||
(?i:static) { return token::HT_STATIC; } | |||||
(?i:string) { return token::HT_STRING; } | |||||
(?i:structuredbuffer) { return token::HT_STRUCTUREDBUFFER; } | |||||
(?i:tbuffer) { return token::HT_TBUFFER; } | |||||
(?i:technique) { return token::HT_TECHNIQUE; } | |||||
(?i:technique10) { return token::HT_TECHNIQUE10; } | |||||
(?i:technique11xz) { return token::HT_TECHNIQUE11XZ; } | |||||
"texture" { return token::HT_TEXTURE; } | |||||
(?i:texture1d) { return token::HT_TEXTURE1D; } | |||||
(?i:texture1darray) { return token::HT_TEXTURE1DARRAY; } | |||||
(?i:texture2d) { return token::HT_TEXTURE2D; } | |||||
(?i:texture2darray) { return token::HT_TEXTURE2DARRAY; } | |||||
(?i:texture2dms) { return token::HT_TEXTURE2DMS; } | |||||
(?i:texture2dmsarray) { return token::HT_TEXTURE2DMSARRAY; } | |||||
(?i:texture3d) { return token::HT_TEXTURE3D; } | |||||
(?i:texturecube) { return token::HT_TEXTURECUBE; } | |||||
(?i:texturecubearray) { return token::HT_TEXTURECUBEARRAY; } | |||||
(?i:true) { return token::HT_TRUE; } | |||||
(?i:typedef) { return token::HT_TYPEDEF; } | |||||
(?i:triangle) { return token::HT_TRIANGLE; } | |||||
(?i:triangleadj) { return token::HT_TRIANGLEADJ; } | |||||
(?i:trianglestream) { return token::HT_TRIANGLESTREAM; } | |||||
(?i:unorm) { return token::HT_UNORM; } | |||||
(?i:vector) { return token::HT_VECTOR; } | |||||
(?i:vertexfragment) { return token::HT_VERTEXFRAGMENT; } | |||||
(?i:vertexshader) { return token::HT_VERTEXSHADER; } | |||||
(?i:volatile) { return token::HT_VOLATILE; } | |||||
/* | |||||
* HLSL vector types | |||||
* TODO: this can probably be factored somehow | |||||
*/ | |||||
(?i:bool1) { return token::HT_BOOL1; } | |||||
(?i:bool1x1) { return token::HT_BOOL1x1; } | |||||
(?i:bool2x1) { return token::HT_BOOL2x1; } | |||||
(?i:bool3x1) { return token::HT_BOOL3x1; } | |||||
(?i:bool4x1) { return token::HT_BOOL4x1; } | |||||
(?i:bool2) { return token::HT_BOOL2; } | |||||
(?i:bool1x2) { return token::HT_BOOL1x2; } | |||||
(?i:bool2x2) { return token::HT_BOOL2x2; } | |||||
(?i:bool3x2) { return token::HT_BOOL3x2; } | |||||
(?i:bool4x2) { return token::HT_BOOL4x2; } | |||||
(?i:bool3) { return token::HT_BOOL3; } | |||||
(?i:bool1x3) { return token::HT_BOOL1x3; } | |||||
(?i:bool2x3) { return token::HT_BOOL2x3; } | |||||
(?i:bool3x3) { return token::HT_BOOL3x3; } | |||||
(?i:bool4x3) { return token::HT_BOOL4x3; } | |||||
(?i:bool4) { return token::HT_BOOL4; } | |||||
(?i:bool1x4) { return token::HT_BOOL1x4; } | |||||
(?i:bool2x4) { return token::HT_BOOL2x4; } | |||||
(?i:bool3x4) { return token::HT_BOOL3x4; } | |||||
(?i:bool4x4) { return token::HT_BOOL4x4; } | |||||
(?i:float1) { return token::HT_FLOAT1; } | |||||
(?i:float1x1) { return token::HT_FLOAT1x1; } | |||||
(?i:float2x1) { return token::HT_FLOAT2x1; } | |||||
(?i:float3x1) { return token::HT_FLOAT3x1; } | |||||
(?i:float4x1) { return token::HT_FLOAT4x1; } | |||||
(?i:float2) { return token::HT_FLOAT2; } | |||||
(?i:float1x2) { return token::HT_FLOAT1x2; } | |||||
(?i:float2x2) { return token::HT_FLOAT2x2; } | |||||
(?i:float3x2) { return token::HT_FLOAT3x2; } | |||||
(?i:float4x2) { return token::HT_FLOAT4x2; } | |||||
(?i:float3) { return token::HT_FLOAT3; } | |||||
(?i:float1x3) { return token::HT_FLOAT1x3; } | |||||
(?i:float2x3) { return token::HT_FLOAT2x3; } | |||||
(?i:float3x3) { return token::HT_FLOAT3x3; } | |||||
(?i:float4x3) { return token::HT_FLOAT4x3; } | |||||
(?i:float4) { return token::HT_FLOAT4; } | |||||
(?i:float1x4) { return token::HT_FLOAT1x4; } | |||||
(?i:float2x4) { return token::HT_FLOAT2x4; } | |||||
(?i:float3x4) { return token::HT_FLOAT3x4; } | |||||
(?i:float4x4) { return token::HT_FLOAT4x4; } | |||||
(?i:double1) { return token::HT_DOUBLE1; } | |||||
(?i:double1x1) { return token::HT_DOUBLE1x1; } | |||||
(?i:double2x1) { return token::HT_DOUBLE2x1; } | |||||
(?i:double3x1) { return token::HT_DOUBLE3x1; } | |||||
(?i:double4x1) { return token::HT_DOUBLE4x1; } | |||||
(?i:double2) { return token::HT_DOUBLE2; } | |||||
(?i:double1x2) { return token::HT_DOUBLE1x2; } | |||||
(?i:double2x2) { return token::HT_DOUBLE2x2; } | |||||
(?i:double3x2) { return token::HT_DOUBLE3x2; } | |||||
(?i:double4x2) { return token::HT_DOUBLE4x2; } | |||||
(?i:double3) { return token::HT_DOUBLE3; } | |||||
(?i:double1x3) { return token::HT_DOUBLE1x3; } | |||||
(?i:double2x3) { return token::HT_DOUBLE2x3; } | |||||
(?i:double3x3) { return token::HT_DOUBLE3x3; } | |||||
(?i:double4x3) { return token::HT_DOUBLE4x3; } | |||||
(?i:double4) { return token::HT_DOUBLE4; } | |||||
(?i:double1x4) { return token::HT_DOUBLE1x4; } | |||||
(?i:double2x4) { return token::HT_DOUBLE2x4; } | |||||
(?i:double3x4) { return token::HT_DOUBLE3x4; } | |||||
(?i:double4x4) { return token::HT_DOUBLE4x4; } | |||||
(?i:dword1) { return token::HT_DWORD1; } | |||||
(?i:dword1x1) { return token::HT_DWORD1x1; } | |||||
(?i:dword2x1) { return token::HT_DWORD2x1; } | |||||
(?i:dword3x1) { return token::HT_DWORD3x1; } | |||||
(?i:dword4x1) { return token::HT_DWORD4x1; } | |||||
(?i:dword2) { return token::HT_DWORD2; } | |||||
(?i:dword1x2) { return token::HT_DWORD1x2; } | |||||
(?i:dword2x2) { return token::HT_DWORD2x2; } | |||||
(?i:dword3x2) { return token::HT_DWORD3x2; } | |||||
(?i:dword4x2) { return token::HT_DWORD4x2; } | |||||
(?i:dword3) { return token::HT_DWORD3; } | |||||
(?i:dword1x3) { return token::HT_DWORD1x3; } | |||||
(?i:dword2x3) { return token::HT_DWORD2x3; } | |||||
(?i:dword3x3) { return token::HT_DWORD3x3; } | |||||
(?i:dword4x3) { return token::HT_DWORD4x3; } | |||||
(?i:dword4) { return token::HT_DWORD4; } | |||||
(?i:dword1x4) { return token::HT_DWORD1x4; } | |||||
(?i:dword2x4) { return token::HT_DWORD2x4; } | |||||
(?i:dword3x4) { return token::HT_DWORD3x4; } | |||||
(?i:dword4x4) { return token::HT_DWORD4x4; } | |||||
(?i:int1) { return token::HT_INT1; } | |||||
(?i:int1x1) { return token::HT_INT1x1; } | |||||
(?i:int2x1) { return token::HT_INT2x1; } | |||||
(?i:int3x1) { return token::HT_INT3x1; } | |||||
(?i:int4x1) { return token::HT_INT4x1; } | |||||
(?i:int2) { return token::HT_INT2; } | |||||
(?i:int1x2) { return token::HT_INT1x2; } | |||||
(?i:int2x2) { return token::HT_INT2x2; } | |||||
(?i:int3x2) { return token::HT_INT3x2; } | |||||
(?i:int4x2) { return token::HT_INT4x2; } | |||||
(?i:int3) { return token::HT_INT3; } | |||||
(?i:int1x3) { return token::HT_INT1x3; } | |||||
(?i:int2x3) { return token::HT_INT2x3; } | |||||
(?i:int3x3) { return token::HT_INT3x3; } | |||||
(?i:int4x3) { return token::HT_INT4x3; } | |||||
(?i:int4) { return token::HT_INT4; } | |||||
(?i:int1x4) { return token::HT_INT1x4; } | |||||
(?i:int2x4) { return token::HT_INT2x4; } | |||||
(?i:int3x4) { return token::HT_INT3x4; } | |||||
(?i:int4x4) { return token::HT_INT4x4; } | |||||
(?i:uint1) { return token::HT_UINT1; } | |||||
(?i:uint1x1) { return token::HT_UINT1x1; } | |||||
(?i:uint2x1) { return token::HT_UINT2x1; } | |||||
(?i:uint3x1) { return token::HT_UINT3x1; } | |||||
(?i:uint4x1) { return token::HT_UINT4x1; } | |||||
(?i:uint2) { return token::HT_UINT2; } | |||||
(?i:uint1x2) { return token::HT_UINT1x2; } | |||||
(?i:uint2x2) { return token::HT_UINT2x2; } | |||||
(?i:uint3x2) { return token::HT_UINT3x2; } | |||||
(?i:uint4x2) { return token::HT_UINT4x2; } | |||||
(?i:uint3) { return token::HT_UINT3; } | |||||
(?i:uint1x3) { return token::HT_UINT1x3; } | |||||
(?i:uint2x3) { return token::HT_UINT2x3; } | |||||
(?i:uint3x3) { return token::HT_UINT3x3; } | |||||
(?i:uint4x3) { return token::HT_UINT4x3; } | |||||
(?i:uint4) { return token::HT_UINT4; } | |||||
(?i:uint1x4) { return token::HT_UINT1x4; } | |||||
(?i:uint2x4) { return token::HT_UINT2x4; } | |||||
(?i:uint3x4) { return token::HT_UINT3x4; } | |||||
(?i:uint4x4) { return token::HT_UINT4x4; } | |||||
/* | |||||
* HLSL preprocessor directives | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb943993%28v=vs.85%29.aspx | |||||
*/ | |||||
"#"[ \t]*"define" { return token::PREPROCESSOR_DEFINE; } | |||||
"#"[ \t]*"elif" { return token::PREPROCESSOR_ELIF; } | |||||
"#"[ \t]*"else" { return token::PREPROCESSOR_ELSE; } | |||||
"#"[ \t]*"endif" { return token::PREPROCESSOR_ENDIF; } | |||||
"#"[ \t]*"error" { return token::PREPROCESSOR_ERROR; } | |||||
"#"[ \t]*"if" { return token::PREPROCESSOR_IF; } | |||||
"#"[ \t]*"ifdef" { return token::PREPROCESSOR_IFDEF; } | |||||
"#"[ \t]*"ifndef" { return token::PREPROCESSOR_IFNDEF; } | |||||
"#"[ \t]*"include" { return token::PREPROCESSOR_INCLUDE; } | |||||
"#"[ \t]*"line" { return token::PREPROCESSOR_LINE; } | |||||
"#"[ \t]*"pragma" { return token::PREPROCESSOR_PRAGMA; } | |||||
"#"[ \t]*"undef" { return token::PREPROCESSOR_UNDEF; } | |||||
/* | |||||
* GLSL preprocessor directives | |||||
*/ | |||||
"#"[ \t]*"version".* { /* ignore for now */ } | |||||
/* | |||||
* LolFx preprocessor directives | |||||
*/ | |||||
"#"[ \t]*(?i:pragma)[ \t]*(?i:lolfx) { return token::PRAGMA_LOLFX; } | |||||
/* | |||||
* HLSL reserved keywords | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509569%28v=vs.85%29.aspx | |||||
*/ | |||||
(?i:auto) { return token::HT_AUTO; } | |||||
(?i:catch) { return token::HT_CATCH; } | |||||
(?i:char) { return token::HT_CHAR; } | |||||
(?i:class) { return token::HT_CLASS; } | |||||
(?i:const_cast) { return token::HT_CONST_CAST; } | |||||
(?i:delete) { return token::HT_DELETE; } | |||||
(?i:dynamic_cast) { return token::HT_DYNAMIC_CAST; } | |||||
(?i:enum) { return token::HT_ENUM; } | |||||
(?i:explicit) { return token::HT_EXPLICIT; } | |||||
(?i:friend) { return token::HT_FRIEND; } | |||||
(?i:goto) { return token::HT_GOTO; } | |||||
(?i:long) { return token::HT_LONG; } | |||||
(?i:mutable) { return token::HT_MUTABLE; } | |||||
(?i:new) { return token::HT_NEW; } | |||||
(?i:operator) { return token::HT_OPERATOR; } | |||||
(?i:private) { return token::HT_PRIVATE; } | |||||
(?i:protected) { return token::HT_PROTECTED; } | |||||
(?i:public) { return token::HT_PUBLIC; } | |||||
(?i:reinterpret_cast) { return token::HT_REINTERPRET_CAST; } | |||||
(?i:short) { return token::HT_SHORT; } | |||||
(?i:signed) { return token::HT_SIGNED; } | |||||
(?i:sizeof) { return token::HT_SIZEOF; } | |||||
(?i:static_cast) { return token::HT_STATIC_CAST; } | |||||
(?i:template) { return token::HT_TEMPLATE; } | |||||
(?i:this) { return token::HT_THIS; } | |||||
(?i:throw) { return token::HT_THROW; } | |||||
(?i:try) { return token::HT_TRY; } | |||||
(?i:typename) { return token::HT_TYPENAME; } | |||||
(?i:union) { return token::HT_UNION; } | |||||
(?i:unsigned) { return token::HT_UNSIGNED; } | |||||
(?i:using) { return token::HT_USING; } | |||||
(?i:virtual) { return token::HT_VIRTUAL; } | |||||
/* | |||||
* Various tokens | |||||
*/ | |||||
"++" { return token::T_INC; } | |||||
"--" { return token::T_DEC; } | |||||
"<=" { return token::T_LE; } | |||||
">=" { return token::T_GE; } | |||||
"==" { return token::T_EQ; } | |||||
"!=" { return token::T_NE; } | |||||
"<<" { return token::T_LEFT; } | |||||
">>" { return token::T_RIGHT; } | |||||
"&&" { return token::T_AND; } | |||||
"||" { return token::T_OR; } | |||||
"^^" { return token::T_XOR; } | |||||
"*=" { return token::T_MULEQ; } | |||||
"/=" { return token::T_DIVEQ; } | |||||
"%=" { return token::T_MODEQ; } | |||||
"+=" { return token::T_ADDEQ; } | |||||
"-=" { return token::T_SUBEQ; } | |||||
"<<=" { return token::T_LEFTEQ; } | |||||
">>=" { return token::T_RIGHTEQ; } | |||||
"&=" { return token::T_ANDEQ; } | |||||
"^=" { return token::T_XOREQ; } | |||||
"|=" { return token::T_OREQ; } | |||||
(0|[1-9][0-9]*)\.[0-9]+ { | |||||
yylval->fval = std::atof(yytext); | |||||
return token::FLOATCONSTANT; | |||||
} | |||||
(0|[1-9][0-9]*)[uU] { | |||||
yylval->uval = std::atoi(yytext); | |||||
return token::UINTCONSTANT; | |||||
} | |||||
(0|[1-9][0-9]*) { | |||||
yylval->ival = std::atoi(yytext); | |||||
return token::INTCONSTANT; | |||||
} | |||||
[a-zA-Z][a-zA-Z0-9_]* { | |||||
/* Copy token for now */ | |||||
yylval->sval = strdup(yytext); | |||||
return token::IDENTIFIER; | |||||
} | |||||
[ \t]+ { /* ignore whitespace */ } | |||||
[\n] { ++yylineno; } | |||||
. { return token::T_ERROR; } | |||||
/* | |||||
* Ignore C comments | |||||
*/ | |||||
"/*" { BEGIN(C_COMMENT); } | |||||
<C_COMMENT>"*/" { BEGIN(INITIAL); } | |||||
<C_COMMENT>[^*\n]* { } | |||||
<C_COMMENT>\n { ++yylineno; } | |||||
<C_COMMENT>. { } | |||||
/* | |||||
* Ignore C++ comments | |||||
*/ | |||||
"//" { BEGIN(CPP_COMMENT); } | |||||
<CPP_COMMENT>\n { ++yylineno; BEGIN(INITIAL); } | |||||
<CPP_COMMENT>.* { } | |||||
%% | |||||
lol::LolFxScanner::LolFxScanner(char const *command) | |||||
: LolFxFlexLexer(0, 0), | |||||
m_input(command) | |||||
{ | |||||
} | |||||
lol::LolFxScanner::~LolFxScanner() | |||||
{ | |||||
} | |||||
int lol::LolFxScanner::LexerInput(char* buf, int max_size) | |||||
{ | |||||
buf[0] = m_input[0]; | |||||
if (buf[0]) | |||||
++m_input; | |||||
return buf[0] ? 1 : 0; | |||||
} | |||||
#ifdef yylex | |||||
#undef yylex | |||||
#endif | |||||
int LolFxFlexLexer::yylex() | |||||
{ | |||||
std::cerr << "in LolFxFlexLexer::yylex() !" << std::endl; | |||||
return 0; | |||||
} | |||||
int LolFxFlexLexer::yywrap() | |||||
{ | |||||
return 1; | |||||
} | |||||
@@ -32,69 +32,68 @@ technique Foo | |||||
alphaop[1] = disable; | alphaop[1] = disable; | ||||
// Ye old way | // Ye old way | ||||
vertexshader = ... | |||||
geometryshader = ... | |||||
pixelshader = ... | |||||
vertexshader = blah; | |||||
geometryshader = blah; | |||||
pixelshader = blah; | |||||
// Ogre crap | // Ogre crap | ||||
// The D3D11 way, but we must make it work with GLSL too | // The D3D11 way, but we must make it work with GLSL too | ||||
SetBlendState(AdditiveBlending, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF); | |||||
SetDepthStencilState(DisableDepth, 0); | |||||
SetRasterizerState() | |||||
SetVertexShader | |||||
SetDomainShader | |||||
SetHullShader | |||||
SetGeometryShader | |||||
SetPixelShader | |||||
SetComputeShader /* WTF? */ | |||||
SetRenderTargets(RTV0, DSV); | |||||
SetRenderTargets(RTV0, RTV1, DSV); | |||||
... | |||||
SetRenderTargets(RTV0, RTV1, RTV2, RTV3, RTV4, RTV5, RTV6, RTV7, DSV); | |||||
//SetBlendState(AdditiveBlending, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF); | |||||
//SetDepthStencilState(DisableDepth, 0); | |||||
//SetRasterizerState() | |||||
//SetVertexShader | |||||
//SetDomainShader | |||||
//SetHullShader | |||||
//SetGeometryShader | |||||
//SetPixelShader | |||||
//SetComputeShader /* WTF? */ | |||||
//SetRenderTargets(RTV0, DSV); | |||||
//SetRenderTargets(RTV0, RTV1, DSV); | |||||
//... | |||||
//SetRenderTargets(RTV0, RTV1, RTV2, RTV3, RTV4, RTV5, RTV6, RTV7, DSV); | |||||
} | } | ||||
pass p1 | pass p1 | ||||
{ | { | ||||
// Autres vertex/pixel shaders avec éventuellement des | // Autres vertex/pixel shaders avec éventuellement des | ||||
// dépendances sur le résultat des passes précédentes | // dépendances sur le résultat des passes précédentes | ||||
vertexshader = ... | |||||
vertexshader = something_else; | |||||
} | } | ||||
} | } | ||||
/* Defines GLSL shader "Prout" */ | /* Defines GLSL shader "Prout" */ | ||||
#section GLSL.Prout | |||||
#pragma lolfx vertexshader(lang=GLSL 1.20, name=prout) | |||||
#version 120 | #version 120 | ||||
/* Valid with my GLSL compiler */ | /* Valid with my GLSL compiler */ | ||||
#pragma lolfx semantic(in_Vertex, POSITION) | |||||
#pragma lolfx semantic(in_Normal, NORMAL) | |||||
#pragma lolfx semantic(in_Color, COLOR) | |||||
//#pragma lolfx semantic(in_Vertex, POSITION) | |||||
//#pragma lolfx semantic(in_Normal, NORMAL) | |||||
//#pragma lolfx semantic(in_Color, COLOR) | |||||
attribute vec3 in_Vertex; | attribute vec3 in_Vertex; | ||||
attribute vec3 in_Normal; | attribute vec3 in_Normal; | ||||
attribute vec4 in_Color; | attribute vec4 in_Color; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
... | |||||
/* ... */ | |||||
} | } | ||||
/* Defines GLSL shader "Zob" */ | /* Defines GLSL shader "Zob" */ | ||||
#section GLSL.Zob | |||||
#pragma lolfx vertexshader(lang=GLSL 1.20, name=zob) | |||||
void main(void) | void main(void) | ||||
{ | { | ||||
shit fuck fuck shit; | |||||
shit(); fuck(); fuck(); shit(); | |||||
} | } | ||||
/* Defines HLSL shader "Prout" */ | |||||
/* Defines HLSL vertex shader "Prout" */ | |||||
#section HLSL.Prout | |||||
#pragma lolfx vertexshader(lang=HLSL, name=prout) | |||||
void main(void) | void main(void) | ||||
{ | { | ||||
@@ -249,8 +249,11 @@ | |||||
<ClCompile Include="forge.cpp" /> | <ClCompile Include="forge.cpp" /> | ||||
<ClCompile Include="generated\easymesh-parser.cpp" /> | <ClCompile Include="generated\easymesh-parser.cpp" /> | ||||
<ClCompile Include="generated\easymesh-scanner.cpp" /> | <ClCompile Include="generated\easymesh-scanner.cpp" /> | ||||
<ClCompile Include="generated\lolfx-parser.cpp" /> | |||||
<ClCompile Include="generated\lolfx-scanner.cpp" /> | |||||
<ClCompile Include="gpu\framebuffer.cpp" /> | <ClCompile Include="gpu\framebuffer.cpp" /> | ||||
<ClCompile Include="gpu\indexbuffer.cpp" /> | <ClCompile Include="gpu\indexbuffer.cpp" /> | ||||
<ClCompile Include="gpu\lolfx-compiler.cpp" /> | |||||
<ClCompile Include="gpu\shader.cpp" /> | <ClCompile Include="gpu\shader.cpp" /> | ||||
<ClCompile Include="gpu\vertexbuffer.cpp" /> | <ClCompile Include="gpu\vertexbuffer.cpp" /> | ||||
<ClCompile Include="gradient.cpp" /> | <ClCompile Include="gradient.cpp" /> | ||||
@@ -561,10 +564,12 @@ | |||||
<ClInclude Include="forge.h" /> | <ClInclude Include="forge.h" /> | ||||
<ClInclude Include="generated\easymesh-parser.h" /> | <ClInclude Include="generated\easymesh-parser.h" /> | ||||
<ClInclude Include="generated\location.hh" /> | <ClInclude Include="generated\location.hh" /> | ||||
<ClInclude Include="generated\lolfx-parser.h" /> | |||||
<ClInclude Include="generated\position.hh" /> | <ClInclude Include="generated\position.hh" /> | ||||
<ClInclude Include="generated\stack.hh" /> | <ClInclude Include="generated\stack.hh" /> | ||||
<ClInclude Include="gpu\framebuffer.h" /> | <ClInclude Include="gpu\framebuffer.h" /> | ||||
<ClInclude Include="gpu\indexbuffer.h" /> | <ClInclude Include="gpu\indexbuffer.h" /> | ||||
<ClInclude Include="gpu\lolfx-compiler.h" /> | |||||
<ClInclude Include="gpu\shader.h" /> | <ClInclude Include="gpu\shader.h" /> | ||||
<ClInclude Include="gpu\vertexbuffer.h" /> | <ClInclude Include="gpu\vertexbuffer.h" /> | ||||
<ClInclude Include="gradient.h" /> | <ClInclude Include="gradient.h" /> | ||||
@@ -621,6 +626,8 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<None Include="easymesh\easymesh-parser.y" /> | <None Include="easymesh\easymesh-parser.y" /> | ||||
<None Include="easymesh\easymesh-scanner.l" /> | <None Include="easymesh\easymesh-scanner.l" /> | ||||
<None Include="gpu\lolfx-parser.y" /> | |||||
<None Include="gpu\lolfx-scanner.l" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
<ImportGroup Label="ExtensionTargets"> | <ImportGroup Label="ExtensionTargets"> | ||||
@@ -241,6 +241,12 @@ | |||||
<ClCompile Include="generated\easymesh-scanner.cpp"> | <ClCompile Include="generated\easymesh-scanner.cpp"> | ||||
<Filter>src\generated</Filter> | <Filter>src\generated</Filter> | ||||
</ClCompile> | </ClCompile> | ||||
<ClCompile Include="generated\lolfx-parser.cpp"> | |||||
<Filter>src\generated</Filter> | |||||
</ClCompile> | |||||
<ClCompile Include="generated\lolfx-scanner.cpp"> | |||||
<Filter>src\generated</Filter> | |||||
</ClCompile> | |||||
<ClCompile Include="platform\ps3\ps3app.cpp"> | <ClCompile Include="platform\ps3\ps3app.cpp"> | ||||
<Filter>src\platform\ps3</Filter> | <Filter>src\platform\ps3</Filter> | ||||
</ClCompile> | </ClCompile> | ||||
@@ -1583,4 +1589,4 @@ | |||||
<Filter>src\easymesh</Filter> | <Filter>src\easymesh</Filter> | ||||
</None> | </None> | ||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | |||||
</Project> |
@@ -1,4 +0,0 @@ | |||||
lex.yy.c | |||||
lolfx.tab.c | |||||
lolfx.tab.h | |||||
parser |
@@ -1,12 +0,0 @@ | |||||
parser: lex.yy.c lolfx.tab.c | |||||
$(CXX) $^ -o $@ -lfl | |||||
lolfx.tab.c: lolfx.y | |||||
bison -d $^ | |||||
lex.yy.c: lolfx.l | |||||
flex -d $^ | |||||
clean: | |||||
rm -f lex.yy.c lolfx.tab.c lolfx.tab.h parser |
@@ -1,561 +0,0 @@ | |||||
%{ | |||||
#include <iostream> | |||||
#define YY_DECL extern "C" int yylex() | |||||
#include "lolfx.tab.h" | |||||
%} | |||||
%x GLSL | |||||
%x HLSL | |||||
%x C_COMMENT | |||||
%x CPP_COMMENT | |||||
%% | |||||
%{ | |||||
int comment_caller = INITIAL; | |||||
%} | |||||
/* | |||||
* GLSL keywords | |||||
*/ | |||||
"subroutine" { return GT_SUBROUTINE; } | |||||
"patch" { return GT_PATCH; } | |||||
"sample" { return GT_SAMPLE; } | |||||
"flat" { return GT_FLAT; } | |||||
"smooth" { return GT_SMOOTH; } | |||||
"layout" { return GT_LAYOUT; } | |||||
"sampler1dshadow" { return GT_SAMPLER1DSHADOW; } | |||||
"sampler2dshadow" { return GT_SAMPLER2DSHADOW; } | |||||
"samplercubeshadow" { return GT_SAMPLERCUBESHADOW; } | |||||
"sampler1darray" { return GT_SAMPLER1DARRAY; } | |||||
"sampler2darray" { return GT_SAMPLER2DARRAY; } | |||||
"sampler1darrayshadow" { return GT_SAMPLER1DARRAYSHADOW; } | |||||
"sampler2darrayshadow" { return GT_SAMPLER2DARRAYSHADOW; } | |||||
"isampler1d" { return GT_ISAMPLER1D; } | |||||
"isampler2d" { return GT_ISAMPLER2D; } | |||||
"isampler3d" { return GT_ISAMPLER3D; } | |||||
"isamplercube" { return GT_ISAMPLERCUBE; } | |||||
"isampler1darray" { return GT_ISAMPLER1DARRAY; } | |||||
"isampler2darray" { return GT_ISAMPLER2DARRAY; } | |||||
"usampler1d" { return GT_USAMPLER1D; } | |||||
"usampler2d" { return GT_USAMPLER2D; } | |||||
"usampler3d" { return GT_USAMPLER3D; } | |||||
"usamplercube" { return GT_USAMPLERCUBE; } | |||||
"usampler1darray" { return GT_USAMPLER1DARRAY; } | |||||
"usampler2darray" { return GT_USAMPLER2DARRAY; } | |||||
"sampler2drect" { return GT_SAMPLER2DRECT; } | |||||
"sampler2drectshadow" { return GT_SAMPLER2DRECTSHADOW; } | |||||
"isampler2drect" { return GT_ISAMPLER2DRECT; } | |||||
"usampler2drect" { return GT_USAMPLER2DRECT; } | |||||
"samplerbuffer" { return GT_SAMPLERBUFFER; } | |||||
"isamplerbuffer" { return GT_ISAMPLERBUFFER; } | |||||
"usamplerbuffer" { return GT_USAMPLERBUFFER; } | |||||
"samplercubearray" { return GT_SAMPLERCUBEARRAY; } | |||||
"samplercubearrayshadow" { return GT_SAMPLERCUBEARRAYSHADOW; } | |||||
"isamplercubearray" { return GT_ISAMPLERCUBEARRAY; } | |||||
"usamplercubearray" { return GT_USAMPLERCUBEARRAY; } | |||||
"sampler2dms" { return GT_SAMPLER2DMS; } | |||||
"isampler2dms" { return GT_ISAMPLER2DMS; } | |||||
"usampler2dms" { return GT_USAMPLER2DMS; } | |||||
"sampler2dmsarray" { return GT_SAMPLER2DMSARRAY; } | |||||
"isampler2dmsarray" { return GT_ISAMPLER2DMSARRAY; } | |||||
"usampler2dmsarray" { return GT_USAMPLER2DMSARRAY; } | |||||
"highp" { return GT_HIGHP; } | |||||
"mediump" { return GT_MEDIUMP; } | |||||
"lowp" { return GT_LOWP; } | |||||
"precision" { return GT_PRECISION; } | |||||
"invariant" { return GT_INVARIANT; } | |||||
/* | |||||
* Deprecated GLSL keywords | |||||
*/ | |||||
"attribute" { return GT_ATTRIBUTE; } | |||||
/* | |||||
* GLSL vector types | |||||
*/ | |||||
"bvec2" { return GT_BVEC2; } | |||||
"bvec3" { return GT_BVEC3; } | |||||
"bvec4" { return GT_BVEC4; } | |||||
"ivec2" { return GT_IVEC2; } | |||||
"ivec3" { return GT_IVEC3; } | |||||
"ivec4" { return GT_IVEC4; } | |||||
"uvec2" { return GT_UVEC2; } | |||||
"uvec3" { return GT_UVEC3; } | |||||
"uvec4" { return GT_UVEC4; } | |||||
"vec2" { return GT_VEC2; } | |||||
"vec3" { return GT_VEC3; } | |||||
"vec4" { return GT_VEC4; } | |||||
"mat2" { return GT_MAT2; } | |||||
"mat2x2" { return GT_MAT2X2; } | |||||
"mat2x3" { return GT_MAT2X3; } | |||||
"mat2x4" { return GT_MAT2X4; } | |||||
"mat3" { return GT_MAT3; } | |||||
"mat3x2" { return GT_MAT3X2; } | |||||
"mat3x3" { return GT_MAT3X3; } | |||||
"mat3x4" { return GT_MAT3X4; } | |||||
"mat4" { return GT_MAT4; } | |||||
"mat4x2" { return GT_MAT4X2; } | |||||
"mat4x3" { return GT_MAT4X3; } | |||||
"mat4x4" { return GT_MAT4X4; } | |||||
"dvec2" { return GT_DVEC2; } | |||||
"dvec3" { return GT_DVEC3; } | |||||
"dvec4" { return GT_DVEC4; } | |||||
"dmat2" { return GT_DMAT2; } | |||||
"dmat2x2" { return GT_DMAT2X2; } | |||||
"dmat2x3" { return GT_DMAT2X3; } | |||||
"dmat2x4" { return GT_DMAT2X4; } | |||||
"dmat3" { return GT_DMAT3; } | |||||
"dmat3x2" { return GT_DMAT3X2; } | |||||
"dmat3x3" { return GT_DMAT3X3; } | |||||
"dmat3x4" { return GT_DMAT3X4; } | |||||
"dmat4" { return GT_DMAT4; } | |||||
"dmat4x2" { return GT_DMAT4X2; } | |||||
"dmat4x3" { return GT_DMAT4X3; } | |||||
"dmat4x4" { return GT_DMAT4X4; } | |||||
/* | |||||
* GLSL constant values | |||||
*/ | |||||
"true" { yylval.ival = 1; return BOOLCONSTANT; } | |||||
"false" { yylval.ival = 0; return BOOLCONSTANT; } | |||||
[xyzw]{1,4} { return FIELDSELECTION; } | |||||
[rgba]{1,4} { return FIELDSELECTION; } | |||||
[stpq]{1,4} { return FIELDSELECTION; } | |||||
/* | |||||
* GLSL keywords that are also valid or reserved in HLSL | |||||
* and HLSL keywords that are also valid or reserved in GLSL. | |||||
*/ | |||||
"bool" { return GHT_BOOL; } | |||||
"break" { return GHT_BREAK; } | |||||
"case" { return GHT_CASE; } | |||||
"centroid" { return GHT_CENTROID; } | |||||
"const" { return GHT_CONST; } | |||||
"continue" { return GHT_CONTINUE; } | |||||
"default" { return GHT_DEFAULT; } | |||||
"discard" { return GHT_DISCARD; } | |||||
"do" { return GHT_DO; } | |||||
"double" { return GHT_DOUBLE; } | |||||
"else" { return GHT_ELSE; } | |||||
"float" { return GHT_FLOAT; } | |||||
"for" { return GHT_FOR; } | |||||
"if" { return GHT_IF; } | |||||
"in" { return GHT_IN; } | |||||
"inout" { return GHT_INOUT; } | |||||
"int" { return GHT_INT; } | |||||
"noperspective" { return GHT_NOPERSPECTIVE; } | |||||
"out" { return GHT_OUT; } | |||||
"return" { return GHT_RETURN; } | |||||
"sampler1d" { return GHT_SAMPLER1D; } | |||||
"sampler2d" { return GHT_SAMPLER2D; } | |||||
"sampler3d" { return GHT_SAMPLER3D; } | |||||
"samplercube" { return GHT_SAMPLERCUBE; } | |||||
"struct" { return GHT_STRUCT; } | |||||
"switch" { return GHT_SWITCH; } | |||||
"uint" { return GHT_UINT; } | |||||
"uniform" { return GHT_UNIFORM; } | |||||
"void" { return GHT_VOID; } | |||||
"while" { return GHT_WHILE; } | |||||
(?i:bool) { return HGT_BOOL; } | |||||
(?i:break) { return HGT_BREAK; } | |||||
(?i:case) { return HGT_CASE; } | |||||
(?i:centroid) { return HGT_CENTROID; } | |||||
(?i:const) { return HGT_CONST; } | |||||
(?i:continue) { return HGT_CONTINUE; } | |||||
(?i:default) { return HGT_DEFAULT; } | |||||
(?i:discard) { return HGT_DISCARD; } | |||||
(?i:do) { return HGT_DO; } | |||||
(?i:double) { return HGT_DOUBLE; } | |||||
(?i:else) { return HGT_ELSE; } | |||||
(?i:float) { return HGT_FLOAT; } | |||||
(?i:for) { return HGT_FOR; } | |||||
(?i:if) { return HGT_IF; } | |||||
(?i:in) { return HGT_IN; } | |||||
(?i:inout) { return HGT_INOUT; } | |||||
(?i:int) { return HGT_INT; } | |||||
(?i:noperspective) { return HGT_NOPERSPECTIVE; } | |||||
(?i:out) { return HGT_OUT; } | |||||
(?i:return) { return HGT_RETURN; } | |||||
(?i:sampler1d) { return HGT_SAMPLER1D; } | |||||
(?i:sampler2d) { return HGT_SAMPLER2D; } | |||||
(?i:sampler3d) { return HGT_SAMPLER3D; } | |||||
(?i:samplercube) { return HGT_SAMPLERCUBE; } | |||||
(?i:struct) { return HGT_STRUCT; } | |||||
(?i:switch) { return HGT_SWITCH; } | |||||
(?i:uint) { return HGT_UINT; } | |||||
(?i:uniform) { return HGT_UNIFORM; } | |||||
(?i:void) { return HGT_VOID; } | |||||
(?i:while) { return HGT_WHILE; } | |||||
/* | |||||
* HLSL keywords | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509568%28v=vs.85%29.aspx | |||||
*/ | |||||
(?i:appendstructuredbuffer) { return HT_APPENDSTRUCTUREDBUFFER; } | |||||
(?i:asm) { return HT_ASM; } | |||||
(?i:asm_fragment) { return HT_ASM_FRAGMENT; } | |||||
(?i:blendstate) { return HT_BLENDSTATE; } | |||||
(?i:buffer) { return HT_BUFFER; } | |||||
(?i:byteaddressbuffer) { return HT_BYTEADDRESSBUFFER; } | |||||
(?i:cbuffer) { return HT_CBUFFER; } | |||||
(?i:column_major) { return HT_COLUMN_MAJOR; } | |||||
(?i:compile) { return HT_COMPILE; } | |||||
(?i:compile_fragment) { return HT_COMPILE_FRAGMENT; } | |||||
(?i:compileshader) { return HT_COMPILESHADER; } | |||||
(?i:computeshader) { return HT_COMPUTESHADER; } | |||||
(?i:consumestructuredbuffer) { return HT_CONSUMESTRUCTUREDBUFFER; } | |||||
(?i:depthstencilstate) { return HT_DEPTHSTENCILSTATE; } | |||||
(?i:depthstencilview) { return HT_DEPTHSTENCILVIEW; } | |||||
(?i:domainshader) { return HT_DOMAINSHADER; } | |||||
(?i:dword) { return HT_DWORD; } | |||||
(?i:extern) { return HT_EXTERN; } | |||||
(?i:false) { return HT_FALSE; } | |||||
(?i:fxgroup) { return HT_FXGROUP; } | |||||
(?i:geometryshader) { return HT_GEOMETRYSHADER; } | |||||
(?i:groupshared) { return HT_GROUPSHARED; } | |||||
(?i:half) { return HT_HALF; } | |||||
(?i:hullshader) { return HT_HULLSHADER; } | |||||
(?i:inline) { return HT_INLINE; } | |||||
(?i:inputpatch) { return HT_INPUTPATCH; } | |||||
(?i:interface) { return HT_INTERFACE; } | |||||
(?i:line) { return HT_LINE; } | |||||
(?i:lineadj) { return HT_LINEADJ; } | |||||
(?i:linear) { return HT_LINEAR; } | |||||
(?i:linestream) { return HT_LINESTREAM; } | |||||
(?i:matrix) { return HT_MATRIX; } | |||||
(?i:namespace) { return HT_NAMESPACE; } | |||||
(?i:nointerpolation) { return HT_NOINTERPOLATION; } | |||||
(?i:null) { return HT_NULL; } | |||||
(?i:outputpatch) { return HT_OUTPUTPATCH; } | |||||
(?i:packoffset) { return HT_PACKOFFSET; } | |||||
(?i:pass) { return HT_PASS; } | |||||
(?i:pixelfragment) { return HT_PIXELFRAGMENT; } | |||||
(?i:pixelshader) { return HT_PIXELSHADER; } | |||||
(?i:point) { return HT_POINT; } | |||||
(?i:pointstream) { return HT_POINTSTREAM; } | |||||
(?i:precise) { return HT_PRECISE; } | |||||
(?i:rasterizerstate) { return HT_RASTERIZERSTATE; } | |||||
(?i:rendertargetview) { return HT_RENDERTARGETVIEW; } | |||||
(?i:register) { return HT_REGISTER; } | |||||
(?i:row_major) { return HT_ROW_MAJOR; } | |||||
(?i:rwbuffer) { return HT_RWBUFFER; } | |||||
(?i:rwbyteaddressbuffer) { return HT_RWBYTEADDRESSBUFFER; } | |||||
(?i:rwstructuredbuffer) { return HT_RWSTRUCTUREDBUFFER; } | |||||
(?i:rwtexture1d) { return HT_RWTEXTURE1D; } | |||||
(?i:rwtexture1darray) { return HT_RWTEXTURE1DARRAY; } | |||||
(?i:rwtexture2d) { return HT_RWTEXTURE2D; } | |||||
(?i:rwtexture2darray) { return HT_RWTEXTURE2DARRAY; } | |||||
(?i:rwtexture3d) { return HT_RWTEXTURE3D; } | |||||
(?i:sampler) { return HT_SAMPLER; } | |||||
(?i:sampler_state) { return HT_SAMPLER_STATE; } | |||||
(?i:samplerstate) { return HT_SAMPLERSTATE; } | |||||
(?i:samplercomparisonstate) { return HT_SAMPLERCOMPARISONSTATE; } | |||||
(?i:shared) { return HT_SHARED; } | |||||
(?i:snorm) { return HT_SNORM; } | |||||
(?i:stateblock) { return HT_STATEBLOCK; } | |||||
(?i:stateblock_state) { return HT_STATEBLOCK_STATE; } | |||||
(?i:static) { return HT_STATIC; } | |||||
(?i:string) { return HT_STRING; } | |||||
(?i:structuredbuffer) { return HT_STRUCTUREDBUFFER; } | |||||
(?i:tbuffer) { return HT_TBUFFER; } | |||||
(?i:technique) { return HT_TECHNIQUE; } | |||||
(?i:technique10) { return HT_TECHNIQUE10; } | |||||
(?i:technique11xz) { return HT_TECHNIQUE11XZ; } | |||||
"texture" { return HT_TEXTURE; } | |||||
(?i:texture1d) { return HT_TEXTURE1D; } | |||||
(?i:texture1darray) { return HT_TEXTURE1DARRAY; } | |||||
(?i:texture2d) { return HT_TEXTURE2D; } | |||||
(?i:texture2darray) { return HT_TEXTURE2DARRAY; } | |||||
(?i:texture2dms) { return HT_TEXTURE2DMS; } | |||||
(?i:texture2dmsarray) { return HT_TEXTURE2DMSARRAY; } | |||||
(?i:texture3d) { return HT_TEXTURE3D; } | |||||
(?i:texturecube) { return HT_TEXTURECUBE; } | |||||
(?i:texturecubearray) { return HT_TEXTURECUBEARRAY; } | |||||
(?i:true) { return HT_TRUE; } | |||||
(?i:typedef) { return HT_TYPEDEF; } | |||||
(?i:triangle) { return HT_TRIANGLE; } | |||||
(?i:triangleadj) { return HT_TRIANGLEADJ; } | |||||
(?i:trianglestream) { return HT_TRIANGLESTREAM; } | |||||
(?i:unorm) { return HT_UNORM; } | |||||
(?i:vector) { return HT_VECTOR; } | |||||
(?i:vertexfragment) { return HT_VERTEXFRAGMENT; } | |||||
(?i:vertexshader) { return HT_VERTEXSHADER; } | |||||
(?i:volatile) { return HT_VOLATILE; } | |||||
/* | |||||
* HLSL vector types | |||||
* TODO: this can probably be factored somehow | |||||
*/ | |||||
(?i:bool1) { return HT_BOOL1; } | |||||
(?i:bool1x1) { return HT_BOOL1x1; } | |||||
(?i:bool2x1) { return HT_BOOL2x1; } | |||||
(?i:bool3x1) { return HT_BOOL3x1; } | |||||
(?i:bool4x1) { return HT_BOOL4x1; } | |||||
(?i:bool2) { return HT_BOOL2; } | |||||
(?i:bool1x2) { return HT_BOOL1x2; } | |||||
(?i:bool2x2) { return HT_BOOL2x2; } | |||||
(?i:bool3x2) { return HT_BOOL3x2; } | |||||
(?i:bool4x2) { return HT_BOOL4x2; } | |||||
(?i:bool3) { return HT_BOOL3; } | |||||
(?i:bool1x3) { return HT_BOOL1x3; } | |||||
(?i:bool2x3) { return HT_BOOL2x3; } | |||||
(?i:bool3x3) { return HT_BOOL3x3; } | |||||
(?i:bool4x3) { return HT_BOOL4x3; } | |||||
(?i:bool4) { return HT_BOOL4; } | |||||
(?i:bool1x4) { return HT_BOOL1x4; } | |||||
(?i:bool2x4) { return HT_BOOL2x4; } | |||||
(?i:bool3x4) { return HT_BOOL3x4; } | |||||
(?i:bool4x4) { return HT_BOOL4x4; } | |||||
(?i:float1) { return HT_FLOAT1; } | |||||
(?i:float1x1) { return HT_FLOAT1x1; } | |||||
(?i:float2x1) { return HT_FLOAT2x1; } | |||||
(?i:float3x1) { return HT_FLOAT3x1; } | |||||
(?i:float4x1) { return HT_FLOAT4x1; } | |||||
(?i:float2) { return HT_FLOAT2; } | |||||
(?i:float1x2) { return HT_FLOAT1x2; } | |||||
(?i:float2x2) { return HT_FLOAT2x2; } | |||||
(?i:float3x2) { return HT_FLOAT3x2; } | |||||
(?i:float4x2) { return HT_FLOAT4x2; } | |||||
(?i:float3) { return HT_FLOAT3; } | |||||
(?i:float1x3) { return HT_FLOAT1x3; } | |||||
(?i:float2x3) { return HT_FLOAT2x3; } | |||||
(?i:float3x3) { return HT_FLOAT3x3; } | |||||
(?i:float4x3) { return HT_FLOAT4x3; } | |||||
(?i:float4) { return HT_FLOAT4; } | |||||
(?i:float1x4) { return HT_FLOAT1x4; } | |||||
(?i:float2x4) { return HT_FLOAT2x4; } | |||||
(?i:float3x4) { return HT_FLOAT3x4; } | |||||
(?i:float4x4) { return HT_FLOAT4x4; } | |||||
(?i:double1) { return HT_DOUBLE1; } | |||||
(?i:double1x1) { return HT_DOUBLE1x1; } | |||||
(?i:double2x1) { return HT_DOUBLE2x1; } | |||||
(?i:double3x1) { return HT_DOUBLE3x1; } | |||||
(?i:double4x1) { return HT_DOUBLE4x1; } | |||||
(?i:double2) { return HT_DOUBLE2; } | |||||
(?i:double1x2) { return HT_DOUBLE1x2; } | |||||
(?i:double2x2) { return HT_DOUBLE2x2; } | |||||
(?i:double3x2) { return HT_DOUBLE3x2; } | |||||
(?i:double4x2) { return HT_DOUBLE4x2; } | |||||
(?i:double3) { return HT_DOUBLE3; } | |||||
(?i:double1x3) { return HT_DOUBLE1x3; } | |||||
(?i:double2x3) { return HT_DOUBLE2x3; } | |||||
(?i:double3x3) { return HT_DOUBLE3x3; } | |||||
(?i:double4x3) { return HT_DOUBLE4x3; } | |||||
(?i:double4) { return HT_DOUBLE4; } | |||||
(?i:double1x4) { return HT_DOUBLE1x4; } | |||||
(?i:double2x4) { return HT_DOUBLE2x4; } | |||||
(?i:double3x4) { return HT_DOUBLE3x4; } | |||||
(?i:double4x4) { return HT_DOUBLE4x4; } | |||||
(?i:dword1) { return HT_DWORD1; } | |||||
(?i:dword1x1) { return HT_DWORD1x1; } | |||||
(?i:dword2x1) { return HT_DWORD2x1; } | |||||
(?i:dword3x1) { return HT_DWORD3x1; } | |||||
(?i:dword4x1) { return HT_DWORD4x1; } | |||||
(?i:dword2) { return HT_DWORD2; } | |||||
(?i:dword1x2) { return HT_DWORD1x2; } | |||||
(?i:dword2x2) { return HT_DWORD2x2; } | |||||
(?i:dword3x2) { return HT_DWORD3x2; } | |||||
(?i:dword4x2) { return HT_DWORD4x2; } | |||||
(?i:dword3) { return HT_DWORD3; } | |||||
(?i:dword1x3) { return HT_DWORD1x3; } | |||||
(?i:dword2x3) { return HT_DWORD2x3; } | |||||
(?i:dword3x3) { return HT_DWORD3x3; } | |||||
(?i:dword4x3) { return HT_DWORD4x3; } | |||||
(?i:dword4) { return HT_DWORD4; } | |||||
(?i:dword1x4) { return HT_DWORD1x4; } | |||||
(?i:dword2x4) { return HT_DWORD2x4; } | |||||
(?i:dword3x4) { return HT_DWORD3x4; } | |||||
(?i:dword4x4) { return HT_DWORD4x4; } | |||||
(?i:int1) { return HT_INT1; } | |||||
(?i:int1x1) { return HT_INT1x1; } | |||||
(?i:int2x1) { return HT_INT2x1; } | |||||
(?i:int3x1) { return HT_INT3x1; } | |||||
(?i:int4x1) { return HT_INT4x1; } | |||||
(?i:int2) { return HT_INT2; } | |||||
(?i:int1x2) { return HT_INT1x2; } | |||||
(?i:int2x2) { return HT_INT2x2; } | |||||
(?i:int3x2) { return HT_INT3x2; } | |||||
(?i:int4x2) { return HT_INT4x2; } | |||||
(?i:int3) { return HT_INT3; } | |||||
(?i:int1x3) { return HT_INT1x3; } | |||||
(?i:int2x3) { return HT_INT2x3; } | |||||
(?i:int3x3) { return HT_INT3x3; } | |||||
(?i:int4x3) { return HT_INT4x3; } | |||||
(?i:int4) { return HT_INT4; } | |||||
(?i:int1x4) { return HT_INT1x4; } | |||||
(?i:int2x4) { return HT_INT2x4; } | |||||
(?i:int3x4) { return HT_INT3x4; } | |||||
(?i:int4x4) { return HT_INT4x4; } | |||||
(?i:uint1) { return HT_UINT1; } | |||||
(?i:uint1x1) { return HT_UINT1x1; } | |||||
(?i:uint2x1) { return HT_UINT2x1; } | |||||
(?i:uint3x1) { return HT_UINT3x1; } | |||||
(?i:uint4x1) { return HT_UINT4x1; } | |||||
(?i:uint2) { return HT_UINT2; } | |||||
(?i:uint1x2) { return HT_UINT1x2; } | |||||
(?i:uint2x2) { return HT_UINT2x2; } | |||||
(?i:uint3x2) { return HT_UINT3x2; } | |||||
(?i:uint4x2) { return HT_UINT4x2; } | |||||
(?i:uint3) { return HT_UINT3; } | |||||
(?i:uint1x3) { return HT_UINT1x3; } | |||||
(?i:uint2x3) { return HT_UINT2x3; } | |||||
(?i:uint3x3) { return HT_UINT3x3; } | |||||
(?i:uint4x3) { return HT_UINT4x3; } | |||||
(?i:uint4) { return HT_UINT4; } | |||||
(?i:uint1x4) { return HT_UINT1x4; } | |||||
(?i:uint2x4) { return HT_UINT2x4; } | |||||
(?i:uint3x4) { return HT_UINT3x4; } | |||||
(?i:uint4x4) { return HT_UINT4x4; } | |||||
/* | |||||
* HLSL preprocessor directives | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb943993%28v=vs.85%29.aspx | |||||
*/ | |||||
"#"[ \t]*"define" { return PREPROCESSOR_DEFINE; } | |||||
"#"[ \t]*"elif" { return PREPROCESSOR_ELIF; } | |||||
"#"[ \t]*"else" { return PREPROCESSOR_ELSE; } | |||||
"#"[ \t]*"endif" { return PREPROCESSOR_ENDIF; } | |||||
"#"[ \t]*"error" { return PREPROCESSOR_ERROR; } | |||||
"#"[ \t]*"if" { return PREPROCESSOR_IF; } | |||||
"#"[ \t]*"ifdef" { return PREPROCESSOR_IFDEF; } | |||||
"#"[ \t]*"ifndef" { return PREPROCESSOR_IFNDEF; } | |||||
"#"[ \t]*"include" { return PREPROCESSOR_INCLUDE; } | |||||
"#"[ \t]*"line" { return PREPROCESSOR_LINE; } | |||||
"#"[ \t]*"pragma" { return PREPROCESSOR_PRAGMA; } | |||||
"#"[ \t]*"undef" { return PREPROCESSOR_UNDEF; } | |||||
/* | |||||
* GLSL preprocessor directives | |||||
*/ | |||||
"#"[ \t]*"version".* { /* ignore for now */ } | |||||
/* | |||||
* LolFx preprocessor directives | |||||
*/ | |||||
"#"[ \t]*"region GLSL" { BEGIN(GLSL); } | |||||
"#"[ \t]*"region HLSL" { BEGIN(HLSL); } | |||||
"#"[ \t]*"pragma"[ \t]*"lolfx".* { /* ignore for now */ } | |||||
/* | |||||
* HLSL reserved keywords | |||||
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509569%28v=vs.85%29.aspx | |||||
*/ | |||||
(?i:auto) { return HT_AUTO; } | |||||
(?i:catch) { return HT_CATCH; } | |||||
(?i:char) { return HT_CHAR; } | |||||
(?i:class) { return HT_CLASS; } | |||||
(?i:const_cast) { return HT_CONST_CAST; } | |||||
(?i:delete) { return HT_DELETE; } | |||||
(?i:dynamic_cast) { return HT_DYNAMIC_CAST; } | |||||
(?i:enum) { return HT_ENUM; } | |||||
(?i:explicit) { return HT_EXPLICIT; } | |||||
(?i:friend) { return HT_FRIEND; } | |||||
(?i:goto) { return HT_GOTO; } | |||||
(?i:long) { return HT_LONG; } | |||||
(?i:mutable) { return HT_MUTABLE; } | |||||
(?i:new) { return HT_NEW; } | |||||
(?i:operator) { return HT_OPERATOR; } | |||||
(?i:private) { return HT_PRIVATE; } | |||||
(?i:protected) { return HT_PROTECTED; } | |||||
(?i:public) { return HT_PUBLIC; } | |||||
(?i:reinterpret_cast) { return HT_REINTERPRET_CAST; } | |||||
(?i:short) { return HT_SHORT; } | |||||
(?i:signed) { return HT_SIGNED; } | |||||
(?i:sizeof) { return HT_SIZEOF; } | |||||
(?i:static_cast) { return HT_STATIC_CAST; } | |||||
(?i:template) { return HT_TEMPLATE; } | |||||
(?i:this) { return HT_THIS; } | |||||
(?i:throw) { return HT_THROW; } | |||||
(?i:try) { return HT_TRY; } | |||||
(?i:typename) { return HT_TYPENAME; } | |||||
(?i:union) { return HT_UNION; } | |||||
(?i:unsigned) { return HT_UNSIGNED; } | |||||
(?i:using) { return HT_USING; } | |||||
(?i:virtual) { return HT_VIRTUAL; } | |||||
/* | |||||
* Various tokens | |||||
*/ | |||||
"++" { return T_INC; } | |||||
"--" { return T_DEC; } | |||||
"<=" { return T_LE; } | |||||
">=" { return T_GE; } | |||||
"==" { return T_EQ; } | |||||
"!=" { return T_NE; } | |||||
"<<" { return T_LEFT; } | |||||
">>" { return T_RIGHT; } | |||||
"&&" { return T_AND; } | |||||
"||" { return T_OR; } | |||||
"^^" { return T_XOR; } | |||||
"*=" { return T_MULEQ; } | |||||
"/=" { return T_DIVEQ; } | |||||
"%=" { return T_MODEQ; } | |||||
"+=" { return T_ADDEQ; } | |||||
"-=" { return T_SUBEQ; } | |||||
"<<=" { return T_LEFTEQ; } | |||||
">>=" { return T_RIGHTEQ; } | |||||
"&=" { return T_ANDEQ; } | |||||
"^=" { return T_XOREQ; } | |||||
"|=" { return T_OREQ; } | |||||
(0|[1-9][0-9]*)\.[0-9]+ { yylval.fval = atof(yytext); return FLOATCONSTANT; } | |||||
(0|[1-9][0-9]*)[uU] { yylval.uval = atoi(yytext); return UINTCONSTANT; } | |||||
(0|[1-9][0-9]*) { yylval.ival = atoi(yytext); return INTCONSTANT; } | |||||
[a-zA-Z][a-zA-Z0-9_]* { | |||||
/* Copy token for now */ | |||||
yylval.sval = strdup(yytext); | |||||
return IDENTIFIER; | |||||
} | |||||
[ \t\n]+ { /* ignore whitespace */ } | |||||
. { return *yytext; } | |||||
/* | |||||
* Ignore C comments | |||||
*/ | |||||
<GLSL>"/*" { comment_caller = GLSL; BEGIN(C_COMMENT); } | |||||
<HLSL>"/*" { comment_caller = HLSL; BEGIN(C_COMMENT); } | |||||
"/*" { comment_caller = INITIAL; BEGIN(C_COMMENT); } | |||||
<C_COMMENT>"*/" { BEGIN(comment_caller); } | |||||
<C_COMMENT>[^*]* { } | |||||
<C_COMMENT>. { } | |||||
/* | |||||
* Ignore C++ comments | |||||
*/ | |||||
<GLSL>"//" { comment_caller = GLSL; BEGIN(CPP_COMMENT); } | |||||
<HLSL>"//" { comment_caller = HLSL; BEGIN(CPP_COMMENT); } | |||||
"//" { comment_caller = INITIAL; BEGIN(CPP_COMMENT); } | |||||
<CPP_COMMENT>\n { BEGIN(comment_caller); } | |||||
<CPP_COMMENT>.* { } | |||||
%% | |||||
@@ -1,103 +0,0 @@ | |||||
/* | |||||
* LolFx Test Material | |||||
*/ | |||||
// Can have lots of different techniques in a single lolfx file, | |||||
// especially if they share common shader code. | |||||
technique Foo | |||||
{ | |||||
// Multiple passes, with alpha on/off, with various blending methods, | |||||
// with depth test disabled... | |||||
pass p0 | |||||
{ | |||||
texture[0] = null; | |||||
texture[1] = null; | |||||
texture[2] = null; | |||||
cullmode = none; // ccw | |||||
lighting = false; | |||||
zenable = true; // false | |||||
alphablendenable = true; // false | |||||
srcblend = src_alpha; // one | |||||
destblend = inv_src_alpha; | |||||
colorop[0] = select_arg1; | |||||
colorarg1[0] = diffuse; | |||||
alphaop[0] = select_arg1; | |||||
alphaarg1[0] = diffuse; | |||||
colorop[1] = disable; | |||||
alphaop[1] = disable; | |||||
// Ye old way | |||||
vertexshader = blah; | |||||
geometryshader = blah; | |||||
pixelshader = blah; | |||||
// Ogre crap | |||||
// The D3D11 way, but we must make it work with GLSL too | |||||
//SetBlendState(AdditiveBlending, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF); | |||||
//SetDepthStencilState(DisableDepth, 0); | |||||
//SetRasterizerState() | |||||
//SetVertexShader | |||||
//SetDomainShader | |||||
//SetHullShader | |||||
//SetGeometryShader | |||||
//SetPixelShader | |||||
//SetComputeShader /* WTF? */ | |||||
//SetRenderTargets(RTV0, DSV); | |||||
//SetRenderTargets(RTV0, RTV1, DSV); | |||||
//... | |||||
//SetRenderTargets(RTV0, RTV1, RTV2, RTV3, RTV4, RTV5, RTV6, RTV7, DSV); | |||||
} | |||||
pass p1 | |||||
{ | |||||
// Autres vertex/pixel shaders avec éventuellement des | |||||
// dépendances sur le résultat des passes précédentes | |||||
vertexshader = something_else; | |||||
} | |||||
} | |||||
/* Defines GLSL shader "Prout" */ | |||||
#region GLSL.Prout | |||||
#version 120 | |||||
/* Valid with my GLSL compiler */ | |||||
#pragma lolfx semantic(in_Vertex, POSITION) | |||||
#pragma lolfx semantic(in_Normal, NORMAL) | |||||
#pragma lolfx semantic(in_Color, COLOR) | |||||
attribute vec3 in_Vertex; | |||||
attribute vec3 in_Normal; | |||||
attribute vec4 in_Color; | |||||
void main(void) | |||||
{ | |||||
/* ... */ | |||||
} | |||||
/* Defines GLSL shader "Zob" */ | |||||
#region GLSL.Zob | |||||
void main(void) | |||||
{ | |||||
shit(); fuck(); fuck(); shit(); | |||||
} | |||||
/* Defines HLSL shader "Prout" */ | |||||
#region HLSL.Prout | |||||
void main(void) | |||||
{ | |||||
/* Blah */ | |||||
} | |||||