Răsfoiți Sursa

BansheeSL: Added more lexer rules
Working on parsing of nested nodes

Marko Pintera 10 ani în urmă
părinte
comite
00f83facf6

Fișier diff suprimat deoarece este prea mare
+ 944 - 134
BansheeSL/BsLexerFX.c


+ 1 - 1
BansheeSL/BsLexerFX.h

@@ -447,7 +447,7 @@ extern int yylex \
 #undef YY_DECL
 #endif
 
-#line 46 "BsLexerFX.l"
+#line 168 "BsLexerFX.l"
 
 #line 453 "BsLexerFX.h"
 #undef yyIN_HEADER

+ 133 - 11
BansheeSL/BsLexerFX.l

@@ -7,14 +7,11 @@
 %option extra-type="struct tagParseState *"
 %option debug
 
-LBRACKET		"{"
-RBRACKET		"}"
- 
-INTEGER		[0-9][0-9]*
-INTEGER_BIN	0x[0-9][0-9]*
-FLOAT		[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?
-STRING		\"[^"\n]*\"
-WS			[ \r\n\t]*
+INTEGER			[0-9][0-9]*
+INTEGER_BIN		0x[0-9][0-9]*
+FLOAT			[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?
+STRING			\"[^"\n]*\"
+WS				[ \r\n\t]*
 
 %%
 
@@ -25,13 +22,27 @@ WS			[ \r\n\t]*
 true			{ yylval->intValue = 1; return TOKEN_BOOLEAN; }
 false			{ yylval->intValue = 0; return TOKEN_BOOLEAN; }
 
-{LBRACKET}      { return TOKEN_LBRACKET; }
-{RBRACKET}      { return TOKEN_RBRACKET; }
-
 	/* Shader keywords */
 Separable		{ return TOKEN_SEPARABLE; }
 Queue			{ return TOKEN_QUEUE; }
 Priority		{ return TOKEN_PRIORITY; }
+Technique		{ return TOKEN_TECHNIQUE; }
+Parameters		{ return TOKEN_PARAMETERS; }
+Blocks			{ return TOKEN_BLOCKS; }
+
+	/* Technique keywords */
+Renderer		{ return TOKEN_RENDERER; }
+Language		{ return TOKEN_LANGUAGE; }
+Include			{ return TOKEN_INCLUDE; }
+Pass			{ return TOKEN_PASS; }
+
+	/* Pass keywords */
+Vertex			{ return TOKEN_VERTEX; }
+Fragment		{ return TOKEN_FRAGMENT; }
+Geometry		{ return TOKEN_GEOMETRY; }
+Hull			{ return TOKEN_HULL; }
+Domain			{ return TOKEN_DOMAIN; }
+Compute			{ return TOKEN_COMPUTE; }
 
 	/* Rasterizer state keywords */
 Fill			{ return TOKEN_FILLMODE; }
@@ -43,4 +54,115 @@ Scissor			{ return TOKEN_SCISSOR; }
 Multisample		{ return TOKEN_MULTISAMPLE; }
 AALine			{ return TOKEN_AALINE; }
 
+	/* Depth-stencil state keywords */
+DepthRead			{ return TOKEN_DEPTHREAD; }
+DepthWrite			{ return TOKEN_DEPTHWRITE; }
+CompareFunc			{ return TOKEN_COMPAREFUNC; }
+Stencil				{ return TOKEN_STENCIL; }
+StencilReadMask		{ return TOKEN_STENCILREADMASK; }
+StencilWriteMask	{ return TOKEN_STENCILWRITEMASK; }
+StencilOpFront		{ return TOKEN_STENCILOPFRONT; }
+StencilOpBack		{ return TOKEN_STENCILOPBACK; }
+Fail				{ return TOKEN_FAIL; }
+ZFail				{ return TOKEN_ZFAIL; }
+
+	/* Blend state keywords */
+AlphaToCoverage		{ return TOKEN_ALPHATOCOVERAGE; }
+IndependantBlend	{ return TOKEN_INDEPENDANTBLEND; }
+Target				{ return TOKEN_TARGET; }
+Index				{ return TOKEN_INDEX; }
+Blend				{ return TOKEN_BLEND; }
+Color				{ return TOKEN_COLOR; }
+Alpha				{ return TOKEN_ALPHA; }
+WriteMask			{ return TOKEN_WRITEMASK; }
+Source				{ return TOKEN_SOURCE; }
+Dest				{ return TOKEN_DEST; }
+Op					{ return TOKEN_OP; }
+
+	/* Sampler state keywords */
+AddressMode			{ return TOKEN_ADDRMODE; }
+MinFilter			{ return TOKEN_MINFILTER; }
+MagFilter			{ return TOKEN_MAGFILTER; }
+MipFilter			{ return TOKEN_MIPFILTER; }
+MaxAniso			{ return TOKEN_MAXANISO; }
+MipmapBias			{ return TOKEN_MIPBIAS; }
+MipMin				{ return TOKEN_MIPMIN; }
+MipMax				{ return TOKEN_MIPMAX; }
+BorderColor			{ return TOKEN_BORDERCOLOR; }
+U					{ return TOKEN_U; }
+V					{ return TOKEN_V; }
+W					{ return TOKEN_W; }
+
+	/* State values */
+wire			{ yylval->intValue = 0; return TOKEN_FILLMODEVALUE; }
+solid			{ yylval->intValue = 1; return TOKEN_FILLMODEVALUE; }
+
+nocull			{ yylval->intValue = 0; return TOKEN_CULLMODEVALUE; }
+cw				{ yylval->intValue = 1; return TOKEN_CULLMODEVALUE; }
+ccw				{ yylval->intValue = 2; return TOKEN_CULLMODEVALUE; }
+
+fail			{ yylval->intValue = 0; return TOKEN_COMPFUNCVALUE; }
+pass			{ yylval->intValue = 1; return TOKEN_COMPFUNCVALUE; }
+lt				{ yylval->intValue = 2; return TOKEN_COMPFUNCVALUE; }
+lte				{ yylval->intValue = 3; return TOKEN_COMPFUNCVALUE; }
+eq				{ yylval->intValue = 4; return TOKEN_COMPFUNCVALUE; }
+neq				{ yylval->intValue = 5; return TOKEN_COMPFUNCVALUE; }
+gte				{ yylval->intValue = 6; return TOKEN_COMPFUNCVALUE; }
+gt				{ yylval->intValue = 7; return TOKEN_COMPFUNCVALUE; }
+
+keep			{ yylval->intValue = 0; return TOKEN_OPVALUE; }
+zero			{ yylval->intValue = 1; return TOKEN_OPVALUE; }
+replace			{ yylval->intValue = 2; return TOKEN_OPVALUE; }
+incr			{ yylval->intValue = 3; return TOKEN_OPVALUE; }
+decr			{ yylval->intValue = 4; return TOKEN_OPVALUE; }
+incrwrap		{ yylval->intValue = 5; return TOKEN_OPVALUE; }
+decrwrap		{ yylval->intValue = 6; return TOKEN_OPVALUE; }
+invert			{ yylval->intValue = 7; return TOKEN_OPVALUE; }
+one				{ yylval->intValue = 8; return TOKEN_OPVALUE; }
+destcolor		{ yylval->intValue = 9; return TOKEN_OPVALUE; }
+srccolor		{ yylval->intValue = 10; return TOKEN_OPVALUE; }
+invdestcolor	{ yylval->intValue = 11; return TOKEN_OPVALUE; }
+invsrccolor		{ yylval->intValue = 12; return TOKEN_OPVALUE; }
+destalpha		{ yylval->intValue = 13; return TOKEN_OPVALUE; }
+srcalpha		{ yylval->intValue = 14; return TOKEN_OPVALUE; }
+invdestalpha	{ yylval->intValue = 15; return TOKEN_OPVALUE; }
+invsrcalpha		{ yylval->intValue = 16; return TOKEN_OPVALUE; }
+
+add				{ yylval->intValue = 0; return TOKEN_BLENDOPVALUE; }
+subtract		{ yylval->intValue = 1; return TOKEN_BLENDOPVALUE; }
+revsubtract		{ yylval->intValue = 2; return TOKEN_BLENDOPVALUE; }
+min				{ yylval->intValue = 3; return TOKEN_BLENDOPVALUE; }
+max				{ yylval->intValue = 4; return TOKEN_BLENDOPVALUE; }
+
+nocolor			{ yylval->intValue = 0x0; return TOKEN_COLORMASK; }
+R				{ yylval->intValue = 0x1; return TOKEN_COLORMASK; }
+G				{ yylval->intValue = 0x2; return TOKEN_COLORMASK; }
+B				{ yylval->intValue = 0x4; return TOKEN_COLORMASK; }
+A				{ yylval->intValue = 0x8; return TOKEN_COLORMASK; }
+RG				{ yylval->intValue = 0x3; return TOKEN_COLORMASK; }
+RB				{ yylval->intValue = 0x5; return TOKEN_COLORMASK; }
+RA				{ yylval->intValue = 0x9; return TOKEN_COLORMASK; }
+GB				{ yylval->intValue = 0x6; return TOKEN_COLORMASK; }
+GA				{ yylval->intValue = 0xA; return TOKEN_COLORMASK; }
+BA				{ yylval->intValue = 0xC; return TOKEN_COLORMASK; }
+RGB				{ yylval->intValue = 0x7; return TOKEN_COLORMASK; }
+RGA				{ yylval->intValue = 0xB; return TOKEN_COLORMASK; }
+RBA				{ yylval->intValue = 0xD; return TOKEN_COLORMASK; }
+GBA				{ yylval->intValue = 0xE; return TOKEN_COLORMASK; }
+RGBA			{ yylval->intValue = 0xF; return TOKEN_COLORMASK; }
+
+wrap			{ yylval->intValue = 0; return TOKEN_ADDRMODEVALUE; }
+mirror			{ yylval->intValue = 1; return TOKEN_ADDRMODEVALUE; }
+clamp			{ yylval->intValue = 2; return TOKEN_ADDRMODEVALUE; }
+border			{ yylval->intValue = 3; return TOKEN_ADDRMODEVALUE; }
+
+nofilter		{ yylval->intValue = 0; return TOKEN_FILTERVALUE; }
+point			{ yylval->intValue = 1; return TOKEN_FILTERVALUE; }
+linear			{ yylval->intValue = 2; return TOKEN_FILTERVALUE; }
+anisotropic		{ yylval->intValue = 3; return TOKEN_FILTERVALUE; }
+pointcmp		{ yylval->intValue = 4; return TOKEN_FILTERVALUE; }
+linearcmp		{ yylval->intValue = 5; return TOKEN_FILTERVALUE; }
+anisotropiccmp	{ yylval->intValue = 6; return TOKEN_FILTERVALUE; }
+
+
 .				{ return yytext[0]; }

+ 144 - 54
BansheeSL/BsParserFX.c

@@ -181,27 +181,27 @@ YYID (i)
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  10
+#define YYFINAL  14
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   13
+#define YYLAST   32
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  22
+#define YYNTOKENS  76
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  4
+#define YYNNTS  9
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  7
+#define YYNRULES  16
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  18
+#define YYNSTATES  41
 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule.  */
-#define YYMAXRHS 4
+#define YYMAXRHS 5
 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
    accessed by $0, $-1, etc., in any rule.  */
 #define YYMAXLEFT 0
 
 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   274
+#define YYMAXUTOK   326
 
 #define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -214,14 +214,14 @@ static const unsigned char yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,    21,
-       2,    20,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,    73,
+       2,    72,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,    74,     2,    75,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -236,7 +236,12 @@ static const unsigned char yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    71
 };
 
 #if YYDEBUG
@@ -244,21 +249,26 @@ static const unsigned char yytranslate[] =
    YYRHS.  */
 static const unsigned char yyprhs[] =
 {
-       0,     0,     3,     4,     7,     9,    14,    19
+       0,     0,     3,     4,     7,     9,    11,    16,    21,    26,
+      32,    35,    36,    39,    41,    46,    51
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 static const signed char yyrhs[] =
 {
-      23,     0,    -1,    -1,    24,    23,    -1,    25,    -1,     5,
-      20,    10,    21,    -1,     6,    20,     8,    21,    -1,     7,
-      20,     8,    21,    -1
+      77,     0,    -1,    -1,    78,    77,    -1,    79,    -1,    80,
+      -1,    15,    72,     5,    73,    -1,    16,    72,     3,    73,
+      -1,    17,    72,     3,    73,    -1,    81,    74,    82,    75,
+      73,    -1,    20,    72,    -1,    -1,    83,    82,    -1,    84,
+      -1,    21,    72,     6,    73,    -1,    22,    72,     6,    73,
+      -1,    23,    72,     6,    73,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const unsigned char yyrline[] =
 {
-       0,    63,    63,    64,    68,    72,    73,    74
+       0,    95,    95,    96,   100,   101,   105,   106,   107,   111,
+     115,   122,   124,   128,   132,   133,   134
 };
 #endif
 
@@ -267,38 +277,58 @@ static const unsigned char yyrline[] =
    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 static const char *const yytname[] =
 {
-  "$end", "error", "$undefined", "TOKEN_LBRACKET", "TOKEN_RBRACKET",
-  "TOKEN_SEPARABLE", "TOKEN_QUEUE", "TOKEN_PRIORITY", "TOKEN_INTEGER",
-  "TOKEN_FLOAT", "TOKEN_BOOLEAN", "TOKEN_STRING", "TOKEN_FILLMODE",
-  "TOKEN_CULLMODE", "TOKEN_DEPTHBIAS", "TOKEN_SDEPTHBIAS",
-  "TOKEN_DEPTHCLIP", "TOKEN_SCISSOR", "TOKEN_MULTISAMPLE", "TOKEN_AALINE",
-  "'='", "';'", "$accept", "shader", "shader_statement",
-  "shader_option_decl", YY_NULL
+  "$end", "error", "$undefined", "TOKEN_INTEGER", "TOKEN_FLOAT",
+  "TOKEN_BOOLEAN", "TOKEN_STRING", "TOKEN_FILLMODEVALUE",
+  "TOKEN_CULLMODEVALUE", "TOKEN_COMPFUNCVALUE", "TOKEN_OPVALUE",
+  "TOKEN_COLORMASK", "TOKEN_ADDRMODEVALUE", "TOKEN_FILTERVALUE",
+  "TOKEN_BLENDOPVALUE", "TOKEN_SEPARABLE", "TOKEN_QUEUE", "TOKEN_PRIORITY",
+  "TOKEN_PARAMETERS", "TOKEN_BLOCKS", "TOKEN_TECHNIQUE", "TOKEN_RENDERER",
+  "TOKEN_LANGUAGE", "TOKEN_INCLUDE", "TOKEN_PASS", "TOKEN_VERTEX",
+  "TOKEN_FRAGMENT", "TOKEN_GEOMETRY", "TOKEN_HULL", "TOKEN_DOMAIN",
+  "TOKEN_COMPUTE", "TOKEN_FILLMODE", "TOKEN_CULLMODE", "TOKEN_DEPTHBIAS",
+  "TOKEN_SDEPTHBIAS", "TOKEN_DEPTHCLIP", "TOKEN_SCISSOR",
+  "TOKEN_MULTISAMPLE", "TOKEN_AALINE", "TOKEN_DEPTHREAD",
+  "TOKEN_DEPTHWRITE", "TOKEN_COMPAREFUNC", "TOKEN_STENCIL",
+  "TOKEN_STENCILREADMASK", "TOKEN_STENCILWRITEMASK",
+  "TOKEN_STENCILOPFRONT", "TOKEN_STENCILOPBACK", "TOKEN_FAIL",
+  "TOKEN_ZFAIL", "TOKEN_ALPHATOCOVERAGE", "TOKEN_INDEPENDANTBLEND",
+  "TOKEN_TARGET", "TOKEN_INDEX", "TOKEN_BLEND", "TOKEN_COLOR",
+  "TOKEN_ALPHA", "TOKEN_WRITEMASK", "TOKEN_SOURCE", "TOKEN_DEST",
+  "TOKEN_OP", "TOKEN_ADDRMODE", "TOKEN_MINFILTER", "TOKEN_MAGFILTER",
+  "TOKEN_MIPFILTER", "TOKEN_MAXANISO", "TOKEN_MIPBIAS", "TOKEN_MIPMIN",
+  "TOKEN_MIPMAX", "TOKEN_BORDERCOLOR", "TOKEN_U", "TOKEN_V", "TOKEN_W",
+  "'='", "';'", "'{'", "'}'", "$accept", "shader", "shader_statement",
+  "shader_option", "technique", "technique_header", "technique_body",
+  "technique_statement", "technique_option", YY_NULL
 };
 #endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const unsigned char yyr1[] =
 {
-       0,    22,    23,    23,    24,    25,    25,    25
+       0,    76,    77,    77,    78,    78,    79,    79,    79,    80,
+      81,    82,    82,    83,    84,    84,    84
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 static const unsigned char yyr2[] =
 {
-       0,     2,     0,     2,     1,     4,     4,     4
+       0,     2,     0,     2,     1,     1,     4,     4,     4,     5,
+       2,     0,     2,     1,     4,     4,     4
 };
 
 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none).  */
 static const unsigned char yydprec[] =
 {
-       0,     0,     0,     0,     0,     0,     0,     0
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0
 };
 
 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM.  */
 static const unsigned char yymerger[] =
 {
-       0,     0,     0,     0,     0,     0,     0,     0
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0
 };
 
 /* YYDEFACT[S] -- default reduction number in state S.  Performed when
@@ -306,29 +336,35 @@ static const unsigned char yymerger[] =
    is an error.  */
 static const unsigned char yydefact[] =
 {
-       2,     0,     0,     0,     0,     2,     4,     0,     0,     0,
-       1,     3,     0,     0,     0,     5,     6,     7
+       2,     0,     0,     0,     0,     0,     2,     4,     5,     0,
+       0,     0,     0,    10,     1,     3,    11,     0,     0,     0,
+       0,     0,     0,     0,    11,    13,     6,     7,     8,     0,
+       0,     0,     0,    12,     0,     0,     0,     9,    14,    15,
+      16
 };
 
 /* YYPDEFGOTO[NTERM-NUM].  */
 static const signed char yydefgoto[] =
 {
-      -1,     4,     5,     6
+      -1,     5,     6,     7,     8,     9,    23,    24,    25
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -18
+#define YYPACT_NINF -70
 static const signed char yypact[] =
 {
-      -5,   -17,   -16,   -15,     6,    -5,   -18,    -3,     0,     1,
-     -18,   -18,   -11,   -10,    -9,   -18,   -18,   -18
+     -15,   -69,   -68,   -66,   -62,    11,   -15,   -70,   -70,   -61,
+       7,    12,    13,   -70,   -70,   -70,   -14,   -59,   -56,   -55,
+     -53,   -52,   -51,   -50,   -14,   -70,   -70,   -70,   -70,    16,
+      17,    18,   -47,   -70,   -46,   -45,   -44,   -70,   -70,   -70,
+     -70
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const signed char yypgoto[] =
 {
-     -18,     8,   -18,   -18
+     -70,    24,   -70,   -70,   -70,   -70,     8,   -70,   -70
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -337,8 +373,10 @@ static const signed char yypgoto[] =
 #define YYTABLE_NINF -1
 static const unsigned char yytable[] =
 {
-       1,     2,     3,     7,     8,     9,    10,    12,    13,    14,
-      15,    16,    17,    11
+       1,     2,     3,    10,    11,     4,    12,    20,    21,    22,
+      13,    14,    17,    16,    26,    18,    19,    27,    28,    29,
+      30,    31,    34,    35,    36,    32,    37,    38,    39,    40,
+      15,     0,    33
 };
 
 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
@@ -348,7 +386,9 @@ static const unsigned char yytable[] =
 static const unsigned char yyconflp[] =
 {
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0
 };
 
 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
@@ -358,18 +398,23 @@ static const short int yyconfl[] =
        0
 };
 
-static const unsigned char yycheck[] =
+static const signed char yycheck[] =
 {
-       5,     6,     7,    20,    20,    20,     0,    10,     8,     8,
-      21,    21,    21,     5
+      15,    16,    17,    72,    72,    20,    72,    21,    22,    23,
+      72,     0,     5,    74,    73,     3,     3,    73,    73,    72,
+      72,    72,     6,     6,     6,    75,    73,    73,    73,    73,
+       6,    -1,    24
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
 static const unsigned char yystos[] =
 {
-       0,     5,     6,     7,    23,    24,    25,    20,    20,    20,
-       0,    23,    10,     8,     8,    21,    21,    21
+       0,    15,    16,    17,    20,    77,    78,    79,    80,    81,
+      72,    72,    72,    72,     0,    77,    74,     5,     3,     3,
+      21,    22,    23,    82,    83,    84,    73,    73,    73,    72,
+      72,    72,    75,    82,     6,     6,     6,    73,    73,    73,
+      73
 };
 
 /* Error token number */
@@ -802,37 +847,82 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
     {
         case 2:
 /* Line 868 of glr.c  */
-#line 63 "BsParserFX.y"
+#line 95 "BsParserFX.y"
     { }
     break;
 
   case 3:
 /* Line 868 of glr.c  */
-#line 64 "BsParserFX.y"
-    { nodeOptionsAdd(parse_state->memContext, parse_state->rootNode->options, &(((yyGLRStackItem const *)yyvsp)[YYFILL ((1) - (2))].yystate.yysemantics.yysval.nodeOption)); }
+#line 96 "BsParserFX.y"
+    { nodeOptionsAdd(parse_state->memContext, parse_state->topNode->options, &(((yyGLRStackItem const *)yyvsp)[YYFILL ((1) - (2))].yystate.yysemantics.yysval.nodeOption)); }
     break;
 
   case 5:
 /* Line 868 of glr.c  */
-#line 72 "BsParserFX.y"
-    { ((*yyvalp).nodeOption).type = OT_Separable; ((*yyvalp).nodeOption).value.intValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.intValue); }
+#line 101 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Technique; ((*yyvalp).nodeOption).value.nodePtr = (((yyGLRStackItem const *)yyvsp)[YYFILL ((1) - (1))].yystate.yysemantics.yysval.nodePtr); }
     break;
 
   case 6:
 /* Line 868 of glr.c  */
-#line 73 "BsParserFX.y"
-    { ((*yyvalp).nodeOption).type = OT_Queue; ((*yyvalp).nodeOption).value.intValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.intValue); }
+#line 105 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Separable; ((*yyvalp).nodeOption).value.intValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.intValue); }
     break;
 
   case 7:
 /* Line 868 of glr.c  */
-#line 74 "BsParserFX.y"
+#line 106 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Queue; ((*yyvalp).nodeOption).value.intValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.intValue); }
+    break;
+
+  case 8:
+/* Line 868 of glr.c  */
+#line 107 "BsParserFX.y"
     { ((*yyvalp).nodeOption).type = OT_Priority; ((*yyvalp).nodeOption).value.intValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.intValue); }
     break;
 
+  case 9:
+/* Line 868 of glr.c  */
+#line 111 "BsParserFX.y"
+    { nodePop(parse_state); ((*yyvalp).nodePtr) = (((yyGLRStackItem const *)yyvsp)[YYFILL ((1) - (5))].yystate.yysemantics.yysval.nodePtr); }
+    break;
+
+  case 10:
+/* Line 868 of glr.c  */
+#line 116 "BsParserFX.y"
+    { 
+			((*yyvalp).nodePtr) = nodeCreate(parse_state->memContext, NT_Technique); 
+			nodePush(parse_state, ((*yyvalp).nodePtr));
+		}
+    break;
+
+  case 12:
+/* Line 868 of glr.c  */
+#line 124 "BsParserFX.y"
+    { nodeOptionsAdd(parse_state->memContext, parse_state->topNode->options, &(((yyGLRStackItem const *)yyvsp)[YYFILL ((1) - (2))].yystate.yysemantics.yysval.nodeOption)); }
+    break;
+
+  case 14:
+/* Line 868 of glr.c  */
+#line 132 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Renderer; ((*yyvalp).nodeOption).value.strValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.strValue); }
+    break;
+
+  case 15:
+/* Line 868 of glr.c  */
+#line 133 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Language; ((*yyvalp).nodeOption).value.strValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.strValue); }
+    break;
+
+  case 16:
+/* Line 868 of glr.c  */
+#line 134 "BsParserFX.y"
+    { ((*yyvalp).nodeOption).type = OT_Include; ((*yyvalp).nodeOption).value.strValue = (((yyGLRStackItem const *)yyvsp)[YYFILL ((3) - (4))].yystate.yysemantics.yysval.strValue); }
+    break;
+
 
 /* Line 868 of glr.c  */
-#line 836 "BsParserFX.c"
+#line 926 "BsParserFX.c"
       default: break;
     }
 
@@ -935,7 +1025,7 @@ yylhsNonterm (yyRuleNum yyrule)
 }
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-18)))
+  (!!((Yystate) == (-70)))
 
 /** True iff LR state STATE has only a default reduction (regardless
  *  of token).  */
