From a8e5f06fe01732fbd643bc435dd3b8eaa602defe Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 9 Nov 2011 16:58:33 +0100 Subject: libX11 mesa pixman git update 9 nov 2011 --- mesalib/src/glsl/glsl_parser.yy | 87 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) (limited to 'mesalib/src/glsl/glsl_parser.yy') 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 struct_declarator_list %type selection_statement %type selection_rest_statement +%type switch_statement +%type switch_body +%type case_label_list +%type case_label +%type case_statement +%type case_statement_list %type iteration_statement %type condition %type 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: -- cgit v1.2.3