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 <witold.baryluk@gmail.com>
This commit is contained in:
@@ -202,6 +202,7 @@ DIGITS [0-9][0-9]*
|
||||
DECIMAL_INTEGER [1-9][0-9]*[uU]?
|
||||
OCTAL_INTEGER 0[0-7]*[uU]?
|
||||
HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
PATH ["][]^./ _A-Za-z0-9+*%[(){}|&~=!:;,?-]*["]
|
||||
|
||||
%%
|
||||
|
||||
@@ -558,6 +559,10 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
}
|
||||
}
|
||||
|
||||
{PATH} {
|
||||
RETURN_STRING_TOKEN (PATH);
|
||||
}
|
||||
|
||||
/* We preserve all newlines, even between #if 0..#endif, so no
|
||||
skipping.. */
|
||||
<*>{NEWLINE} {
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user