diff options
author | Timothy Arceri <[email protected]> | 2019-08-14 14:24:31 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-11-20 05:05:55 +0000 |
commit | 67b32190f3c953c5b7091d76ddeff95c0cbfb439 (patch) | |
tree | f80299cbb521fb547dd685dd46a5aae6b06bc7ef /src/compiler/glsl/glcpp/glcpp-parse.y | |
parent | 2497c517176c2c9bd418d7d54eaef9aba0711727 (diff) |
glsl: add ARB_shading_language_include support to #line
From the ARB_shading_language_include spec:
"#line must have, after macro substitution, one of the following
forms:
#line <line>
#line <line> <source-string-number>
#line <line> "<path>"
where <line> and <source-string-number> are constant integer
expressions and <path> is a valid string for a path supplied in the
#include directive. After processing this directive (including its
new-line), the implementation will behave as if it is compiling at
line number <line> and source string number <source-string-number>
or <path> path. Subsequent source strings will be numbered
sequentially, until another #line directive overrides that
numbering."
Reviewed-by: Witold Baryluk <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glcpp/glcpp-parse.y')
-rw-r--r-- | src/compiler/glsl/glcpp/glcpp-parse.y | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y index 51bc85dcee7..b975e8b3f40 100644 --- a/src/compiler/glsl/glcpp/glcpp-parse.y +++ b/src/compiler/glsl/glcpp/glcpp-parse.y @@ -174,11 +174,11 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* We use HASH_TOKEN, DEFINE_TOKEN and VERSION_TOKEN (as opposed to * HASH, DEFINE, and VERSION) to avoid conflicts with other symbols, * (such as the <HASH> and <DEFINE> start conditions in the lexer). */ -%token DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS +%token DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS PATH %token PASTE %type <ival> INTEGER operator SPACE integer_constant version_constant %type <expression_value> expression -%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR_TOKEN PRAGMA +%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR_TOKEN PRAGMA PATH %type <string_list> identifier_list %type <token> preprocessing_token %type <token_list> pp_tokens replacement_list text_line @@ -238,6 +238,13 @@ expanded_line: "#line %" PRIiMAX " %" PRIiMAX "\n", $2, $3); } +| LINE_EXPANDED integer_constant PATH NEWLINE { + parser->has_new_line_number = 1; + parser->new_line_number = $2; + _mesa_string_buffer_printf(parser->output, + "#line %" PRIiMAX " %s\n", + $2, $3); + } ; define: @@ -706,6 +713,10 @@ preprocessing_token: $$ = _token_create_str (parser, INTEGER_STRING, $1); $$->location = yylloc; } +| PATH { + $$ = _token_create_str (parser, PATH, $1); + $$->location = yylloc; + } | operator { $$ = _token_create_ival (parser, $1, $1); $$->location = yylloc; |