From d06069f30513163108489dd189dc8027cb4ad643 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 8 Sep 2009 10:46:29 +0200 Subject: slang: Remove the old preprocessor. --- src/mesa/shader/slang/slang_compile.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index c1b97c7cb7..f988c58c8a 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -38,7 +38,6 @@ #include "shader/grammar/grammar_mesa.h" #include "slang_codegen.h" #include "slang_compile.h" -#include "slang_preprocess.h" #include "slang_storage.h" #include "slang_emit.h" #include "slang_log.h" @@ -2496,8 +2495,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, struct gl_sl_pragmas *pragmas) { byte *prod; - GLuint size, start, version; - slang_string preprocessed; + GLuint size, version; GLuint maxVersion; #if FEATURE_ARB_shading_language_120 @@ -2509,8 +2507,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, #endif /* First retrieve the version number. */ - if (!_slang_preprocess_version(source, &version, &start, infolog)) - return GL_FALSE; + version = 110; if (version > maxVersion) { slang_info_log_error(infolog, @@ -2519,23 +2516,13 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, return GL_FALSE; } - /* Now preprocess the source string. */ - slang_string_init(&preprocessed); - if (!_slang_preprocess_directives(&preprocessed, &source[start], - infolog, extensions, pragmas)) { - slang_string_free(&preprocessed); - slang_info_log_error(infolog, "failed to preprocess the source."); - return GL_FALSE; - } - /* Finally check the syntax and generate its binary representation. */ if (!grammar_fast_check(id, - (const byte *) (slang_string_cstr(&preprocessed)), + (const byte *)source, &prod, &size, 65536)) { char buf[1024]; GLint pos; - slang_string_free(&preprocessed); grammar_get_last_error((byte *) (buf), sizeof(buf), &pos); slang_info_log_error(infolog, buf); /* syntax error (possibly in library code) */ @@ -2551,7 +2538,6 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, #endif return GL_FALSE; } - slang_string_free(&preprocessed); /* Syntax is okay - translate it to internal representation. */ if (!compile_binary(prod, unit, version, type, infolog, builtin, -- cgit v1.2.3 From 58fa89c90279e2bdfc7331d7b632a748e2126ca1 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 8 Sep 2009 12:46:34 +0200 Subject: slang: Correctly parse numbers from the new preprocessor. --- src/mesa/shader/slang/library/slang_shader.syn | 4 +- src/mesa/shader/slang/library/slang_shader_syn.h | 4 +- src/mesa/shader/slang/slang_compile.c | 153 ++++++++++++++++++----- 3 files changed, 123 insertions(+), 38 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn index f35356bf4a..af83543cbb 100644 --- a/src/mesa/shader/slang/library/slang_shader.syn +++ b/src/mesa/shader/slang/library/slang_shader.syn @@ -1416,10 +1416,10 @@ identifier "@ID" .emit *; float - "@NUM" .emit *; + "@NUM" .emit 1 .emit *; integer - "@NUM" .emit *; + "@NUM" .emit 1 .emit *; boolean "true" .emit '1' .emit '\0' .or diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h index ca62d41b7f..98e6453a00 100644 --- a/src/mesa/shader/slang/library/slang_shader_syn.h +++ b/src/mesa/shader/slang/library/slang_shader_syn.h @@ -685,9 +685,9 @@ "identifier\n" " \"@ID\" .emit *;\n" "float\n" -" \"@NUM\" .emit *;\n" +" \"@NUM\" .emit 1 .emit *;\n" "integer\n" -" \"@NUM\" .emit *;\n" +" \"@NUM\" .emit 1 .emit *;\n" "boolean\n" " \"true\" .emit '1' .emit '\\0' .or\n" " \"false\" .emit '0' .emit '\\0';\n" diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index f988c58c8a..75dd8a045b 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -182,23 +182,103 @@ parse_identifier(slang_parse_ctx * C) return slang_atom_pool_atom(C->atoms, id); } +static int +is_hex_digit(char c) +{ + return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + +static int +parse_general_number(slang_parse_ctx *ctx, float *number) +{ + char *flt = NULL; + + if (*ctx->I == '0') { + int value = 0; + const byte *pi; + + if (ctx->I[1] == 'x' || ctx->I[1] == 'X') { + ctx->I += 2; + if (!is_hex_digit(*ctx->I)) { + return 0; + } + do { + int digit; + + if (*ctx->I >= '0' && *ctx->I <= '9') { + digit = (int)(*ctx->I - '0'); + } else if (*ctx->I >= 'a' && *ctx->I <= 'f') { + digit = (int)(*ctx->I - 'a') + 10; + } else { + digit = (int)(*ctx->I - 'A') + 10; + } + value = value * 0x10 + digit; + ctx->I++; + } while (is_hex_digit(*ctx->I)); + if (*ctx->I != '\0') { + return 0; + } + ctx->I++; + *number = (float)value; + return 1; + } + + pi = ctx->I; + pi++; + while (*pi >= '0' && *pi <= '7') { + int digit; + + digit = (int)(*pi - '0'); + value = value * 010 + digit; + pi++; + } + if (*pi == '\0') { + pi++; + ctx->I = pi; + *number = (float)value; + return 1; + } + } + + parse_identifier_str(ctx, &flt); + flt = strdup(flt); + if (!flt) { + return 0; + } + if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') { + flt[strlen(flt) - 1] = '\0'; + } + *number = (float)_mesa_strtod(flt, (char **)NULL); + free(flt); + + return 1; +} + static int parse_number(slang_parse_ctx * C, int *number) { const int radix = (int) (*C->I++); - *number = 0; - while (*C->I != '\0') { - int digit; - if (*C->I >= '0' && *C->I <= '9') - digit = (int) (*C->I - '0'); - else if (*C->I >= 'A' && *C->I <= 'Z') - digit = (int) (*C->I - 'A') + 10; - else - digit = (int) (*C->I - 'a') + 10; - *number = *number * radix + digit; + + if (radix == 1) { + float f = 0.0f; + + parse_general_number(C, &f); + *number = (int)f; + } else { + *number = 0; + while (*C->I != '\0') { + int digit; + if (*C->I >= '0' && *C->I <= '9') + digit = (int) (*C->I - '0'); + else if (*C->I >= 'A' && *C->I <= 'Z') + digit = (int) (*C->I - 'A') + 10; + else + digit = (int) (*C->I - 'a') + 10; + *number = *number * radix + digit; + C->I++; + } C->I++; } - C->I++; if (*number > 65535) slang_info_log_warning(C->L, "%d: literal integer overflow.", *number); return 1; @@ -207,32 +287,37 @@ parse_number(slang_parse_ctx * C, int *number) static int parse_float(slang_parse_ctx * C, float *number) { - char *integral = NULL; - char *fractional = NULL; - char *exponent = NULL; - char *whole = NULL; - - parse_identifier_str(C, &integral); - parse_identifier_str(C, &fractional); - parse_identifier_str(C, &exponent); - - whole = (char *) _slang_alloc((_mesa_strlen(integral) + - _mesa_strlen(fractional) + - _mesa_strlen(exponent) + 3) * sizeof(char)); - if (whole == NULL) { - slang_info_log_memory(C->L); - RETURN0; - } + if (*C->I == 1) { + C->I++; + parse_general_number(C, number); + } else { + char *integral = NULL; + char *fractional = NULL; + char *exponent = NULL; + char *whole = NULL; + + parse_identifier_str(C, &integral); + parse_identifier_str(C, &fractional); + parse_identifier_str(C, &exponent); + + whole = (char *) _slang_alloc((_mesa_strlen(integral) + + _mesa_strlen(fractional) + + _mesa_strlen(exponent) + 3) * sizeof(char)); + if (whole == NULL) { + slang_info_log_memory(C->L); + RETURN0; + } - slang_string_copy(whole, integral); - slang_string_concat(whole, "."); - slang_string_concat(whole, fractional); - slang_string_concat(whole, "E"); - slang_string_concat(whole, exponent); + slang_string_copy(whole, integral); + slang_string_concat(whole, "."); + slang_string_concat(whole, fractional); + slang_string_concat(whole, "E"); + slang_string_concat(whole, exponent); - *number = (float) (_mesa_strtod(whole, (char **) NULL)); + *number = (float) (_mesa_strtod(whole, (char **) NULL)); - _slang_free(whole); + _slang_free(whole); + } return 1; } -- cgit v1.2.3 From eeb5202e5ddf1cc95c35d46fd425afd0695b85bb Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 16 Sep 2009 19:24:50 +0200 Subject: slang: Invoke the preprocessor from withing the slang compiler. This allows us to validate the shader version number. --- src/mesa/shader/grammar/grammar.c | 125 +------------------------------ src/mesa/shader/grammar/grammar.h | 9 ++- src/mesa/shader/grammar/grammar_mesa.h | 4 - src/mesa/shader/slang/slang_compile.c | 131 ++++++++++++++++++++++++++++++--- 4 files changed, 132 insertions(+), 137 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/grammar/grammar.c b/src/mesa/shader/grammar/grammar.c index ebfcef0680..eb58e0cddd 100644 --- a/src/mesa/shader/grammar/grammar.c +++ b/src/mesa/shader/grammar/grammar.c @@ -3106,14 +3106,13 @@ int grammar_set_reg8 (grammar id, const byte *name, byte value) int grammar_fast_check (grammar id, - const byte *text, + struct sl_pp_context *context, + struct sl_pp_token_info *tokens, byte **prod, unsigned int *size, unsigned int estimate_prod_size) { dict *di = NULL; - struct sl_pp_context context; - struct sl_pp_token_info *tokens; int index = 0; regbyte_ctx *rbc = NULL; bytepool *bp = NULL; @@ -3131,135 +3130,17 @@ grammar_fast_check (grammar id, *prod = NULL; *size = 0; - /* - * Preprocess the source string with a GLSL preprocessor. - * This is a hack but since nowadays we use grammar only for - * GLSL compiler, and that also is going away, we'll do it anyway. - */ - - { - struct sl_pp_purify_options options; - char *outbuf; - struct sl_pp_token_info *intokens; - unsigned int version; - unsigned int tokens_eaten; - - memset(&options, 0, sizeof(options)); - if (sl_pp_purify((const char *)text, &options, &outbuf)) { - return 0; - } - - if (sl_pp_context_init(&context)) { - free(outbuf); - return 1; - } - - if (sl_pp_tokenise(&context, outbuf, &intokens)) { - sl_pp_context_destroy(&context); - free(outbuf); - return 0; - } - - free(outbuf); - - if (sl_pp_version(&context, intokens, &version, &tokens_eaten)) { - sl_pp_context_destroy(&context); - free(intokens); - return 0; - } - - if (sl_pp_process(&context, &intokens[tokens_eaten], &tokens)) { - sl_pp_context_destroy(&context); - free(intokens); - return 0; - } - - free(intokens); - - /* For the time being we care about only a handful of tokens. */ - { - const struct sl_pp_token_info *src = tokens; - struct sl_pp_token_info *dst = tokens; - - while (src->token != SL_PP_EOF) { - switch (src->token) { - case SL_PP_COMMA: - case SL_PP_SEMICOLON: - case SL_PP_LBRACE: - case SL_PP_RBRACE: - case SL_PP_LPAREN: - case SL_PP_RPAREN: - case SL_PP_LBRACKET: - case SL_PP_RBRACKET: - case SL_PP_DOT: - case SL_PP_INCREMENT: - case SL_PP_ADDASSIGN: - case SL_PP_PLUS: - case SL_PP_DECREMENT: - case SL_PP_SUBASSIGN: - case SL_PP_MINUS: - case SL_PP_BITNOT: - case SL_PP_NOTEQUAL: - case SL_PP_NOT: - case SL_PP_MULASSIGN: - case SL_PP_STAR: - case SL_PP_DIVASSIGN: - case SL_PP_SLASH: - case SL_PP_MODASSIGN: - case SL_PP_MODULO: - case SL_PP_LSHIFTASSIGN: - case SL_PP_LSHIFT: - case SL_PP_LESSEQUAL: - case SL_PP_LESS: - case SL_PP_RSHIFTASSIGN: - case SL_PP_RSHIFT: - case SL_PP_GREATEREQUAL: - case SL_PP_GREATER: - case SL_PP_EQUAL: - case SL_PP_ASSIGN: - case SL_PP_AND: - case SL_PP_BITANDASSIGN: - case SL_PP_BITAND: - case SL_PP_XOR: - case SL_PP_BITXORASSIGN: - case SL_PP_BITXOR: - case SL_PP_OR: - case SL_PP_BITORASSIGN: - case SL_PP_BITOR: - case SL_PP_QUESTION: - case SL_PP_COLON: - case SL_PP_IDENTIFIER: - case SL_PP_NUMBER: - *dst++ = *src++; - break; - - default: - src++; - } - } - - /* The end of stream token. */ - *dst = *src; - } - } - bytepool_create(&bp, estimate_prod_size); if (bp == NULL) { - sl_pp_context_destroy(&context); - free(tokens); return 0; } - if (fast_match(di, tokens, &index, di->m_syntax, &_P, bp, &rbc, &context) != mr_matched) { - sl_pp_context_destroy(&context); - free(tokens); + if (fast_match(di, tokens, &index, di->m_syntax, &_P, bp, &rbc, context) != mr_matched) { bytepool_destroy (&bp); free_regbyte_ctx_stack (rbc, NULL); return 0; } - sl_pp_context_destroy(&context); - free(tokens); free_regbyte_ctx_stack(rbc, NULL); *prod = bp->_F; diff --git a/src/mesa/shader/grammar/grammar.h b/src/mesa/shader/grammar/grammar.h index 151b5f082b..c3c21659d6 100644 --- a/src/mesa/shader/grammar/grammar.h +++ b/src/mesa/shader/grammar/grammar.h @@ -69,8 +69,13 @@ int grammar_set_reg8 (grammar id, const byte *name, byte value); is a hint - the initial production buffer size will be of this size, but if more room is needed it will be safely resized; set it to 0x1000 or so */ -int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size, - unsigned int estimate_prod_size); +int +grammar_fast_check (grammar id, + struct sl_pp_context *context, + struct sl_pp_token_info *tokens, + byte **prod, + unsigned int *size, + unsigned int estimate_prod_size); /* destroys grammar object identified by diff --git a/src/mesa/shader/grammar/grammar_mesa.h b/src/mesa/shader/grammar/grammar_mesa.h index 7f4370f32d..20d13da838 100644 --- a/src/mesa/shader/grammar/grammar_mesa.h +++ b/src/mesa/shader/grammar/grammar_mesa.h @@ -27,10 +27,6 @@ #include "../../glsl/pp/sl_pp_context.h" -#include "../../glsl/pp/sl_pp_purify.h" -#include "../../glsl/pp/sl_pp_version.h" -#include "../../glsl/pp/sl_pp_process.h" - #include "main/imports.h" /* NOTE: include Mesa 3-D specific headers here */ diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 75dd8a045b..8ea8675618 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -36,6 +36,10 @@ #include "shader/prog_print.h" #include "shader/prog_parameter.h" #include "shader/grammar/grammar_mesa.h" +#include "../../glsl/pp/sl_pp_context.h" +#include "../../glsl/pp/sl_pp_purify.h" +#include "../../glsl/pp/sl_pp_version.h" +#include "../../glsl/pp/sl_pp_process.h" #include "slang_codegen.h" #include "slang_compile.h" #include "slang_storage.h" @@ -2579,9 +2583,115 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, const struct gl_extensions *extensions, struct gl_sl_pragmas *pragmas) { + struct sl_pp_context context; + struct sl_pp_token_info *tokens; byte *prod; - GLuint size, version; - GLuint maxVersion; + GLuint size; + unsigned int version; + unsigned int maxVersion; + int result; + struct sl_pp_purify_options options; + char *outbuf; + struct sl_pp_token_info *intokens; + unsigned int tokens_eaten; + + memset(&options, 0, sizeof(options)); + if (sl_pp_purify(source, &options, &outbuf)) { + return GL_FALSE; + } + + if (sl_pp_context_init(&context)) { + free(outbuf); + return GL_FALSE; + } + + if (sl_pp_tokenise(&context, outbuf, &intokens)) { + sl_pp_context_destroy(&context); + free(outbuf); + return GL_FALSE; + } + + free(outbuf); + + if (sl_pp_version(&context, intokens, &version, &tokens_eaten)) { + sl_pp_context_destroy(&context); + free(intokens); + return GL_FALSE; + } + + if (sl_pp_process(&context, &intokens[tokens_eaten], &tokens)) { + sl_pp_context_destroy(&context); + free(intokens); + return GL_FALSE; + } + + free(intokens); + + /* For the time being we care about only a handful of tokens. */ + { + const struct sl_pp_token_info *src = tokens; + struct sl_pp_token_info *dst = tokens; + + while (src->token != SL_PP_EOF) { + switch (src->token) { + case SL_PP_COMMA: + case SL_PP_SEMICOLON: + case SL_PP_LBRACE: + case SL_PP_RBRACE: + case SL_PP_LPAREN: + case SL_PP_RPAREN: + case SL_PP_LBRACKET: + case SL_PP_RBRACKET: + case SL_PP_DOT: + case SL_PP_INCREMENT: + case SL_PP_ADDASSIGN: + case SL_PP_PLUS: + case SL_PP_DECREMENT: + case SL_PP_SUBASSIGN: + case SL_PP_MINUS: + case SL_PP_BITNOT: + case SL_PP_NOTEQUAL: + case SL_PP_NOT: + case SL_PP_MULASSIGN: + case SL_PP_STAR: + case SL_PP_DIVASSIGN: + case SL_PP_SLASH: + case SL_PP_MODASSIGN: + case SL_PP_MODULO: + case SL_PP_LSHIFTASSIGN: + case SL_PP_LSHIFT: + case SL_PP_LESSEQUAL: + case SL_PP_LESS: + case SL_PP_RSHIFTASSIGN: + case SL_PP_RSHIFT: + case SL_PP_GREATEREQUAL: + case SL_PP_GREATER: + case SL_PP_EQUAL: + case SL_PP_ASSIGN: + case SL_PP_AND: + case SL_PP_BITANDASSIGN: + case SL_PP_BITAND: + case SL_PP_XOR: + case SL_PP_BITXORASSIGN: + case SL_PP_BITXOR: + case SL_PP_OR: + case SL_PP_BITORASSIGN: + case SL_PP_BITOR: + case SL_PP_QUESTION: + case SL_PP_COLON: + case SL_PP_IDENTIFIER: + case SL_PP_NUMBER: + *dst++ = *src++; + break; + + default: + src++; + } + } + + /* The end of stream token. */ + *dst = *src; + } #if FEATURE_ARB_shading_language_120 maxVersion = 120; @@ -2591,20 +2701,23 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, maxVersion = 110; #endif - /* First retrieve the version number. */ - version = 110; - - if (version > maxVersion) { + if (version > maxVersion || + (version != 100 && version != 110 && version != 120)) { slang_info_log_error(infolog, "language version %.2f is not supported.", version * 0.01); + sl_pp_context_destroy(&context); + free(tokens); return GL_FALSE; } /* Finally check the syntax and generate its binary representation. */ - if (!grammar_fast_check(id, - (const byte *)source, - &prod, &size, 65536)) { + result = grammar_fast_check(id, &context, tokens, &prod, &size, 65536); + + sl_pp_context_destroy(&context); + free(tokens); + + if (!result) { char buf[1024]; GLint pos; -- cgit v1.2.3 From c9de313f1b6d0ee8d9304fc3fe11fb84ff494f12 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 16 Sep 2009 20:28:20 +0200 Subject: slang: Propagate error messages from preprocessor. --- src/mesa/shader/slang/slang_compile.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 8ea8675618..19fec53877 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2597,15 +2597,18 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, memset(&options, 0, sizeof(options)); if (sl_pp_purify(source, &options, &outbuf)) { + slang_info_log_error(infolog, "unable to preprocess the source"); return GL_FALSE; } if (sl_pp_context_init(&context)) { + slang_info_log_error(infolog, "out of memory"); free(outbuf); return GL_FALSE; } if (sl_pp_tokenise(&context, outbuf, &intokens)) { + slang_info_log_error(infolog, "%s", context.error_msg); sl_pp_context_destroy(&context); free(outbuf); return GL_FALSE; @@ -2614,12 +2617,14 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, free(outbuf); if (sl_pp_version(&context, intokens, &version, &tokens_eaten)) { + slang_info_log_error(infolog, "%s", context.error_msg); sl_pp_context_destroy(&context); free(intokens); return GL_FALSE; } if (sl_pp_process(&context, &intokens[tokens_eaten], &tokens)) { + slang_info_log_error(infolog, "%s", context.error_msg); sl_pp_context_destroy(&context); free(intokens); return GL_FALSE; -- cgit v1.2.3 From 8302208b02739904cfeb5bcc22e63b15c8ec26e9 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 18 Sep 2009 11:19:54 +0200 Subject: slang: Use glsl pp public interface. --- src/mesa/shader/slang/slang_compile.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 19fec53877..fb452e5d2c 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -36,10 +36,7 @@ #include "shader/prog_print.h" #include "shader/prog_parameter.h" #include "shader/grammar/grammar_mesa.h" -#include "../../glsl/pp/sl_pp_context.h" -#include "../../glsl/pp/sl_pp_purify.h" -#include "../../glsl/pp/sl_pp_version.h" -#include "../../glsl/pp/sl_pp_process.h" +#include "../../glsl/pp/sl_pp_public.h" #include "slang_codegen.h" #include "slang_compile.h" #include "slang_storage.h" @@ -2583,7 +2580,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, const struct gl_extensions *extensions, struct gl_sl_pragmas *pragmas) { - struct sl_pp_context context; + struct sl_pp_context *context; struct sl_pp_token_info *tokens; byte *prod; GLuint size; @@ -2601,31 +2598,32 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, return GL_FALSE; } - if (sl_pp_context_init(&context)) { + context = sl_pp_context_create(); + if (!context) { slang_info_log_error(infolog, "out of memory"); free(outbuf); return GL_FALSE; } - if (sl_pp_tokenise(&context, outbuf, &intokens)) { - slang_info_log_error(infolog, "%s", context.error_msg); - sl_pp_context_destroy(&context); + if (sl_pp_tokenise(context, outbuf, &intokens)) { + slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); + sl_pp_context_destroy(context); free(outbuf); return GL_FALSE; } free(outbuf); - if (sl_pp_version(&context, intokens, &version, &tokens_eaten)) { - slang_info_log_error(infolog, "%s", context.error_msg); - sl_pp_context_destroy(&context); + if (sl_pp_version(context, intokens, &version, &tokens_eaten)) { + slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); + sl_pp_context_destroy(context); free(intokens); return GL_FALSE; } - if (sl_pp_process(&context, &intokens[tokens_eaten], &tokens)) { - slang_info_log_error(infolog, "%s", context.error_msg); - sl_pp_context_destroy(&context); + if (sl_pp_process(context, &intokens[tokens_eaten], &tokens)) { + slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); + sl_pp_context_destroy(context); free(intokens); return GL_FALSE; } @@ -2711,15 +2709,15 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, slang_info_log_error(infolog, "language version %.2f is not supported.", version * 0.01); - sl_pp_context_destroy(&context); + sl_pp_context_destroy(context); free(tokens); return GL_FALSE; } /* Finally check the syntax and generate its binary representation. */ - result = grammar_fast_check(id, &context, tokens, &prod, &size, 65536); + result = grammar_fast_check(id, context, tokens, &prod, &size, 65536); - sl_pp_context_destroy(&context); + sl_pp_context_destroy(context); free(tokens); if (!result) { -- cgit v1.2.3 From b1e6514a94effb1a5ea03c31f5a50e9e60638e51 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 22 Sep 2009 12:54:45 +0200 Subject: slang: Differentiate between uints and floats. --- src/mesa/shader/slang/library/slang_shader.syn | 4 ++-- src/mesa/shader/slang/library/slang_shader_syn.h | 4 ++-- src/mesa/shader/slang/slang_compile.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn index f6bf7f1e54..11f9825c01 100644 --- a/src/mesa/shader/slang/library/slang_shader.syn +++ b/src/mesa/shader/slang/library/slang_shader.syn @@ -1362,10 +1362,10 @@ identifier "@ID" .emit *; float - "@NUM" .emit 1 .emit *; + "@FLOAT" .emit 1 .emit *; integer - "@NUM" .emit 1 .emit *; + "@UINT" .emit 1 .emit *; boolean "true" .emit '1' .emit '\0' .or diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h index 9a56643d2f..488cf1a504 100644 --- a/src/mesa/shader/slang/library/slang_shader_syn.h +++ b/src/mesa/shader/slang/library/slang_shader_syn.h @@ -631,9 +631,9 @@ "identifier\n" " \"@ID\" .emit *;\n" "float\n" -" \"@NUM\" .emit 1 .emit *;\n" +" \"@FLOAT\" .emit 1 .emit *;\n" "integer\n" -" \"@NUM\" .emit 1 .emit *;\n" +" \"@UINT\" .emit 1 .emit *;\n" "boolean\n" " \"true\" .emit '1' .emit '\\0' .or\n" " \"false\" .emit '0' .emit '\\0';\n" diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index fb452e5d2c..ce3a85ebf8 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2683,7 +2683,8 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, case SL_PP_QUESTION: case SL_PP_COLON: case SL_PP_IDENTIFIER: - case SL_PP_NUMBER: + case SL_PP_UINT: + case SL_PP_FLOAT: *dst++ = *src++; break; -- cgit v1.2.3 From 4703d7d3f8d50a0ff00dd043e999b0b8b11d45e6 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 10 Nov 2009 00:16:09 +0100 Subject: slang: Update for glsl/pp interface changes. --- src/mesa/shader/slang/slang_compile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index ce3a85ebf8..b8b7b3d494 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2589,12 +2589,14 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, int result; struct sl_pp_purify_options options; char *outbuf; + char errmsg[200] = ""; + unsigned int errline = 0; struct sl_pp_token_info *intokens; unsigned int tokens_eaten; memset(&options, 0, sizeof(options)); - if (sl_pp_purify(source, &options, &outbuf)) { - slang_info_log_error(infolog, "unable to preprocess the source"); + if (sl_pp_purify(source, &options, &outbuf, errmsg, sizeof(errmsg), &errline)) { + slang_info_log_error(infolog, errmsg); return GL_FALSE; } -- cgit v1.2.3 From cd5553b457e2111f7057201aed4ad537e2f31ff9 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 13 Nov 2009 05:52:39 +0100 Subject: slang: Plug in the new syntax parser. --- src/mesa/shader/slang/slang_compile.c | 115 +++++++++++++++++----------------- 1 file changed, 58 insertions(+), 57 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index b8b7b3d494..830a2d00bc 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -35,8 +35,8 @@ #include "shader/prog_optimize.h" #include "shader/prog_print.h" #include "shader/prog_parameter.h" -#include "shader/grammar/grammar_mesa.h" #include "../../glsl/pp/sl_pp_public.h" +#include "../../glsl/cl/sl_cl_parse.h" #include "slang_codegen.h" #include "slang_compile.h" #include "slang_storage.h" @@ -128,7 +128,7 @@ _slang_code_object_dtr(slang_code_object * self) typedef struct slang_parse_ctx_ { - const byte *I; + const unsigned char *I; slang_info_log *L; int parsing_builtin; GLboolean global_scope; /**< Is object being declared a global? */ @@ -196,7 +196,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number) if (*ctx->I == '0') { int value = 0; - const byte *pi; + const unsigned char *pi; if (ctx->I[1] == 'x' || ctx->I[1] == 'X') { ctx->I += 2; @@ -2540,7 +2540,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, } static GLboolean -compile_binary(const byte * prod, slang_code_unit * unit, +compile_binary(const unsigned char * prod, slang_code_unit * unit, GLuint version, slang_unit_type type, slang_info_log * infolog, slang_code_unit * builtin, slang_code_unit * downlink, @@ -2573,16 +2573,20 @@ compile_binary(const byte * prod, slang_code_unit * unit, } static GLboolean -compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, - slang_unit_type type, slang_info_log * infolog, - slang_code_unit * builtin, +compile_with_grammar(const char *source, + slang_code_unit *unit, + slang_unit_type type, + slang_info_log *infolog, + slang_code_unit *builtin, struct gl_shader *shader, const struct gl_extensions *extensions, - struct gl_sl_pragmas *pragmas) + struct gl_sl_pragmas *pragmas, + unsigned int shader_type, + unsigned int parsing_builtin) { struct sl_pp_context *context; struct sl_pp_token_info *tokens; - byte *prod; + unsigned char *prod; GLuint size; unsigned int version; unsigned int maxVersion; @@ -2718,17 +2722,17 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, } /* Finally check the syntax and generate its binary representation. */ - result = grammar_fast_check(id, context, tokens, &prod, &size, 65536); + result = sl_cl_compile(context, tokens, shader_type, &prod, &size); sl_pp_context_destroy(context); free(tokens); - if (!result) { - char buf[1024]; - GLint pos; + if (result) { + /*char buf[1024]; + GLint pos;*/ - grammar_get_last_error((byte *) (buf), sizeof(buf), &pos); - slang_info_log_error(infolog, buf); + /*slang_info_log_error(infolog, buf);*/ + slang_info_log_error(infolog, "Syntax error."); /* syntax error (possibly in library code) */ #if 0 { @@ -2747,10 +2751,10 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, if (!compile_binary(prod, unit, version, type, infolog, builtin, &builtin[SLANG_BUILTIN_TOTAL - 1], shader)) { - grammar_alloc_free(prod); + free(prod); return GL_FALSE; } - grammar_alloc_free(prod); + free(prod); return GL_TRUE; } @@ -2758,60 +2762,53 @@ LONGSTRING static const char *slang_shader_syn = #include "library/slang_shader_syn.h" ; -static const byte slang_core_gc[] = { +static const unsigned char slang_core_gc[] = { #include "library/slang_core_gc.h" }; -static const byte slang_120_core_gc[] = { +static const unsigned char slang_120_core_gc[] = { #include "library/slang_120_core_gc.h" }; -static const byte slang_120_fragment_gc[] = { +static const unsigned char slang_120_fragment_gc[] = { #include "library/slang_builtin_120_fragment_gc.h" }; -static const byte slang_common_builtin_gc[] = { +static const unsigned char slang_common_builtin_gc[] = { #include "library/slang_common_builtin_gc.h" }; -static const byte slang_fragment_builtin_gc[] = { +static const unsigned char slang_fragment_builtin_gc[] = { #include "library/slang_fragment_builtin_gc.h" }; -static const byte slang_vertex_builtin_gc[] = { +static const unsigned char slang_vertex_builtin_gc[] = { #include "library/slang_vertex_builtin_gc.h" }; static GLboolean -compile_object(grammar * id, const char *source, slang_code_object * object, - slang_unit_type type, slang_info_log * infolog, +compile_object(const char *source, + slang_code_object *object, + slang_unit_type type, + slang_info_log *infolog, struct gl_shader *shader, const struct gl_extensions *extensions, struct gl_sl_pragmas *pragmas) { slang_code_unit *builtins = NULL; GLuint base_version = 110; - - /* load GLSL grammar */ - *id = grammar_load_from_text((const byte *) (slang_shader_syn)); - if (*id == 0) { - byte buf[1024]; - int pos; - - grammar_get_last_error(buf, 1024, &pos); - slang_info_log_error(infolog, (const char *) (buf)); - return GL_FALSE; - } + unsigned int shader_type; + unsigned int parsing_builtin; /* set shader type - the syntax is slightly different for different shaders */ - if (type == SLANG_UNIT_FRAGMENT_SHADER - || type == SLANG_UNIT_FRAGMENT_BUILTIN) - grammar_set_reg8(*id, (const byte *) "shader_type", 1); - else - grammar_set_reg8(*id, (const byte *) "shader_type", 2); + if (type == SLANG_UNIT_FRAGMENT_SHADER || type == SLANG_UNIT_FRAGMENT_BUILTIN) { + shader_type = 1; + } else { + shader_type = 2; + } /* enable language extensions */ - grammar_set_reg8(*id, (const byte *) "parsing_builtin", 1); + parsing_builtin = 1; /* if parsing user-specified shader, load built-in library */ if (type == SLANG_UNIT_FRAGMENT_SHADER || type == SLANG_UNIT_VERTEX_SHADER) { @@ -2877,16 +2874,24 @@ compile_object(grammar * id, const char *source, slang_code_object * object, /* disable language extensions */ #if NEW_SLANG /* allow-built-ins */ - grammar_set_reg8(*id, (const byte *) "parsing_builtin", 1); + parsing_builtin = 1; #else - grammar_set_reg8(*id, (const byte *) "parsing_builtin", 0); + parsing_builtin = 0; #endif builtins = object->builtin; } /* compile the actual shader - pass-in built-in library for external shader */ - return compile_with_grammar(*id, source, &object->unit, type, infolog, - builtins, shader, extensions, pragmas); + return compile_with_grammar(source, + &object->unit, + type, + infolog, + builtins, + shader, + extensions, + pragmas, + shader_type, + parsing_builtin); } @@ -2895,9 +2900,6 @@ compile_shader(GLcontext *ctx, slang_code_object * object, slang_unit_type type, slang_info_log * infolog, struct gl_shader *shader) { - GLboolean success; - grammar id = 0; - #if 0 /* for debug */ _mesa_printf("********* COMPILE SHADER ***********\n"); _mesa_printf("%s\n", shader->Source); @@ -2909,14 +2911,13 @@ compile_shader(GLcontext *ctx, slang_code_object * object, _slang_code_object_dtr(object); _slang_code_object_ctr(object); - success = compile_object(&id, shader->Source, object, type, infolog, shader, - &ctx->Extensions, &shader->Pragmas); - if (id != 0) - grammar_destroy(id); - if (!success) - return GL_FALSE; - - return GL_TRUE; + return compile_object(shader->Source, + object, + type, + infolog, + shader, + &ctx->Extensions, + &shader->Pragmas); } -- cgit v1.2.3 From 7593562a61ed59e5b645d9285a957a57704bfd6d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 13 Nov 2009 05:58:46 +0100 Subject: slang: Get rid of the old syntax file and utilities. --- src/mesa/shader/slang/library/gc_to_bin.c | 85 -- src/mesa/shader/slang/library/slang_shader.syn | 1525 ---------------------- src/mesa/shader/slang/library/slang_shader_syn.h | 714 ---------- src/mesa/shader/slang/library/syn_to_c.c | 72 - src/mesa/shader/slang/slang_compile.c | 4 - 5 files changed, 2400 deletions(-) delete mode 100644 src/mesa/shader/slang/library/gc_to_bin.c delete mode 100644 src/mesa/shader/slang/library/slang_shader.syn delete mode 100644 src/mesa/shader/slang/library/slang_shader_syn.h delete mode 100644 src/mesa/shader/slang/library/syn_to_c.c (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/library/gc_to_bin.c b/src/mesa/shader/slang/library/gc_to_bin.c deleted file mode 100644 index 8aef7b5412..0000000000 --- a/src/mesa/shader/slang/library/gc_to_bin.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "../../grammar/grammar_crt.h" -#include "../../grammar/grammar_crt.c" -#include -#include - -static const char *slang_shader_syn = -#include "slang_shader_syn.h" -; - -static int gc_to_bin (grammar id, const char *in, const char *out) -{ - FILE *f; - byte *source, *prod; - unsigned int size, i, line = 0; - - printf ("Precompiling %s\n", in); - - f = fopen (in, "r"); - if (f == NULL) - return 1; - fseek (f, 0, SEEK_END); - size = ftell (f); - fseek (f, 0, SEEK_SET); - source = (byte *) grammar_alloc_malloc (size + 1); - source[fread (source, 1, size, f)] = '\0'; - fclose (f); - - if (!grammar_fast_check (id, source, &prod, &size, 65536)) - { - grammar_alloc_free (source); - return 1; - } - - f = fopen (out, "w"); - fprintf (f, "\n"); - fprintf (f, "/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n"); - fprintf (f, "/* %s */\n", in); - fprintf (f, "\n"); - for (i = 0; i < size; i++) - { - unsigned int a; - if (prod[i] < 10) - a = 1; - else if (prod[i] < 100) - a = 2; - else - a = 3; - if (i < size - 1) - a++; - if (line + a >= 100) - { - fprintf (f, "\n"); - line = 0; - } - line += a; - fprintf (f, "%d", prod[i]); - if (i < size - 1) - fprintf (f, ","); - } - fprintf (f, "\n"); - fclose (f); - grammar_alloc_free (prod); - return 0; -} - -int main (int argc, char *argv[]) -{ - grammar id; - - id = grammar_load_from_text ((const byte *) slang_shader_syn); - if (id == 0) { - fprintf(stderr, "Error loading grammar from text\n"); - return 1; - } - grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1); - grammar_set_reg8 (id, (const byte *) "shader_type", atoi (argv[1])); - if (gc_to_bin (id, argv[2], argv[3])) { - fprintf(stderr, "Error in gc_to_bin %s %s\n", argv[2], argv[3]); - grammar_destroy (id); - return 1; - } - grammar_destroy (id); - return 0; -} - diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn deleted file mode 100644 index 11f9825c01..0000000000 --- a/src/mesa/shader/slang/library/slang_shader.syn +++ /dev/null @@ -1,1525 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2006 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * \file slang_shader.syn - * slang vertex/fragment shader syntax - * \author Michal Krol - */ - -/* - * usage: - * syn2c slang_shader.syn > slang_shader_syn.h - * - * when modifying or extending this file, several things must be taken into - * consideration: - * - * - when adding new operators that were marked as reserved in the - * initial specification, one must only uncomment particular lines of - * code that refer to operators being added; - * - * - when adding new shader targets, one must reserve a new value for - * shader_type register and use it in .if constructs for symbols that - * are exclusive for that shader; - * - * - some symbols mimic output of other symbols - the best example is - * the "for" construct: expression "for (foo(); ; bar())" is seen as - * "for (foo(); true; bar())" by the output processor - hence, special - * care must be taken when rearranging output of essential symbols; - * - * - order of single-quoted tokens does matter in alternatives - so do not - * parse "<" operator before "<<" and "<<" before "<<="; - * - * - all double-quoted tokens are internally preprocessed to eliminate - * problems with parsing strings that are prefixes of other strings, - * like "sampler1D" and "sampler1DShadow"; - */ - -.syntax translation_unit; - -/* revision number - increment after each change affecting emitted output */ -.emtcode REVISION 5 - -/* external declaration (or precision or invariant stmt) */ -.emtcode EXTERNAL_NULL 0 -.emtcode EXTERNAL_FUNCTION_DEFINITION 1 -.emtcode EXTERNAL_DECLARATION 2 -.emtcode DEFAULT_PRECISION 3 -.emtcode INVARIANT_STMT 4 - -/* precision */ -.emtcode PRECISION_DEFAULT 0 -.emtcode PRECISION_LOW 1 -.emtcode PRECISION_MEDIUM 2 -.emtcode PRECISION_HIGH 3 - -/* declaration */ -.emtcode DECLARATION_FUNCTION_PROTOTYPE 1 -.emtcode DECLARATION_INIT_DECLARATOR_LIST 2 - -/* function type */ -.emtcode FUNCTION_ORDINARY 0 -.emtcode FUNCTION_CONSTRUCTOR 1 -.emtcode FUNCTION_OPERATOR 2 - -/* function call type */ -.emtcode FUNCTION_CALL_NONARRAY 0 -.emtcode FUNCTION_CALL_ARRAY 1 - -/* operator type */ -.emtcode OPERATOR_ADDASSIGN 1 -.emtcode OPERATOR_SUBASSIGN 2 -.emtcode OPERATOR_MULASSIGN 3 -.emtcode OPERATOR_DIVASSIGN 4 -/*.emtcode OPERATOR_MODASSIGN 5*/ -/*.emtcode OPERATOR_LSHASSIGN 6*/ -/*.emtcode OPERATOR_RSHASSIGN 7*/ -/*.emtcode OPERATOR_ORASSIGN 8*/ -/*.emtcode OPERATOR_XORASSIGN 9*/ -/*.emtcode OPERATOR_ANDASSIGN 10*/ -.emtcode OPERATOR_LOGICALXOR 11 -/*.emtcode OPERATOR_BITOR 12*/ -/*.emtcode OPERATOR_BITXOR 13*/ -/*.emtcode OPERATOR_BITAND 14*/ -.emtcode OPERATOR_LESS 15 -.emtcode OPERATOR_GREATER 16 -.emtcode OPERATOR_LESSEQUAL 17 -.emtcode OPERATOR_GREATEREQUAL 18 -/*.emtcode OPERATOR_LSHIFT 19*/ -/*.emtcode OPERATOR_RSHIFT 20*/ -.emtcode OPERATOR_MULTIPLY 21 -.emtcode OPERATOR_DIVIDE 22 -/*.emtcode OPERATOR_MODULUS 23*/ -.emtcode OPERATOR_INCREMENT 24 -.emtcode OPERATOR_DECREMENT 25 -.emtcode OPERATOR_PLUS 26 -.emtcode OPERATOR_MINUS 27 -/*.emtcode OPERATOR_COMPLEMENT 28*/ -.emtcode OPERATOR_NOT 29 - -/* init declarator list */ -.emtcode DECLARATOR_NONE 0 -.emtcode DECLARATOR_NEXT 1 - -/* variable declaration */ -.emtcode VARIABLE_NONE 0 -.emtcode VARIABLE_IDENTIFIER 1 -.emtcode VARIABLE_INITIALIZER 2 -.emtcode VARIABLE_ARRAY_EXPLICIT 3 -.emtcode VARIABLE_ARRAY_UNKNOWN 4 - -/* type qualifier */ -.emtcode TYPE_QUALIFIER_NONE 0 -.emtcode TYPE_QUALIFIER_CONST 1 -.emtcode TYPE_QUALIFIER_ATTRIBUTE 2 -.emtcode TYPE_QUALIFIER_VARYING 3 -.emtcode TYPE_QUALIFIER_UNIFORM 4 -.emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5 -.emtcode TYPE_QUALIFIER_FIXEDINPUT 6 - -/* invariant qualifier */ -.emtcode TYPE_VARIANT 90 -.emtcode TYPE_INVARIANT 91 - -/* centroid qualifier */ -.emtcode TYPE_CENTER 95 -.emtcode TYPE_CENTROID 96 - -/* type specifier */ -.emtcode TYPE_SPECIFIER_VOID 0 -.emtcode TYPE_SPECIFIER_BOOL 1 -.emtcode TYPE_SPECIFIER_BVEC2 2 -.emtcode TYPE_SPECIFIER_BVEC3 3 -.emtcode TYPE_SPECIFIER_BVEC4 4 -.emtcode TYPE_SPECIFIER_INT 5 -.emtcode TYPE_SPECIFIER_IVEC2 6 -.emtcode TYPE_SPECIFIER_IVEC3 7 -.emtcode TYPE_SPECIFIER_IVEC4 8 -.emtcode TYPE_SPECIFIER_FLOAT 9 -.emtcode TYPE_SPECIFIER_VEC2 10 -.emtcode TYPE_SPECIFIER_VEC3 11 -.emtcode TYPE_SPECIFIER_VEC4 12 -.emtcode TYPE_SPECIFIER_MAT2 13 -.emtcode TYPE_SPECIFIER_MAT3 14 -.emtcode TYPE_SPECIFIER_MAT4 15 -.emtcode TYPE_SPECIFIER_SAMPLER1D 16 -.emtcode TYPE_SPECIFIER_SAMPLER2D 17 -.emtcode TYPE_SPECIFIER_SAMPLER3D 18 -.emtcode TYPE_SPECIFIER_SAMPLERCUBE 19 -.emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20 -.emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21 -.emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22 -.emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23 -.emtcode TYPE_SPECIFIER_STRUCT 24 -.emtcode TYPE_SPECIFIER_TYPENAME 25 - -/* OpenGL 2.1 */ -.emtcode TYPE_SPECIFIER_MAT23 26 -.emtcode TYPE_SPECIFIER_MAT32 27 -.emtcode TYPE_SPECIFIER_MAT24 28 -.emtcode TYPE_SPECIFIER_MAT42 29 -.emtcode TYPE_SPECIFIER_MAT34 30 -.emtcode TYPE_SPECIFIER_MAT43 31 - -/* type specifier array */ -.emtcode TYPE_SPECIFIER_NONARRAY 0 -.emtcode TYPE_SPECIFIER_ARRAY 1 - -/* structure field */ -.emtcode FIELD_NONE 0 -.emtcode FIELD_NEXT 1 -.emtcode FIELD_ARRAY 2 - -/* operation */ -.emtcode OP_END 0 -.emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1 -.emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2 -.emtcode OP_DECLARE 3 -.emtcode OP_ASM 4 -.emtcode OP_BREAK 5 -.emtcode OP_CONTINUE 6 -.emtcode OP_DISCARD 7 -.emtcode OP_RETURN 8 -.emtcode OP_EXPRESSION 9 -.emtcode OP_IF 10 -.emtcode OP_WHILE 11 -.emtcode OP_DO 12 -.emtcode OP_FOR 13 -.emtcode OP_PUSH_VOID 14 -.emtcode OP_PUSH_BOOL 15 -.emtcode OP_PUSH_INT 16 -.emtcode OP_PUSH_FLOAT 17 -.emtcode OP_PUSH_IDENTIFIER 18 -.emtcode OP_SEQUENCE 19 -.emtcode OP_ASSIGN 20 -.emtcode OP_ADDASSIGN 21 -.emtcode OP_SUBASSIGN 22 -.emtcode OP_MULASSIGN 23 -.emtcode OP_DIVASSIGN 24 -/*.emtcode OP_MODASSIGN 25*/ -/*.emtcode OP_LSHASSIGN 26*/ -/*.emtcode OP_RSHASSIGN 27*/ -/*.emtcode OP_ORASSIGN 28*/ -/*.emtcode OP_XORASSIGN 29*/ -/*.emtcode OP_ANDASSIGN 30*/ -.emtcode OP_SELECT 31 -.emtcode OP_LOGICALOR 32 -.emtcode OP_LOGICALXOR 33 -.emtcode OP_LOGICALAND 34 -/*.emtcode OP_BITOR 35*/ -/*.emtcode OP_BITXOR 36*/ -/*.emtcode OP_BITAND 37*/ -.emtcode OP_EQUAL 38 -.emtcode OP_NOTEQUAL 39 -.emtcode OP_LESS 40 -.emtcode OP_GREATER 41 -.emtcode OP_LESSEQUAL 42 -.emtcode OP_GREATEREQUAL 43 -/*.emtcode OP_LSHIFT 44*/ -/*.emtcode OP_RSHIFT 45*/ -.emtcode OP_ADD 46 -.emtcode OP_SUBTRACT 47 -.emtcode OP_MULTIPLY 48 -.emtcode OP_DIVIDE 49 -/*.emtcode OP_MODULUS 50*/ -.emtcode OP_PREINCREMENT 51 -.emtcode OP_PREDECREMENT 52 -.emtcode OP_PLUS 53 -.emtcode OP_MINUS 54 -/*.emtcode OP_COMPLEMENT 55*/ -.emtcode OP_NOT 56 -.emtcode OP_SUBSCRIPT 57 -.emtcode OP_CALL 58 -.emtcode OP_FIELD 59 -.emtcode OP_POSTINCREMENT 60 -.emtcode OP_POSTDECREMENT 61 -.emtcode OP_PRECISION 62 -.emtcode OP_METHOD 63 - -/* parameter qualifier */ -.emtcode PARAM_QUALIFIER_IN 0 -.emtcode PARAM_QUALIFIER_OUT 1 -.emtcode PARAM_QUALIFIER_INOUT 2 - -/* function parameter */ -.emtcode PARAMETER_NONE 0 -.emtcode PARAMETER_NEXT 1 - -/* function parameter array presence */ -.emtcode PARAMETER_ARRAY_NOT_PRESENT 0 -.emtcode PARAMETER_ARRAY_PRESENT 1 - -/* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */ -/* any syntax errors... */ -.errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error." -.errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override." -.errtext LBRACE_EXPECTED "2003: '{' expected but token found." -.errtext LPAREN_EXPECTED "2004: '(' expected but token found." -.errtext RPAREN_EXPECTED "2005: ')' expected but token found." -.errtext INVALID_PRECISION "2006: Invalid precision specifier." -.errtext INVALID_PRECISION_TYPE "2007: Invalid precision type." - - -/* - * tells whether the shader that is being parsed is a built-in shader or not - * 0 - normal behaviour - * 1 - accepts constructor and operator definitions and __asm statements - * the implementation will set it to 1 when compiling internal built-in shaders - */ -.regbyte parsing_builtin 0 - -/* - * holds the type of the shader being parsed; possible values are - * listed below. - * FRAGMENT_SHADER 1 - * VERTEX_SHADER 2 - * shader type is set by the caller before parsing - */ -.regbyte shader_type 0 - -/* - * ::= - */ -variable_identifier - identifier .emit OP_PUSH_IDENTIFIER; - -/* - * ::= - * | - * | - * | - * | "(" ")" - */ -primary_expression - floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1; -primary_expression_1 - lparen .and expression .and rparen; - -/* - * ::= - * | "[" "]" - * | - * | "." - * | "++" - * | "--" - */ -postfix_expression - postfix_expression_1 .and .loop postfix_expression_2; -postfix_expression_1 - function_call .or primary_expression; -postfix_expression_2 - postfix_expression_3 .or postfix_expression_4 .or - plusplus .emit OP_POSTINCREMENT .or - minusminus .emit OP_POSTDECREMENT; -postfix_expression_3 - lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT; -postfix_expression_4 - dot .and field_selection .emit OP_FIELD; - -/* - * ::= - */ -integer_expression - expression; - -/* - * ::= - */ -function_call - function_call_or_method; - -/* - * ::= - * | "." - */ -function_call_or_method - regular_function_call .or method_call; - -/* - * ::= "." - */ -method_call - identifier .emit OP_METHOD .and dot .and function_call_generic .and .true .emit OP_END; - -/* - * ::= - */ -regular_function_call - function_call_generic .emit OP_CALL .and .true .emit OP_END; - -/* - * ::= ")" - * | ")" - */ -function_call_generic - function_call_generic_1 .or function_call_generic_2; -function_call_generic_1 - function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED; -function_call_generic_2 - function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED; - -/* - * ::= "void" - * | - */ -function_call_header_no_parameters - function_call_header .and function_call_header_no_parameters_1; -function_call_header_no_parameters_1 - "void" .or .true; - -/* - * ::= - * | "," - */ -function_call_header_with_parameters - function_call_header .and assignment_expression .and .true .emit OP_END .and - .loop function_call_header_with_parameters_1; -function_call_header_with_parameters_1 - comma .and assignment_expression .and .true .emit OP_END; - -/* - * ::= "(" - */ -function_call_header - function_identifier .and lparen; - -/* - * ::= - * | - * | - * - * note: and have been deleted - */ -function_identifier - identifier .and function_identifier_opt_array; -function_identifier_opt_array - function_identifier_array .emit FUNCTION_CALL_ARRAY .or - .true .emit FUNCTION_CALL_NONARRAY; -function_identifier_array - lbracket .and constant_expression .and rbracket; - -/* - * ::= - * | "++" - * | "--" - * | - * - * ::= "+" - * | "-" - * | "!" - * | "~" // reserved - */ -unary_expression - postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or - unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/; -unary_expression_1 - plusplus .and unary_expression .and .true .emit OP_PREINCREMENT; -unary_expression_2 - minusminus .and unary_expression .and .true .emit OP_PREDECREMENT; -unary_expression_3 - plus .and unary_expression .and .true .emit OP_PLUS; -unary_expression_4 - minus .and unary_expression .and .true .emit OP_MINUS; -unary_expression_5 - bang .and unary_expression .and .true .emit OP_NOT; -/*unary_expression_6 - tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/ - -/* - * ::= - * | "*" - * | "/" - * | "%" // reserved - */ -multiplicative_expression - unary_expression .and .loop multiplicative_expression_1; -multiplicative_expression_1 - multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/; -multiplicative_expression_2 - star .and unary_expression .and .true .emit OP_MULTIPLY; -multiplicative_expression_3 - slash .and unary_expression .and .true .emit OP_DIVIDE; -/*multiplicative_expression_4 - percent .and unary_expression .and .true .emit OP_MODULUS;*/ - -/* - * ::= - * | "+" - * | "-" - */ -additive_expression - multiplicative_expression .and .loop additive_expression_1; -additive_expression_1 - additive_expression_2 .or additive_expression_3; -additive_expression_2 - plus .and multiplicative_expression .and .true .emit OP_ADD; -additive_expression_3 - minus .and multiplicative_expression .and .true .emit OP_SUBTRACT; - -/* - * ::= - * | "<<" // reserved - * | ">>" // reserved - */ -shift_expression - additive_expression/* .and .loop shift_expression_1*/; -/*shift_expression_1 - shift_expression_2 .or shift_expression_3;*/ -/*shift_expression_2 - lessless .and additive_expression .and .true .emit OP_LSHIFT;*/ -/*shift_expression_3 - greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/ - -/* - * ::= - * | "<" - * | ">" - * | "<=" - * | ">=" - */ -relational_expression - shift_expression .and .loop relational_expression_1; -relational_expression_1 - relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or - relational_expression_5; -relational_expression_2 - lessequals .and shift_expression .and .true .emit OP_LESSEQUAL; -relational_expression_3 - greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL; -relational_expression_4 - less .and shift_expression .and .true .emit OP_LESS; -relational_expression_5 - greater .and shift_expression .and .true .emit OP_GREATER; - -/* - * ::= - * | "==" - * | "!=" - */ -equality_expression - relational_expression .and .loop equality_expression_1; -equality_expression_1 - equality_expression_2 .or equality_expression_3; -equality_expression_2 - equalsequals .and relational_expression .and .true .emit OP_EQUAL; -equality_expression_3 - bangequals .and relational_expression .and .true .emit OP_NOTEQUAL; - -/* - * ::= - * | "&" // reserved - */ -and_expression - equality_expression/* .and .loop and_expression_1*/; -/*and_expression_1 - ampersand .and equality_expression .and .true .emit OP_BITAND;*/ - -/* - * ::= - * | "^" // reserved - */ -exclusive_or_expression - and_expression/* .and .loop exclusive_or_expression_1*/; -/*exclusive_or_expression_1 - caret .and and_expression .and .true .emit OP_BITXOR;*/ - -/* - * ::= - * | "|" // reserved - */ -inclusive_or_expression - exclusive_or_expression/* .and .loop inclusive_or_expression_1*/; -/*inclusive_or_expression_1 - bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/ - -/* - * ::= - * | "&&" - */ -logical_and_expression - inclusive_or_expression .and .loop logical_and_expression_1; -logical_and_expression_1 - ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND; - -/* - * ::= - * | "^^" - */ -logical_xor_expression - logical_and_expression .and .loop logical_xor_expression_1; -logical_xor_expression_1 - caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR; - -/* - * ::= - * | "||" - */ -logical_or_expression - logical_xor_expression .and .loop logical_or_expression_1; -logical_or_expression_1 - barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR; - -/* - * ::= - * | "?" ":" - */ -conditional_expression - logical_or_expression .and .loop conditional_expression_1; -conditional_expression_1 - question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT; - -/* - * ::= - * | - * - * ::= "=" - * | "*=" - * | "/=" - * | "+=" - * | "-=" - * | "%=" // reserved - * | "<<=" // reserved - * | ">>=" // reserved - * | "&=" // reserved - * | "^=" // reserved - * | "|=" // reserved - */ -assignment_expression - assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or - assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or - assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or - assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression; -assignment_expression_1 - unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN; -assignment_expression_2 - unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN; -assignment_expression_3 - unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN; -assignment_expression_4 - unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN; -assignment_expression_5 - unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN; -/*assignment_expression_6 - unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/ -/*assignment_expression_7 - unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/ -/*assignment_expression_8 - unary_expression .and greatergreaterequals .and assignment_expression .and - .true .emit OP_RSHASSIGN;*/ -/*assignment_expression_9 - unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/ -/*assignment_expression_10 - unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/ -/*assignment_expression_11 - unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/ - -/* - * ::= - * | "," - */ -expression - assignment_expression .and .loop expression_1; -expression_1 - comma .and assignment_expression .and .true .emit OP_SEQUENCE; - -/* - * ::= - */ -constant_expression - conditional_expression .and .true .emit OP_END; - -/* - * ::= ";" - * | ";" - */ -declaration - declaration_1 .or declaration_2; -declaration_1 - function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon; -declaration_2 - init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon; - -/* - * ::= "void" ")" - * | ")" - */ -function_prototype - function_prototype_1 .or function_prototype_2; -function_prototype_1 - function_header .and "void" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE; -function_prototype_2 - function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE; - -/* - * ::= - * | - */ -function_declarator - function_header_with_parameters .or function_header; - -/* - * ::= - * | "," - * - */ -function_header_with_parameters - function_header .and parameter_declaration .and .loop function_header_with_parameters_1; -function_header_with_parameters_1 - comma .and parameter_declaration; - -/* - * ::= "(" - */ -function_header - fully_specified_type .and function_decl_identifier .and lparen; - -/* - * ::= "__constructor" - * | <__operator> - * | - * - * note: this is an extension to the standard language specification. - * normally slang disallows operator and constructor prototypes and definitions - */ -function_decl_identifier - .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or - .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or - identifier .emit FUNCTION_ORDINARY; - -/* - * <__operator> ::= "__operator" - * - * note: this is an extension to the standard language specification. - * normally slang disallows operator prototypes and definitions - */ -__operator - "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE; - -/* - * ::= "=" - * | "+=" - * | "-=" - * | "*=" - * | "/=" - * | "%=" // reserved - * | "<<=" // reserved - * | ">>=" // reserved - * | "&=" // reserved - * | "^=" // reserved - * | "|=" // reserved - * | "^^" - * | "|" // reserved - * | "^" // reserved - * | "&" // reserved - * | "==" - * | "!=" - * | "<" - * | ">" - * | "<=" - * | ">=" - * | "<<" // reserved - * | ">>" // reserved - * | "*" - * | "/" - * | "%" // reserved - * | "++" - * | "--" - * | "+" - * | "-" - * | "~" // reserved - * | "!" - * - * note: this is an extension to the standard language specification. - * normally slang disallows operator prototypes and definitions - */ -overriden_operator - plusplus .emit OPERATOR_INCREMENT .or - plusequals .emit OPERATOR_ADDASSIGN .or - plus .emit OPERATOR_PLUS .or - minusminus .emit OPERATOR_DECREMENT .or - minusequals .emit OPERATOR_SUBASSIGN .or - minus .emit OPERATOR_MINUS .or - bang .emit OPERATOR_NOT .or - starequals .emit OPERATOR_MULASSIGN .or - star .emit OPERATOR_MULTIPLY .or - slashequals .emit OPERATOR_DIVASSIGN .or - slash .emit OPERATOR_DIVIDE .or - lessequals .emit OPERATOR_LESSEQUAL .or - /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/ - /*lessless .emit OPERATOR_LSHIFT .or*/ - less .emit OPERATOR_LESS .or - greaterequals .emit OPERATOR_GREATEREQUAL .or - /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/ - /*greatergreater .emit OPERATOR_RSHIFT .or*/ - greater .emit OPERATOR_GREATER .or - /*percentequals .emit OPERATOR_MODASSIGN .or*/ - /*percent .emit OPERATOR_MODULUS .or*/ - /*ampersandequals .emit OPERATOR_ANDASSIGN */ - /*ampersand .emit OPERATOR_BITAND .or*/ - /*barequals .emit OPERATOR_ORASSIGN .or*/ - /*bar .emit OPERATOR_BITOR .or*/ - /*tilde .emit OPERATOR_COMPLEMENT .or*/ - /*caretequals .emit OPERATOR_XORASSIGN .or*/ - caretcaret .emit OPERATOR_LOGICALXOR /*.or - caret .emit OPERATOR_BITXOR*/; - -/* - * ::= - * | "[" "]" - */ -parameter_declarator - type_specifier .and identifier .and parameter_declarator_1; -parameter_declarator_1 - parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or - .true .emit PARAMETER_ARRAY_NOT_PRESENT; -parameter_declarator_2 - lbracket .and constant_expression .and rbracket; - -/* - * ::= - * - * | - * - * | - * - * | - * - * | - * - * | - * - * | - * | - */ -parameter_declaration - parameter_declaration_1 .emit PARAMETER_NEXT; -parameter_declaration_1 - parameter_declaration_2 .or parameter_declaration_3; -parameter_declaration_2 - type_qualifier .and parameter_qualifier .and parameter_declaration_4; -parameter_declaration_3 - parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4; -parameter_declaration_4 - parameter_declaration_optprec .and parameter_declaration_rest; -parameter_declaration_optprec - precision .or .true .emit PRECISION_DEFAULT; -parameter_declaration_rest - parameter_declarator .or parameter_type_specifier; - -/* - * ::= "in" - * | "out" - * | "inout" - * | "" - */ -parameter_qualifier - parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN; -parameter_qualifier_1 - "in" .emit PARAM_QUALIFIER_IN .or - "out" .emit PARAM_QUALIFIER_OUT .or - "inout" .emit PARAM_QUALIFIER_INOUT; - -/* - * ::= - * | "[" "]" - */ -parameter_type_specifier - type_specifier .and .true .emit '\0' .and parameter_type_specifier_2; -parameter_type_specifier_2 - parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or - .true .emit PARAMETER_ARRAY_NOT_PRESENT; -parameter_type_specifier_3 - lbracket .and constant_expression .and rbracket; - -/* - * ::= - * | "," - * | "," "[" "]" - * | "," "[" "]" - * | "," "=" - */ -init_declarator_list - single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and - .true .emit DECLARATOR_NONE; -init_declarator_list_1 - comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2; -init_declarator_list_2 - init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE; -init_declarator_list_3 - equals .and initializer .emit VARIABLE_INITIALIZER; -init_declarator_list_4 - lbracket .and init_declarator_list_5 .and rbracket; -init_declarator_list_5 - constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN; - -/* - * ::= - * | - * | "[" "]" - * | "[" "]" - * | "=" - */ -single_declaration - fully_specified_type .and single_declaration_1; -single_declaration_1 - single_declaration_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE; -single_declaration_2 - identifier .and single_declaration_3; -single_declaration_3 - single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE; -single_declaration_4 - equals .and initializer .emit VARIABLE_INITIALIZER; -single_declaration_5 - lbracket .and single_declaration_6 .and rbracket; -single_declaration_6 - constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN; - -/* - * ::= - * - * Example: "invariant varying highp vec3" - */ -fully_specified_type - fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier; -fully_specified_type_optinvariant - invariant_qualifier .or .true .emit TYPE_VARIANT; -fully_specified_type_optcentroid - centroid_qualifier .or .true .emit TYPE_CENTER; -fully_specified_type_optqual - type_qualifier .or .true .emit TYPE_QUALIFIER_NONE; -fully_specified_type_optprec - precision .or .true .emit PRECISION_DEFAULT; - -/* - * ::= "invariant" - */ -invariant_qualifier - "invariant" .emit TYPE_INVARIANT; - -centroid_qualifier - "centroid" .emit TYPE_CENTROID; - - -/* - * ::= "const" - * | "attribute" // Vertex only. - * | "varying" - * | "uniform" - * | "__fixed_output" - * | "__fixed_input" - * - * note: this is an extension to the standard language specification, - * normally slang disallows __fixed_output and __fixed_input type qualifiers - */ -type_qualifier - "const" .emit TYPE_QUALIFIER_CONST .or - .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or - "varying" .emit TYPE_QUALIFIER_VARYING .or - "uniform" .emit TYPE_QUALIFIER_UNIFORM .or - .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or - .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT; - -/* - * ::= "void" - * | "float" - * | "int" - * | "bool" - * | "vec2" - * | "vec3" - * | "vec4" - * | "bvec2" - * | "bvec3" - * | "bvec4" - * | "ivec2" - * | "ivec3" - * | "ivec4" - * | "mat2" - * | "mat3" - * | "mat4" - * | "mat2x3" - * | "mat3x2" - * | "mat2x4" - * | "mat4x2" - * | "mat3x4" - * | "mat4x3" - * | "sampler1D" - * | "sampler2D" - * | "sampler3D" - * | "samplerCube" - * | "sampler1DShadow" - * | "sampler2DShadow" - * | "sampler2DRect" - * | "sampler2DRectShadow" - * | - * | - */ -type_specifier_nonarray - struct_specifier .emit TYPE_SPECIFIER_STRUCT .or - "void" .emit TYPE_SPECIFIER_VOID .or - "float" .emit TYPE_SPECIFIER_FLOAT .or - "int" .emit TYPE_SPECIFIER_INT .or - "bool" .emit TYPE_SPECIFIER_BOOL .or - "vec2" .emit TYPE_SPECIFIER_VEC2 .or - "vec3" .emit TYPE_SPECIFIER_VEC3 .or - "vec4" .emit TYPE_SPECIFIER_VEC4 .or - "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or - "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or - "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or - "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or - "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or - "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or - "mat2" .emit TYPE_SPECIFIER_MAT2 .or - "mat3" .emit TYPE_SPECIFIER_MAT3 .or - "mat4" .emit TYPE_SPECIFIER_MAT4 .or - "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or - "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or - "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or - "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or - "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or - "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or - "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or - "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or - "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or - "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or - "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or - "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or - "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or - "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or - type_name .emit TYPE_SPECIFIER_TYPENAME; - -/* - * ::= - * | "[" "]" - */ -type_specifier - type_specifier_array .or type_specifier_1; -type_specifier_1 - type_specifier_nonarray .and .true .emit TYPE_SPECIFIER_NONARRAY; -type_specifier_array - type_specifier_nonarray .and lbracket .emit TYPE_SPECIFIER_ARRAY .and constant_expression .and rbracket; - -/* - * ::= "struct" "{" "}" - * | "struct" "{" "}" - */ -struct_specifier - "struct" .and struct_specifier_1 .and lbrace .error LBRACE_EXPECTED .and - struct_declaration_list .and rbrace .emit FIELD_NONE; -struct_specifier_1 - identifier .or .true .emit '\0'; - -/* - * ::= - * | - */ -struct_declaration_list - struct_declaration .and .loop struct_declaration .emit FIELD_NEXT; - -/* - * ::= ";" - */ -struct_declaration - type_specifier .and struct_declarator_list .and semicolon .emit FIELD_NONE; - -/* - * ::= - * | "," - */ -struct_declarator_list - struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT; -struct_declarator_list_1 - comma .and struct_declarator; - -/* - * ::= - * | "[" "]" - */ -struct_declarator - identifier .and struct_declarator_1; -struct_declarator_1 - struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE; -struct_declarator_2 - lbracket .and constant_expression .and rbracket; - -/* - * ::= - */ -initializer - assignment_expression .and .true .emit OP_END; - -/* - * ::= - */ -declaration_statement - declaration; - -/* - * ::= - * | - */ -statement - compound_statement .or simple_statement; - -/* - * ::= <__asm_statement> - * | - * | - * | - * | - * | - * - * note: this is an extension to the standard language specification. - * normally slang disallows use of __asm statements - */ -simple_statement - .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or - selection_statement .or - iteration_statement .or - precision_stmt .emit OP_PRECISION .or - jump_statement .or - expression_statement .emit OP_EXPRESSION .or - declaration_statement .emit OP_DECLARE; - -/* - * ::= "{" "}" - * | "{" "}" - */ -compound_statement - compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END; -compound_statement_1 - compound_statement_2 .or compound_statement_3; -compound_statement_2 - lbrace .and rbrace; -compound_statement_3 - lbrace .and statement_list .and rbrace; - -/* - * ::= "{" "}" - * | "{" "}" - */ -compound_statement_no_new_scope - compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END; -compound_statement_no_new_scope_1 - compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3; -compound_statement_no_new_scope_2 - lbrace .and rbrace; -compound_statement_no_new_scope_3 - lbrace .and statement_list .and rbrace; - - -/* - * ::= - * | - */ -statement_list - statement .and .loop statement; - -/* - * ::= ";" - * | ";" - */ -expression_statement - expression_statement_1 .or expression_statement_2; -expression_statement_1 - semicolon .emit OP_PUSH_VOID .emit OP_END; -expression_statement_2 - expression .and semicolon .emit OP_END; - -/* - * ::= "if" "(" ")" - */ -selection_statement - "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and - rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement; - -/* - * ::= "else" - * | - */ -selection_rest_statement - statement .and selection_rest_statement_1; -selection_rest_statement_1 - selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END; -selection_rest_statement_2 - "else" .and statement; - -/* - * ::= - * | "=" - * - * note: if is executed, the emit format must - * match emit format - */ -condition - condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or - condition_2 .emit OP_EXPRESSION; -condition_1 - fully_specified_type .and identifier .emit VARIABLE_IDENTIFIER .and - equals .emit VARIABLE_INITIALIZER .and initializer .and .true .emit DECLARATOR_NONE; -condition_2 - expression .and .true .emit OP_END; - -/* - * ::= "while" "(" ")" - * | "do" "while" "(" ")" ";" - * | "for" "(" ")" - */ -iteration_statement - iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3; -iteration_statement_1 - "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and - rparen .error RPAREN_EXPECTED .and statement; -iteration_statement_2 - "do" .emit OP_DO .and statement .and "while" .and lparen .error LPAREN_EXPECTED .and - expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon; -iteration_statement_3 - "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and - for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement; - -/* - * ::= - * | - */ -for_init_statement - expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE; - -/* - * ::= - * | "" - * - * note: is used only by "for" statement. - * if is ommitted, parser simulates default behaviour, - * that is simulates "true" expression - */ -conditionopt - condition .or - .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END; - -/* - * ::= ";" - * | ";" - */ -for_rest_statement - conditionopt .and semicolon .and for_rest_statement_1; -for_rest_statement_1 - for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END; -for_rest_statement_2 - expression .and .true .emit OP_END; - -/* - * ::= "continue" ";" - * | "break" ";" - * | "return" ";" - * | "return" ";" - * | "discard" ";" // Fragment shader only. - */ -jump_statement - jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or - .if (shader_type == 1) jump_statement_5; -jump_statement_1 - "continue" .and semicolon .emit OP_CONTINUE; -jump_statement_2 - "break" .and semicolon .emit OP_BREAK; -jump_statement_3 - "return" .emit OP_RETURN .and expression .and semicolon .emit OP_END; -jump_statement_4 - "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END; -jump_statement_5 - "discard" .and semicolon .emit OP_DISCARD; - -/* - * <__asm_statement> ::= "__asm" ";" - * - * note: this is an extension to the standard language specification. - * normally slang disallows __asm statements - */ -__asm_statement - "__asm" .and identifier .and asm_arguments .and semicolon .emit OP_END; - -/* - * ::= - * | "," - * - * note: this is an extension to the standard language specification. - * normally slang disallows __asm statements - */ -asm_arguments - asm_argument .and .true .emit OP_END .and .loop asm_arguments_1; -asm_arguments_1 - comma .and asm_argument .and .true .emit OP_END; - -/* - * ::= - * | - * - * note: this is an extension to the standard language specification. - * normally slang disallows __asm statements - */ -asm_argument - var_with_field .or - variable_identifier .or - floatconstant; - -var_with_field - variable_identifier .and dot .and field_selection .emit OP_FIELD; - - -/* - * ::= - * | - */ -translation_unit - .true .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and - .loop external_declaration .and "@EOF" .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL; - - -/* - * ::= - * | - */ -external_declaration - precision_stmt .emit DEFAULT_PRECISION .or - function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or - invariant_stmt .emit INVARIANT_STMT .or - declaration .emit EXTERNAL_DECLARATION; - - -/* - * ::= "precision" - */ -precision_stmt - "precision" .and precision .error INVALID_PRECISION .and prectype .error INVALID_PRECISION_TYPE .and semicolon; - -/* - * ::= "lowp" - * | "mediump" - * | "highp" - */ -precision - "lowp" .emit PRECISION_LOW .or - "mediump" .emit PRECISION_MEDIUM .or - "highp" .emit PRECISION_HIGH; - -/* - * ::= "int" - * | "float" - * | "a sampler type" - */ -prectype - "int" .emit TYPE_SPECIFIER_INT .or - "float" .emit TYPE_SPECIFIER_FLOAT .or - "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or - "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or - "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or - "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or - "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or - "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or - "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or - "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW; - - -/* - * ::= "invariant" identifier; - */ -invariant_stmt - "invariant" .and identifier .and semicolon; - - -/* - * :: - */ -function_definition - function_prototype .and compound_statement_no_new_scope; - - - -/* - * helper rules, not part of the official language syntax - */ - -identifier - "@ID" .emit *; - -float - "@FLOAT" .emit 1 .emit *; - -integer - "@UINT" .emit 1 .emit *; - -boolean - "true" .emit '1' .emit '\0' .or - "false" .emit '0' .emit '\0'; - -type_name - identifier; - -field_selection - identifier; - -floatconstant - float .emit OP_PUSH_FLOAT; - -intconstant - integer .emit OP_PUSH_INT; - -boolconstant - boolean .emit OP_PUSH_BOOL; - -/* lexical rules */ - -/*ampersand - optional_space .and '&' .and optional_space;*/ - -ampersandampersand - "@&&"; - -/*ampersandequals - optional_space .and '&' .and '=' .and optional_space;*/ - -/*bar - optional_space .and '|' .and optional_space;*/ - -barbar - "@||"; - -/*barequals - optional_space .and '|' .and '=' .and optional_space;*/ - -bang - "@!"; - -bangequals - "@!="; - -/*caret - optional_space .and '^' .and optional_space;*/ - -caretcaret - "@^^"; - -/*caretequals - optional_space .and '^' .and '=' .and optional_space;*/ - -colon - "@:"; - -comma - "@,"; - -dot - "@."; - -equals - "@="; - -equalsequals - "@=="; - -greater - "@>"; - -greaterequals - "@>="; - -/*greatergreater - optional_space .and '>' .and '>' .and optional_space;*/ - -/*greatergreaterequals - optional_space .and '>' .and '>' .and '=' .and optional_space;*/ - -lbrace - "@{"; - -lbracket - "@["; - -less - "@<"; - -lessequals - "@<="; - -/*lessless - optional_space .and '<' .and '<' .and optional_space;*/ - -/*lesslessequals - optional_space .and '<' .and '<' .and '=' .and optional_space;*/ - -lparen - "@("; - -minus - "@-"; - -minusequals - "@-="; - -minusminus - "@--"; - -/*percent - optional_space .and '%' .and optional_space;*/ - -/*percentequals - optional_space .and '%' .and '=' .and optional_space;*/ - -plus - "@+"; - -plusequals - "@+="; - -plusplus - "@++"; - -question - "@?"; - -rbrace - "@}"; - -rbracket - "@]"; - -rparen - "@)"; - -semicolon - "@;"; - -slash - "@/"; - -slashequals - "@/="; - -star - "@*"; - -starequals - "@*="; - -/*tilde - optional_space .and '~' .and optional_space;*/ - diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h deleted file mode 100644 index 488cf1a504..0000000000 --- a/src/mesa/shader/slang/library/slang_shader_syn.h +++ /dev/null @@ -1,714 +0,0 @@ - -/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */ - -".syntax translation_unit;\n" -".emtcode REVISION 5\n" -".emtcode EXTERNAL_NULL 0\n" -".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n" -".emtcode EXTERNAL_DECLARATION 2\n" -".emtcode DEFAULT_PRECISION 3\n" -".emtcode INVARIANT_STMT 4\n" -".emtcode PRECISION_DEFAULT 0\n" -".emtcode PRECISION_LOW 1\n" -".emtcode PRECISION_MEDIUM 2\n" -".emtcode PRECISION_HIGH 3\n" -".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n" -".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n" -".emtcode FUNCTION_ORDINARY 0\n" -".emtcode FUNCTION_CONSTRUCTOR 1\n" -".emtcode FUNCTION_OPERATOR 2\n" -".emtcode FUNCTION_CALL_NONARRAY 0\n" -".emtcode FUNCTION_CALL_ARRAY 1\n" -".emtcode OPERATOR_ADDASSIGN 1\n" -".emtcode OPERATOR_SUBASSIGN 2\n" -".emtcode OPERATOR_MULASSIGN 3\n" -".emtcode OPERATOR_DIVASSIGN 4\n" -".emtcode OPERATOR_LOGICALXOR 11\n" -".emtcode OPERATOR_LESS 15\n" -".emtcode OPERATOR_GREATER 16\n" -".emtcode OPERATOR_LESSEQUAL 17\n" -".emtcode OPERATOR_GREATEREQUAL 18\n" -".emtcode OPERATOR_MULTIPLY 21\n" -".emtcode OPERATOR_DIVIDE 22\n" -".emtcode OPERATOR_INCREMENT 24\n" -".emtcode OPERATOR_DECREMENT 25\n" -".emtcode OPERATOR_PLUS 26\n" -".emtcode OPERATOR_MINUS 27\n" -".emtcode OPERATOR_NOT 29\n" -".emtcode DECLARATOR_NONE 0\n" -".emtcode DECLARATOR_NEXT 1\n" -".emtcode VARIABLE_NONE 0\n" -".emtcode VARIABLE_IDENTIFIER 1\n" -".emtcode VARIABLE_INITIALIZER 2\n" -".emtcode VARIABLE_ARRAY_EXPLICIT 3\n" -".emtcode VARIABLE_ARRAY_UNKNOWN 4\n" -".emtcode TYPE_QUALIFIER_NONE 0\n" -".emtcode TYPE_QUALIFIER_CONST 1\n" -".emtcode TYPE_QUALIFIER_ATTRIBUTE 2\n" -".emtcode TYPE_QUALIFIER_VARYING 3\n" -".emtcode TYPE_QUALIFIER_UNIFORM 4\n" -".emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5\n" -".emtcode TYPE_QUALIFIER_FIXEDINPUT 6\n" -".emtcode TYPE_VARIANT 90\n" -".emtcode TYPE_INVARIANT 91\n" -".emtcode TYPE_CENTER 95\n" -".emtcode TYPE_CENTROID 96\n" -".emtcode TYPE_SPECIFIER_VOID 0\n" -".emtcode TYPE_SPECIFIER_BOOL 1\n" -".emtcode TYPE_SPECIFIER_BVEC2 2\n" -".emtcode TYPE_SPECIFIER_BVEC3 3\n" -".emtcode TYPE_SPECIFIER_BVEC4 4\n" -".emtcode TYPE_SPECIFIER_INT 5\n" -".emtcode TYPE_SPECIFIER_IVEC2 6\n" -".emtcode TYPE_SPECIFIER_IVEC3 7\n" -".emtcode TYPE_SPECIFIER_IVEC4 8\n" -".emtcode TYPE_SPECIFIER_FLOAT 9\n" -".emtcode TYPE_SPECIFIER_VEC2 10\n" -".emtcode TYPE_SPECIFIER_VEC3 11\n" -".emtcode TYPE_SPECIFIER_VEC4 12\n" -".emtcode TYPE_SPECIFIER_MAT2 13\n" -".emtcode TYPE_SPECIFIER_MAT3 14\n" -".emtcode TYPE_SPECIFIER_MAT4 15\n" -".emtcode TYPE_SPECIFIER_SAMPLER1D 16\n" -".emtcode TYPE_SPECIFIER_SAMPLER2D 17\n" -".emtcode TYPE_SPECIFIER_SAMPLER3D 18\n" -".emtcode TYPE_SPECIFIER_SAMPLERCUBE 19\n" -".emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20\n" -".emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21\n" -".emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22\n" -".emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23\n" -".emtcode TYPE_SPECIFIER_STRUCT 24\n" -".emtcode TYPE_SPECIFIER_TYPENAME 25\n" -".emtcode TYPE_SPECIFIER_MAT23 26\n" -".emtcode TYPE_SPECIFIER_MAT32 27\n" -".emtcode TYPE_SPECIFIER_MAT24 28\n" -".emtcode TYPE_SPECIFIER_MAT42 29\n" -".emtcode TYPE_SPECIFIER_MAT34 30\n" -".emtcode TYPE_SPECIFIER_MAT43 31\n" -".emtcode TYPE_SPECIFIER_NONARRAY 0\n" -".emtcode TYPE_SPECIFIER_ARRAY 1\n" -".emtcode FIELD_NONE 0\n" -".emtcode FIELD_NEXT 1\n" -".emtcode FIELD_ARRAY 2\n" -".emtcode OP_END 0\n" -".emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1\n" -".emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2\n" -".emtcode OP_DECLARE 3\n" -".emtcode OP_ASM 4\n" -".emtcode OP_BREAK 5\n" -".emtcode OP_CONTINUE 6\n" -".emtcode OP_DISCARD 7\n" -".emtcode OP_RETURN 8\n" -".emtcode OP_EXPRESSION 9\n" -".emtcode OP_IF 10\n" -".emtcode OP_WHILE 11\n" -".emtcode OP_DO 12\n" -".emtcode OP_FOR 13\n" -".emtcode OP_PUSH_VOID 14\n" -".emtcode OP_PUSH_BOOL 15\n" -".emtcode OP_PUSH_INT 16\n" -".emtcode OP_PUSH_FLOAT 17\n" -".emtcode OP_PUSH_IDENTIFIER 18\n" -".emtcode OP_SEQUENCE 19\n" -".emtcode OP_ASSIGN 20\n" -".emtcode OP_ADDASSIGN 21\n" -".emtcode OP_SUBASSIGN 22\n" -".emtcode OP_MULASSIGN 23\n" -".emtcode OP_DIVASSIGN 24\n" -".emtcode OP_SELECT 31\n" -".emtcode OP_LOGICALOR 32\n" -".emtcode OP_LOGICALXOR 33\n" -".emtcode OP_LOGICALAND 34\n" -".emtcode OP_EQUAL 38\n" -".emtcode OP_NOTEQUAL 39\n" -".emtcode OP_LESS 40\n" -".emtcode OP_GREATER 41\n" -".emtcode OP_LESSEQUAL 42\n" -".emtcode OP_GREATEREQUAL 43\n" -".emtcode OP_ADD 46\n" -".emtcode OP_SUBTRACT 47\n" -".emtcode OP_MULTIPLY 48\n" -".emtcode OP_DIVIDE 49\n" -".emtcode OP_PREINCREMENT 51\n" -".emtcode OP_PREDECREMENT 52\n" -".emtcode OP_PLUS 53\n" -".emtcode OP_MINUS 54\n" -".emtcode OP_NOT 56\n" -".emtcode OP_SUBSCRIPT 57\n" -".emtcode OP_CALL 58\n" -".emtcode OP_FIELD 59\n" -".emtcode OP_POSTINCREMENT 60\n" -".emtcode OP_POSTDECREMENT 61\n" -".emtcode OP_PRECISION 62\n" -".emtcode OP_METHOD 63\n" -".emtcode PARAM_QUALIFIER_IN 0\n" -".emtcode PARAM_QUALIFIER_OUT 1\n" -".emtcode PARAM_QUALIFIER_INOUT 2\n" -".emtcode PARAMETER_NONE 0\n" -".emtcode PARAMETER_NEXT 1\n" -".emtcode PARAMETER_ARRAY_NOT_PRESENT 0\n" -".emtcode PARAMETER_ARRAY_PRESENT 1\n" -".errtext INVALID_EXTERNAL_DECLARATION \"2001: Syntax error.\"\n" -".errtext INVALID_OPERATOR_OVERRIDE \"2002: Invalid operator override.\"\n" -".errtext LBRACE_EXPECTED \"2003: '{' expected but token found.\"\n" -".errtext LPAREN_EXPECTED \"2004: '(' expected but token found.\"\n" -".errtext RPAREN_EXPECTED \"2005: ')' expected but token found.\"\n" -".errtext INVALID_PRECISION \"2006: Invalid precision specifier.\"\n" -".errtext INVALID_PRECISION_TYPE \"2007: Invalid precision type.\"\n" -".regbyte parsing_builtin 0\n" -".regbyte shader_type 0\n" -"variable_identifier\n" -" identifier .emit OP_PUSH_IDENTIFIER;\n" -"primary_expression\n" -" floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;\n" -"primary_expression_1\n" -" lparen .and expression .and rparen;\n" -"postfix_expression\n" -" postfix_expression_1 .and .loop postfix_expression_2;\n" -"postfix_expression_1\n" -" function_call .or primary_expression;\n" -"postfix_expression_2\n" -" postfix_expression_3 .or postfix_expression_4 .or\n" -" plusplus .emit OP_POSTINCREMENT .or\n" -" minusminus .emit OP_POSTDECREMENT;\n" -"postfix_expression_3\n" -" lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;\n" -"postfix_expression_4\n" -" dot .and field_selection .emit OP_FIELD;\n" -"integer_expression\n" -" expression;\n" -"function_call\n" -" function_call_or_method;\n" -"function_call_or_method\n" -" regular_function_call .or method_call;\n" -"method_call\n" -" identifier .emit OP_METHOD .and dot .and function_call_generic .and .true .emit OP_END;\n" -"regular_function_call\n" -" function_call_generic .emit OP_CALL .and .true .emit OP_END;\n" -"function_call_generic\n" -" function_call_generic_1 .or function_call_generic_2;\n" -"function_call_generic_1\n" -" function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;\n" -"function_call_generic_2\n" -" function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;\n" -"function_call_header_no_parameters\n" -" function_call_header .and function_call_header_no_parameters_1;\n" -"function_call_header_no_parameters_1\n" -" \"void\" .or .true;\n" -"function_call_header_with_parameters\n" -" function_call_header .and assignment_expression .and .true .emit OP_END .and\n" -" .loop function_call_header_with_parameters_1;\n" -"function_call_header_with_parameters_1\n" -" comma .and assignment_expression .and .true .emit OP_END;\n" -"function_call_header\n" -" function_identifier .and lparen;\n" -"function_identifier\n" -" identifier .and function_identifier_opt_array;\n" -"function_identifier_opt_array\n" -" function_identifier_array .emit FUNCTION_CALL_ARRAY .or\n" -" .true .emit FUNCTION_CALL_NONARRAY;\n" -"function_identifier_array\n" -" lbracket .and constant_expression .and rbracket;\n" -"unary_expression\n" -" postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or\n" -" unary_expression_4 .or unary_expression_5;\n" -"unary_expression_1\n" -" plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;\n" -"unary_expression_2\n" -" minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;\n" -"unary_expression_3\n" -" plus .and unary_expression .and .true .emit OP_PLUS;\n" -"unary_expression_4\n" -" minus .and unary_expression .and .true .emit OP_MINUS;\n" -"unary_expression_5\n" -" bang .and unary_expression .and .true .emit OP_NOT;\n" -"multiplicative_expression\n" -" unary_expression .and .loop multiplicative_expression_1;\n" -"multiplicative_expression_1\n" -" multiplicative_expression_2 .or multiplicative_expression_3;\n" -"multiplicative_expression_2\n" -" star .and unary_expression .and .true .emit OP_MULTIPLY;\n" -"multiplicative_expression_3\n" -" slash .and unary_expression .and .true .emit OP_DIVIDE;\n" -"additive_expression\n" -" multiplicative_expression .and .loop additive_expression_1;\n" -"additive_expression_1\n" -" additive_expression_2 .or additive_expression_3;\n" -"additive_expression_2\n" -" plus .and multiplicative_expression .and .true .emit OP_ADD;\n" -"additive_expression_3\n" -" minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;\n" -"shift_expression\n" -" additive_expression;\n" -"relational_expression\n" -" shift_expression .and .loop relational_expression_1;\n" -"relational_expression_1\n" -" relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or\n" -" relational_expression_5;\n" -"relational_expression_2\n" -" lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;\n" -"relational_expression_3\n" -" greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;\n" -"relational_expression_4\n" -" less .and shift_expression .and .true .emit OP_LESS;\n" -"relational_expression_5\n" -" greater .and shift_expression .and .true .emit OP_GREATER;\n" -"equality_expression\n" -" relational_expression .and .loop equality_expression_1;\n" -"equality_expression_1\n" -" equality_expression_2 .or equality_expression_3;\n" -"equality_expression_2\n" -" equalsequals .and relational_expression .and .true .emit OP_EQUAL;\n" -"equality_expression_3\n" -" bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;\n" -"and_expression\n" -" equality_expression;\n" -"exclusive_or_expression\n" -" and_expression;\n" -"inclusive_or_expression\n" -" exclusive_or_expression;\n" -"logical_and_expression\n" -" inclusive_or_expression .and .loop logical_and_expression_1;\n" -"logical_and_expression_1\n" -" ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;\n" -"logical_xor_expression\n" -" logical_and_expression .and .loop logical_xor_expression_1;\n" -"logical_xor_expression_1\n" -" caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;\n" -"logical_or_expression\n" -" logical_xor_expression .and .loop logical_or_expression_1;\n" -"logical_or_expression_1\n" -" barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;\n" -"conditional_expression\n" -" logical_or_expression .and .loop conditional_expression_1;\n" -"conditional_expression_1\n" -" question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;\n" -"assignment_expression\n" -" assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or\n" -" assignment_expression_4 .or assignment_expression_5 .or conditional_expression;\n" -"assignment_expression_1\n" -" unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;\n" -"assignment_expression_2\n" -" unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;\n" -"assignment_expression_3\n" -" unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;\n" -"assignment_expression_4\n" -" unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;\n" -"assignment_expression_5\n" -" unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;\n" -"expression\n" -" assignment_expression .and .loop expression_1;\n" -"expression_1\n" -" comma .and assignment_expression .and .true .emit OP_SEQUENCE;\n" -"constant_expression\n" -" conditional_expression .and .true .emit OP_END;\n" -"declaration\n" -" declaration_1 .or declaration_2;\n" -"declaration_1\n" -" function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;\n" -"declaration_2\n" -" init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;\n" -"function_prototype\n" -" function_prototype_1 .or function_prototype_2;\n" -"function_prototype_1\n" -" function_header .and \"void\" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;\n" -"function_prototype_2\n" -" function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;\n" -"function_declarator\n" -" function_header_with_parameters .or function_header;\n" -"function_header_with_parameters\n" -" function_header .and parameter_declaration .and .loop function_header_with_parameters_1;\n" -"function_header_with_parameters_1\n" -" comma .and parameter_declaration;\n" -"function_header\n" -" fully_specified_type .and function_decl_identifier .and lparen;\n" -"function_decl_identifier\n" -" .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or\n" -" .if (parsing_builtin != 0) \"__constructor\" .emit FUNCTION_CONSTRUCTOR .or\n" -" identifier .emit FUNCTION_ORDINARY;\n" -"__operator\n" -" \"__operator\" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;\n" -"overriden_operator\n" -" plusplus .emit OPERATOR_INCREMENT .or\n" -" plusequals .emit OPERATOR_ADDASSIGN .or\n" -" plus .emit OPERATOR_PLUS .or\n" -" minusminus .emit OPERATOR_DECREMENT .or\n" -" minusequals .emit OPERATOR_SUBASSIGN .or\n" -" minus .emit OPERATOR_MINUS .or\n" -" bang .emit OPERATOR_NOT .or\n" -" starequals .emit OPERATOR_MULASSIGN .or\n" -" star .emit OPERATOR_MULTIPLY .or\n" -" slashequals .emit OPERATOR_DIVASSIGN .or\n" -" slash .emit OPERATOR_DIVIDE .or\n" -" lessequals .emit OPERATOR_LESSEQUAL .or\n" -" \n" -" \n" -" less .emit OPERATOR_LESS .or\n" -" greaterequals .emit OPERATOR_GREATEREQUAL .or\n" -" \n" -" \n" -" greater .emit OPERATOR_GREATER .or\n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" caretcaret .emit OPERATOR_LOGICALXOR ;\n" -"parameter_declarator\n" -" type_specifier .and identifier .and parameter_declarator_1;\n" -"parameter_declarator_1\n" -" parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or\n" -" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n" -"parameter_declarator_2\n" -" lbracket .and constant_expression .and rbracket;\n" -"parameter_declaration\n" -" parameter_declaration_1 .emit PARAMETER_NEXT;\n" -"parameter_declaration_1\n" -" parameter_declaration_2 .or parameter_declaration_3;\n" -"parameter_declaration_2\n" -" type_qualifier .and parameter_qualifier .and parameter_declaration_4;\n" -"parameter_declaration_3\n" -" parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;\n" -"parameter_declaration_4\n" -" parameter_declaration_optprec .and parameter_declaration_rest;\n" -"parameter_declaration_optprec\n" -" precision .or .true .emit PRECISION_DEFAULT;\n" -"parameter_declaration_rest\n" -" parameter_declarator .or parameter_type_specifier;\n" -"parameter_qualifier\n" -" parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;\n" -"parameter_qualifier_1\n" -" \"in\" .emit PARAM_QUALIFIER_IN .or\n" -" \"out\" .emit PARAM_QUALIFIER_OUT .or\n" -" \"inout\" .emit PARAM_QUALIFIER_INOUT;\n" -"parameter_type_specifier\n" -" type_specifier .and .true .emit '\\0' .and parameter_type_specifier_2;\n" -"parameter_type_specifier_2\n" -" parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or\n" -" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n" -"parameter_type_specifier_3\n" -" lbracket .and constant_expression .and rbracket;\n" -"init_declarator_list\n" -" single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and\n" -" .true .emit DECLARATOR_NONE;\n" -"init_declarator_list_1\n" -" comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;\n" -"init_declarator_list_2\n" -" init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;\n" -"init_declarator_list_3\n" -" equals .and initializer .emit VARIABLE_INITIALIZER;\n" -"init_declarator_list_4\n" -" lbracket .and init_declarator_list_5 .and rbracket;\n" -"init_declarator_list_5\n" -" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n" -"single_declaration\n" -" fully_specified_type .and single_declaration_1;\n" -"single_declaration_1\n" -" single_declaration_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n" -"single_declaration_2\n" -" identifier .and single_declaration_3;\n" -"single_declaration_3\n" -" single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;\n" -"single_declaration_4\n" -" equals .and initializer .emit VARIABLE_INITIALIZER;\n" -"single_declaration_5\n" -" lbracket .and single_declaration_6 .and rbracket;\n" -"single_declaration_6\n" -" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n" -"fully_specified_type\n" -" fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier;\n" -"fully_specified_type_optinvariant\n" -" invariant_qualifier .or .true .emit TYPE_VARIANT;\n" -"fully_specified_type_optcentroid\n" -" centroid_qualifier .or .true .emit TYPE_CENTER;\n" -"fully_specified_type_optqual\n" -" type_qualifier .or .true .emit TYPE_QUALIFIER_NONE;\n" -"fully_specified_type_optprec\n" -" precision .or .true .emit PRECISION_DEFAULT;\n" -"invariant_qualifier\n" -" \"invariant\" .emit TYPE_INVARIANT;\n" -"centroid_qualifier\n" -" \"centroid\" .emit TYPE_CENTROID;\n" -"type_qualifier\n" -" \"const\" .emit TYPE_QUALIFIER_CONST .or\n" -" .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n" -" \"varying\" .emit TYPE_QUALIFIER_VARYING .or\n" -" \"uniform\" .emit TYPE_QUALIFIER_UNIFORM .or\n" -" .if (parsing_builtin != 0) \"__fixed_output\" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or\n" -" .if (parsing_builtin != 0) \"__fixed_input\" .emit TYPE_QUALIFIER_FIXEDINPUT;\n" -"type_specifier_nonarray\n" -" struct_specifier .emit TYPE_SPECIFIER_STRUCT .or\n" -" \"void\" .emit TYPE_SPECIFIER_VOID .or\n" -" \"float\" .emit TYPE_SPECIFIER_FLOAT .or\n" -" \"int\" .emit TYPE_SPECIFIER_INT .or\n" -" \"bool\" .emit TYPE_SPECIFIER_BOOL .or\n" -" \"vec2\" .emit TYPE_SPECIFIER_VEC2 .or\n" -" \"vec3\" .emit TYPE_SPECIFIER_VEC3 .or\n" -" \"vec4\" .emit TYPE_SPECIFIER_VEC4 .or\n" -" \"bvec2\" .emit TYPE_SPECIFIER_BVEC2 .or\n" -" \"bvec3\" .emit TYPE_SPECIFIER_BVEC3 .or\n" -" \"bvec4\" .emit TYPE_SPECIFIER_BVEC4 .or\n" -" \"ivec2\" .emit TYPE_SPECIFIER_IVEC2 .or\n" -" \"ivec3\" .emit TYPE_SPECIFIER_IVEC3 .or\n" -" \"ivec4\" .emit TYPE_SPECIFIER_IVEC4 .or\n" -" \"mat2\" .emit TYPE_SPECIFIER_MAT2 .or\n" -" \"mat3\" .emit TYPE_SPECIFIER_MAT3 .or\n" -" \"mat4\" .emit TYPE_SPECIFIER_MAT4 .or\n" -" \"mat2x3\" .emit TYPE_SPECIFIER_MAT23 .or\n" -" \"mat3x2\" .emit TYPE_SPECIFIER_MAT32 .or\n" -" \"mat2x4\" .emit TYPE_SPECIFIER_MAT24 .or\n" -" \"mat4x2\" .emit TYPE_SPECIFIER_MAT42 .or\n" -" \"mat3x4\" .emit TYPE_SPECIFIER_MAT34 .or\n" -" \"mat4x3\" .emit TYPE_SPECIFIER_MAT43 .or\n" -" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n" -" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n" -" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n" -" \"samplerCube\" .emit TYPE_SPECIFIER_SAMPLERCUBE .or\n" -" \"sampler1DShadow\" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or\n" -" \"sampler2DShadow\" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or\n" -" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n" -" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or\n" -" type_name .emit TYPE_SPECIFIER_TYPENAME;\n" -"type_specifier\n" -" type_specifier_array .or type_specifier_1;\n" -"type_specifier_1\n" -" type_specifier_nonarray .and .true .emit TYPE_SPECIFIER_NONARRAY;\n" -"type_specifier_array\n" -" type_specifier_nonarray .and lbracket .emit TYPE_SPECIFIER_ARRAY .and constant_expression .and rbracket;\n" -"struct_specifier\n" -" \"struct\" .and struct_specifier_1 .and lbrace .error LBRACE_EXPECTED .and\n" -" struct_declaration_list .and rbrace .emit FIELD_NONE;\n" -"struct_specifier_1\n" -" identifier .or .true .emit '\\0';\n" -"struct_declaration_list\n" -" struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;\n" -"struct_declaration\n" -" type_specifier .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n" -"struct_declarator_list\n" -" struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;\n" -"struct_declarator_list_1\n" -" comma .and struct_declarator;\n" -"struct_declarator\n" -" identifier .and struct_declarator_1;\n" -"struct_declarator_1\n" -" struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;\n" -"struct_declarator_2\n" -" lbracket .and constant_expression .and rbracket;\n" -"initializer\n" -" assignment_expression .and .true .emit OP_END;\n" -"declaration_statement\n" -" declaration;\n" -"statement\n" -" compound_statement .or simple_statement;\n" -"simple_statement\n" -" .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or\n" -" selection_statement .or\n" -" iteration_statement .or\n" -" precision_stmt .emit OP_PRECISION .or\n" -" jump_statement .or\n" -" expression_statement .emit OP_EXPRESSION .or\n" -" declaration_statement .emit OP_DECLARE;\n" -"compound_statement\n" -" compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;\n" -"compound_statement_1\n" -" compound_statement_2 .or compound_statement_3;\n" -"compound_statement_2\n" -" lbrace .and rbrace;\n" -"compound_statement_3\n" -" lbrace .and statement_list .and rbrace;\n" -"compound_statement_no_new_scope\n" -" compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;\n" -"compound_statement_no_new_scope_1\n" -" compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;\n" -"compound_statement_no_new_scope_2\n" -" lbrace .and rbrace;\n" -"compound_statement_no_new_scope_3\n" -" lbrace .and statement_list .and rbrace;\n" -"statement_list\n" -" statement .and .loop statement;\n" -"expression_statement\n" -" expression_statement_1 .or expression_statement_2;\n" -"expression_statement_1\n" -" semicolon .emit OP_PUSH_VOID .emit OP_END;\n" -"expression_statement_2\n" -" expression .and semicolon .emit OP_END;\n" -"selection_statement\n" -" \"if\" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and\n" -" rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;\n" -"selection_rest_statement\n" -" statement .and selection_rest_statement_1;\n" -"selection_rest_statement_1\n" -" selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;\n" -"selection_rest_statement_2\n" -" \"else\" .and statement;\n" -"condition\n" -" condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or\n" -" condition_2 .emit OP_EXPRESSION;\n" -"condition_1\n" -" fully_specified_type .and identifier .emit VARIABLE_IDENTIFIER .and\n" -" equals .emit VARIABLE_INITIALIZER .and initializer .and .true .emit DECLARATOR_NONE;\n" -"condition_2\n" -" expression .and .true .emit OP_END;\n" -"iteration_statement\n" -" iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;\n" -"iteration_statement_1\n" -" \"while\" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and\n" -" rparen .error RPAREN_EXPECTED .and statement;\n" -"iteration_statement_2\n" -" \"do\" .emit OP_DO .and statement .and \"while\" .and lparen .error LPAREN_EXPECTED .and\n" -" expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;\n" -"iteration_statement_3\n" -" \"for\" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and\n" -" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;\n" -"for_init_statement\n" -" expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;\n" -"conditionopt\n" -" condition .or\n" -" .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\\0' .emit OP_END;\n" -"for_rest_statement\n" -" conditionopt .and semicolon .and for_rest_statement_1;\n" -"for_rest_statement_1\n" -" for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;\n" -"for_rest_statement_2\n" -" expression .and .true .emit OP_END;\n" -"jump_statement\n" -" jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or\n" -" .if (shader_type == 1) jump_statement_5;\n" -"jump_statement_1\n" -" \"continue\" .and semicolon .emit OP_CONTINUE;\n" -"jump_statement_2\n" -" \"break\" .and semicolon .emit OP_BREAK;\n" -"jump_statement_3\n" -" \"return\" .emit OP_RETURN .and expression .and semicolon .emit OP_END;\n" -"jump_statement_4\n" -" \"return\" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;\n" -"jump_statement_5\n" -" \"discard\" .and semicolon .emit OP_DISCARD;\n" -"__asm_statement\n" -" \"__asm\" .and identifier .and asm_arguments .and semicolon .emit OP_END;\n" -"asm_arguments\n" -" asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;\n" -"asm_arguments_1\n" -" comma .and asm_argument .and .true .emit OP_END;\n" -"asm_argument\n" -" var_with_field .or\n" -" variable_identifier .or\n" -" floatconstant;\n" -"var_with_field\n" -" variable_identifier .and dot .and field_selection .emit OP_FIELD;\n" -"translation_unit\n" -" .true .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n" -" .loop external_declaration .and \"@EOF\" .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;\n" -"external_declaration\n" -" precision_stmt .emit DEFAULT_PRECISION .or\n" -" function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or\n" -" invariant_stmt .emit INVARIANT_STMT .or\n" -" declaration .emit EXTERNAL_DECLARATION;\n" -"precision_stmt\n" -" \"precision\" .and precision .error INVALID_PRECISION .and prectype .error INVALID_PRECISION_TYPE .and semicolon;\n" -"precision\n" -" \"lowp\" .emit PRECISION_LOW .or\n" -" \"mediump\" .emit PRECISION_MEDIUM .or\n" -" \"highp\" .emit PRECISION_HIGH;\n" -"prectype\n" -" \"int\" .emit TYPE_SPECIFIER_INT .or\n" -" \"float\" .emit TYPE_SPECIFIER_FLOAT .or\n" -" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n" -" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n" -" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n" -" \"samplerCube\" .emit TYPE_SPECIFIER_SAMPLERCUBE .or\n" -" \"sampler1DShadow\" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or\n" -" \"sampler2DShadow\" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or\n" -" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n" -" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;\n" -"invariant_stmt\n" -" \"invariant\" .and identifier .and semicolon;\n" -"function_definition\n" -" function_prototype .and compound_statement_no_new_scope;\n" -"identifier\n" -" \"@ID\" .emit *;\n" -"float\n" -" \"@FLOAT\" .emit 1 .emit *;\n" -"integer\n" -" \"@UINT\" .emit 1 .emit *;\n" -"boolean\n" -" \"true\" .emit '1' .emit '\\0' .or\n" -" \"false\" .emit '0' .emit '\\0';\n" -"type_name\n" -" identifier;\n" -"field_selection\n" -" identifier;\n" -"floatconstant\n" -" float .emit OP_PUSH_FLOAT;\n" -"intconstant\n" -" integer .emit OP_PUSH_INT;\n" -"boolconstant\n" -" boolean .emit OP_PUSH_BOOL;\n" -"ampersandampersand\n" -" \"@&&\";\n" -"barbar\n" -" \"@||\";\n" -"bang\n" -" \"@!\";\n" -"bangequals\n" -" \"@!=\";\n" -"caretcaret\n" -" \"@^^\";\n" -"colon\n" -" \"@:\";\n" -"comma\n" -" \"@,\";\n" -"dot\n" -" \"@.\";\n" -"equals\n" -" \"@=\";\n" -"equalsequals\n" -" \"@==\";\n" -"greater\n" -" \"@>\";\n" -"greaterequals\n" -" \"@>=\";\n" -"lbrace\n" -" \"@{\";\n" -"lbracket\n" -" \"@[\";\n" -"less\n" -" \"@<\";\n" -"lessequals\n" -" \"@<=\";\n" -"lparen\n" -" \"@(\";\n" -"minus\n" -" \"@-\";\n" -"minusequals\n" -" \"@-=\";\n" -"minusminus\n" -" \"@--\";\n" -"plus\n" -" \"@+\";\n" -"plusequals\n" -" \"@+=\";\n" -"plusplus\n" -" \"@++\";\n" -"question\n" -" \"@?\";\n" -"rbrace\n" -" \"@}\";\n" -"rbracket\n" -" \"@]\";\n" -"rparen\n" -" \"@)\";\n" -"semicolon\n" -" \"@;\";\n" -"slash\n" -" \"@/\";\n" -"slashequals\n" -" \"@/=\";\n" -"star\n" -" \"@*\";\n" -"starequals\n" -" \"@*=\";\n" -"" diff --git a/src/mesa/shader/slang/library/syn_to_c.c b/src/mesa/shader/slang/library/syn_to_c.c deleted file mode 100644 index f997edfd8b..0000000000 --- a/src/mesa/shader/slang/library/syn_to_c.c +++ /dev/null @@ -1,72 +0,0 @@ -#include - -static int was_space = 0; -static int first_char = 1; - -static void put_char (int c) -{ - if (c == '\n') { - if (!first_char) { - fputs ("\\n\"\n\"", stdout); - first_char = 1; - } - } - else { - first_char = 0; - if (c == '\\') - fputs ("\\\\", stdout); - else if (c == '\"') - fputs ("\\\"", stdout); - else if (!was_space || !(c == ' ' || c == '\t')) - fputc (c, stdout); - was_space = (c == ' ' || c == '\t'); - } -} - -int main (int argc, char *argv[]) -{ - int c; - FILE *f; - - if (argc == 1) - return 1; - f = fopen (argv[1], "r"); - if (f == NULL) - return 1; - - fputs ("\n", stdout); - fputs ("/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */\n", stdout); - fputs ("\n", stdout); - fputs ("\"", stdout); - c = getc (f); - while (c != EOF) { - if (c == '/') { - int c2 = getc (f); - if (c2 == '*') { - was_space = 0; - c = getc (f); - for (;;) { - if (c == '*') { - c2 = getc (f); - if (c2 == '/') - break; - } - c = getc (f); - } - } - else { - put_char (c); - put_char (c2); - } - } - else { - put_char (c); - } - c = getc (f); - } - fputs ("\"\n", stdout); - - fclose (f); - return 0; -} - diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 830a2d00bc..7669b7e8a6 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2758,10 +2758,6 @@ compile_with_grammar(const char *source, return GL_TRUE; } -LONGSTRING static const char *slang_shader_syn = -#include "library/slang_shader_syn.h" - ; - static const unsigned char slang_core_gc[] = { #include "library/slang_core_gc.h" }; -- cgit v1.2.3 From 3f147c71eda9e8b8f55562f30193584b6fb74704 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 13 Nov 2009 19:51:24 +0100 Subject: slang: Report syntax parser errors. --- src/mesa/shader/slang/slang_compile.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 7669b7e8a6..44c889734b 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2722,17 +2722,22 @@ compile_with_grammar(const char *source, } /* Finally check the syntax and generate its binary representation. */ - result = sl_cl_compile(context, tokens, shader_type, &prod, &size); + result = sl_cl_compile(context, + tokens, + shader_type, + parsing_builtin, + &prod, + &size, + errmsg, + sizeof(errmsg)); sl_pp_context_destroy(context); free(tokens); if (result) { - /*char buf[1024]; - GLint pos;*/ + /*GLint pos;*/ - /*slang_info_log_error(infolog, buf);*/ - slang_info_log_error(infolog, "Syntax error."); + slang_info_log_error(infolog, errmsg); /* syntax error (possibly in library code) */ #if 0 { -- cgit v1.2.3 From 1cf021475a6628cdf4c26457bc7ca0c603fe2c7c Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 21 Nov 2009 20:43:02 +0100 Subject: slang: No need to purify source text for tokeniser. --- src/mesa/shader/slang/slang_compile.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 44c889734b..f2342bfdcb 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2592,34 +2592,24 @@ compile_with_grammar(const char *source, unsigned int maxVersion; int result; struct sl_pp_purify_options options; - char *outbuf; char errmsg[200] = ""; unsigned int errline = 0; struct sl_pp_token_info *intokens; unsigned int tokens_eaten; - memset(&options, 0, sizeof(options)); - if (sl_pp_purify(source, &options, &outbuf, errmsg, sizeof(errmsg), &errline)) { - slang_info_log_error(infolog, errmsg); - return GL_FALSE; - } - context = sl_pp_context_create(); if (!context) { slang_info_log_error(infolog, "out of memory"); - free(outbuf); return GL_FALSE; } - if (sl_pp_tokenise(context, outbuf, &intokens)) { + memset(&options, 0, sizeof(options)); + if (sl_pp_tokenise(context, &options, source, &intokens)) { slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); sl_pp_context_destroy(context); - free(outbuf); return GL_FALSE; } - free(outbuf); - if (sl_pp_version(context, intokens, &version, &tokens_eaten)) { slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); sl_pp_context_destroy(context); -- cgit v1.2.3 From 03f0ebe3bd202b955a0e68bdad65a9a2d27bee2f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 23 Nov 2009 20:12:17 +0100 Subject: slang: Fix order of parameters to sl_pp_tokenise(). --- src/mesa/shader/slang/slang_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index f2342bfdcb..a194f2fc9e 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2604,7 +2604,7 @@ compile_with_grammar(const char *source, } memset(&options, 0, sizeof(options)); - if (sl_pp_tokenise(context, &options, source, &intokens)) { + if (sl_pp_tokenise(context, source, &options, &intokens)) { slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); sl_pp_context_destroy(context); return GL_FALSE; -- cgit v1.2.3 From 48c60b0ecbc7d2f2b153d218a46c61928daddb8e Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 10 Dec 2009 12:39:10 +0100 Subject: slang: Explicitly enable ARB_draw_buffers and ARB_texture_rectangle. They are no longer built into the glsl preprocessor. --- src/mesa/shader/slang/slang_compile.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index a194f2fc9e..00db299a27 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2603,6 +2603,13 @@ compile_with_grammar(const char *source, return GL_FALSE; } + if (sl_pp_context_add_extension(context, "ARB_draw_buffers", "GL_ARB_draw_buffers") || + sl_pp_context_add_extension(context, "ARB_texture_rectangle", "GL_ARB_texture_rectangle")) { + slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); + sl_pp_context_destroy(context); + return GL_FALSE; + } + memset(&options, 0, sizeof(options)); if (sl_pp_tokenise(context, source, &options, &intokens)) { slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); -- cgit v1.2.3 From f00805a11756fa9d2bdfce15f51ae4798d72b5fb Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 10 Dec 2009 12:59:23 +0100 Subject: slang: Predefine ES symbols for FEATURE_es2_glsl. --- src/mesa/shader/slang/slang_compile.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mesa/shader/slang/slang_compile.c') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 00db299a27..478acb89d3 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2610,6 +2610,15 @@ compile_with_grammar(const char *source, return GL_FALSE; } +#if FEATURE_es2_glsl + if (sl_pp_context_add_predefined(context, "GL_ES", "1") || + sl_pp_context_add_predefined(context, "GL_FRAGMENT_PRECISION_HIGH", "1")) { + slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); + sl_pp_context_destroy(context); + return GL_FALSE; + } +#endif + memset(&options, 0, sizeof(options)); if (sl_pp_tokenise(context, source, &options, &intokens)) { slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context)); -- cgit v1.2.3