@@ -2472,4 +2562,4 @@ yypdumpstack (yyGLRStack* yystackp)
 }
 #endif
 /* Line 2575 of glr.c  */
-#line 77 "BsParserFX.y"
+#line 136 "BsParserFX.y"

+ 70 - 18
BansheeSL/BsParserFX.h

@@ -62,23 +62,75 @@ extern int yydebug;
    /* Put the tokens into the symbol table, so that GDB and other debuggers
       know about them.  */
    enum yytokentype {
-     TOKEN_LBRACKET = 258,
-     TOKEN_RBRACKET = 259,
-     TOKEN_SEPARABLE = 260,
-     TOKEN_QUEUE = 261,
-     TOKEN_PRIORITY = 262,
-     TOKEN_INTEGER = 263,
-     TOKEN_FLOAT = 264,
-     TOKEN_BOOLEAN = 265,
-     TOKEN_STRING = 266,
-     TOKEN_FILLMODE = 267,
-     TOKEN_CULLMODE = 268,
-     TOKEN_DEPTHBIAS = 269,
-     TOKEN_SDEPTHBIAS = 270,
-     TOKEN_DEPTHCLIP = 271,
-     TOKEN_SCISSOR = 272,
-     TOKEN_MULTISAMPLE = 273,
-     TOKEN_AALINE = 274
+     TOKEN_INTEGER = 258,
+     TOKEN_FLOAT = 259,
+     TOKEN_BOOLEAN = 260,
+     TOKEN_STRING = 261,
+     TOKEN_FILLMODEVALUE = 262,
+     TOKEN_CULLMODEVALUE = 263,
+     TOKEN_COMPFUNCVALUE = 264,
+     TOKEN_OPVALUE = 265,
+     TOKEN_COLORMASK = 266,
+     TOKEN_ADDRMODEVALUE = 267,
+     TOKEN_FILTERVALUE = 268,
+     TOKEN_BLENDOPVALUE = 269,
+     TOKEN_SEPARABLE = 270,
+     TOKEN_QUEUE = 271,
+     TOKEN_PRIORITY = 272,
+     TOKEN_PARAMETERS = 273,
+     TOKEN_BLOCKS = 274,
+     TOKEN_TECHNIQUE = 275,
+     TOKEN_RENDERER = 276,
+     TOKEN_LANGUAGE = 277,
+     TOKEN_INCLUDE = 278,
+     TOKEN_PASS = 279,
+     TOKEN_VERTEX = 280,
+     TOKEN_FRAGMENT = 281,
+     TOKEN_GEOMETRY = 282,
+     TOKEN_HULL = 283,
+     TOKEN_DOMAIN = 284,
+     TOKEN_COMPUTE = 285,
+     TOKEN_FILLMODE = 286,
+     TOKEN_CULLMODE = 287,
+     TOKEN_DEPTHBIAS = 288,
+     TOKEN_SDEPTHBIAS = 289,
+     TOKEN_DEPTHCLIP = 290,
+     TOKEN_SCISSOR = 291,
+     TOKEN_MULTISAMPLE = 292,
+     TOKEN_AALINE = 293,
+     TOKEN_DEPTHREAD = 294,
+     TOKEN_DEPTHWRITE = 295,
+     TOKEN_COMPAREFUNC = 296,
+     TOKEN_STENCIL = 297,
+     TOKEN_STENCILREADMASK = 298,
+     TOKEN_STENCILWRITEMASK = 299,
+     TOKEN_STENCILOPFRONT = 300,
+     TOKEN_STENCILOPBACK = 301,
+     TOKEN_FAIL = 302,
+     TOKEN_ZFAIL = 303,
+     TOKEN_ALPHATOCOVERAGE = 304,
+     TOKEN_INDEPENDANTBLEND = 305,
+     TOKEN_TARGET = 306,
+     TOKEN_INDEX = 307,
+     TOKEN_BLEND = 308,
+     TOKEN_COLOR = 309,
+     TOKEN_ALPHA = 310,
+     TOKEN_WRITEMASK = 311,
+     TOKEN_SOURCE = 312,
+     TOKEN_DEST = 313,
+     TOKEN_OP = 314,
+     TOKEN_ADDRMODE = 315,
+     TOKEN_MINFILTER = 316,
+     TOKEN_MAGFILTER = 317,
+     TOKEN_MIPFILTER = 318,
+     TOKEN_MAXANISO = 319,
+     TOKEN_MIPBIAS = 320,
+     TOKEN_MIPMIN = 321,
+     TOKEN_MIPMAX = 322,
+     TOKEN_BORDERCOLOR = 323,
+     TOKEN_U = 324,
+     TOKEN_V = 325,
+     TOKEN_W = 326
    };
 #endif
 
@@ -96,7 +148,7 @@ typedef union YYSTYPE
 
 
 /* Line 2579 of glr.c  */
-#line 100 "BsParserFX.h"
+#line 152 "BsParserFX.h"
 } YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */

+ 69 - 10
BansheeSL/BsParserFX.y

@@ -39,39 +39,98 @@
 	NodeOption nodeOption;
 }
 
-%token TOKEN_LBRACKET
-%token TOKEN_RBRACKET
-%token TOKEN_SEPARABLE
-%token TOKEN_QUEUE
-%token TOKEN_PRIORITY
-
+	/* Value types */
 %token <intValue>	TOKEN_INTEGER
 %token <floatValue> TOKEN_FLOAT
 %token <intValue>	TOKEN_BOOLEAN
 %token <strValue>	TOKEN_STRING
 
+%token <intValue>	TOKEN_FILLMODEVALUE
+%token <intValue>	TOKEN_CULLMODEVALUE
+%token <intValue>	TOKEN_COMPFUNCVALUE
+%token <intValue>	TOKEN_OPVALUE
+%token <intValue>	TOKEN_COLORMASK
+%token <intValue>	TOKEN_ADDRMODEVALUE
+%token <intValue>	TOKEN_FILTERVALUE
+%token <intValue>	TOKEN_BLENDOPVALUE
+
+	/* Shader keywords */
+%token TOKEN_SEPARABLE TOKEN_QUEUE TOKEN_PRIORITY
+%token TOKEN_PARAMETERS TOKEN_BLOCKS TOKEN_TECHNIQUE
+
+	/* Technique keywords */
+%token	TOKEN_RENDERER TOKEN_LANGUAGE TOKEN_INCLUDE TOKEN_PASS
+
+	/* Pass keywords */
+%token	TOKEN_VERTEX TOKEN_FRAGMENT TOKEN_GEOMETRY TOKEN_HULL TOKEN_DOMAIN TOKEN_COMPUTE
+
 %token	TOKEN_FILLMODE TOKEN_CULLMODE TOKEN_DEPTHBIAS TOKEN_SDEPTHBIAS
 %token	TOKEN_DEPTHCLIP TOKEN_SCISSOR TOKEN_MULTISAMPLE TOKEN_AALINE
 
+%token	TOKEN_DEPTHREAD TOKEN_DEPTHWRITE TOKEN_COMPAREFUNC TOKEN_STENCIL
+%token	TOKEN_STENCILREADMASK TOKEN_STENCILWRITEMASK TOKEN_STENCILOPFRONT TOKEN_STENCILOPBACK
+%token	TOKEN_FAIL TOKEN_ZFAIL TOKEN_PASS
+
+%token	TOKEN_ALPHATOCOVERAGE TOKEN_INDEPENDANTBLEND TOKEN_TARGET TOKEN_INDEX
+%token	TOKEN_BLEND TOKEN_COLOR TOKEN_ALPHA TOKEN_WRITEMASK
+%token	TOKEN_SOURCE TOKEN_DEST TOKEN_OP
+
+	/* Sampler state keywords */
+%token	TOKEN_ADDRMODE TOKEN_MINFILTER TOKEN_MAGFILTER TOKEN_MIPFILTER
+%token	TOKEN_MAXANISO TOKEN_MIPBIAS TOKEN_MIPMIN TOKEN_MIPMAX
+%token	TOKEN_BORDERCOLOR TOKEN_U TOKEN_V TOKEN_W
+
 %type <nodePtr>		shader;
 %type <nodeOption>	shader_statement;
