aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/glsl_parser.yy
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-09 16:58:33 +0100
committermarha <marha@users.sourceforge.net>2011-11-09 16:58:33 +0100
commita8e5f06fe01732fbd643bc435dd3b8eaa602defe (patch)
treeb18cd9881bc5a6d317edca6c38fa912bade00802 /mesalib/src/glsl/glsl_parser.yy
parent1ed503a856d9753a813951796bc6ba56c42ecd28 (diff)
downloadvcxsrv-a8e5f06fe01732fbd643bc435dd3b8eaa602defe.tar.gz
vcxsrv-a8e5f06fe01732fbd643bc435dd3b8eaa602defe.tar.bz2
vcxsrv-a8e5f06fe01732fbd643bc435dd3b8eaa602defe.zip
libX11 mesa pixman git update 9 nov 2011
Diffstat (limited to 'mesalib/src/glsl/glsl_parser.yy')
-rw-r--r--mesalib/src/glsl/glsl_parser.yy87
1 files changed, 84 insertions, 3 deletions
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index d32d6e4e1..f3e873800 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -67,6 +67,11 @@
ast_declarator_list *declarator_list;
ast_struct_specifier *struct_specifier;
ast_declaration *declaration;
+ ast_switch_body *switch_body;
+ ast_case_label *case_label;
+ ast_case_label_list *case_label_list;
+ ast_case_statement *case_statement;
+ ast_case_statement_list *case_statement_list;
struct {
ast_node *cond;
@@ -207,6 +212,12 @@
%type <declaration> struct_declarator_list
%type <node> selection_statement
%type <selection_rest_statement> selection_rest_statement
+%type <node> switch_statement
+%type <switch_body> switch_body
+%type <case_label_list> case_label_list
+%type <case_label> case_label
+%type <case_statement> case_statement
+%type <case_statement_list> case_statement_list
%type <node> iteration_statement
%type <node> condition
%type <node> conditionopt
@@ -1517,8 +1528,7 @@ simple_statement:
declaration_statement
| expression_statement
| selection_statement
- | switch_statement { $$ = NULL; }
- | case_label { $$ = NULL; }
+ | switch_statement
| iteration_statement
| jump_statement
;
@@ -1640,13 +1650,84 @@ condition:
}
;
+/*
+ * siwtch_statement grammar is based on the syntax described in the body
+ * of the GLSL spec, not in it's appendix!!!
+ */
switch_statement:
- SWITCH '(' expression ')' compound_statement
+ SWITCH '(' expression ')' switch_body
+ {
+ $$ = new(state) ast_switch_statement($3, $5);
+ }
+ ;
+
+switch_body:
+ '{' '}'
+ {
+ $$ = new(state) ast_switch_body(NULL);
+ $$->set_location(yylloc);
+ }
+ | '{' case_statement_list '}'
+ {
+ $$ = new(state) ast_switch_body($2);
+ $$->set_location(yylloc);
+ }
;
case_label:
CASE expression ':'
+ {
+ $$ = new(state) ast_case_label($2);
+ }
| DEFAULT ':'
+ {
+ $$ = new(state) ast_case_label(NULL);
+ }
+ ;
+
+case_label_list:
+ case_label
+ {
+ ast_case_label_list *labels = new(state) ast_case_label_list();
+
+ labels->labels.push_tail(& $1->link);
+ $$ = labels;
+ }
+ | case_label_list case_label
+ {
+ $$ = $1;
+ $$->labels.push_tail(& $2->link);
+ }
+ ;
+
+case_statement:
+ case_label_list statement
+ {
+ ast_case_statement *stmts = new(state) ast_case_statement($1);
+
+ stmts->stmts.push_tail(& $2->link);
+ $$ = stmts
+ }
+ | case_statement statement
+ {
+ $$ = $1;
+ $$->stmts.push_tail(& $2->link);
+ }
+ ;
+
+case_statement_list:
+ case_statement
+ {
+ ast_case_statement_list *cases= new(state) ast_case_statement_list();
+
+ cases->cases.push_tail(& $1->link);
+ $$ = cases;
+ }
+ | case_statement_list case_statement
+ {
+ $$ = $1;
+ $$->cases.push_tail(& $2->link);
+ }
;
iteration_statement: