diff options
author | Kenneth Graunke <[email protected]> | 2013-07-15 15:58:29 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2013-07-18 16:57:23 -0700 |
commit | 6eec502e84f2b4f6118544e78d2e97928618ba0f (patch) | |
tree | 4038419dc9b63470ead127b85d0950186660dce5 /src/glsl/glsl_parser.yy | |
parent | 308d4c71466af7ad5cbb99f8b4fddd743f2a2b25 (diff) |
glsl: Move precision handling to be part of qualifier handling.
This is necessary for the parser to be able to accept precision
qualifiers not immediately adjacent to the type, such as "const highp
inout float foo".
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl/glsl_parser.yy')
-rw-r--r-- | src/glsl/glsl_parser.yy | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 1a13f485503..08806a32bcf 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -169,7 +169,6 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type <type_qualifier> interface_block_layout_qualifier %type <type_qualifier> interface_qualifier %type <type_specifier> type_specifier -%type <type_specifier> type_specifier_no_prec %type <type_specifier> type_specifier_nonarray %type <identifier> basic_type_specifier_nonarray %type <fully_specified_type> fully_specified_type @@ -790,9 +789,8 @@ declaration: { $$ = $1; } - | PRECISION precision_qualifier type_specifier_no_prec ';' + | PRECISION precision_qualifier type_specifier ';' { - $3->precision = $2; $3->default_precision = $2; $$ = $3; } @@ -905,6 +903,17 @@ parameter_qualifier: $$ = $1; $$.merge_qualifier(&@1, state, $2); } + | precision_qualifier parameter_qualifier + { + if ($2.precision != ast_precision_none) + _mesa_glsl_error(&@1, state, "Duplicate precision qualifier.\n"); + + if ($2.flags.i != 0) + _mesa_glsl_error(&@1, state, "Precision qualifiers must come last.\n"); + + $$ = $2; + $$.precision = $1; + } parameter_direction_qualifier: IN_TOK @@ -1319,6 +1328,11 @@ type_qualifier: | storage_qualifier | interpolation_qualifier | layout_qualifier + | precision_qualifier + { + memset(&$$, 0, sizeof($$)); + $$.precision = $1; + } /* Multiple qualifiers: * In GLSL 4.20, these can be specified in any order. In earlier versions, @@ -1414,6 +1428,17 @@ type_qualifier: $$ = $1; $$.merge_qualifier(&@1, state, $2); } + | precision_qualifier type_qualifier + { + if ($2.precision != ast_precision_none) + _mesa_glsl_error(&@1, state, "Duplicate precision qualifier.\n"); + + if ($2.flags.i != 0) + _mesa_glsl_error(&@1, state, "Precision qualifiers must come last.\n"); + + $$ = $2; + $$.precision = $1; + } ; storage_qualifier: @@ -1466,18 +1491,6 @@ storage_qualifier: ; type_specifier: - type_specifier_no_prec - { - $$ = $1; - } - | precision_qualifier type_specifier_no_prec - { - $$ = $2; - $$->precision = $1; - } - ; - -type_specifier_no_prec: type_specifier_nonarray | type_specifier_nonarray '[' ']' { |