-%type <nodeOption>	shader_option_decl;
+%type <nodeOption>	shader_option;
+
+%type <nodePtr>		technique;
+%type <nodePtr>		technique_header;
+%type <nodeOption>	technique_statement;
+%type <nodeOption>	technique_option;
 
 %%
 
 shader
 	: /* empty */				{ }
-	| shader_statement shader	{ nodeOptionsAdd(parse_state->memContext, parse_state->rootNode->options, &$1); }
+	| shader_statement shader	{ nodeOptionsAdd(parse_state->memContext, parse_state->topNode->options, &$1); }
 	;
 
 shader_statement
-	: shader_option_decl
+	: shader_option
+	| technique			{ $$.type = OT_Technique; $$.value.nodePtr = $1; }
 	;
 
-shader_option_decl
+shader_option
 	: TOKEN_SEPARABLE '=' TOKEN_BOOLEAN ';'		{ $$.type = OT_Separable; $$.value.intValue = $3; }
 	| TOKEN_QUEUE '=' TOKEN_INTEGER ';'			{ $$.type = OT_Queue; $$.value.intValue = $3; }
 	| TOKEN_PRIORITY '=' TOKEN_INTEGER ';'		{ $$.type = OT_Priority; $$.value.intValue = $3; }
 	;
 
+technique
+	: technique_header '{' technique_body '}' ';' { nodePop(parse_state); $$ = $1; }
+	;
+
+technique_header
+	: TOKEN_TECHNIQUE '=' 
+		{ 
+			$$ = nodeCreate(parse_state->memContext, NT_Technique); 
+			nodePush(parse_state, $$);
+		}
+	;
+
+technique_body
+	: /* empty */
+	| technique_statement technique_body		{ nodeOptionsAdd(parse_state->memContext, parse_state->topNode->options, &$1); }
+	;
+
+technique_statement
+	: technique_option
+	;
+
+technique_option
+	: TOKEN_RENDERER '=' TOKEN_STRING ';'	{ $$.type = OT_Renderer; $$.value.strValue = $3; }
+	| TOKEN_LANGUAGE '=' TOKEN_STRING ';'	{ $$.type = OT_Language; $$.value.strValue = $3; }
+	| TOKEN_INCLUDE '=' TOKEN_STRING ';'	{ $$.type = OT_Include; $$.value.strValue = $3; }
+
 %%

+ 23 - 3
BansheeSL/Include/BsASTFX.h

@@ -13,6 +13,7 @@ typedef union tagOptionData OptionData;
 typedef struct tagNodeOptions NodeOptions;
 typedef struct tagNodeOption NodeOption;
 typedef struct tagASTFXNode ASTFXNode;
+typedef struct tagNodeLink NodeLink;
 
 enum tagNodeType
 {
@@ -28,7 +29,12 @@ enum tagOptionType
 	OT_Node,
 	OT_Separable,
 	OT_Priority,
-	OT_Queue
+	OT_Queue,
+	OT_Technique,
+	OT_Renderer,
+	OT_Language,
+	OT_Include,
+	OT_Pass
 	// TODO - Add others
 };
 
