mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
glsl: Change grammar rules for selection statements to match the spec.
Fixes piglit test case loop-06.vert. Unfortunately, causes 1 shift/reduce conflict.
This commit is contained in:
parent
24c12e6c7f
commit
0427228bbc
3 changed files with 945 additions and 982 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.3. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2009, 2010 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
|
||||
|
|
@ -236,7 +235,7 @@
|
|||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 52 "glsl_parser.ypp"
|
||||
|
||||
int n;
|
||||
|
|
@ -265,10 +264,15 @@ typedef union YYSTYPE
|
|||
ast_expression *rest;
|
||||
} for_rest_statement;
|
||||
|
||||
struct {
|
||||
ast_node *then_statement;
|
||||
ast_node *else_statement;
|
||||
} selection_rest_statement;
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 272 "glsl_parser.h"
|
||||
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 276 "glsl_parser.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
|
|
|||
|
|
@ -75,6 +75,11 @@
|
|||
ast_node *cond;
|
||||
ast_expression *rest;
|
||||
} for_rest_statement;
|
||||
|
||||
struct {
|
||||
ast_node *then_statement;
|
||||
ast_node *else_statement;
|
||||
} selection_rest_statement;
|
||||
}
|
||||
|
||||
%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK
|
||||
|
|
@ -130,8 +135,6 @@
|
|||
%type <node> statement
|
||||
%type <node> statement_list
|
||||
%type <node> simple_statement
|
||||
%type <node> statement_matched
|
||||
%type <node> statement_unmatched
|
||||
%type <n> precision_qualifier
|
||||
%type <type_qualifier> type_qualifier
|
||||
%type <type_qualifier> storage_qualifier
|
||||
|
|
@ -197,8 +200,8 @@
|
|||
%type <declarator_list> struct_declaration
|
||||
%type <declaration> struct_declarator
|
||||
%type <declaration> struct_declarator_list
|
||||
%type <node> selection_statement_matched
|
||||
%type <node> selection_statement_unmatched
|
||||
%type <node> selection_statement
|
||||
%type <selection_rest_statement> selection_rest_statement
|
||||
%type <node> iteration_statement
|
||||
%type <node> condition
|
||||
%type <node> conditionopt
|
||||
|
|
@ -1266,23 +1269,14 @@ declaration_statement:
|
|||
// Grammar Note: labeled statements for SWITCH only; 'goto' is not
|
||||
// supported.
|
||||
statement:
|
||||
statement_matched
|
||||
| statement_unmatched
|
||||
;
|
||||
|
||||
statement_matched:
|
||||
compound_statement { $$ = (ast_node *) $1; }
|
||||
| simple_statement
|
||||
;
|
||||
|
||||
statement_unmatched:
|
||||
selection_statement_unmatched
|
||||
;
|
||||
|
||||
simple_statement:
|
||||
declaration_statement
|
||||
| expression_statement
|
||||
| selection_statement_matched
|
||||
| selection_statement
|
||||
| switch_statement { $$ = NULL; }
|
||||
| case_label { $$ = NULL; }
|
||||
| iteration_statement
|
||||
|
|
@ -1361,33 +1355,25 @@ expression_statement:
|
|||
}
|
||||
;
|
||||
|
||||
selection_statement_matched:
|
||||
IF '(' expression ')' statement_matched ELSE statement_matched
|
||||
selection_statement:
|
||||
IF '(' expression ')' selection_rest_statement
|
||||
{
|
||||
void *ctx = state;
|
||||
$$ = new(ctx) ast_selection_statement($3, $5, $7);
|
||||
$$ = new(state) ast_selection_statement($3, $5.then_statement,
|
||||
$5.else_statement);
|
||||
$$->set_location(yylloc);
|
||||
}
|
||||
;
|
||||
|
||||
selection_statement_unmatched:
|
||||
IF '(' expression ')' statement_matched
|
||||
selection_rest_statement:
|
||||
statement ELSE statement
|
||||
{
|
||||
void *ctx = state;
|
||||
$$ = new(ctx) ast_selection_statement($3, $5, NULL);
|
||||
$$->set_location(yylloc);
|
||||
$$.then_statement = $1;
|
||||
$$.else_statement = $3;
|
||||
}
|
||||
| IF '(' expression ')' statement_unmatched
|
||||
| statement
|
||||
{
|
||||
void *ctx = state;
|
||||
$$ = new(ctx) ast_selection_statement($3, $5, NULL);
|
||||
$$->set_location(yylloc);
|
||||
}
|
||||
| IF '(' expression ')' statement_matched ELSE statement_unmatched
|
||||
{
|
||||
void *ctx = state;
|
||||
$$ = new(ctx) ast_selection_statement($3, $5, $7);
|
||||
$$->set_location(yylloc);
|
||||
$$.then_statement = $1;
|
||||
$$.else_statement = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue