daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | // |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 3 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 8 | This file contains the Lex specification for GLSL ES. |
| 9 | Based on ANSI C grammar, Lex specification: |
| 10 | http://www.lysator.liu.se/c/ANSI-C-grammar-l.html |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11 | |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 12 | IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 13 | WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 16 | %top{ |
| 17 | // |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 18 | // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 19 | // Use of this source code is governed by a BSD-style license that can be |
| 20 | // found in the LICENSE file. |
| 21 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 22 | |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 23 | // This file is auto-generated by generate_parser.sh. DO NOT EDIT! |
apatrick@chromium.org | 536888b | 2012-01-25 02:10:25 +0000 | [diff] [blame] | 24 | |
| 25 | // Ignore errors in auto-generated code. |
| 26 | #if defined(__GNUC__) |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 27 | #pragma GCC diagnostic ignored "-Wunused-function" |
apatrick@chromium.org | 536888b | 2012-01-25 02:10:25 +0000 | [diff] [blame] | 28 | #pragma GCC diagnostic ignored "-Wunused-variable" |
apatrick@chromium.org | e057c5d | 2012-01-26 19:18:24 +0000 | [diff] [blame] | 29 | #pragma GCC diagnostic ignored "-Wswitch-enum" |
apatrick@chromium.org | 536888b | 2012-01-25 02:10:25 +0000 | [diff] [blame] | 30 | #elif defined(_MSC_VER) |
Scott Graham | a825fdc | 2015-04-14 16:05:47 -0700 | [diff] [blame] | 31 | #pragma warning(disable: 4005) |
apatrick@chromium.org | 536888b | 2012-01-25 02:10:25 +0000 | [diff] [blame] | 32 | #pragma warning(disable: 4065) |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 33 | #pragma warning(disable: 4189) |
Minmin Gong | 794e000 | 2015-04-07 18:31:54 -0700 | [diff] [blame] | 34 | #pragma warning(disable: 4244) |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 35 | #pragma warning(disable: 4505) |
| 36 | #pragma warning(disable: 4701) |
Austin Kinross | c8ef69d | 2015-03-18 16:43:22 -0700 | [diff] [blame] | 37 | #pragma warning(disable: 4702) |
apatrick@chromium.org | 536888b | 2012-01-25 02:10:25 +0000 | [diff] [blame] | 38 | #endif |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 39 | } |
| 40 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | %{ |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 42 | #include "compiler/translator/glslang.h" |
Jamie Madill | 6b9cb25 | 2013-10-17 10:45:47 -0400 | [diff] [blame] | 43 | #include "compiler/translator/ParseContext.h" |
daniel@transgaming.com | b401a92 | 2012-10-26 18:58:24 +0000 | [diff] [blame] | 44 | #include "compiler/preprocessor/Token.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 45 | #include "compiler/translator/util.h" |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 46 | #include "compiler/translator/length_limits.h" |
alokp@chromium.org | eab1ef1 | 2010-04-23 17:33:49 +0000 | [diff] [blame] | 47 | #include "glslang_tab.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 48 | |
| 49 | /* windows only pragma */ |
| 50 | #ifdef _MSC_VER |
| 51 | #pragma warning(disable : 4102) |
| 52 | #endif |
| 53 | |
Jamie Madill | 2dc8bf8 | 2015-04-30 15:56:52 -0400 | [diff] [blame] | 54 | // Workaround for flex using the register keyword, deprecated in C++11. |
| 55 | #ifdef __cplusplus |
| 56 | #if __cplusplus > 199711L |
| 57 | #define register |
| 58 | #endif |
| 59 | #endif |
| 60 | |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 61 | #define YY_USER_ACTION \ |
| 62 | yylloc->first_file = yylloc->last_file = yycolumn; \ |
| 63 | yylloc->first_line = yylloc->last_line = yylineno; |
| 64 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 65 | #define YY_INPUT(buf, result, max_size) \ |
| 66 | result = string_input(buf, max_size, yyscanner); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 67 | |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 68 | static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner); |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 69 | static int check_type(yyscan_t yyscanner); |
| 70 | static int reserved_word(yyscan_t yyscanner); |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 71 | static int ES2_reserved_ES3_keyword(TParseContext *context, int token); |
| 72 | static int ES2_keyword_ES3_reserved(TParseContext *context, int token); |
shannonwoods@chromium.org | 16242ef | 2013-05-30 00:18:11 +0000 | [diff] [blame] | 73 | static int ES2_ident_ES3_keyword(TParseContext *context, int token); |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 74 | static int uint_constant(TParseContext *context); |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 75 | static int int_constant(yyscan_t yyscanner); |
| 76 | static int float_constant(yyscan_t yyscanner); |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 77 | static int floatsuffix_check(TParseContext* context); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 78 | %} |
| 79 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 80 | %option noyywrap nounput never-interactive |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 81 | %option yylineno reentrant bison-bridge bison-locations |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 82 | %option extra-type="TParseContext*" |
Olli Etuaho | 2728eda | 2015-03-16 10:23:50 +0200 | [diff] [blame] | 83 | %x FIELDS |
alokp@chromium.org | 29d56fb | 2010-04-06 15:42:22 +0000 | [diff] [blame] | 84 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 85 | D [0-9] |
| 86 | L [a-zA-Z_] |
| 87 | H [a-fA-F0-9] |
| 88 | E [Ee][+-]?{D}+ |
| 89 | O [0-7] |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 90 | |
| 91 | %% |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 92 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 93 | %{ |
| 94 | TParseContext* context = yyextra; |
| 95 | %} |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 96 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 97 | "invariant" { return INVARIANT; } |
| 98 | "highp" { return HIGH_PRECISION; } |
| 99 | "mediump" { return MEDIUM_PRECISION; } |
| 100 | "lowp" { return LOW_PRECISION; } |
| 101 | "precision" { return PRECISION; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 102 | |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 103 | "attribute" { return ES2_keyword_ES3_reserved(context, ATTRIBUTE); } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 104 | "const" { return CONST_QUAL; } |
| 105 | "uniform" { return UNIFORM; } |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 106 | "varying" { return ES2_keyword_ES3_reserved(context, VARYING); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 107 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 108 | "break" { return BREAK; } |
| 109 | "continue" { return CONTINUE; } |
| 110 | "do" { return DO; } |
| 111 | "for" { return FOR; } |
| 112 | "while" { return WHILE; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 113 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 114 | "if" { return IF; } |
| 115 | "else" { return ELSE; } |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 116 | "switch" { return ES2_reserved_ES3_keyword(context, SWITCH); } |
Jamie Madill | 5c55caf | 2014-02-18 15:27:18 -0500 | [diff] [blame] | 117 | "case" { return ES2_ident_ES3_keyword(context, CASE); } |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 118 | "default" { return ES2_reserved_ES3_keyword(context, DEFAULT); } |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 119 | |
Jamie Madill | 5c55caf | 2014-02-18 15:27:18 -0500 | [diff] [blame] | 120 | "centroid" { return ES2_ident_ES3_keyword(context, CENTROID); } |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 121 | "flat" { return ES2_reserved_ES3_keyword(context, FLAT); } |
Jamie Madill | 5c55caf | 2014-02-18 15:27:18 -0500 | [diff] [blame] | 122 | "smooth" { return ES2_ident_ES3_keyword(context, SMOOTH); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 124 | "in" { return IN_QUAL; } |
| 125 | "out" { return OUT_QUAL; } |
| 126 | "inout" { return INOUT_QUAL; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 127 | |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 128 | "float" { return FLOAT_TYPE; } |
| 129 | "int" { return INT_TYPE; } |
shannonwoods@chromium.org | 6b70991 | 2013-05-30 00:20:04 +0000 | [diff] [blame] | 130 | "uint" { return ES2_ident_ES3_keyword(context, UINT_TYPE); } |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 131 | "void" { return VOID_TYPE; } |
| 132 | "bool" { return BOOL_TYPE; } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 133 | "true" { yylval->lex.b = true; return BOOLCONSTANT; } |
| 134 | "false" { yylval->lex.b = false; return BOOLCONSTANT; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 135 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 136 | "discard" { return DISCARD; } |
| 137 | "return" { return RETURN; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 138 | |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 139 | "mat2" { return MATRIX2; } |
| 140 | "mat3" { return MATRIX3; } |
| 141 | "mat4" { return MATRIX4; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 142 | |
shannonwoods@chromium.org | 9bd22fa | 2013-05-30 00:18:47 +0000 | [diff] [blame] | 143 | "mat2x2" { return ES2_ident_ES3_keyword(context, MATRIX2); } |
| 144 | "mat3x3" { return ES2_ident_ES3_keyword(context, MATRIX3); } |
| 145 | "mat4x4" { return ES2_ident_ES3_keyword(context, MATRIX4); } |
| 146 | |
| 147 | "mat2x3" { return ES2_ident_ES3_keyword(context, MATRIX2x3); } |
| 148 | "mat3x2" { return ES2_ident_ES3_keyword(context, MATRIX3x2); } |
| 149 | "mat2x4" { return ES2_ident_ES3_keyword(context, MATRIX2x4); } |
| 150 | "mat4x2" { return ES2_ident_ES3_keyword(context, MATRIX4x2); } |
| 151 | "mat3x4" { return ES2_ident_ES3_keyword(context, MATRIX3x4); } |
| 152 | "mat4x3" { return ES2_ident_ES3_keyword(context, MATRIX4x3); } |
| 153 | |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 154 | "vec2" { return VEC2; } |
| 155 | "vec3" { return VEC3; } |
| 156 | "vec4" { return VEC4; } |
| 157 | "ivec2" { return IVEC2; } |
| 158 | "ivec3" { return IVEC3; } |
| 159 | "ivec4" { return IVEC4; } |
| 160 | "bvec2" { return BVEC2; } |
| 161 | "bvec3" { return BVEC3; } |
| 162 | "bvec4" { return BVEC4; } |
shannonwoods@chromium.org | 8c788e8 | 2013-05-30 00:20:21 +0000 | [diff] [blame] | 163 | "uvec2" { return ES2_ident_ES3_keyword(context, UVEC2); } |
| 164 | "uvec3" { return ES2_ident_ES3_keyword(context, UVEC3); } |
| 165 | "uvec4" { return ES2_ident_ES3_keyword(context, UVEC4); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 166 | |
Nicolas Capens | 2a1d8a3 | 2013-07-18 11:49:40 -0400 | [diff] [blame] | 167 | "sampler2D" { return SAMPLER2D; } |
| 168 | "samplerCube" { return SAMPLERCUBE; } |
| 169 | "samplerExternalOES" { return SAMPLER_EXTERNAL_OES; } |
| 170 | "sampler3D" { return ES2_reserved_ES3_keyword(context, SAMPLER3D); } |
| 171 | "sampler3DRect" { return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); } |
| 172 | "sampler2DRect" { return SAMPLER2DRECT; } |
| 173 | "sampler2DArray" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAY); } |
| 174 | "isampler2D" { return ES2_ident_ES3_keyword(context, ISAMPLER2D); } |
| 175 | "isampler3D" { return ES2_ident_ES3_keyword(context, ISAMPLER3D); } |
| 176 | "isamplerCube" { return ES2_ident_ES3_keyword(context, ISAMPLERCUBE); } |
| 177 | "isampler2DArray" { return ES2_ident_ES3_keyword(context, ISAMPLER2DARRAY); } |
| 178 | "usampler2D" { return ES2_ident_ES3_keyword(context, USAMPLER2D); } |
| 179 | "usampler3D" { return ES2_ident_ES3_keyword(context, USAMPLER3D); } |
| 180 | "usamplerCube" { return ES2_ident_ES3_keyword(context, USAMPLERCUBE); } |
| 181 | "usampler2DArray" { return ES2_ident_ES3_keyword(context, USAMPLER2DARRAY); } |
Jamie Madill | 5c55caf | 2014-02-18 15:27:18 -0500 | [diff] [blame] | 182 | "sampler2DShadow" { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); } |
Nicolas Capens | 2a1d8a3 | 2013-07-18 11:49:40 -0400 | [diff] [blame] | 183 | "samplerCubeShadow" { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); } |
| 184 | "sampler2DArrayShadow" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 185 | |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 186 | "struct" { return STRUCT; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 187 | |
shannonwoods@chromium.org | 302adfe | 2013-05-30 00:21:06 +0000 | [diff] [blame] | 188 | "layout" { return ES2_ident_ES3_keyword(context, LAYOUT); } |
| 189 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 190 | /* Reserved keywords for GLSL ES 3.00 that are not reserved for GLSL ES 1.00 */ |
| 191 | "coherent" | |
| 192 | "restrict" | |
| 193 | "readonly" | |
| 194 | "writeonly" | |
| 195 | "resource" | |
| 196 | "atomic_uint" | |
| 197 | "noperspective" | |
| 198 | "patch" | |
| 199 | "sample" | |
| 200 | "subroutine" | |
| 201 | "common" | |
| 202 | "partition" | |
| 203 | "active" | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 204 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 205 | "filter" | |
| 206 | "image1D" | |
| 207 | "image2D" | |
| 208 | "image3D" | |
| 209 | "imageCube" | |
| 210 | "iimage1D" | |
| 211 | "iimage2D" | |
| 212 | "iimage3D" | |
| 213 | "iimageCube" | |
| 214 | "uimage1D" | |
| 215 | "uimage2D" | |
| 216 | "uimage3D" | |
| 217 | "uimageCube" | |
| 218 | "image1DArray" | |
| 219 | "image2DArray" | |
| 220 | "iimage1DArray" | |
| 221 | "iimage2DArray" | |
| 222 | "uimage1DArray" | |
| 223 | "uimage2DArray" | |
| 224 | "image1DShadow" | |
| 225 | "image2DShadow" | |
| 226 | "image1DArrayShadow" | |
| 227 | "image2DArrayShadow" | |
| 228 | "imageBuffer" | |
| 229 | "iimageBuffer" | |
| 230 | "uimageBuffer" | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 231 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 232 | "sampler1DArray" | |
| 233 | "sampler1DArrayShadow" | |
| 234 | "isampler1D" | |
| 235 | "isampler1DArray" | |
| 236 | "usampler1D" | |
| 237 | "usampler1DArray" | |
| 238 | "isampler2DRect" | |
| 239 | "usampler2DRect" | |
| 240 | "samplerBuffer" | |
| 241 | "isamplerBuffer" | |
| 242 | "usamplerBuffer" | |
| 243 | "sampler2DMS" | |
| 244 | "isampler2DMS" | |
| 245 | "usampler2DMS" | |
| 246 | "sampler2DMSArray" | |
| 247 | "isampler2DMSArray" | |
| 248 | "usampler2DMSArray" { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 249 | if (context->getShaderVersion() < 300) { |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 250 | yylval->lex.string = NewPoolTString(yytext); |
| 251 | return check_type(yyscanner); |
| 252 | } |
| 253 | return reserved_word(yyscanner); |
| 254 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 255 | |
shannonwoods@chromium.org | 302adfe | 2013-05-30 00:21:06 +0000 | [diff] [blame] | 256 | /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */ |
| 257 | "packed" { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 258 | if (context->getShaderVersion() >= 300) |
shannonwoods@chromium.org | 302adfe | 2013-05-30 00:21:06 +0000 | [diff] [blame] | 259 | { |
| 260 | yylval->lex.string = NewPoolTString(yytext); |
| 261 | return check_type(yyscanner); |
| 262 | } |
| 263 | |
| 264 | return reserved_word(yyscanner); |
| 265 | } |
| 266 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 267 | /* Reserved keywords */ |
| 268 | "asm" | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 269 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 270 | "class" | |
| 271 | "union" | |
| 272 | "enum" | |
| 273 | "typedef" | |
| 274 | "template" | |
| 275 | "this" | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 276 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 277 | "goto" | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 278 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 279 | "inline" | |
| 280 | "noinline" | |
| 281 | "volatile" | |
| 282 | "public" | |
| 283 | "static" | |
| 284 | "extern" | |
| 285 | "external" | |
| 286 | "interface" | |
daniel@transgaming.com | beadd5d | 2012-04-12 02:35:31 +0000 | [diff] [blame] | 287 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 288 | "long" | |
| 289 | "short" | |
| 290 | "double" | |
| 291 | "half" | |
| 292 | "fixed" | |
| 293 | "unsigned" | |
| 294 | "superp" | |
daniel@transgaming.com | beadd5d | 2012-04-12 02:35:31 +0000 | [diff] [blame] | 295 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 296 | "input" | |
| 297 | "output" | |
daniel@transgaming.com | beadd5d | 2012-04-12 02:35:31 +0000 | [diff] [blame] | 298 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 299 | "hvec2" | |
| 300 | "hvec3" | |
| 301 | "hvec4" | |
| 302 | "dvec2" | |
| 303 | "dvec3" | |
| 304 | "dvec4" | |
| 305 | "fvec2" | |
| 306 | "fvec3" | |
| 307 | "fvec4" | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 308 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 309 | "sampler1D" | |
| 310 | "sampler1DShadow" | |
| 311 | "sampler2DRectShadow" | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 312 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 313 | "sizeof" | |
| 314 | "cast" | |
| 315 | |
| 316 | "namespace" | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 317 | "using" { return reserved_word(yyscanner); } |
| 318 | |
| 319 | {L}({L}|{D})* { |
| 320 | yylval->lex.string = NewPoolTString(yytext); |
| 321 | return check_type(yyscanner); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 324 | 0[xX]{H}+ { return int_constant(yyscanner); } |
| 325 | 0{O}+ { return int_constant(yyscanner); } |
| 326 | {D}+ { return int_constant(yyscanner); } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 327 | |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 328 | 0[xX]{H}+[uU] { return uint_constant(context); } |
| 329 | 0{O}+[uU] { return uint_constant(context); } |
| 330 | {D}+[uU] { return uint_constant(context); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 331 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 332 | {D}+{E} { return float_constant(yyscanner); } |
| 333 | {D}+"."{D}*({E})? { return float_constant(yyscanner); } |
| 334 | "."{D}+({E})? { return float_constant(yyscanner); } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 335 | |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 336 | {D}+{E}[fF] { return floatsuffix_check(context); } |
| 337 | {D}+"."{D}*({E})?[fF] { return floatsuffix_check(context); } |
| 338 | "."{D}+({E})?[fF] { return floatsuffix_check(context); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 339 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 340 | "+=" { return ADD_ASSIGN; } |
| 341 | "-=" { return SUB_ASSIGN; } |
| 342 | "*=" { return MUL_ASSIGN; } |
| 343 | "/=" { return DIV_ASSIGN; } |
| 344 | "%=" { return MOD_ASSIGN; } |
| 345 | "<<=" { return LEFT_ASSIGN; } |
| 346 | ">>=" { return RIGHT_ASSIGN; } |
| 347 | "&=" { return AND_ASSIGN; } |
| 348 | "^=" { return XOR_ASSIGN; } |
| 349 | "|=" { return OR_ASSIGN; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 350 | |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 351 | "++" { return INC_OP; } |
| 352 | "--" { return DEC_OP; } |
| 353 | "&&" { return AND_OP; } |
| 354 | "||" { return OR_OP; } |
| 355 | "^^" { return XOR_OP; } |
| 356 | "<=" { return LE_OP; } |
| 357 | ">=" { return GE_OP; } |
| 358 | "==" { return EQ_OP; } |
| 359 | "!=" { return NE_OP; } |
| 360 | "<<" { return LEFT_OP; } |
| 361 | ">>" { return RIGHT_OP; } |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 362 | ";" { return SEMICOLON; } |
| 363 | ("{"|"<%") { return LEFT_BRACE; } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 364 | ("}"|"%>") { return RIGHT_BRACE; } |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 365 | "," { return COMMA; } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 366 | ":" { return COLON; } |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 367 | "=" { return EQUAL; } |
| 368 | "(" { return LEFT_PAREN; } |
| 369 | ")" { return RIGHT_PAREN; } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 370 | ("["|"<:") { return LEFT_BRACKET; } |
| 371 | ("]"|":>") { return RIGHT_BRACKET; } |
Olli Etuaho | 2728eda | 2015-03-16 10:23:50 +0200 | [diff] [blame] | 372 | "." { BEGIN(FIELDS); return DOT; } |
Jamie Madill | 56b0651 | 2013-05-24 16:34:04 -0400 | [diff] [blame] | 373 | "!" { return BANG; } |
| 374 | "-" { return DASH; } |
| 375 | "~" { return TILDE; } |
| 376 | "+" { return PLUS; } |
| 377 | "*" { return STAR; } |
| 378 | "/" { return SLASH; } |
| 379 | "%" { return PERCENT; } |
| 380 | "<" { return LEFT_ANGLE; } |
| 381 | ">" { return RIGHT_ANGLE; } |
| 382 | "|" { return VERTICAL_BAR; } |
| 383 | "^" { return CARET; } |
| 384 | "&" { return AMPERSAND; } |
| 385 | "?" { return QUESTION; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 386 | |
Olli Etuaho | 2728eda | 2015-03-16 10:23:50 +0200 | [diff] [blame] | 387 | <FIELDS>{L}({L}|{D})* { |
| 388 | BEGIN(INITIAL); |
| 389 | yylval->lex.string = NewPoolTString(yytext); |
| 390 | return FIELD_SELECTION; |
| 391 | } |
| 392 | <FIELDS>[ \t\v\f\r] {} |
| 393 | |
Jamie Madill | 39a8ce6 | 2013-06-13 10:30:38 -0400 | [diff] [blame] | 394 | [ \t\v\n\f\r] { } |
Olli Etuaho | 2728eda | 2015-03-16 10:23:50 +0200 | [diff] [blame] | 395 | <*><<EOF>> { yyterminate(); } |
| 396 | <*>. { assert(false); return 0; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 397 | |
| 398 | %% |
| 399 | |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 400 | yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 401 | pp::Token token; |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 402 | yyget_extra(yyscanner)->getPreprocessor().lex(&token); |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 403 | yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); |
| 404 | if (len < max_size) |
alokp@chromium.org | 5b6a68e | 2012-06-28 20:29:13 +0000 | [diff] [blame] | 405 | memcpy(buf, token.text.c_str(), len); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 406 | yyset_column(token.location.file, yyscanner); |
| 407 | yyset_lineno(token.location.line, yyscanner); |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 408 | |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 409 | if (len >= max_size) |
| 410 | YY_FATAL_ERROR("Input buffer overflow"); |
| 411 | else if (len > 0) |
| 412 | buf[len++] = ' '; |
| 413 | return len; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 414 | } |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 415 | |
| 416 | int check_type(yyscan_t yyscanner) { |
| 417 | struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; |
| 418 | |
| 419 | int token = IDENTIFIER; |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 420 | TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); |
Jamie Madill | 78eb5df | 2013-05-24 16:34:05 -0400 | [diff] [blame] | 421 | if (symbol && symbol->isVariable()) { |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 422 | TVariable* variable = static_cast<TVariable*>(symbol); |
| 423 | if (variable->isUserType()) { |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 424 | token = TYPE_NAME; |
| 425 | } |
| 426 | } |
| 427 | yylval->lex.symbol = symbol; |
| 428 | return token; |
| 429 | } |
| 430 | |
| 431 | int reserved_word(yyscan_t yyscanner) { |
| 432 | struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; |
| 433 | |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 434 | yyextra->error(*yylloc, "Illegal use of reserved word", yytext, ""); |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 435 | yyextra->recover(); |
| 436 | return 0; |
| 437 | } |
| 438 | |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 439 | int ES2_reserved_ES3_keyword(TParseContext *context, int token) |
| 440 | { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 441 | yyscan_t yyscanner = (yyscan_t) context->getScanner(); |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 442 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 443 | if (context->getShaderVersion() < 300) |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 444 | { |
| 445 | return reserved_word(yyscanner); |
| 446 | } |
| 447 | |
| 448 | return token; |
| 449 | } |
| 450 | |
| 451 | int ES2_keyword_ES3_reserved(TParseContext *context, int token) |
| 452 | { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 453 | yyscan_t yyscanner = (yyscan_t) context->getScanner(); |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 454 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 455 | if (context->getShaderVersion() >= 300) |
shannonwoods@chromium.org | 35f156d | 2013-05-30 00:18:04 +0000 | [diff] [blame] | 456 | { |
| 457 | return reserved_word(yyscanner); |
| 458 | } |
| 459 | |
| 460 | return token; |
| 461 | } |
| 462 | |
shannonwoods@chromium.org | 16242ef | 2013-05-30 00:18:11 +0000 | [diff] [blame] | 463 | int ES2_ident_ES3_keyword(TParseContext *context, int token) |
| 464 | { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 465 | struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); |
| 466 | yyscan_t yyscanner = (yyscan_t) context->getScanner(); |
shannonwoods@chromium.org | 16242ef | 2013-05-30 00:18:11 +0000 | [diff] [blame] | 467 | |
| 468 | // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 469 | if (context->getShaderVersion() < 300) |
shannonwoods@chromium.org | 16242ef | 2013-05-30 00:18:11 +0000 | [diff] [blame] | 470 | { |
| 471 | yylval->lex.string = NewPoolTString(yytext); |
| 472 | return check_type(yyscanner); |
| 473 | } |
| 474 | |
| 475 | return token; |
| 476 | } |
| 477 | |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 478 | int uint_constant(TParseContext *context) |
| 479 | { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 480 | struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); |
| 481 | yyscan_t yyscanner = (yyscan_t) context->getScanner(); |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 482 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 483 | if (context->getShaderVersion() < 300) |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 484 | { |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 485 | context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 486 | context->recover(); |
| 487 | return 0; |
| 488 | } |
| 489 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 490 | if (!atoi_clamp(yytext, &(yylval->lex.i))) |
| 491 | yyextra->warning(*yylloc, "Integer overflow", yytext, ""); |
| 492 | |
shannonwoods@chromium.org | c8100b8 | 2013-05-30 00:20:34 +0000 | [diff] [blame] | 493 | return UINTCONSTANT; |
| 494 | } |
| 495 | |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 496 | int floatsuffix_check(TParseContext* context) |
| 497 | { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 498 | struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 499 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 500 | if (context->getShaderVersion() < 300) |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 501 | { |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 502 | context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 503 | context->recover(); |
| 504 | return 0; |
| 505 | } |
| 506 | |
Corentin Wallez | e2adce1 | 2015-06-19 23:06:32 +0200 | [diff] [blame] | 507 | std::string text = yytext; |
| 508 | text.resize(text.size() - 1); |
| 509 | if (!strtof_clamp(text, &(yylval->lex.f))) |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 510 | yyextra->warning(*yylloc, "Float overflow", yytext, ""); |
| 511 | |
shannonwoods@chromium.org | 4d20a84 | 2013-05-30 00:21:48 +0000 | [diff] [blame] | 512 | return(FLOATCONSTANT); |
| 513 | } |
| 514 | |
Jamie Madill | 185de88 | 2014-12-22 15:17:52 -0500 | [diff] [blame] | 515 | void yyerror(YYLTYPE* lloc, TParseContext* context, void *scanner, const char* reason) { |
| 516 | context->error(*lloc, reason, yyget_text(scanner)); |
Alok Priyadarshi | 0b67bfb | 2013-09-23 14:56:59 -0400 | [diff] [blame] | 517 | context->recover(); |
| 518 | } |
| 519 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 520 | int int_constant(yyscan_t yyscanner) { |
| 521 | struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; |
| 522 | |
| 523 | if (!atoi_clamp(yytext, &(yylval->lex.i))) |
| 524 | yyextra->warning(*yylloc, "Integer overflow", yytext, ""); |
| 525 | return INTCONSTANT; |
| 526 | } |
| 527 | |
| 528 | int float_constant(yyscan_t yyscanner) { |
| 529 | struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; |
| 530 | |
Corentin Wallez | e2adce1 | 2015-06-19 23:06:32 +0200 | [diff] [blame] | 531 | if (!strtof_clamp(yytext, &(yylval->lex.f))) |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 532 | yyextra->warning(*yylloc, "Float overflow", yytext, ""); |
| 533 | return FLOATCONSTANT; |
| 534 | } |
| 535 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 536 | int glslang_initialize(TParseContext* context) { |
| 537 | yyscan_t scanner = NULL; |
| 538 | if (yylex_init_extra(context, &scanner)) |
| 539 | return 1; |
| 540 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 541 | context->setScanner(scanner); |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | int glslang_finalize(TParseContext* context) { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 546 | yyscan_t scanner = context->getScanner(); |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 547 | if (scanner == NULL) return 0; |
| 548 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 549 | context->setScanner(NULL); |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 550 | yylex_destroy(scanner); |
| 551 | |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 552 | return 0; |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 553 | } |
| 554 | |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 555 | int glslang_scan(size_t count, const char* const string[], const int length[], |
alokp@chromium.org | 408c45e | 2012-04-05 15:54:43 +0000 | [diff] [blame] | 556 | TParseContext* context) { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 557 | yyrestart(NULL, context->getScanner()); |
| 558 | yyset_column(0, context->getScanner()); |
| 559 | yyset_lineno(1, context->getScanner()); |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 560 | |
| 561 | // Initialize preprocessor. |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 562 | pp::Preprocessor *preprocessor = &context->getPreprocessor(); |
| 563 | |
| 564 | if (!preprocessor->init(count, string, length)) |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 565 | return 1; |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 566 | |
| 567 | // Define extension macros. |
| 568 | const TExtensionBehavior& extBehavior = context->extensionBehavior(); |
| 569 | for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); |
| 570 | iter != extBehavior.end(); ++iter) { |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 571 | preprocessor->predefineMacro(iter->first.c_str(), 1); |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 572 | } |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 573 | if (context->getFragmentPrecisionHigh()) |
| 574 | preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 575 | |
Jamie Madill | 6e06b1f | 2015-05-14 10:01:17 -0400 | [diff] [blame] | 576 | preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 577 | |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 578 | return 0; |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 579 | } |
| 580 | |