@@ -41,10 +47,19 @@ enum tagOptionDataType
 	ODT_Complex
 };
 
+struct tagNodeLink
+{
+	ASTFXNode* node;
+	NodeLink* next;
+};
+
 struct tagParseState
 {
 	ASTFXNode* rootNode;
+	ASTFXNode* topNode;
 	void* memContext;
+
+	NodeLink* nodeStack;
 };
 
 struct tagOptionInfo
@@ -57,9 +72,8 @@ union tagOptionData
 {
 	int intValue;
 	float floatValue;
-	int boolValue;
 	const char* strValue;
-	void* complexValue;
+	ASTFXNode* nodePtr;
 };
 
 struct tagNodeOption
@@ -95,4 +109,10 @@ void nodeOptionsAdd(void* context, NodeOptions* options, NodeOption* option);
 ASTFXNode* nodeCreate(void* context, NodeType type);
 void nodeDelete(ASTFXNode* node);
 
+void nodePush(ParseState* parseState, ASTFXNode* node);
+void nodePop(ParseState* parseState);
+
+ParseState* parseStateCreate();
+void parseStateDelete(ParseState* parseState);
+
 #endif

+ 52 - 2
BansheeSL/Source/BsASTFX.c

@@ -27,8 +27,8 @@ void nodeOptionDelete(NodeOption* option)
 {
 	if (OPTION_LOOKUP[(int)option->type].dataType == ODT_Complex)
 	{
-		mmfree(option->value.complexValue); // TODO - Maybe this has more complex delete logic? (It probably will have)
-		option->value.complexValue = 0;
+		nodeDelete(option->value.nodePtr);
+		option->value.nodePtr = 0;
 	}
 	else if (OPTION_LOOKUP[(int)option->type].dataType == ODT_String)
 	{
@@ -108,3 +108,53 @@ void nodeDelete(ASTFXNode* node)
 
 	mmfree(node);
 }
+
+void nodePush(ParseState* parseState, ASTFXNode* node)
+{
+	NodeLink* linkNode = (NodeLink*)mmalloc(parseState->memContext, sizeof(NodeLink));
+	linkNode->next = parseState->nodeStack;
+	linkNode->node = node;
+
+	parseState->nodeStack = linkNode;
+	parseState->topNode = node;
+}
+
+void nodePop(ParseState* parseState)
+{
+	if (!parseState->nodeStack)
+		return;
+
+	NodeLink* toRemove = parseState->nodeStack;
+	parseState->nodeStack = toRemove->next;
+
+	if (parseState->nodeStack)
+		parseState->topNode = parseState->nodeStack->node;
+	else
+		parseState->topNode = 0;
+
+	mmfree(toRemove);
+}
+
+ParseState* parseStateCreate()
+{
+	ParseState* parseState = (ParseState*)malloc(sizeof(ParseState));
+	parseState->memContext = mmalloc_new_context();
+	parseState->rootNode = nodeCreate(parseState->memContext, NT_Shader);
+	parseState->topNode = 0;
+	parseState->nodeStack = 0;
+
+	nodePush(parseState, parseState->rootNode);
+
+	return parseState;
+}
+
+void parseStateDelete(ParseState* parseState)
+{
+	while (parseState->nodeStack != 0)
+		nodePop(parseState);
+
+	nodeDelete(parseState->rootNode);
+	mmalloc_free_context(parseState->memContext);
+
+	free(parseState);
+}

+ 5 - 10
BansheeSL/Source/BsSLPlugin.cpp

@@ -12,19 +12,19 @@ extern "C" {
 
 namespace BansheeEngine
 {
-	void parseFX(ParseState& parseState, const char* source)
+	void parseFX(ParseState* parseState, const char* source)
 	{
 		yyscan_t scanner;
 		YY_BUFFER_STATE state;
 
-		if (yylex_init_extra(&parseState, &scanner)) {
+		if (yylex_init_extra(parseState, &scanner)) {
 			// couldn't initialize
 			return;
 		}
 
 		state = yy_scan_string(source, scanner);
 
-		if (yyparse(&parseState, scanner)) {
+		if (yyparse(parseState, scanner)) {
 			// error parsing
 			return;
 		}
@@ -56,17 +56,12 @@ namespace BansheeEngine
 
 		String contents = file->getAsString();
 
-		ParseState parseState;
-		parseState.memContext = mmalloc_new_context();
-		parseState.rootNode = nodeCreate(parseState.memContext, NT_Shader);
-
+		ParseState* parseState = parseStateCreate();
 		parseFX(parseState, contents.c_str());
 
 		int bp = 0;
 
-		nodeDelete(parseState.rootNode);
-		mmalloc_free_context(parseState.memContext);
-
+		parseStateDelete(parseState);
 
 		return nullptr;
 	}

+ 4 - 0
TODO.txt

@@ -284,6 +284,10 @@ BlockQualifierNode
  - T Value (create different qualifier node types for each qualifier since each has its own type (or multiple values)?)
   - But it's better just to have a void pointer and detect actual value stored here (it can be a struct with multiple values too)
 
+-------------------
+
+In lexer I use numbers to identify different values, but use enums instead so I can use the same ones when parsing AST
+
 ----------------------------------------------------------------------
 Scene View
 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff