summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/grammar/grammar.c451
-rw-r--r--src/mesa/shader/grammar/grammar.h8
-rw-r--r--src/mesa/shader/grammar/grammar_mesa.h6
-rw-r--r--src/mesa/shader/slang/descrip.mms3
-rw-r--r--src/mesa/shader/slang/library/Makefile11
-rw-r--r--src/mesa/shader/slang/library/slang_pp_directives.syn405
-rw-r--r--src/mesa/shader/slang/library/slang_pp_directives_syn.h250
-rw-r--r--src/mesa/shader/slang/library/slang_pp_expression.syn265
-rw-r--r--src/mesa/shader/slang/library/slang_pp_expression_syn.h179
-rw-r--r--src/mesa/shader/slang/library/slang_pp_version.syn122
-rw-r--r--src/mesa/shader/slang/library/slang_pp_version_syn.h69
-rw-r--r--src/mesa/shader/slang/library/slang_shader.syn347
-rw-r--r--src/mesa/shader/slang/library/slang_shader_syn.h308
-rw-r--r--src/mesa/shader/slang/library/slang_version.syn118
-rw-r--r--src/mesa/shader/slang/slang_compile.c173
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c1406
-rw-r--r--src/mesa/shader/slang/slang_preprocess.h41
17 files changed, 594 insertions, 3568 deletions
diff --git a/src/mesa/shader/grammar/grammar.c b/src/mesa/shader/grammar/grammar.c
index a9775961d3..54e94bbf6a 100644
--- a/src/mesa/shader/grammar/grammar.c
+++ b/src/mesa/shader/grammar/grammar.c
@@ -566,7 +566,7 @@ static void emit_destroy (emit **em)
}
}
-static unsigned int emit_size (emit *_E)
+static unsigned int emit_size (emit *_E, const char *str)
{
unsigned int n = 0;
@@ -576,7 +576,9 @@ static unsigned int emit_size (emit *_E)
{
if (_E->m_emit_type == et_position)
n += 4; /* position is a 32-bit unsigned integer */
- else
+ else if (_E->m_emit_type == et_stream) {
+ n += strlen(str) + 1;
+ } else
n++;
}
_E = _E->m_next;
@@ -585,7 +587,7 @@ static unsigned int emit_size (emit *_E)
return n;
}
-static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx **_Ctx)
+static int emit_push (emit *_E, byte *_P, const char *str, unsigned int _Pos, regbyte_ctx **_Ctx)
{
while (_E != NULL)
{
@@ -593,9 +595,10 @@ static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx
{
if (_E->m_emit_type == et_byte)
*_P++ = _E->m_byte;
- else if (_E->m_emit_type == et_stream)
- *_P++ = c;
- else /* _Em->type == et_position */
+ else if (_E->m_emit_type == et_stream) {
+ strcpy(_P, str);
+ _P += strlen(str) + 1;
+ } else /* _Em->type == et_position */
{
*_P++ = (byte) (_Pos);
*_P++ = (byte) (_Pos >> 8);
@@ -617,7 +620,7 @@ static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx
if (_E->m_emit_type == et_byte)
new_rbc->m_current_value = _E->m_byte;
else if (_E->m_emit_type == et_stream)
- new_rbc->m_current_value = c;
+ new_rbc->m_current_value = str[0];
}
_E = _E->m_next;
@@ -727,6 +730,7 @@ typedef enum spec_type_
{
st_false,
st_true,
+ st_token,
st_byte,
st_byte_range,
st_string,
@@ -741,6 +745,7 @@ typedef enum spec_type_
typedef struct spec_
{
spec_type m_spec_type;
+ enum sl_pp_token m_token; /* st_token */
byte m_byte[2]; /* st_byte, st_byte_range */
byte *m_string; /* st_string */
struct rule_ *m_rule; /* st_identifier, st_identifier_loop */
@@ -979,12 +984,12 @@ static int barray_append (barray **ba, barray **nb)
*/
static int barray_push (barray **ba, emit *em, byte c, unsigned int pos, regbyte_ctx **rbc)
{
- unsigned int count = emit_size (em);
+ unsigned int count = emit_size(em, " ");
if (barray_resize (ba, (**ba).len + count))
return 1;
- return emit_push (em, (**ba).data + ((**ba).len - count), c, pos, rbc);
+ return emit_push (em, (**ba).data + ((**ba).len - count), " ", pos, rbc);
}
/*
@@ -1967,7 +1972,112 @@ static int get_spec (const byte **text, spec **sp, map_str *maps, map_byte *mapb
}
eat_spaces (&t);
- s->m_spec_type = st_string;
+ /* Try to convert string to a token. */
+ if (s->m_string[0] == '@') {
+ s->m_spec_type = st_token;
+ if (!strcmp(s->m_string, "@,")) {
+ s->m_token = SL_PP_COMMA;
+ } else if (!strcmp(s->m_string, "@;")) {
+ s->m_token = SL_PP_SEMICOLON;
+ } else if (!strcmp(s->m_string, "@{")) {
+ s->m_token = SL_PP_LBRACE;
+ } else if (!strcmp(s->m_string, "@}")) {
+ s->m_token = SL_PP_RBRACE;
+ } else if (!strcmp(s->m_string, "@(")) {
+ s->m_token = SL_PP_LPAREN;
+ } else if (!strcmp(s->m_string, "@)")) {
+ s->m_token = SL_PP_RPAREN;
+ } else if (!strcmp(s->m_string, "@[")) {
+ s->m_token = SL_PP_LBRACKET;
+ } else if (!strcmp(s->m_string, "@]")) {
+ s->m_token = SL_PP_RBRACKET;
+ } else if (!strcmp(s->m_string, "@.")) {
+ s->m_token = SL_PP_DOT;
+ } else if (!strcmp(s->m_string, "@++")) {
+ s->m_token = SL_PP_INCREMENT;
+ } else if (!strcmp(s->m_string, "@+=")) {
+ s->m_token = SL_PP_ADDASSIGN;
+ } else if (!strcmp(s->m_string, "@+")) {
+ s->m_token = SL_PP_PLUS;
+ } else if (!strcmp(s->m_string, "@--")) {
+ s->m_token = SL_PP_DECREMENT;
+ } else if (!strcmp(s->m_string, "@-=")) {
+ s->m_token = SL_PP_SUBASSIGN;
+ } else if (!strcmp(s->m_string, "@-")) {
+ s->m_token = SL_PP_MINUS;
+ } else if (!strcmp(s->m_string, "@~")) {
+ s->m_token = SL_PP_BITNOT;
+ } else if (!strcmp(s->m_string, "@!=")) {
+ s->m_token = SL_PP_NOTEQUAL;
+ } else if (!strcmp(s->m_string, "@!")) {
+ s->m_token = SL_PP_NOT;
+ } else if (!strcmp(s->m_string, "@*=")) {
+ s->m_token = SL_PP_MULASSIGN;
+ } else if (!strcmp(s->m_string, "@*")) {
+ s->m_token = SL_PP_STAR;
+ } else if (!strcmp(s->m_string, "@/=")) {
+ s->m_token = SL_PP_DIVASSIGN;
+ } else if (!strcmp(s->m_string, "@/")) {
+ s->m_token = SL_PP_SLASH;
+ } else if (!strcmp(s->m_string, "@%=")) {
+ s->m_token = SL_PP_MODASSIGN;
+ } else if (!strcmp(s->m_string, "@%")) {
+ s->m_token = SL_PP_MODULO;
+ } else if (!strcmp(s->m_string, "@<<=")) {
+ s->m_token = SL_PP_LSHIFTASSIGN;
+ } else if (!strcmp(s->m_string, "@<<")) {
+ s->m_token = SL_PP_LSHIFT;
+ } else if (!strcmp(s->m_string, "@<=")) {
+ s->m_token = SL_PP_LESSEQUAL;
+ } else if (!strcmp(s->m_string, "@<")) {
+ s->m_token = SL_PP_LESS;
+ } else if (!strcmp(s->m_string, "@>>=")) {
+ s->m_token = SL_PP_RSHIFTASSIGN;
+ } else if (!strcmp(s->m_string, "@>>")) {
+ s->m_token = SL_PP_RSHIFT;
+ } else if (!strcmp(s->m_string, "@>=")) {
+ s->m_token = SL_PP_GREATEREQUAL;
+ } else if (!strcmp(s->m_string, "@>")) {
+ s->m_token = SL_PP_GREATER;
+ } else if (!strcmp(s->m_string, "@==")) {
+ s->m_token = SL_PP_EQUAL;
+ } else if (!strcmp(s->m_string, "@=")) {
+ s->m_token = SL_PP_ASSIGN;
+ } else if (!strcmp(s->m_string, "@&&")) {
+ s->m_token = SL_PP_AND;
+ } else if (!strcmp(s->m_string, "@&=")) {
+ s->m_token = SL_PP_BITANDASSIGN;
+ } else if (!strcmp(s->m_string, "@&")) {
+ s->m_token = SL_PP_BITAND;
+ } else if (!strcmp(s->m_string, "@^^")) {
+ s->m_token = SL_PP_XOR;
+ } else if (!strcmp(s->m_string, "@^=")) {
+ s->m_token = SL_PP_BITXORASSIGN;
+ } else if (!strcmp(s->m_string, "@^")) {
+ s->m_token = SL_PP_BITXOR;
+ } else if (!strcmp(s->m_string, "@||")) {
+ s->m_token = SL_PP_OR;
+ } else if (!strcmp(s->m_string, "@|=")) {
+ s->m_token = SL_PP_BITORASSIGN;
+ } else if (!strcmp(s->m_string, "@|")) {
+ s->m_token = SL_PP_BITOR;
+ } else if (!strcmp(s->m_string, "@?")) {
+ s->m_token = SL_PP_QUESTION;
+ } else if (!strcmp(s->m_string, "@:")) {
+ s->m_token = SL_PP_COLON;
+ } else if (!strcmp(s->m_string, "@ID")) {
+ s->m_token = SL_PP_IDENTIFIER;
+ } else if (!strcmp(s->m_string, "@NUM")) {
+ s->m_token = SL_PP_NUMBER;
+ } else if (!strcmp(s->m_string, "@EOF")) {
+ s->m_token = SL_PP_EOF;
+ } else {
+ spec_destroy(&s);
+ return 1;
+ }
+ } else {
+ s->m_spec_type = st_string;
+ }
}
else if (*t == '.')
{
@@ -2518,11 +2628,17 @@ match (dict *di, const byte *text, int *index, rule *ru, barray **ba, int filter
}
static match_result
-fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool *_BP,
- int filtering_string, regbyte_ctx **rbc)
+fast_match(dict *di,
+ const struct sl_pp_token_info *tokens,
+ int *index,
+ rule *ru,
+ int *_PP,
+ bytepool *_BP,
+ regbyte_ctx **rbc,
+ struct sl_pp_context *context)
{
int ind = *index;
- int _P = filtering_string ? 0 : *_PP;
+ int _P = *_PP;
int _P2;
match_result status = mr_not_matched;
spec *sp = ru->m_specs;
@@ -2531,9 +2647,9 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
/* for every specifier in the rule */
while (sp)
{
- int i, len, save_ind = ind;
+ int save_ind = ind;
- _P2 = _P + (sp->m_emits ? emit_size (sp->m_emits) : 0);
+ _P2 = _P + (sp->m_emits ? emit_size(sp->m_emits, sl_pp_context_cstr(context, tokens[ind].data.identifier)) : 0);
if (bytepool_reserve (_BP, _P2))
{
free_regbyte_ctx_stack (ctx, *rbc);
@@ -2545,7 +2661,7 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
switch (sp->m_spec_type)
{
case st_identifier:
- status = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
+ status = fast_match(di, tokens, &ind, sp->m_rule, &_P2, _BP, &ctx, context);
if (status == mr_internal_error)
{
@@ -2553,58 +2669,38 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
return mr_internal_error;
}
break;
- case st_string:
- len = str_length (sp->m_string);
-
- /* prefilter the stream */
- if (!filtering_string && di->m_string)
- {
- int filter_index = 0;
- match_result result;
- regbyte_ctx *null_ctx = NULL;
-
- result = fast_match (di, text + ind, &filter_index, di->m_string, NULL, _BP, 1, &null_ctx);
-
- if (result == mr_internal_error)
- {
- free_regbyte_ctx_stack (ctx, *rbc);
- return mr_internal_error;
- }
- if (result != mr_matched)
- {
- status = mr_not_matched;
- break;
- }
+ case st_token:
+ if (tokens[ind].token == sp->m_token) {
+ status = mr_matched;
+ ind++;
+ } else {
+ status = mr_not_matched;
+ }
+ break;
- if (filter_index != len || !str_equal_n (sp->m_string, text + ind, len))
- {
- status = mr_not_matched;
- break;
- }
+ case st_string:
+ if (tokens[ind].token != SL_PP_IDENTIFIER) {
+ status = mr_not_matched;
+ break;
+ }
- status = mr_matched;
- ind += len;
- }
- else
- {
- status = mr_matched;
- for (i = 0; status == mr_matched && i < len; i++)
- if (text[ind + i] != sp->m_string[i])
- status = mr_not_matched;
+ if (!strcmp(sl_pp_context_cstr(context, tokens[ind].data.identifier), sp->m_string)) {
+ status = mr_matched;
+ ind++;
+ } else {
+ status = mr_not_matched;
+ }
+ break;
- if (status == mr_matched)
- ind += len;
- }
- break;
case st_byte:
- status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;
+ /**status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;**/
if (status == mr_matched)
ind++;
break;
case st_byte_range:
- status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
- mr_matched : mr_not_matched;
+ /**status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
+ mr_matched : mr_not_matched;**/
if (status == mr_matched)
ind++;
break;
@@ -2624,7 +2720,7 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
match_result result;
save_ind = ind;
- result = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
+ result = fast_match(di, tokens, &ind, sp->m_rule, &_P2, _BP, &ctx, context);
if (result == mr_error_raised)
{
@@ -2633,11 +2729,9 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
}
else if (result == mr_matched)
{
- if (!filtering_string)
- {
if (sp->m_emits != NULL)
{
- if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
+ if (emit_push (sp->m_emits, _BP->_F + _P, sl_pp_context_cstr(context, tokens[ind - 1].data.identifier), save_ind, &ctx))
{
free_regbyte_ctx_stack (ctx, *rbc);
return mr_internal_error;
@@ -2645,13 +2739,12 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
}
_P = _P2;
- _P2 += sp->m_emits ? emit_size (sp->m_emits) : 0;
+ _P2 += sp->m_emits ? emit_size(sp->m_emits, sl_pp_context_cstr(context, tokens[ind].data.identifier)) : 0;
if (bytepool_reserve (_BP, _P2))
{
free_regbyte_ctx_stack (ctx, *rbc);
return mr_internal_error;
}
- }
}
else if (result == mr_internal_error)
{
@@ -2682,8 +2775,8 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
if (sp->m_errtext)
{
- set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
- ind), ind);
+ /**set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
+ ind), ind);**/
return mr_error_raised;
}
@@ -2694,8 +2787,8 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
if (status == mr_matched)
{
if (sp->m_emits != NULL) {
- const byte ch = (ind <= 0) ? 0 : text[ind - 1];
- if (emit_push (sp->m_emits, _BP->_F + _P, ch, save_ind, &ctx))
+ const char *str = (ind <= 0) ? "" : sl_pp_context_cstr(context, tokens[ind - 1].data.identifier);
+ if (emit_push (sp->m_emits, _BP->_F + _P, str, save_ind, &ctx))
{
free_regbyte_ctx_stack (ctx, *rbc);
return mr_internal_error;
@@ -2710,7 +2803,6 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
{
*index = ind;
*rbc = ctx;
- if (!filtering_string)
*_PP = _P;
return mr_matched;
}
@@ -2723,7 +2815,6 @@ fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
{
*index = ind;
*rbc = ctx;
- if (!filtering_string)
*_PP = _P;
return mr_matched;
}
@@ -3013,14 +3104,20 @@ int grammar_set_reg8 (grammar id, const byte *name, byte value)
return 1;
}
-/*
- internal checking function used by both grammar_check and grammar_fast_check functions
-*/
-static int _grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size,
- unsigned int estimate_prod_size, int use_fast_path)
+int
+grammar_fast_check (grammar id,
+ const byte *text,
+ byte **prod,
+ unsigned int *size,
+ unsigned int estimate_prod_size)
{
- dict *di = NULL;
+ dict *di = NULL;
+ struct sl_pp_context context;
+ struct sl_pp_token_info *tokens;
int index = 0;
+ regbyte_ctx *rbc = NULL;
+ bytepool *bp = NULL;
+ int _P = 0;
clear_last_error ();
@@ -3034,72 +3131,140 @@ static int _grammar_check (grammar id, const byte *text, byte **prod, unsigned i
*prod = NULL;
*size = 0;
- if (use_fast_path)
- {
- regbyte_ctx *rbc = NULL;
- bytepool *bp = NULL;
- int _P = 0;
-
- bytepool_create (&bp, estimate_prod_size);
- if (bp == NULL)
- return 0;
-
- if (fast_match (di, text, &index, di->m_syntax, &_P, bp, 0, &rbc) != mr_matched)
- {
- bytepool_destroy (&bp);
- free_regbyte_ctx_stack (rbc, NULL);
- return 0;
- }
-
- free_regbyte_ctx_stack (rbc, NULL);
-
- *prod = bp->_F;
- *size = _P;
- bp->_F = NULL;
- bytepool_destroy (&bp);
- }
- else
- {
- regbyte_ctx *rbc = NULL;
- barray *ba = NULL;
-
- barray_create (&ba);
- if (ba == NULL)
- return 0;
-
- if (match (di, text, &index, di->m_syntax, &ba, 0, &rbc) != mr_matched)
- {
- barray_destroy (&ba);
- free_regbyte_ctx_stack (rbc, NULL);
- return 0;
- }
-
- free_regbyte_ctx_stack (rbc, NULL);
-
- *prod = (byte *) mem_alloc (ba->len * sizeof (byte));
- if (*prod == NULL)
- {
- barray_destroy (&ba);
- return 0;
- }
-
- mem_copy (*prod, ba->data, ba->len * sizeof (byte));
- *size = ba->len;
- barray_destroy (&ba);
- }
-
- return 1;
-}
-
-int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size)
-{
- return _grammar_check (id, text, prod, size, 0, 0);
-}
-
-int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size,
- unsigned int estimate_prod_size)
-{
- return _grammar_check (id, text, prod, size, estimate_prod_size, 1);
+ /*
+ * 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;
+ }
+
+ sl_pp_context_init(&context);
+
+ 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);
+ 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;
+ *size = _P;
+ bp->_F = NULL;
+ bytepool_destroy(&bp);
+
+ return 1;
}
int grammar_destroy (grammar id)
diff --git a/src/mesa/shader/grammar/grammar.h b/src/mesa/shader/grammar/grammar.h
index 591e38aefa..151b5f082b 100644
--- a/src/mesa/shader/grammar/grammar.h
+++ b/src/mesa/shader/grammar/grammar.h
@@ -61,19 +61,11 @@ grammar grammar_load_from_text (const byte *text);
int grammar_set_reg8 (grammar id, const byte *name, byte value);
/*
- this function is obsolete, use only for debugging purposes
-
checks if a null-terminated <text> matches given grammar <id>
returns 0 on error (call grammar_get_last_error to retrieve the error text)
returns 1 on success, the <prod> points to newly allocated buffer with production and <size>
is filled with the production size
call grammar_alloc_free to free the memory block pointed by <prod>
-*/
-int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size);
-
-/*
- does the same what grammar_check does but much more (approx. 4 times) faster
- use this function instead of grammar_check
<estimate_prod_size> 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
*/
diff --git a/src/mesa/shader/grammar/grammar_mesa.h b/src/mesa/shader/grammar/grammar_mesa.h
index 6c92c5812d..7f4370f32d 100644
--- a/src/mesa/shader/grammar/grammar_mesa.h
+++ b/src/mesa/shader/grammar/grammar_mesa.h
@@ -26,6 +26,12 @@
#define 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 "main/imports.h"
/* NOTE: include Mesa 3-D specific headers here */
diff --git a/src/mesa/shader/slang/descrip.mms b/src/mesa/shader/slang/descrip.mms
index 6eefbcf5bd..759a01cf04 100644
--- a/src/mesa/shader/slang/descrip.mms
+++ b/src/mesa/shader/slang/descrip.mms
@@ -22,7 +22,7 @@ LIBDIR = [----.lib]
CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
SOURCES = \
- slang_compile.c,slang_preprocess.c
+ slang_compile.c
OBJECTS = slang_builtin.obj,slang_codegen.obj,slang_compile.obj,\
slang_compile_function.obj,slang_compile_operation.obj,\
@@ -59,7 +59,6 @@ slang_library_noise.obj : slang_library_noise.c
slang_link.obj : slang_link.c
slang_log.obj : slang_log.c
slang_mem.obj : slang_mem.c
-slang_preprocess.obj : slang_preprocess.c
slang_print.obj : slang_print.c
slang_simplify.obj : slang_simplify.c
slang_storage.obj : slang_storage.c
diff --git a/src/mesa/shader/slang/library/Makefile b/src/mesa/shader/slang/library/Makefile
index 0e03fac2ee..5033d887c5 100644
--- a/src/mesa/shader/slang/library/Makefile
+++ b/src/mesa/shader/slang/library/Makefile
@@ -19,7 +19,7 @@ default: syntax builtin
clean:
-rm -f syn_to_c gc_to_bin *_syn.h *_gc.h
-syntax: slang_pp_directives_syn.h slang_pp_expression_syn.h slang_shader_syn.h slang_pp_version_syn.h
+syntax: slang_shader_syn.h
builtin: builtin_110 builtin_120
@@ -37,18 +37,9 @@ gc_to_bin: gc_to_bin.c slang_shader_syn.h
# syntax scripts
#
-slang_pp_directives_syn.h: syn_to_c slang_pp_directives.syn
- ./syn_to_c slang_pp_directives.syn > slang_pp_directives_syn.h
-
-slang_pp_expression_syn.h: syn_to_c slang_pp_expression.syn
- ./syn_to_c slang_pp_expression.syn > slang_pp_expression_syn.h
-
slang_shader_syn.h: syn_to_c slang_shader.syn
./syn_to_c slang_shader.syn > slang_shader_syn.h
-slang_pp_version_syn.h: syn_to_c slang_pp_version.syn
- ./syn_to_c slang_pp_version.syn > slang_pp_version_syn.h
-
#
# builtin library sources
#
diff --git a/src/mesa/shader/slang/library/slang_pp_directives.syn b/src/mesa/shader/slang/library/slang_pp_directives.syn
deleted file mode 100644
index b51d168cc0..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_directives.syn
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.6
- *
- * Copyright (C) 2006 Brian Paul 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_pp_directives.syn
- * slang preprocessor directives parser
- * \author Michal Krol
- */
-
-.syntax source;
-
-/*
- * This syntax script preprocesses a GLSL shader.
- * It is assumed, that the #version directive has been parsed. Separate pass for parsing
- * version gives better control on behavior depending on the version number given.
- *
- * The output is a source string with comments and directives removed. White spaces and comments
- * are replaced with on or more spaces. All new-lines are preserved and converted to Linux format.
- * Directives are escaped with a null character. The end of the source string is marked by
- * two consecutive null characters. The consumer is responsible for executing the escaped
- * directives, removing dead portions of code and expanding macros.
- */
-
-.emtcode ESCAPE_TOKEN 0
-
-/*
- * The TOKEN_* symbols follow the ESCAPE_TOKEN.
- *
- * NOTE:
- * There is no TOKEN_IFDEF and neither is TOKEN_IFNDEF. They are handled with TOKEN_IF and
- * operator defined.
- * The "#ifdef SYMBOL" is replaced with "#if defined SYMBOL"
- * The "#ifndef SYMBOL" is replaced with "#if !defined SYMBOL"
- */
-.emtcode TOKEN_END 0
-.emtcode TOKEN_DEFINE 1
-.emtcode TOKEN_UNDEF 2
-.emtcode TOKEN_IF 3
-.emtcode TOKEN_ELSE 4
-.emtcode TOKEN_ELIF 5
-.emtcode TOKEN_ENDIF 6
-.emtcode TOKEN_ERROR 7
-.emtcode TOKEN_PRAGMA 8
-.emtcode TOKEN_EXTENSION 9
-.emtcode TOKEN_LINE 10
-
-/*
- * The PARAM_* symbols follow the TOKEN_DEFINE.
- */
-.emtcode PARAM_END 0
-.emtcode PARAM_PARAMETER 1
-
-/*
- * The BEHAVIOR_* symbols follow the TOKEN_EXTENSION.
- */
-.emtcode BEHAVIOR_REQUIRE 1
-.emtcode BEHAVIOR_ENABLE 2
-.emtcode BEHAVIOR_WARN 3
-.emtcode BEHAVIOR_DISABLE 4
-
-/*
- * The PRAGMA_* symbols follow TOKEN_PRAGMA
- */
-.emtcode PRAGMA_NO_PARAM 0
-.emtcode PRAGMA_PARAM 1
-
-source
- optional_directive .and .loop source_element .and '\0' .emit ESCAPE_TOKEN .emit TOKEN_END;
-
-source_element
- c_style_comment_block .or cpp_style_comment_block .or new_line_directive .or source_token;
-
-c_style_comment_block
- '/' .and '*' .and c_style_comment_rest .and .true .emit ' ';
-
-c_style_comment_rest
- .loop c_style_comment_body .and c_style_comment_end;
-
-c_style_comment_body
- c_style_comment_char_nostar .or c_style_comment_char_star_noslashstar;
-
-c_style_comment_char_nostar
- new_line .or '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_char_star_noslashstar
- '*' .and c_style_comment_char_star_noslashstar_1;
-c_style_comment_char_star_noslashstar_1
- c_style_comment_char_noslashstar .or c_style_comment_char_star_noslashstar;
-
-c_style_comment_char_noslashstar
- new_line .or '\x30'-'\xFF' .or '\x01'-'\x29' .or '\x2B'-'\x2E';
-
-c_style_comment_end
- '*' .and .loop c_style_comment_char_star .and '/';
-
-c_style_comment_char_star
- '*';
-
-cpp_style_comment_block
- '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
- cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
- .loop cpp_style_comment_char .and new_line_directive;
-cpp_style_comment_block_3
- .loop cpp_style_comment_char;
-
-cpp_style_comment_char
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line_directive
- new_line .and optional_directive;
-
-new_line
- generic_new_line .emit '\n';
-
-generic_new_line
- carriage_return_line_feed .or line_feed_carriage_return .or '\n' .or '\r';
-
-carriage_return_line_feed
- '\r' .and '\n';
-
-line_feed_carriage_return
- '\n' .and '\r';
-
-optional_directive
- directive .emit ESCAPE_TOKEN .or .true;
-
-directive
- dir_define .emit TOKEN_DEFINE .or
- dir_undef .emit TOKEN_UNDEF .or
- dir_if .emit TOKEN_IF .or
- dir_ifdef .emit TOKEN_IF .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e' .emit 'd'
- .emit ' ' .or
- dir_ifndef .emit TOKEN_IF .emit '!' .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e'
- .emit 'd' .emit ' ' .or
- dir_else .emit TOKEN_ELSE .or
- dir_elif .emit TOKEN_ELIF .or
- dir_endif .emit TOKEN_ENDIF .or
- dir_ext .emit TOKEN_EXTENSION .or
- dir_pragma .emit TOKEN_PRAGMA .or
- dir_line .emit TOKEN_LINE;
-
-dir_define
- optional_space .and '#' .and optional_space .and "define" .and symbol .and opt_parameters .and
- definition;
-
-dir_undef
- optional_space .and '#' .and optional_space .and "undef" .and symbol;
-
-dir_if
- optional_space .and '#' .and optional_space .and "if" .and expression;
-
-dir_ifdef
- optional_space .and '#' .and optional_space .and "ifdef" .and symbol;
-
-dir_ifndef
- optional_space .and '#' .and optional_space .and "ifndef" .and symbol;
-
-dir_else
- optional_space .and '#' .and optional_space .and "else";
-
-dir_elif
- optional_space .and '#' .and optional_space .and "elif" .and expression;
-
-dir_endif
- optional_space .and '#' .and optional_space .and "endif";
-
-dir_ext
- optional_space .and '#' .and optional_space .and "extension" .and space .and extension_name .and
- optional_space .and ':' .and optional_space .and extension_behavior;
-
-dir_line
- optional_space .and '#' .and optional_space .and "line" .and expression;
-
-dir_pragma
- optional_space .and '#' .and optional_space .and "pragma" .and symbol .and opt_pragma_param;
-
-
-opt_pragma_param
- pragma_param .or .true .emit PRAGMA_NO_PARAM;
-
-pragma_param
- optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';
-
-symbol_no_space
- symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-symbol
- space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-opt_parameters
- parameters .or .true .emit PARAM_END;
-
-parameters
- '(' .and parameters_1 .and optional_space .and ')' .emit PARAM_END;
-parameters_1
- parameters_2 .or .true;
-parameters_2
- parameter .emit PARAM_PARAMETER .and .loop parameters_3;
-parameters_3
- optional_space .and ',' .and parameter .emit PARAM_PARAMETER;
-
-parameter
- optional_space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and
- .true .emit '\0';
-
-definition
- .loop definition_character .emit * .and .true .emit '\0';
-
-definition_character
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-expression
- expression_element .and .loop expression_element .and .true .emit '\0';
-
-expression_element
- expression_character .emit *;
-
-expression_character
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-extension_name
- symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
-
-extension_behavior
- "require" .emit BEHAVIOR_REQUIRE .or
- "enable" .emit BEHAVIOR_ENABLE .or
- "warn" .emit BEHAVIOR_WARN .or
- "disable" .emit BEHAVIOR_DISABLE;
-
-optional_space
- .loop single_space;
-
-space
- single_space .and .loop single_space;
-
-single_space
- ' ' .or '\t';
-
-source_token
- space .emit ' ' .or complex_token .or source_token_1;
-source_token_1
- simple_token .emit ' ' .and .true .emit ' ';
-
-/*
- * All possible tokens.
- */
-
-complex_token
- identifier .or number;
-
-simple_token
- increment .or decrement .or lequal .or gequal .or equal .or nequal .or and .or xor .or or .or
- addto .or subtractfrom .or multiplyto .or divideto .or other;
-
-identifier
- identifier_char1 .emit * .and .loop identifier_char2 .emit *;
-identifier_char1
- 'a'-'z' .or 'A'-'Z' .or '_';
-identifier_char2
- 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
-number
- float .or integer;
-
-digit_oct
- '0'-'7';
-
-digit_dec
- '0'-'9';
-
-digit_hex
- '0'-'9' .or 'A'-'F' .or 'a'-'f';
-
-float
- float_1 .or float_2;
-float_1
- float_fractional_constant .and float_optional_exponent_part;
-float_2
- float_digit_sequence .and float_exponent_part;
-
-float_fractional_constant
- float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
-float_fractional_constant_1
- float_digit_sequence .and '.' .emit '.' .and float_digit_sequence;
-float_fractional_constant_2
- float_digit_sequence .and '.' .emit '.';
-float_fractional_constant_3
- '.' .emit '.' .and float_digit_sequence;
-
-float_optional_exponent_part
- float_exponent_part .or .true;
-
-float_digit_sequence
- digit_dec .emit * .and .loop digit_dec .emit *;
-
-float_exponent_part
- float_exponent_part_1 .or float_exponent_part_2;
-float_exponent_part_1
- 'e' .emit 'e' .and float_optional_sign .and float_digit_sequence;
-float_exponent_part_2
- 'E' .emit 'E' .and float_optional_sign .and float_digit_sequence;
-
-float_optional_sign
- '+' .emit '+' .or '-' .emit '-' .or .true;
-
-integer
- integer_hex .or integer_oct .or integer_dec;
-
-integer_hex
- '0' .emit '0' .and integer_hex_1 .emit * .and digit_hex .emit * .and
- .loop digit_hex .emit *;
-integer_hex_1
- 'x' .or 'X';
-
-integer_oct
- '0' .emit '0' .and .loop digit_oct .emit *;
-
-integer_dec
- digit_dec .emit * .and .loop digit_dec .emit *;
-
-increment
- '+' .emit * .and '+' .emit *;
-
-decrement
- '-' .emit * .and '-' .emit *;
-
-lequal
- '<' .emit * .and '=' .emit *;
-
-gequal
- '>' .emit * .and '=' .emit *;
-
-equal
- '=' .emit * .and '=' .emit *;
-
-nequal
- '!' .emit * .and '=' .emit *;
-
-and
- '&' .emit * .and '&' .emit *;
-
-xor
- '^' .emit * .and '^' .emit *;
-
-or
- '|' .emit * .and '|' .emit *;
-
-addto
- '+' .emit * .and '=' .emit *;
-
-subtractfrom
- '-' .emit * .and '=' .emit *;
-
-multiplyto
- '*' .emit * .and '=' .emit *;
-
-divideto
- '/' .emit * .and '=' .emit *;
-
-/*
- * All characters except '\0' and '#'.
- */
-other
- '\x24'-'\xFF' .emit * .or '\x01'-'\x22' .emit *;
-
-symbol_character
- 'A'-'Z' .or 'a'-'z' .or '_';
-
-symbol_character2
- 'A'-'Z' .or 'a'-'z' .or '0'-'9' .or '_';
-
-.string string_lexer;
-
-string_lexer
- lex_first_identifier_character .and .loop lex_next_identifier_character;
-
-lex_first_identifier_character
- 'a'-'z' .or 'A'-'Z' .or '_';
-
-lex_next_identifier_character
- 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
diff --git a/src/mesa/shader/slang/library/slang_pp_directives_syn.h b/src/mesa/shader/slang/library/slang_pp_directives_syn.h
deleted file mode 100644
index 430f8d8217..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_directives_syn.h
+++ /dev/null
@@ -1,250 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax source;\n"
-".emtcode ESCAPE_TOKEN 0\n"
-".emtcode TOKEN_END 0\n"
-".emtcode TOKEN_DEFINE 1\n"
-".emtcode TOKEN_UNDEF 2\n"
-".emtcode TOKEN_IF 3\n"
-".emtcode TOKEN_ELSE 4\n"
-".emtcode TOKEN_ELIF 5\n"
-".emtcode TOKEN_ENDIF 6\n"
-".emtcode TOKEN_ERROR 7\n"
-".emtcode TOKEN_PRAGMA 8\n"
-".emtcode TOKEN_EXTENSION 9\n"
-".emtcode TOKEN_LINE 10\n"
-".emtcode PARAM_END 0\n"
-".emtcode PARAM_PARAMETER 1\n"
-".emtcode BEHAVIOR_REQUIRE 1\n"
-".emtcode BEHAVIOR_ENABLE 2\n"
-".emtcode BEHAVIOR_WARN 3\n"
-".emtcode BEHAVIOR_DISABLE 4\n"
-".emtcode PRAGMA_NO_PARAM 0\n"
-".emtcode PRAGMA_PARAM 1\n"
-"source\n"
-" optional_directive .and .loop source_element .and '\\0' .emit ESCAPE_TOKEN .emit TOKEN_END;\n"
-"source_element\n"
-" c_style_comment_block .or cpp_style_comment_block .or new_line_directive .or source_token;\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest .and .true .emit ' ';\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_body .and c_style_comment_end;\n"
-"c_style_comment_body\n"
-" c_style_comment_char_nostar .or c_style_comment_char_star_noslashstar;\n"
-"c_style_comment_char_nostar\n"
-" new_line .or '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_char_star_noslashstar\n"
-" '*' .and c_style_comment_char_star_noslashstar_1;\n"
-"c_style_comment_char_star_noslashstar_1\n"
-" c_style_comment_char_noslashstar .or c_style_comment_char_star_noslashstar;\n"
-"c_style_comment_char_noslashstar\n"
-" new_line .or '\\x30'-'\\xFF' .or '\\x01'-'\\x29' .or '\\x2B'-'\\x2E';\n"
-"c_style_comment_end\n"
-" '*' .and .loop c_style_comment_char_star .and '/';\n"
-"c_style_comment_char_star\n"
-" '*';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line_directive;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"new_line_directive\n"
-" new_line .and optional_directive;\n"
-"new_line\n"
-" generic_new_line .emit '\\n';\n"
-"generic_new_line\n"
-" carriage_return_line_feed .or line_feed_carriage_return .or '\\n' .or '\\r';\n"
-"carriage_return_line_feed\n"
-" '\\r' .and '\\n';\n"
-"line_feed_carriage_return\n"
-" '\\n' .and '\\r';\n"
-"optional_directive\n"
-" directive .emit ESCAPE_TOKEN .or .true;\n"
-"directive\n"
-" dir_define .emit TOKEN_DEFINE .or\n"
-" dir_undef .emit TOKEN_UNDEF .or\n"
-" dir_if .emit TOKEN_IF .or\n"
-" dir_ifdef .emit TOKEN_IF .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e' .emit 'd'\n"
-" .emit ' ' .or\n"
-" dir_ifndef .emit TOKEN_IF .emit '!' .emit 'd' .emit 'e' .emit 'f' .emit 'i' .emit 'n' .emit 'e'\n"
-" .emit 'd' .emit ' ' .or\n"
-" dir_else .emit TOKEN_ELSE .or\n"
-" dir_elif .emit TOKEN_ELIF .or\n"
-" dir_endif .emit TOKEN_ENDIF .or\n"
-" dir_ext .emit TOKEN_EXTENSION .or\n"
-" dir_pragma .emit TOKEN_PRAGMA .or\n"
-" dir_line .emit TOKEN_LINE;\n"
-"dir_define\n"
-" optional_space .and '#' .and optional_space .and \"define\" .and symbol .and opt_parameters .and\n"
-" definition;\n"
-"dir_undef\n"
-" optional_space .and '#' .and optional_space .and \"undef\" .and symbol;\n"
-"dir_if\n"
-" optional_space .and '#' .and optional_space .and \"if\" .and expression;\n"
-"dir_ifdef\n"
-" optional_space .and '#' .and optional_space .and \"ifdef\" .and symbol;\n"
-"dir_ifndef\n"
-" optional_space .and '#' .and optional_space .and \"ifndef\" .and symbol;\n"
-"dir_else\n"
-" optional_space .and '#' .and optional_space .and \"else\";\n"
-"dir_elif\n"
-" optional_space .and '#' .and optional_space .and \"elif\" .and expression;\n"
-"dir_endif\n"
-" optional_space .and '#' .and optional_space .and \"endif\";\n"
-"dir_ext\n"
-" optional_space .and '#' .and optional_space .and \"extension\" .and space .and extension_name .and\n"
-" optional_space .and ':' .and optional_space .and extension_behavior;\n"
-"dir_line\n"
-" optional_space .and '#' .and optional_space .and \"line\" .and expression;\n"
-"dir_pragma\n"
-" optional_space .and '#' .and optional_space .and \"pragma\" .and symbol .and opt_pragma_param;\n"
-"opt_pragma_param\n"
-" pragma_param .or .true .emit PRAGMA_NO_PARAM;\n"
-"pragma_param\n"
-" optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';\n"
-"symbol_no_space\n"
-" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"symbol\n"
-" space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"opt_parameters\n"
-" parameters .or .true .emit PARAM_END;\n"
-"parameters\n"
-" '(' .and parameters_1 .and optional_space .and ')' .emit PARAM_END;\n"
-"parameters_1\n"
-" parameters_2 .or .true;\n"
-"parameters_2\n"
-" parameter .emit PARAM_PARAMETER .and .loop parameters_3;\n"
-"parameters_3\n"
-" optional_space .and ',' .and parameter .emit PARAM_PARAMETER;\n"
-"parameter\n"
-" optional_space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and\n"
-" .true .emit '\\0';\n"
-"definition\n"
-" .loop definition_character .emit * .and .true .emit '\\0';\n"
-"definition_character\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"expression\n"
-" expression_element .and .loop expression_element .and .true .emit '\\0';\n"
-"expression_element\n"
-" expression_character .emit *;\n"
-"expression_character\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"extension_name\n"
-" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
-"extension_behavior\n"
-" \"require\" .emit BEHAVIOR_REQUIRE .or\n"
-" \"enable\" .emit BEHAVIOR_ENABLE .or\n"
-" \"warn\" .emit BEHAVIOR_WARN .or\n"
-" \"disable\" .emit BEHAVIOR_DISABLE;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"source_token\n"
-" space .emit ' ' .or complex_token .or source_token_1;\n"
-"source_token_1\n"
-" simple_token .emit ' ' .and .true .emit ' ';\n"
-"complex_token\n"
-" identifier .or number;\n"
-"simple_token\n"
-" increment .or decrement .or lequal .or gequal .or equal .or nequal .or and .or xor .or or .or\n"
-" addto .or subtractfrom .or multiplyto .or divideto .or other;\n"
-"identifier\n"
-" identifier_char1 .emit * .and .loop identifier_char2 .emit *;\n"
-"identifier_char1\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"identifier_char2\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-"number\n"
-" float .or integer;\n"
-"digit_oct\n"
-" '0'-'7';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"digit_hex\n"
-" '0'-'9' .or 'A'-'F' .or 'a'-'f';\n"
-"float\n"
-" float_1 .or float_2;\n"
-"float_1\n"
-" float_fractional_constant .and float_optional_exponent_part;\n"
-"float_2\n"
-" float_digit_sequence .and float_exponent_part;\n"
-"float_fractional_constant\n"
-" float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;\n"
-"float_fractional_constant_1\n"
-" float_digit_sequence .and '.' .emit '.' .and float_digit_sequence;\n"
-"float_fractional_constant_2\n"
-" float_digit_sequence .and '.' .emit '.';\n"
-"float_fractional_constant_3\n"
-" '.' .emit '.' .and float_digit_sequence;\n"
-"float_optional_exponent_part\n"
-" float_exponent_part .or .true;\n"
-"float_digit_sequence\n"
-" digit_dec .emit * .and .loop digit_dec .emit *;\n"
-"float_exponent_part\n"
-" float_exponent_part_1 .or float_exponent_part_2;\n"
-"float_exponent_part_1\n"
-" 'e' .emit 'e' .and float_optional_sign .and float_digit_sequence;\n"
-"float_exponent_part_2\n"
-" 'E' .emit 'E' .and float_optional_sign .and float_digit_sequence;\n"
-"float_optional_sign\n"
-" '+' .emit '+' .or '-' .emit '-' .or .true;\n"
-"integer\n"
-" integer_hex .or integer_oct .or integer_dec;\n"
-"integer_hex\n"
-" '0' .emit '0' .and integer_hex_1 .emit * .and digit_hex .emit * .and\n"
-" .loop digit_hex .emit *;\n"
-"integer_hex_1\n"
-" 'x' .or 'X';\n"
-"integer_oct\n"
-" '0' .emit '0' .and .loop digit_oct .emit *;\n"
-"integer_dec\n"
-" digit_dec .emit * .and .loop digit_dec .emit *;\n"
-"increment\n"
-" '+' .emit * .and '+' .emit *;\n"
-"decrement\n"
-" '-' .emit * .and '-' .emit *;\n"
-"lequal\n"
-" '<' .emit * .and '=' .emit *;\n"
-"gequal\n"
-" '>' .emit * .and '=' .emit *;\n"
-"equal\n"
-" '=' .emit * .and '=' .emit *;\n"
-"nequal\n"
-" '!' .emit * .and '=' .emit *;\n"
-"and\n"
-" '&' .emit * .and '&' .emit *;\n"
-"xor\n"
-" '^' .emit * .and '^' .emit *;\n"
-"or\n"
-" '|' .emit * .and '|' .emit *;\n"
-"addto\n"
-" '+' .emit * .and '=' .emit *;\n"
-"subtractfrom\n"
-" '-' .emit * .and '=' .emit *;\n"
-"multiplyto\n"
-" '*' .emit * .and '=' .emit *;\n"
-"divideto\n"
-" '/' .emit * .and '=' .emit *;\n"
-"other\n"
-" '\\x24'-'\\xFF' .emit * .or '\\x01'-'\\x22' .emit *;\n"
-"symbol_character\n"
-" 'A'-'Z' .or 'a'-'z' .or '_';\n"
-"symbol_character2\n"
-" 'A'-'Z' .or 'a'-'z' .or '0'-'9' .or '_';\n"
-".string string_lexer;\n"
-"string_lexer\n"
-" lex_first_identifier_character .and .loop lex_next_identifier_character;\n"
-"lex_first_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"lex_next_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_pp_expression.syn b/src/mesa/shader/slang/library/slang_pp_expression.syn
deleted file mode 100644
index bfdb220bf5..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_expression.syn
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.6
- *
- * Copyright (C) 2006 Brian Paul 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_pp_expression.syn
- * slang preprocessor expression parser
- * \author Michal Krol
- */
-
-/*
- * Parses one or two (optional) expressions on literal integer constants. Those expressions come
- * from #if #elif and #line directives. The preprocessor already parsed those directives and
- * expanded the expression (expressions). All occurences of the operator "defined" are already
- * replaced with either "0" or "1" literals.
- */
-
-.syntax expression;
-
-/*
- * Those separate individual expressions.
- * For #if/#elif case it is: EXP_EXPRESSION ... EXP_END
- * For #line case it may be: EXP_EXPRESSION ... EXP_EXPRESSION ... EXP_END
- */
-.emtcode EXP_END 0
-.emtcode EXP_EXPRESSION 1
-
-.emtcode OP_END 0
-.emtcode OP_PUSHINT 1
-.emtcode OP_LOGICALOR 2
-.emtcode OP_LOGICALAND 3
-.emtcode OP_OR 4
-.emtcode OP_XOR 5
-.emtcode OP_AND 6
-.emtcode OP_EQUAL 7
-.emtcode OP_NOTEQUAL 8
-.emtcode OP_LESSEQUAL 9
-.emtcode OP_GREATEREQUAL 10
-.emtcode OP_LESS 11
-.emtcode OP_GREATER 12
-.emtcode OP_LEFTSHIFT 13
-.emtcode OP_RIGHTSHIFT 14
-.emtcode OP_ADD 15
-.emtcode OP_SUBTRACT 16
-.emtcode OP_MULTIPLY 17
-.emtcode OP_DIVIDE 18
-.emtcode OP_MODULUS 19
-.emtcode OP_PLUS 20
-.emtcode OP_MINUS 21
-.emtcode OP_NEGATE 22
-.emtcode OP_COMPLEMENT 23
-
-expression
- first_expression .and optional_second_expression .and optional_space .and '\0' .emit EXP_END;
-
-first_expression
- optional_space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;
-
-optional_second_expression
- second_expression .or .true;
-
-second_expression
- space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;
-
-logical_or_expression
- logical_and_expression .and .loop logical_or_expression_1;
-logical_or_expression_1
- barbar .and logical_and_expression .and .true .emit OP_LOGICALOR;
-
-logical_and_expression
- or_expression .and .loop logical_and_expression_1;
-logical_and_expression_1
- ampersandampersand .and or_expression .and .true .emit OP_LOGICALAND;
-
-or_expression
- xor_expression .and .loop or_expression_1;
-or_expression_1
- bar .and xor_expression .and .true .emit OP_OR;
-
-xor_expression
- and_expression .and .loop xor_expression_1;
-xor_expression_1
- caret .and and_expression .and .true .emit OP_XOR;
-
-and_expression
- equality_expression .and .loop and_expression_1;
-and_expression_1
- ampersand .and equality_expression .and .true .emit OP_AND;
-
-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;
-
-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;
-
-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_LEFTSHIFT;
-shift_expression_3
- greatergreater .and additive_expression .and .true .emit OP_RIGHTSHIFT;
-
-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
- dash .and multiplicative_expression .and .true .emit OP_SUBTRACT;
-
-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;
-
-unary_expression
- primary_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
- unary_expression_4;
-unary_expression_1
- plus .and unary_expression .and .true .emit OP_PLUS;
-unary_expression_2
- dash .and unary_expression .and .true .emit OP_MINUS;
-unary_expression_3
- bang .and unary_expression .and .true .emit OP_NEGATE;
-unary_expression_4
- tilda .and unary_expression .and .true .emit OP_COMPLEMENT;
-
-primary_expression
- intconstant .or primary_expression_1;
-primary_expression_1
- lparen .and logical_or_expression .and rparen;
-
-intconstant
- integer .emit OP_PUSHINT;
-
-integer
- integer_dec;
-
-integer_dec
- digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-digit_dec
- '0'-'9';
-
-optional_space
- .loop single_space;
-
-space
- single_space .and .loop single_space;
-
-single_space
- ' ' .or '\t';
-
-ampersand
- optional_space .and '&' .and optional_space;
-
-ampersandampersand
- optional_space .and '&' .and '&' .and optional_space;
-
-bang
- optional_space .and '!' .and optional_space;
-
-bangequals
- optional_space .and '!' .and '=' .and optional_space;
-
-bar
- optional_space .and '|' .and optional_space;
-
-barbar
- optional_space .and '|' .and '|' .and optional_space;
-
-caret
- optional_space .and '^' .and optional_space;
-
-dash
- optional_space .and '-' .and optional_space;
-
-equalsequals
- optional_space .and '=' .and '=' .and optional_space;
-
-greater
- optional_space .and '>' .and optional_space;
-
-greaterequals
- optional_space .and '>' .and '=' .and optional_space;
-
-greatergreater
- optional_space .and '>' .and '>' .and optional_space;
-
-less
- optional_space .and '<' .and optional_space;
-
-lessequals
- optional_space .and '<' .and '=' .and optional_space;
-
-lessless
- optional_space .and '<' .and '<' .and optional_space;
-
-lparen
- optional_space .and '(' .and optional_space;
-
-percent
- optional_space .and '%' .and optional_space;
-
-plus
- optional_space .and '+' .and optional_space;
-
-rparen
- optional_space .and ')' .and optional_space;
-
-slash
- optional_space .and '/' .and optional_space;
-
-star
- optional_space .and '*' .and optional_space;
-
-tilda
- optional_space .and '~' .and optional_space;
-
diff --git a/src/mesa/shader/slang/library/slang_pp_expression_syn.h b/src/mesa/shader/slang/library/slang_pp_expression_syn.h
deleted file mode 100644
index f3e9ef6b22..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_expression_syn.h
+++ /dev/null
@@ -1,179 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax expression;\n"
-".emtcode EXP_END 0\n"
-".emtcode EXP_EXPRESSION 1\n"
-".emtcode OP_END 0\n"
-".emtcode OP_PUSHINT 1\n"
-".emtcode OP_LOGICALOR 2\n"
-".emtcode OP_LOGICALAND 3\n"
-".emtcode OP_OR 4\n"
-".emtcode OP_XOR 5\n"
-".emtcode OP_AND 6\n"
-".emtcode OP_EQUAL 7\n"
-".emtcode OP_NOTEQUAL 8\n"
-".emtcode OP_LESSEQUAL 9\n"
-".emtcode OP_GREATEREQUAL 10\n"
-".emtcode OP_LESS 11\n"
-".emtcode OP_GREATER 12\n"
-".emtcode OP_LEFTSHIFT 13\n"
-".emtcode OP_RIGHTSHIFT 14\n"
-".emtcode OP_ADD 15\n"
-".emtcode OP_SUBTRACT 16\n"
-".emtcode OP_MULTIPLY 17\n"
-".emtcode OP_DIVIDE 18\n"
-".emtcode OP_MODULUS 19\n"
-".emtcode OP_PLUS 20\n"
-".emtcode OP_MINUS 21\n"
-".emtcode OP_NEGATE 22\n"
-".emtcode OP_COMPLEMENT 23\n"
-"expression\n"
-" first_expression .and optional_second_expression .and optional_space .and '\\0' .emit EXP_END;\n"
-"first_expression\n"
-" optional_space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;\n"
-"optional_second_expression\n"
-" second_expression .or .true;\n"
-"second_expression\n"
-" space .and logical_or_expression .emit EXP_EXPRESSION .and .true .emit OP_END;\n"
-"logical_or_expression\n"
-" logical_and_expression .and .loop logical_or_expression_1;\n"
-"logical_or_expression_1\n"
-" barbar .and logical_and_expression .and .true .emit OP_LOGICALOR;\n"
-"logical_and_expression\n"
-" or_expression .and .loop logical_and_expression_1;\n"
-"logical_and_expression_1\n"
-" ampersandampersand .and or_expression .and .true .emit OP_LOGICALAND;\n"
-"or_expression\n"
-" xor_expression .and .loop or_expression_1;\n"
-"or_expression_1\n"
-" bar .and xor_expression .and .true .emit OP_OR;\n"
-"xor_expression\n"
-" and_expression .and .loop xor_expression_1;\n"
-"xor_expression_1\n"
-" caret .and and_expression .and .true .emit OP_XOR;\n"
-"and_expression\n"
-" equality_expression .and .loop and_expression_1;\n"
-"and_expression_1\n"
-" ampersand .and equality_expression .and .true .emit OP_AND;\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"
-"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"
-"shift_expression\n"
-" additive_expression .and .loop shift_expression_1;\n"
-"shift_expression_1\n"
-" shift_expression_2 .or shift_expression_3;\n"
-"shift_expression_2\n"
-" lessless .and additive_expression .and .true .emit OP_LEFTSHIFT;\n"
-"shift_expression_3\n"
-" greatergreater .and additive_expression .and .true .emit OP_RIGHTSHIFT;\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"
-" dash .and multiplicative_expression .and .true .emit OP_SUBTRACT;\n"
-"multiplicative_expression\n"
-" unary_expression .and .loop multiplicative_expression_1;\n"
-"multiplicative_expression_1\n"
-" multiplicative_expression_2 .or multiplicative_expression_3 .or multiplicative_expression_4;\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"
-"multiplicative_expression_4\n"
-" percent .and unary_expression .and .true .emit OP_MODULUS;\n"
-"unary_expression\n"
-" primary_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or\n"
-" unary_expression_4;\n"
-"unary_expression_1\n"
-" plus .and unary_expression .and .true .emit OP_PLUS;\n"
-"unary_expression_2\n"
-" dash .and unary_expression .and .true .emit OP_MINUS;\n"
-"unary_expression_3\n"
-" bang .and unary_expression .and .true .emit OP_NEGATE;\n"
-"unary_expression_4\n"
-" tilda .and unary_expression .and .true .emit OP_COMPLEMENT;\n"
-"primary_expression\n"
-" intconstant .or primary_expression_1;\n"
-"primary_expression_1\n"
-" lparen .and logical_or_expression .and rparen;\n"
-"intconstant\n"
-" integer .emit OP_PUSHINT;\n"
-"integer\n"
-" integer_dec;\n"
-"integer_dec\n"
-" digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"ampersand\n"
-" optional_space .and '&' .and optional_space;\n"
-"ampersandampersand\n"
-" optional_space .and '&' .and '&' .and optional_space;\n"
-"bang\n"
-" optional_space .and '!' .and optional_space;\n"
-"bangequals\n"
-" optional_space .and '!' .and '=' .and optional_space;\n"
-"bar\n"
-" optional_space .and '|' .and optional_space;\n"
-"barbar\n"
-" optional_space .and '|' .and '|' .and optional_space;\n"
-"caret\n"
-" optional_space .and '^' .and optional_space;\n"
-"dash\n"
-" optional_space .and '-' .and optional_space;\n"
-"equalsequals\n"
-" optional_space .and '=' .and '=' .and optional_space;\n"
-"greater\n"
-" optional_space .and '>' .and optional_space;\n"
-"greaterequals\n"
-" optional_space .and '>' .and '=' .and optional_space;\n"
-"greatergreater\n"
-" optional_space .and '>' .and '>' .and optional_space;\n"
-"less\n"
-" optional_space .and '<' .and optional_space;\n"
-"lessequals\n"
-" optional_space .and '<' .and '=' .and optional_space;\n"
-"lessless\n"
-" optional_space .and '<' .and '<' .and optional_space;\n"
-"lparen\n"
-" optional_space .and '(' .and optional_space;\n"
-"percent\n"
-" optional_space .and '%' .and optional_space;\n"
-"plus\n"
-" optional_space .and '+' .and optional_space;\n"
-"rparen\n"
-" optional_space .and ')' .and optional_space;\n"
-"slash\n"
-" optional_space .and '/' .and optional_space;\n"
-"star\n"
-" optional_space .and '*' .and optional_space;\n"
-"tilda\n"
-" optional_space .and '~' .and optional_space;\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_pp_version.syn b/src/mesa/shader/slang/library/slang_pp_version.syn
deleted file mode 100644
index 3fe1a57ba2..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_version.syn
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.6
- *
- * Copyright (C) 2005-2006 Brian Paul 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_pp_version.syn
- * slang #version directive syntax
- * \author Michal Krol
- */
-
-.syntax version_directive;
-
-version_directive
- version_directive_1;
-version_directive_1
- prior_optional_spaces .and optional_version_directive .and .true .emit $;
-
-optional_version_directive
- version_directive_body .or .true .emit 10 .emit 1;
-
-version_directive_body
- '#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
- new_line;
-
-version_number
- version_number_100 .or version_number_110 .or version_number_120;
-
-version_number_100
- leading_zeroes .and "100" .emit 0 .emit 1;
-
-version_number_110
- leading_zeroes .and "110" .emit 10 .emit 1;
-
-version_number_120
- leading_zeroes .and "120" .emit 20 .emit 1;
-
-leading_zeroes
- .loop zero;
-
-zero
- '0';
-
-space
- single_space .and .loop single_space;
-
-optional_space
- .loop single_space;
-
-single_space
- ' ' .or '\t';
-
-prior_optional_spaces
- .loop prior_space;
-
-prior_space
- c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
-
-c_style_comment_block
- '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
- .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
- c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
- '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
- '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
- '*' .and '/';
-
-cpp_style_comment_block
- '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
- cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
- .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
- .loop cpp_style_comment_char;
-
-cpp_style_comment_char
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line
- cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
- '\r' .and '\n';
-
-lf_cr
- '\n' .and '\r';
-
-.string __string_filter;
-
-__string_filter
- .loop __identifier_char;
-
-__identifier_char
- 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
-
diff --git a/src/mesa/shader/slang/library/slang_pp_version_syn.h b/src/mesa/shader/slang/library/slang_pp_version_syn.h
deleted file mode 100644
index 54aee3ff28..0000000000
--- a/src/mesa/shader/slang/library/slang_pp_version_syn.h
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
-
-".syntax version_directive;\n"
-"version_directive\n"
-" version_directive_1;\n"
-"version_directive_1\n"
-" prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
-"optional_version_directive\n"
-" version_directive_body .or .true .emit 10 .emit 1;\n"
-"version_directive_body\n"
-" '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
-" new_line;\n"
-"version_number\n"
-" version_number_100 .or version_number_110 .or version_number_120;\n"
-"version_number_100\n"
-" leading_zeroes .and \"100\" .emit 0 .emit 1;\n"
-"version_number_110\n"
-" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
-"version_number_120\n"
-" leading_zeroes .and \"120\" .emit 20 .emit 1;\n"
-"leading_zeroes\n"
-" .loop zero;\n"
-"zero\n"
-" '0';\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"single_space\n"
-" ' ' .or '\\t';\n"
-"prior_optional_spaces\n"
-" .loop prior_space;\n"
-"prior_space\n"
-" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest;\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
-"c_style_comment_rest_1\n"
-" c_style_comment_end .or c_style_comment_rest_2;\n"
-"c_style_comment_rest_2\n"
-" '*' .and c_style_comment_rest;\n"
-"c_style_comment_char_no_star\n"
-" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_end\n"
-" '*' .and '/';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
-"new_line\n"
-" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
-"cr_lf\n"
-" '\\r' .and '\\n';\n"
-"lf_cr\n"
-" '\\n' .and '\\r';\n"
-".string __string_filter;\n"
-"__string_filter\n"
-" .loop __identifier_char;\n"
-"__identifier_char\n"
-" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
-""
diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn
index cc5c70a02f..f6bf7f1e54 100644
--- a/src/mesa/shader/slang/library/slang_shader.syn
+++ b/src/mesa/shader/slang/library/slang_shader.syn
@@ -274,11 +274,11 @@
/* any syntax errors... */
.errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error."
.errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override."
-.errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found."
-.errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found."
-.errtext RPAREN_EXPECTED "2005: ')' expected but '$err_token$' found."
-.errtext INVALID_PRECISION "2006: Invalid precision specifier '$err_token$'."
-.errtext INVALID_PRECISION_TYPE "2007: Invalid precision type '$err_token$'."
+.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."
/*
@@ -692,11 +692,7 @@ function_header_with_parameters_1
* <function_header> ::= <fully_specified_type> <identifier> "("
*/
function_header
- function_header_nospace .or function_header_space;
-function_header_space
- fully_specified_type_space .and space .and function_decl_identifier .and lparen;
-function_header_nospace
- fully_specified_type_nospace .and function_decl_identifier .and lparen;
+ fully_specified_type .and function_decl_identifier .and lparen;
/*
* <function_decl_identifier> ::= "__constructor"
@@ -793,11 +789,7 @@ overriden_operator
* | <type_specifier> <identifier> "[" <constant_expression> "]"
*/
parameter_declarator
- parameter_declarator_nospace .or parameter_declarator_space;
-parameter_declarator_nospace
- type_specifier_nospace .and identifier .and parameter_declarator_1;
-parameter_declarator_space
- type_specifier_space .and space .and identifier .and parameter_declarator_1;
+ 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;
@@ -825,15 +817,13 @@ parameter_declaration
parameter_declaration_1
parameter_declaration_2 .or parameter_declaration_3;
parameter_declaration_2
- type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
+ 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
- parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;
-parameter_declaration_prec
- precision .and space;
+ precision .or .true .emit PRECISION_DEFAULT;
parameter_declaration_rest
parameter_declarator .or parameter_type_specifier;
@@ -846,8 +836,6 @@ parameter_declaration_rest
parameter_qualifier
parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
parameter_qualifier_1
- parameter_qualifier_2 .and space;
-parameter_qualifier_2
"in" .emit PARAM_QUALIFIER_IN .or
"out" .emit PARAM_QUALIFIER_OUT .or
"inout" .emit PARAM_QUALIFIER_INOUT;
@@ -857,9 +845,7 @@ parameter_qualifier_2
* | <type_specifier> "[" <constant_expression> "]"
*/
parameter_type_specifier
- parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
-parameter_type_specifier_1
- type_specifier_nospace .or type_specifier_space;
+ 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;
@@ -895,18 +881,10 @@ init_declarator_list_5
* | <fully_specified_type> <identifier> "=" <initializer>
*/
single_declaration
- single_declaration_nospace .or single_declaration_space;
-single_declaration_space
- fully_specified_type_space .and single_declaration_space_1;
-single_declaration_nospace
- fully_specified_type_nospace .and single_declaration_nospace_1;
-single_declaration_space_1
- single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
-single_declaration_nospace_1
- single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
-single_declaration_space_2
- space .and identifier .and single_declaration_3;
-single_declaration_nospace_2
+ 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;
@@ -922,26 +900,16 @@ single_declaration_6
*
* Example: "invariant varying highp vec3"
*/
-fully_specified_type_space
- fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
-fully_specified_type_nospace
- fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
+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
- fully_specified_type_invariant .or .true .emit TYPE_VARIANT;
-fully_specified_type_invariant
- invariant_qualifier .and space;
+ invariant_qualifier .or .true .emit TYPE_VARIANT;
fully_specified_type_optcentroid
- fully_specified_type_centroid .or .true .emit TYPE_CENTER;
-fully_specified_type_centroid
- centroid_qualifier .and space;
+ centroid_qualifier .or .true .emit TYPE_CENTER;
fully_specified_type_optqual
- fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
-fully_specified_type_qual
- type_qualifier .and space;
+ type_qualifier .or .true .emit TYPE_QUALIFIER_NONE;
fully_specified_type_optprec
- fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
-fully_specified_type_prec
- precision .and space;
+ precision .or .true .emit PRECISION_DEFAULT;
/*
* <invariant_qualifier> ::= "invariant"
@@ -1006,7 +974,8 @@ type_qualifier
* | <struct_specifier>
* | <type_name>
*/
-type_specifier_nonarray_space
+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
@@ -1038,22 +1007,16 @@ type_specifier_nonarray_space
"sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
"sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
type_name .emit TYPE_SPECIFIER_TYPENAME;
-type_specifier_nonarray_nospace
- struct_specifier .emit TYPE_SPECIFIER_STRUCT;
-type_specifier_nonarray
- type_specifier_nonarray_nospace .or type_specifier_nonarray_space;
/*
* <type_specifier> ::= <type_specifier_nonarray>
* | <type_specifier_nonarray> "[" <constant_expression> "]"
*/
-type_specifier_space
- type_specifier_nonarray_space .and .true .emit TYPE_SPECIFIER_NONARRAY;
-type_specifier_nospace
- type_specifier_nospace_array .or type_specifier_nospace_1;
-type_specifier_nospace_1
- type_specifier_nonarray_nospace .and .true .emit TYPE_SPECIFIER_NONARRAY;
-type_specifier_nospace_array
+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;
/*
@@ -1061,12 +1024,10 @@ type_specifier_nospace_array
* | "struct" "{" <struct_declaration_list> "}"
*/
struct_specifier
- "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
+ "struct" .and struct_specifier_1 .and lbrace .error LBRACE_EXPECTED .and
struct_declaration_list .and rbrace .emit FIELD_NONE;
struct_specifier_1
- struct_specifier_2 .or .true .emit '\0';
-struct_specifier_2
- space .and identifier;
+ identifier .or .true .emit '\0';
/*
* <struct_declaration_list> ::= <struct_declaration>
@@ -1079,11 +1040,7 @@ struct_declaration_list
* <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
*/
struct_declaration
- struct_declaration_nospace .or struct_declaration_space;
-struct_declaration_space
- type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
-struct_declaration_nospace
- type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
+ type_specifier .and struct_declarator_list .and semicolon .emit FIELD_NONE;
/*
* <struct_declarator_list> ::= <struct_declarator>
@@ -1123,10 +1080,6 @@ declaration_statement
*/
statement
compound_statement .or simple_statement;
-statement_space
- compound_statement .or statement_space_1;
-statement_space_1
- space .and simple_statement;
/*
* <simple_statement> ::= <__asm_statement>
@@ -1209,7 +1162,7 @@ selection_rest_statement
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 optional_space .and statement;
+ "else" .and statement;
/*
* <condition> ::= <expression>
@@ -1220,17 +1173,11 @@ selection_rest_statement_2
*/
condition
condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
- condition_3 .emit OP_EXPRESSION;
+ condition_2 .emit OP_EXPRESSION;
condition_1
- condition_1_nospace .or condition_1_space;
-condition_1_nospace
- fully_specified_type_nospace .and condition_2;
-condition_1_space
- fully_specified_type_space .and space .and condition_2;
+ fully_specified_type .and identifier .emit VARIABLE_IDENTIFIER .and
+ equals .emit VARIABLE_INITIALIZER .and initializer .and .true .emit DECLARATOR_NONE;
condition_2
- identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
- initializer .and .true .emit DECLARATOR_NONE;
-condition_3
expression .and .true .emit OP_END;
/*
@@ -1244,7 +1191,7 @@ 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_space .and "while" .and lparen .error LPAREN_EXPECTED .and
+ "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
@@ -1295,7 +1242,7 @@ jump_statement_1
jump_statement_2
"break" .and semicolon .emit OP_BREAK;
jump_statement_3
- "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
+ "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
@@ -1308,7 +1255,7 @@ jump_statement_5
* normally slang disallows __asm statements
*/
__asm_statement
- "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
+ "__asm" .and identifier .and asm_arguments .and semicolon .emit OP_END;
/*
* <asm_arguments> ::= <asm_argument>
@@ -1343,9 +1290,8 @@ var_with_field
* | <translation_unit> <external_declaration>
*/
translation_unit
- optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
- .loop external_declaration .and optional_space .and
- '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
+ .true .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
+ .loop external_declaration .and "@EOF" .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
/*
@@ -1363,7 +1309,7 @@ external_declaration
* <precision_stmt> ::= "precision" <precision> <prectype>
*/
precision_stmt
- "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
+ "precision" .and precision .error INVALID_PRECISION .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
/*
* <precision> ::= "lowp"
@@ -1397,7 +1343,7 @@ prectype
* <invariant_stmt> ::= "invariant" identifier;
*/
invariant_stmt
- "invariant" .and space .and identifier .and semicolon;
+ "invariant" .and identifier .and semicolon;
/*
@@ -1412,83 +1358,18 @@ function_definition
* helper rules, not part of the official language syntax
*/
-digit_oct
- '0'-'7';
-
-digit_dec
- '0'-'9';
-
-digit_hex
- '0'-'9' .or 'A'-'F' .or 'a'-'f';
-
-id_character_first
- 'a'-'z' .or 'A'-'Z' .or '_';
-
-id_character_next
- id_character_first .or digit_dec;
-
identifier
- id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
+ "@ID" .emit *;
float
- float_1 .or float_2 .or float_3;
-float_1
- float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;
-float_2
- float_digit_sequence .and .true .emit '\0' .and float_exponent_part .and optional_f_suffix;
-float_3
- float_digit_sequence .and .true .emit '\0' .and 'f' .emit '\0';
-
-float_fractional_constant
- float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
-float_fractional_constant_1
- float_digit_sequence .and '.' .and float_digit_sequence;
-float_fractional_constant_2
- float_digit_sequence .and '.' .and .true .emit '\0';
-float_fractional_constant_3
- '.' .emit '\0' .and float_digit_sequence;
-
-float_optional_exponent_part
- float_exponent_part .or .true .emit '\0';
-
-float_digit_sequence
- digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
-
-float_exponent_part
- float_exponent_part_1 .or float_exponent_part_2;
-float_exponent_part_1
- 'e' .and float_optional_sign .and float_digit_sequence;
-float_exponent_part_2
- 'E' .and float_optional_sign .and float_digit_sequence;
-
-float_optional_sign
- float_sign .or .true;
-
-float_sign
- '+' .or '-' .emit '-';
-
-optional_f_suffix
- 'f' .or .true;
-
+ "@NUM" .emit 1 .emit *;
integer
- integer_hex .or integer_oct .or integer_dec;
-
-integer_hex
- '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
- .true .emit '\0';
-integer_hex_1
- 'x' .or 'X';
-
-integer_oct
- '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
-
-integer_dec
- digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
+ "@NUM" .emit 1 .emit *;
boolean
- "true" .emit 2 .emit '1' .emit '\0' .or
- "false" .emit 2 .emit '0' .emit '\0';
+ "true" .emit '1' .emit '\0' .or
+ "false" .emit '0' .emit '\0';
type_name
identifier;
@@ -1505,62 +1386,13 @@ intconstant
boolconstant
boolean .emit OP_PUSH_BOOL;
-optional_space
- .loop single_space;
-
-space
- single_space .and .loop single_space;
-
-single_space
- white_char .or c_style_comment_block .or cpp_style_comment_block;
-
-white_char
- ' ' .or '\t' .or new_line .or '\v' .or '\f';
-
-new_line
- cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
- '\r' .and '\n';
-
-lf_cr
- '\n' .and '\r';
-
-c_style_comment_block
- '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
- .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
- c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
- '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
- '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
- '*' .and '/';
-
-cpp_style_comment_block
- '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
- cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
- .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
- .loop cpp_style_comment_char;
-
-cpp_style_comment_char
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
/* lexical rules */
/*ampersand
optional_space .and '&' .and optional_space;*/
ampersandampersand
- optional_space .and '&' .and '&' .and optional_space;
+ "@&&";
/*ampersandequals
optional_space .and '&' .and '=' .and optional_space;*/
@@ -1569,46 +1401,46 @@ ampersandampersand
optional_space .and '|' .and optional_space;*/
barbar
- optional_space .and '|' .and '|' .and optional_space;
+ "@||";
/*barequals
optional_space .and '|' .and '=' .and optional_space;*/
bang
- optional_space .and '!' .and optional_space;
+ "@!";
bangequals
- optional_space .and '!' .and '=' .and optional_space;
+ "@!=";
/*caret
optional_space .and '^' .and optional_space;*/
caretcaret
- optional_space .and '^' .and '^' .and optional_space;
+ "@^^";
/*caretequals
optional_space .and '^' .and '=' .and optional_space;*/
colon
- optional_space .and ':' .and optional_space;
+ "@:";
comma
- optional_space .and ',' .and optional_space;
+ "@,";
dot
- optional_space .and '.' .and optional_space;
+ "@.";
equals
- optional_space .and '=' .and optional_space;
+ "@=";
equalsequals
- optional_space .and '=' .and '=' .and optional_space;
+ "@==";
greater
- optional_space .and '>' .and optional_space;
+ "@>";
greaterequals
- optional_space .and '>' .and '=' .and optional_space;
+ "@>=";
/*greatergreater
optional_space .and '>' .and '>' .and optional_space;*/
@@ -1617,16 +1449,16 @@ greaterequals
optional_space .and '>' .and '>' .and '=' .and optional_space;*/
lbrace
- optional_space .and '{' .and optional_space;
+ "@{";
lbracket
- optional_space .and '[' .and optional_space;
+ "@[";
less
- optional_space .and '<' .and optional_space;
+ "@<";
lessequals
- optional_space .and '<' .and '=' .and optional_space;
+ "@<=";
/*lessless
optional_space .and '<' .and '<' .and optional_space;*/
@@ -1635,16 +1467,16 @@ lessequals
optional_space .and '<' .and '<' .and '=' .and optional_space;*/
lparen
- optional_space .and '(' .and optional_space;
+ "@(";
minus
- optional_space .and '-' .and optional_space;
+ "@-";
minusequals
- optional_space .and '-' .and '=' .and optional_space;
+ "@-=";
minusminus
- optional_space .and '-' .and '-' .and optional_space;
+ "@--";
/*percent
optional_space .and '%' .and optional_space;*/
@@ -1653,64 +1485,41 @@ minusminus
optional_space .and '%' .and '=' .and optional_space;*/
plus
- optional_space .and '+' .and optional_space;
+ "@+";
plusequals
- optional_space .and '+' .and '=' .and optional_space;
+ "@+=";
plusplus
- optional_space .and '+' .and '+' .and optional_space;
+ "@++";
question
- optional_space .and '?' .and optional_space;
+ "@?";
rbrace
- optional_space .and '}' .and optional_space;
+ "@}";
rbracket
- optional_space .and ']' .and optional_space;
+ "@]";
rparen
- optional_space .and ')' .and optional_space;
+ "@)";
semicolon
- optional_space .and ';' .and optional_space;
+ "@;";
slash
- optional_space .and '/' .and optional_space;
+ "@/";
slashequals
- optional_space .and '/' .and '=' .and optional_space;
+ "@/=";
star
- optional_space .and '*' .and optional_space;
+ "@*";
starequals
- optional_space .and '*' .and '=' .and optional_space;
+ "@*=";
/*tilde
optional_space .and '~' .and optional_space;*/
-/* string rules - these are used internally by the parser when parsing quoted strings */
-
-.string string_lexer;
-
-string_lexer
- lex_first_identifier_character .and .loop lex_next_identifier_character;
-
-lex_first_identifier_character
- 'a'-'z' .or 'A'-'Z' .or '_';
-
-lex_next_identifier_character
- 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
-
-/* error rules - these are used by error messages */
-
-err_token
- '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
- '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
- '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
-
-err_identifier
- id_character_first .and .loop id_character_next;
-
diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h
index 6a382970e1..9a56643d2f 100644
--- a/src/mesa/shader/slang/library/slang_shader_syn.h
+++ b/src/mesa/shader/slang/library/slang_shader_syn.h
@@ -150,11 +150,11 @@
".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 '$err_token$' found.\"\n"
-".errtext LPAREN_EXPECTED \"2004: '(' expected but '$err_token$' found.\"\n"
-".errtext RPAREN_EXPECTED \"2005: ')' expected but '$err_token$' found.\"\n"
-".errtext INVALID_PRECISION \"2006: Invalid precision specifier '$err_token$'.\"\n"
-".errtext INVALID_PRECISION_TYPE \"2007: Invalid precision type '$err_token$'.\"\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"
@@ -321,11 +321,7 @@
"function_header_with_parameters_1\n"
" comma .and parameter_declaration;\n"
"function_header\n"
-" function_header_nospace .or function_header_space;\n"
-"function_header_space\n"
-" fully_specified_type_space .and space .and function_decl_identifier .and lparen;\n"
-"function_header_nospace\n"
-" fully_specified_type_nospace .and function_decl_identifier .and lparen;\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"
@@ -362,11 +358,7 @@
" \n"
" caretcaret .emit OPERATOR_LOGICALXOR ;\n"
"parameter_declarator\n"
-" parameter_declarator_nospace .or parameter_declarator_space;\n"
-"parameter_declarator_nospace\n"
-" type_specifier_nospace .and identifier .and parameter_declarator_1;\n"
-"parameter_declarator_space\n"
-" type_specifier_space .and space .and identifier .and parameter_declarator_1;\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"
@@ -377,29 +369,23 @@
"parameter_declaration_1\n"
" parameter_declaration_2 .or parameter_declaration_3;\n"
"parameter_declaration_2\n"
-" type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;\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"
-" parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;\n"
-"parameter_declaration_prec\n"
-" precision .and space;\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"
-" parameter_qualifier_2 .and space;\n"
-"parameter_qualifier_2\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"
-" parameter_type_specifier_1 .and .true .emit '\\0' .and parameter_type_specifier_2;\n"
-"parameter_type_specifier_1\n"
-" type_specifier_nospace .or type_specifier_space;\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"
@@ -419,18 +405,10 @@
"init_declarator_list_5\n"
" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
"single_declaration\n"
-" single_declaration_nospace .or single_declaration_space;\n"
-"single_declaration_space\n"
-" fully_specified_type_space .and single_declaration_space_1;\n"
-"single_declaration_nospace\n"
-" fully_specified_type_nospace .and single_declaration_nospace_1;\n"
-"single_declaration_space_1\n"
-" single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
-"single_declaration_nospace_1\n"
-" single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
-"single_declaration_space_2\n"
-" space .and identifier .and single_declaration_3;\n"
-"single_declaration_nospace_2\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"
@@ -440,26 +418,16 @@
" 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_space\n"
-" fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;\n"
-"fully_specified_type_nospace\n"
-" fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;\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"
-" fully_specified_type_invariant .or .true .emit TYPE_VARIANT;\n"
-"fully_specified_type_invariant\n"
-" invariant_qualifier .and space;\n"
+" invariant_qualifier .or .true .emit TYPE_VARIANT;\n"
"fully_specified_type_optcentroid\n"
-" fully_specified_type_centroid .or .true .emit TYPE_CENTER;\n"
-"fully_specified_type_centroid\n"
-" centroid_qualifier .and space;\n"
+" centroid_qualifier .or .true .emit TYPE_CENTER;\n"
"fully_specified_type_optqual\n"
-" fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;\n"
-"fully_specified_type_qual\n"
-" type_qualifier .and space;\n"
+" type_qualifier .or .true .emit TYPE_QUALIFIER_NONE;\n"
"fully_specified_type_optprec\n"
-" fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;\n"
-"fully_specified_type_prec\n"
-" precision .and space;\n"
+" precision .or .true .emit PRECISION_DEFAULT;\n"
"invariant_qualifier\n"
" \"invariant\" .emit TYPE_INVARIANT;\n"
"centroid_qualifier\n"
@@ -471,7 +439,8 @@
" \"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_space\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"
@@ -503,33 +472,21 @@
" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n"
" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or\n"
" type_name .emit TYPE_SPECIFIER_TYPENAME;\n"
-"type_specifier_nonarray_nospace\n"
-" struct_specifier .emit TYPE_SPECIFIER_STRUCT;\n"
-"type_specifier_nonarray\n"
-" type_specifier_nonarray_nospace .or type_specifier_nonarray_space;\n"
-"type_specifier_space\n"
-" type_specifier_nonarray_space .and .true .emit TYPE_SPECIFIER_NONARRAY;\n"
-"type_specifier_nospace\n"
-" type_specifier_nospace_array .or type_specifier_nospace_1;\n"
-"type_specifier_nospace_1\n"
-" type_specifier_nonarray_nospace .and .true .emit TYPE_SPECIFIER_NONARRAY;\n"
-"type_specifier_nospace_array\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 optional_space .and lbrace .error LBRACE_EXPECTED .and\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"
-" struct_specifier_2 .or .true .emit '\\0';\n"
-"struct_specifier_2\n"
-" space .and identifier;\n"
+" identifier .or .true .emit '\\0';\n"
"struct_declaration_list\n"
" struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;\n"
"struct_declaration\n"
-" struct_declaration_nospace .or struct_declaration_space;\n"
-"struct_declaration_space\n"
-" type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n"
-"struct_declaration_nospace\n"
-" type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;\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"
@@ -546,10 +503,6 @@
" declaration;\n"
"statement\n"
" compound_statement .or simple_statement;\n"
-"statement_space\n"
-" compound_statement .or statement_space_1;\n"
-"statement_space_1\n"
-" space .and simple_statement;\n"
"simple_statement\n"
" .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or\n"
" selection_statement .or\n"
@@ -590,20 +543,14 @@
"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 optional_space .and statement;\n"
+" \"else\" .and statement;\n"
"condition\n"
" condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or\n"
-" condition_3 .emit OP_EXPRESSION;\n"
+" condition_2 .emit OP_EXPRESSION;\n"
"condition_1\n"
-" condition_1_nospace .or condition_1_space;\n"
-"condition_1_nospace\n"
-" fully_specified_type_nospace .and condition_2;\n"
-"condition_1_space\n"
-" fully_specified_type_space .and space .and condition_2;\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"
-" identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and\n"
-" initializer .and .true .emit DECLARATOR_NONE;\n"
-"condition_3\n"
" expression .and .true .emit OP_END;\n"
"iteration_statement\n"
" iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;\n"
@@ -611,7 +558,7 @@
" \"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_space .and \"while\" .and lparen .error LPAREN_EXPECTED .and\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"
@@ -635,13 +582,13 @@
"jump_statement_2\n"
" \"break\" .and semicolon .emit OP_BREAK;\n"
"jump_statement_3\n"
-" \"return\" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;\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 space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\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"
@@ -653,16 +600,15 @@
"var_with_field\n"
" variable_identifier .and dot .and field_selection .emit OP_FIELD;\n"
"translation_unit\n"
-" optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n"
-" .loop external_declaration .and optional_space .and\n"
-" '\\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;\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 space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;\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"
@@ -679,67 +625,18 @@
" \"sampler2DRect\" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or\n"
" \"sampler2DRectShadow\" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;\n"
"invariant_stmt\n"
-" \"invariant\" .and space .and identifier .and semicolon;\n"
+" \"invariant\" .and identifier .and semicolon;\n"
"function_definition\n"
" function_prototype .and compound_statement_no_new_scope;\n"
-"digit_oct\n"
-" '0'-'7';\n"
-"digit_dec\n"
-" '0'-'9';\n"
-"digit_hex\n"
-" '0'-'9' .or 'A'-'F' .or 'a'-'f';\n"
-"id_character_first\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"id_character_next\n"
-" id_character_first .or digit_dec;\n"
"identifier\n"
-" id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\\0';\n"
+" \"@ID\" .emit *;\n"
"float\n"
-" float_1 .or float_2 .or float_3;\n"
-"float_1\n"
-" float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;\n"
-"float_2\n"
-" float_digit_sequence .and .true .emit '\\0' .and float_exponent_part .and optional_f_suffix;\n"
-"float_3\n"
-" float_digit_sequence .and .true .emit '\\0' .and 'f' .emit '\\0';\n"
-"float_fractional_constant\n"
-" float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;\n"
-"float_fractional_constant_1\n"
-" float_digit_sequence .and '.' .and float_digit_sequence;\n"
-"float_fractional_constant_2\n"
-" float_digit_sequence .and '.' .and .true .emit '\\0';\n"
-"float_fractional_constant_3\n"
-" '.' .emit '\\0' .and float_digit_sequence;\n"
-"float_optional_exponent_part\n"
-" float_exponent_part .or .true .emit '\\0';\n"
-"float_digit_sequence\n"
-" digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
-"float_exponent_part\n"
-" float_exponent_part_1 .or float_exponent_part_2;\n"
-"float_exponent_part_1\n"
-" 'e' .and float_optional_sign .and float_digit_sequence;\n"
-"float_exponent_part_2\n"
-" 'E' .and float_optional_sign .and float_digit_sequence;\n"
-"float_optional_sign\n"
-" float_sign .or .true;\n"
-"float_sign\n"
-" '+' .or '-' .emit '-';\n"
-"optional_f_suffix\n"
-" 'f' .or .true;\n"
+" \"@NUM\" .emit 1 .emit *;\n"
"integer\n"
-" integer_hex .or integer_oct .or integer_dec;\n"
-"integer_hex\n"
-" '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and\n"
-" .true .emit '\\0';\n"
-"integer_hex_1\n"
-" 'x' .or 'X';\n"
-"integer_oct\n"
-" '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\\0';\n"
-"integer_dec\n"
-" digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
+" \"@NUM\" .emit 1 .emit *;\n"
"boolean\n"
-" \"true\" .emit 2 .emit '1' .emit '\\0' .or\n"
-" \"false\" .emit 2 .emit '0' .emit '\\0';\n"
+" \"true\" .emit '1' .emit '\\0' .or\n"
+" \"false\" .emit '0' .emit '\\0';\n"
"type_name\n"
" identifier;\n"
"field_selection\n"
@@ -750,117 +647,68 @@
" integer .emit OP_PUSH_INT;\n"
"boolconstant\n"
" boolean .emit OP_PUSH_BOOL;\n"
-"optional_space\n"
-" .loop single_space;\n"
-"space\n"
-" single_space .and .loop single_space;\n"
-"single_space\n"
-" white_char .or c_style_comment_block .or cpp_style_comment_block;\n"
-"white_char\n"
-" ' ' .or '\\t' .or new_line .or '\\v' .or '\\f';\n"
-"new_line\n"
-" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
-"cr_lf\n"
-" '\\r' .and '\\n';\n"
-"lf_cr\n"
-" '\\n' .and '\\r';\n"
-"c_style_comment_block\n"
-" '/' .and '*' .and c_style_comment_rest;\n"
-"c_style_comment_rest\n"
-" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
-"c_style_comment_rest_1\n"
-" c_style_comment_end .or c_style_comment_rest_2;\n"
-"c_style_comment_rest_2\n"
-" '*' .and c_style_comment_rest;\n"
-"c_style_comment_char_no_star\n"
-" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
-"c_style_comment_end\n"
-" '*' .and '/';\n"
-"cpp_style_comment_block\n"
-" '/' .and '/' .and cpp_style_comment_block_1;\n"
-"cpp_style_comment_block_1\n"
-" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
-"cpp_style_comment_block_2\n"
-" .loop cpp_style_comment_char .and new_line;\n"
-"cpp_style_comment_block_3\n"
-" .loop cpp_style_comment_char;\n"
-"cpp_style_comment_char\n"
-" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
"ampersandampersand\n"
-" optional_space .and '&' .and '&' .and optional_space;\n"
+" \"@&&\";\n"
"barbar\n"
-" optional_space .and '|' .and '|' .and optional_space;\n"
+" \"@||\";\n"
"bang\n"
-" optional_space .and '!' .and optional_space;\n"
+" \"@!\";\n"
"bangequals\n"
-" optional_space .and '!' .and '=' .and optional_space;\n"
+" \"@!=\";\n"
"caretcaret\n"
-" optional_space .and '^' .and '^' .and optional_space;\n"
+" \"@^^\";\n"
"colon\n"
-" optional_space .and ':' .and optional_space;\n"
+" \"@:\";\n"
"comma\n"
-" optional_space .and ',' .and optional_space;\n"
+" \"@,\";\n"
"dot\n"
-" optional_space .and '.' .and optional_space;\n"
+" \"@.\";\n"
"equals\n"
-" optional_space .and '=' .and optional_space;\n"
+" \"@=\";\n"
"equalsequals\n"
-" optional_space .and '=' .and '=' .and optional_space;\n"
+" \"@==\";\n"
"greater\n"
-" optional_space .and '>' .and optional_space;\n"
+" \"@>\";\n"
"greaterequals\n"
-" optional_space .and '>' .and '=' .and optional_space;\n"
+" \"@>=\";\n"
"lbrace\n"
-" optional_space .and '{' .and optional_space;\n"
+" \"@{\";\n"
"lbracket\n"
-" optional_space .and '[' .and optional_space;\n"
+" \"@[\";\n"
"less\n"
-" optional_space .and '<' .and optional_space;\n"
+" \"@<\";\n"
"lessequals\n"
-" optional_space .and '<' .and '=' .and optional_space;\n"
+" \"@<=\";\n"
"lparen\n"
-" optional_space .and '(' .and optional_space;\n"
+" \"@(\";\n"
"minus\n"
-" optional_space .and '-' .and optional_space;\n"
+" \"@-\";\n"
"minusequals\n"
-" optional_space .and '-' .and '=' .and optional_space;\n"
+" \"@-=\";\n"
"minusminus\n"
-" optional_space .and '-' .and '-' .and optional_space;\n"
+" \"@--\";\n"
"plus\n"
-" optional_space .and '+' .and optional_space;\n"
+" \"@+\";\n"
"plusequals\n"
-" optional_space .and '+' .and '=' .and optional_space;\n"
+" \"@+=\";\n"
"plusplus\n"
-" optional_space .and '+' .and '+' .and optional_space;\n"
+" \"@++\";\n"
"question\n"
-" optional_space .and '?' .and optional_space;\n"
+" \"@?\";\n"
"rbrace\n"
-" optional_space .and '}' .and optional_space;\n"
+" \"@}\";\n"
"rbracket\n"
-" optional_space .and ']' .and optional_space;\n"
+" \"@]\";\n"
"rparen\n"
-" optional_space .and ')' .and optional_space;\n"
+" \"@)\";\n"
"semicolon\n"
-" optional_space .and ';' .and optional_space;\n"
+" \"@;\";\n"
"slash\n"
-" optional_space .and '/' .and optional_space;\n"
+" \"@/\";\n"
"slashequals\n"
-" optional_space .and '/' .and '=' .and optional_space;\n"
+" \"@/=\";\n"
"star\n"
-" optional_space .and '*' .and optional_space;\n"
+" \"@*\";\n"
"starequals\n"
-" optional_space .and '*' .and '=' .and optional_space;\n"
-".string string_lexer;\n"
-"string_lexer\n"
-" lex_first_identifier_character .and .loop lex_next_identifier_character;\n"
-"lex_first_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '_';\n"
-"lex_next_identifier_character\n"
-" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
-"err_token\n"
-" '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or\n"
-" '-' .or '+' .or '=' .or '|' .or '\\\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '\"' .or\n"
-" '\\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;\n"
-"err_identifier\n"
-" id_character_first .and .loop id_character_next;\n"
+" \"@*=\";\n"
""
diff --git a/src/mesa/shader/slang/library/slang_version.syn b/src/mesa/shader/slang/library/slang_version.syn
deleted file mode 100644
index aaf8bef342..0000000000
--- a/src/mesa/shader/slang/library/slang_version.syn
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 2005 Brian Paul 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_version.syn
- * slang #version directive syntax
- * \author Michal Krol
- */
-
-.syntax version_directive;
-
-version_directive
- version_directive_1 .and .loop version_directive_2;
-version_directive_1
- prior_optional_spaces .and optional_version_directive .and .true .emit $;
-version_directive_2
- prior_optional_spaces .and version_directive_body .and .true .emit $;
-
-optional_version_directive
- version_directive_body .or .true .emit 10 .emit 1;
-
-version_directive_body
- '#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
- new_line;
-
-version_number
- version_number_110;
-
-version_number_110
- leading_zeroes .and "110" .emit 10 .emit 1;
-
-leading_zeroes
- .loop zero;
-
-zero
- '0';
-
-space
- single_space .and .loop single_space;
-
-optional_space
- .loop single_space;
-
-single_space
- ' ' .or '\t';
-
-prior_optional_spaces
- .loop prior_space;
-
-prior_space
- c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
-
-c_style_comment_block
- '/' .and '*' .and c_style_comment_rest;
-
-c_style_comment_rest
- .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
-c_style_comment_rest_1
- c_style_comment_end .or c_style_comment_rest_2;
-c_style_comment_rest_2
- '*' .and c_style_comment_rest;
-
-c_style_comment_char_no_star
- '\x2B'-'\xFF' .or '\x01'-'\x29';
-
-c_style_comment_end
- '*' .and '/';
-
-cpp_style_comment_block
- '/' .and '/' .and cpp_style_comment_block_1;
-cpp_style_comment_block_1
- cpp_style_comment_block_2 .or cpp_style_comment_block_3;
-cpp_style_comment_block_2
- .loop cpp_style_comment_char .and new_line;
-cpp_style_comment_block_3
- .loop cpp_style_comment_char;
-
-cpp_style_comment_char
- '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
-
-new_line
- cr_lf .or lf_cr .or '\n' .or '\r';
-
-cr_lf
- '\r' .and '\n';
-
-lf_cr
- '\n' .and '\r';
-
-.string __string_filter;
-
-__string_filter
- .loop __identifier_char;
-
-__identifier_char
- 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
-
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index c1b97c7cb7..75dd8a045b 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"
@@ -184,22 +183,102 @@ parse_identifier(slang_parse_ctx * C)
}
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;
@@ -208,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;
}
@@ -2496,8 +2580,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 +2592,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 +2601,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 +2623,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,
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
deleted file mode 100644
index e9a24cc009..0000000000
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ /dev/null
@@ -1,1406 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 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_preprocess.c
- * slang preprocessor
- * \author Michal Krol
- */
-
-#include "main/imports.h"
-#include "shader/grammar/grammar_mesa.h"
-#include "slang_preprocess.h"
-
-LONGSTRING static const char *slang_pp_directives_syn =
-#include "library/slang_pp_directives_syn.h"
-;
-
-LONGSTRING static const char *slang_pp_expression_syn =
-#include "library/slang_pp_expression_syn.h"
-;
-
-LONGSTRING static const char *slang_pp_version_syn =
-#include "library/slang_pp_version_syn.h"
-;
-
-static GLvoid
-grammar_error_to_log (slang_info_log *log)
-{
- char buf[1024];
- GLint pos;
-
- grammar_get_last_error ((byte *) (buf), sizeof (buf), &pos);
- if (buf[0] == 0) {
- _mesa_snprintf(buf, sizeof(buf), "Preprocessor error");
- }
- slang_info_log_error (log, buf);
-}
-
-GLboolean
-_slang_preprocess_version (const char *text, GLuint *version, GLuint *eaten, slang_info_log *log)
-{
- grammar id;
- byte *prod, *I;
- unsigned int size;
-
- id = grammar_load_from_text ((const byte *) (slang_pp_version_syn));
- if (id == 0) {
- grammar_error_to_log (log);
- return GL_FALSE;
- }
-
- if (!grammar_fast_check (id, (const byte *) (text), &prod, &size, 8)) {
- grammar_error_to_log (log);
- grammar_destroy (id);
- return GL_FALSE;
- }
-
- /* there can be multiple #version directives - grab the last one */
- I = &prod[size - 6];
- *version = (GLuint) (I[0]) + (GLuint) (I[1]) * 100;
- *eaten = (GLuint) (I[2]) + ((GLuint) (I[3]) << 8) + ((GLuint) (I[4]) << 16) + ((GLuint) (I[5]) << 24);
-
- grammar_destroy (id);
- grammar_alloc_free (prod);
- return GL_TRUE;
-}
-
-/*
- * The preprocessor does the following work.
- * 1. Remove comments. Each comment block is replaced with a single space and if the
- * block contains new-lines, they are preserved. This ensures that line numbers
- * stay the same and if a comment block delimits two tokens, the are delitmited
- * by the space after comment removal.
- * 2. Remove preprocessor directives from the source string, checking their syntax and
- * executing them if appropriate. Again, new-lines are preserved.
- * 3. Expand macros.
- * 4. Tokenize the source string by ensuring there is at least one space between every
- * two adjacent tokens.
- */
-
-#define PP_ANNOTATE 0
-
-static GLvoid
-pp_annotate (slang_string *output, const char *fmt, ...)
-{
-#if PP_ANNOTATE
- va_list va;
- char buffer[1024];
-
- va_start (va, fmt);
- _mesa_vsprintf (buffer, fmt, va);
- va_end (va);
- slang_string_pushs (output, buffer, _mesa_strlen (buffer));
-#else
- (GLvoid) (output);
- (GLvoid) (fmt);
-#endif
-}
-
- /*
- * The expression is executed on a fixed-sized stack. The PUSH macro makes a runtime
- * check if the stack is not overflown by too complex expressions. In that situation the
- * GLSL preprocessor should report internal compiler error.
- * The BINARYDIV makes a runtime check if the divider is not 0. If it is, it reports
- * compilation error.
- */
-
-#define EXECUTION_STACK_SIZE 1024
-
-#define PUSH(x)\
- do {\
- if (sp == 0) {\
- slang_info_log_error (elog, "internal compiler error: preprocessor execution stack overflow.");\
- return GL_FALSE;\
- }\
- stack[--sp] = x;\
- } while (GL_FALSE)
-
-#define POP(x)\
- do {\
- assert (sp < EXECUTION_STACK_SIZE);\
- x = stack[sp++];\
- } while (GL_FALSE)
-
-#define BINARY(op)\
- do {\
- GLint a, b;\
- POP(b);\
- POP(a);\
- PUSH(a op b);\
- } while (GL_FALSE)
-
-#define BINARYDIV(op)\
- do {\
- GLint a, b;\
- POP(b);\
- POP(a);\
- if (b == 0) {\
- slang_info_log_error (elog, "division by zero in preprocessor expression.");\
- return GL_FALSE;\
- }\
- PUSH(a op b);\
- } while (GL_FALSE)
-
-#define UNARY(op)\
- do {\
- GLint a;\
- POP(a);\
- PUSH(op a);\
- } while (GL_FALSE)
-
-#define OP_END 0
-#define OP_PUSHINT 1
-#define OP_LOGICALOR 2
-#define OP_LOGICALAND 3
-#define OP_OR 4
-#define OP_XOR 5
-#define OP_AND 6
-#define OP_EQUAL 7
-#define OP_NOTEQUAL 8
-#define OP_LESSEQUAL 9
-#define OP_GREATEREQUAL 10
-#define OP_LESS 11
-#define OP_GREATER 12
-#define OP_LEFTSHIFT 13
-#define OP_RIGHTSHIFT 14
-#define OP_ADD 15
-#define OP_SUBTRACT 16
-#define OP_MULTIPLY 17
-#define OP_DIVIDE 18
-#define OP_MODULUS 19
-#define OP_PLUS 20
-#define OP_MINUS 21
-#define OP_NEGATE 22
-#define OP_COMPLEMENT 23
-
-static GLboolean
-execute_expression (slang_string *output, const byte *code, GLuint *pi, GLint *result,
- slang_info_log *elog)
-{
- GLuint i = *pi;
- GLint stack[EXECUTION_STACK_SIZE];
- GLuint sp = EXECUTION_STACK_SIZE;
-
- while (code[i] != OP_END) {
- switch (code[i++]) {
- case OP_PUSHINT:
- i++;
- PUSH(_mesa_atoi ((const char *) (&code[i])));
- i += _mesa_strlen ((const char *) (&code[i])) + 1;
- break;
- case OP_LOGICALOR:
- BINARY(||);
- break;
- case OP_LOGICALAND:
- BINARY(&&);
- break;
- case OP_OR:
- BINARY(|);
- break;
- case OP_XOR:
- BINARY(^);
- break;
- case OP_AND:
- BINARY(&);
- break;
- case OP_EQUAL:
- BINARY(==);
- break;
- case OP_NOTEQUAL:
- BINARY(!=);
- break;
- case OP_LESSEQUAL:
- BINARY(<=);
- break;
- case OP_GREATEREQUAL:
- BINARY(>=);
- break;
- case OP_LESS:
- BINARY(<);
- break;
- case OP_GREATER:
- BINARY(>);
- break;
- case OP_LEFTSHIFT:
- BINARY(<<);
- break;
- case OP_RIGHTSHIFT:
- BINARY(>>);
- break;
- case OP_ADD:
- BINARY(+);
- break;
- case OP_SUBTRACT:
- BINARY(-);
- break;
- case OP_MULTIPLY:
- BINARY(*);
- break;
- case OP_DIVIDE:
- BINARYDIV(/);
- break;
- case OP_MODULUS:
- BINARYDIV(%);
- break;
- case OP_PLUS:
- UNARY(+);
- break;
- case OP_MINUS:
- UNARY(-);
- break;
- case OP_NEGATE:
- UNARY(!);
- break;
- case OP_COMPLEMENT:
- UNARY(~);
- break;
- default:
- assert (0);
- }
- }
-
- /* Write-back the index skipping the OP_END. */
- *pi = i + 1;
-
- /* There should be exactly one value left on the stack. This is our result. */
- POP(*result);
- pp_annotate (output, "%d ", *result);
- assert (sp == EXECUTION_STACK_SIZE);
- return GL_TRUE;
-}
-
-/*
- * Function execute_expressions() executes up to 2 expressions. The second expression is there
- * for the #line directive which takes 1 or 2 expressions that indicate line and file numbers.
- * If it fails, it returns 0. If it succeeds, it returns the number of executed expressions.
- */
-
-#define EXP_END 0
-#define EXP_EXPRESSION 1
-
-static GLuint
-execute_expressions (slang_string *output, grammar eid, const byte *expr, GLint results[2],
- slang_info_log *elog)
-{
- GLint success;
- byte *code;
- GLuint size, count = 0;
-
- success = grammar_fast_check (eid, expr, &code, &size, 64);
- if (success) {
- GLuint i = 0;
-
- while (code[i++] == EXP_EXPRESSION) {
- assert (count < 2);
-
- if (!execute_expression (output, code, &i, &results[count], elog)) {
- count = 0;
- break;
- }
- count++;
- }
- grammar_alloc_free (code);
- }
- else {
- slang_info_log_error (elog, "syntax error in preprocessor expression.");\
- }
- return count;
-}
-
-/*
- * The pp_symbol structure is used to hold macro definitions and macro formal parameters. The
- * pp_symbols strcture is a collection of pp_symbol. It is used both for storing macro formal
- * parameters and all global macro definitions. Making this unification wastes some memory,
- * becuse macro formal parameters don't need further lists of symbols. We lose 8 bytes per
- * formal parameter here, but making this we can use the same code to substitute macro parameters
- * as well as macros in the source string.
- */
-
-typedef struct
-{
- struct pp_symbol_ *symbols;
- GLuint count;
-} pp_symbols;
-
-static GLvoid
-pp_symbols_init (pp_symbols *self)
-{
- self->symbols = NULL;
- self->count = 0;
-}
-
-static GLvoid
-pp_symbols_free (pp_symbols *);
-
-typedef struct pp_symbol_
-{
- slang_string name;
- slang_string replacement;
- pp_symbols parameters;
-} pp_symbol;
-
-static GLvoid
-pp_symbol_init (pp_symbol *self)
-{
- slang_string_init (&self->name);
- slang_string_init (&self->replacement);
- pp_symbols_init (&self->parameters);
-}
-
-static GLvoid
-pp_symbol_free (pp_symbol *self)
-{
- slang_string_free (&self->name);
- slang_string_free (&self->replacement);
- pp_symbols_free (&self->parameters);
-}
-
-static GLvoid
-pp_symbol_reset (pp_symbol *self)
-{
- /* Leave symbol name intact. */
- slang_string_reset (&self->replacement);
- pp_symbols_free (&self->parameters);
- pp_symbols_init (&self->parameters);
-}
-
-static GLvoid
-pp_symbols_free (pp_symbols *self)
-{
- GLuint i;
-
- for (i = 0; i < self->count; i++)
- pp_symbol_free (&self->symbols[i]);
- _mesa_free (self->symbols);
-}
-
-static pp_symbol *
-pp_symbols_push (pp_symbols *self)
-{
- self->symbols = (pp_symbol *) (_mesa_realloc (self->symbols, self->count * sizeof (pp_symbol),
- (self->count + 1) * sizeof (pp_symbol)));
- if (self->symbols == NULL)
- return NULL;
- pp_symbol_init (&self->symbols[self->count]);
- return &self->symbols[self->count++];
-}
-
-static GLboolean
-pp_symbols_erase (pp_symbols *self, pp_symbol *symbol)
-{
- assert (symbol >= self->symbols && symbol < self->symbols + self->count);
-
- self->count--;
- pp_symbol_free (symbol);
- if (symbol < self->symbols + self->count)
- _mesa_memcpy (symbol, symbol + 1, sizeof (pp_symbol) * (self->symbols + self->count - symbol));
- self->symbols = (pp_symbol *) (_mesa_realloc (self->symbols, (self->count + 1) * sizeof (pp_symbol),
- self->count * sizeof (pp_symbol)));
- return self->symbols != NULL;
-}
-
-static pp_symbol *
-pp_symbols_find (pp_symbols *self, const char *name)
-{
- GLuint i;
-
- for (i = 0; i < self->count; i++)
- if (_mesa_strcmp (name, slang_string_cstr (&self->symbols[i].name)) == 0)
- return &self->symbols[i];
- return NULL;
-}
-
-/*
- * The condition context of a single #if/#else/#endif level. Those can be nested, so there
- * is a stack of condition contexts.
- * There is a special global context on the bottom of the stack. It is there to simplify
- * context handling.
- */
-
-typedef struct
-{
- GLboolean current; /* The condition value of this level. */
- GLboolean effective; /* The effective product of current condition, outer level conditions
- * and position within #if-#else-#endif sections. */
- GLboolean else_allowed; /* TRUE if in #if-#else section, FALSE if in #else-#endif section
- * and for global context. */
- GLboolean endif_required; /* FALSE for global context only. */
-} pp_cond_ctx;
-
-/* Should be enuff. */
-#define CONDITION_STACK_SIZE 64
-
-typedef struct
-{
- pp_cond_ctx stack[CONDITION_STACK_SIZE];
- pp_cond_ctx *top;
-} pp_cond_stack;
-
-static GLboolean
-pp_cond_stack_push (pp_cond_stack *self, slang_info_log *elog)
-{
- if (self->top == self->stack) {
- slang_info_log_error (elog, "internal compiler error: preprocessor condition stack overflow.");
- return GL_FALSE;
- }
- self->top--;
- return GL_TRUE;
-}
-
-static GLvoid
-pp_cond_stack_reevaluate (pp_cond_stack *self)
-{
- /* There must be at least 2 conditions on the stack - one global and one being evaluated. */
- assert (self->top <= &self->stack[CONDITION_STACK_SIZE - 2]);
-
- self->top->effective = self->top->current && self->top[1].effective;
-}
-
-
-/**
- * Extension enables through #extension directive.
- * NOTE: Currently, only enable/disable state is stored.
- */
-typedef struct
-{
- GLboolean ARB_draw_buffers;
- GLboolean ARB_texture_rectangle;
-} pp_ext;
-
-
-/**
- * Disable all extensions. Called at startup and on #extension all: disable.
- */
-static GLvoid
-pp_ext_disable_all(pp_ext *self)
-{
- _mesa_memset(self, 0, sizeof(self));
-}
-
-
-/**
- * Called during preprocessor initialization to set the initial enable/disable
- * state of extensions.
- */
-static GLvoid
-pp_ext_init(pp_ext *self, const struct gl_extensions *extensions)
-{
- pp_ext_disable_all (self);
- self->ARB_draw_buffers = GL_TRUE;
- if (extensions->NV_texture_rectangle)
- self->ARB_texture_rectangle = GL_TRUE;
-}
-
-/**
- * Called in response to #extension directives to enable/disable
- * the named extension.
- */
-static GLboolean
-pp_ext_set(pp_ext *self, const char *name, GLboolean enable)
-{
- if (_mesa_strcmp (name, "GL_ARB_draw_buffers") == 0)
- self->ARB_draw_buffers = enable;
- else if (_mesa_strcmp (name, "GL_ARB_texture_rectangle") == 0)
- self->ARB_texture_rectangle = enable;
- else
- return GL_FALSE;
- return GL_TRUE;
-}
-
-
-/**
- * Called in response to #pragma. For example, "#pragma debug(on)" would
- * call this function as pp_pragma("debug", "on").
- * \return GL_TRUE if pragma is valid, GL_FALSE if invalid
- */
-static GLboolean
-pp_pragma(struct gl_sl_pragmas *pragmas, const char *pragma, const char *param)
-{
-#if 0
- printf("#pragma %s %s\n", pragma, param);
-#endif
- if (_mesa_strcmp(pragma, "optimize") == 0) {
- if (!param)
- return GL_FALSE; /* missing required param */
- if (_mesa_strcmp(param, "on") == 0) {
- if (!pragmas->IgnoreOptimize)
- pragmas->Optimize = GL_TRUE;
- }
- else if (_mesa_strcmp(param, "off") == 0) {
- if (!pragmas->IgnoreOptimize)
- pragmas->Optimize = GL_FALSE;
- }
- else {
- return GL_FALSE; /* invalid param */
- }
- }
- else if (_mesa_strcmp(pragma, "debug") == 0) {
- if (!param)
- return GL_FALSE; /* missing required param */
- if (_mesa_strcmp(param, "on") == 0) {
- if (!pragmas->IgnoreDebug)
- pragmas->Debug = GL_TRUE;
- }
- else if (_mesa_strcmp(param, "off") == 0) {
- if (!pragmas->IgnoreDebug)
- pragmas->Debug = GL_FALSE;
- }
- else {
- return GL_FALSE; /* invalid param */
- }
- }
- /* all other pragmas are silently ignored */
- return GL_TRUE;
-}
-
-
-/**
- * The state of preprocessor: current line, file and version number, list
- * of all defined macros and the #if/#endif context.
- */
-typedef struct
-{
- GLint line;
- GLint file;
- GLint version;
- pp_symbols symbols;
- pp_ext ext;
- slang_info_log *elog;
- pp_cond_stack cond;
-} pp_state;
-
-static GLvoid
-pp_state_init (pp_state *self, slang_info_log *elog,
- const struct gl_extensions *extensions)
-{
- self->line = 0;
- self->file = 1;
-#if FEATURE_es2_glsl
- self->version = 100;
-#else
- self->version = 110;
-#endif
- pp_symbols_init (&self->symbols);
- pp_ext_init (&self->ext, extensions);
- self->elog = elog;
-
- /* Initialize condition stack and create the global context. */
- self->cond.top = &self->cond.stack[CONDITION_STACK_SIZE - 1];
- self->cond.top->current = GL_TRUE;
- self->cond.top->effective = GL_TRUE;
- self->cond.top->else_allowed = GL_FALSE;
- self->cond.top->endif_required = GL_FALSE;
-}
-
-static GLvoid
-pp_state_free (pp_state *self)
-{
- pp_symbols_free (&self->symbols);
-}
-
-#define IS_FIRST_ID_CHAR(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || (x) == '_')
-#define IS_NEXT_ID_CHAR(x) (IS_FIRST_ID_CHAR(x) || ((x) >= '0' && (x) <= '9'))
-#define IS_WHITE(x) ((x) == ' ' || (x) == '\n')
-#define IS_NULL(x) ((x) == '\0')
-
-#define SKIP_WHITE(x) do { while (IS_WHITE(*(x))) (x)++; } while (GL_FALSE)
-
-typedef struct
-{
- slang_string *output;
- const char *input;
- pp_state *state;
-} expand_state;
-
-static GLboolean
-expand_defined (expand_state *e, slang_string *buffer)
-{
- GLboolean in_paren = GL_FALSE;
- const char *id;
-
- /* Parse the optional opening parenthesis. */
- SKIP_WHITE(e->input);
- if (*e->input == '(') {
- e->input++;
- in_paren = GL_TRUE;
- SKIP_WHITE(e->input);
- }
-
- /* Parse operand. */
- if (!IS_FIRST_ID_CHAR(*e->input)) {
- slang_info_log_error (e->state->elog,
- "preprocess error: identifier expected after operator 'defined'.");
- return GL_FALSE;
- }
- slang_string_reset (buffer);
- slang_string_pushc (buffer, *e->input++);
- while (IS_NEXT_ID_CHAR(*e->input))
- slang_string_pushc (buffer, *e->input++);
- id = slang_string_cstr (buffer);
-
- /* Check if the operand is defined. Output 1 if it is defined, output 0 if not. */
- if (pp_symbols_find (&e->state->symbols, id) == NULL)
- slang_string_pushs (e->output, " 0 ", 3);
- else
- slang_string_pushs (e->output, " 1 ", 3);
-
- /* Parse the closing parentehesis if the opening one was there. */
- if (in_paren) {
- SKIP_WHITE(e->input);
- if (*e->input != ')') {
- slang_info_log_error (e->state->elog, "preprocess error: ')' expected.");
- return GL_FALSE;
- }
- e->input++;
- SKIP_WHITE(e->input);
- }
- return GL_TRUE;
-}
-
-static GLboolean
-expand (expand_state *, pp_symbols *);
-
-static GLboolean
-expand_symbol (expand_state *e, pp_symbol *symbol)
-{
- expand_state es;
-
- /* If the macro has some parameters, we need to parse them. */
- if (symbol->parameters.count != 0) {
- GLuint i;
-
- /* Parse the opening parenthesis. */
- SKIP_WHITE(e->input);
- if (*e->input != '(') {
- slang_info_log_error (e->state->elog, "preprocess error: '(' expected.");
- return GL_FALSE;
- }
- e->input++;
- SKIP_WHITE(e->input);
-
- /* Parse macro actual parameters. This can be anything, separated by a colon.
- */
- for (i = 0; i < symbol->parameters.count; i++) {
- GLuint nested_paren_count = 0; /* track number of nested parentheses */
-
- if (*e->input == ')') {
- slang_info_log_error (e->state->elog, "preprocess error: unexpected ')'.");
- return GL_FALSE;
- }
-
- /* Eat all characters up to the comma or closing parentheses. */
- pp_symbol_reset (&symbol->parameters.symbols[i]);
- while (!IS_NULL(*e->input)) {
- /* Exit loop only when all nested parens have been eaten. */
- if (nested_paren_count == 0 && (*e->input == ',' || *e->input == ')'))
- break;
-
- /* Actually count nested parens here. */
- if (*e->input == '(')
- nested_paren_count++;
- else if (*e->input == ')')
- nested_paren_count--;
-
- slang_string_pushc (&symbol->parameters.symbols[i].replacement, *e->input++);
- }
-
- /* If it was not the last paremeter, skip the comma. Otherwise, skip the
- * closing parentheses. */
- if (i + 1 == symbol->parameters.count) {
- /* This is the last paremeter - skip the closing parentheses. */
- if (*e->input != ')') {
- slang_info_log_error (e->state->elog, "preprocess error: ')' expected.");
- return GL_FALSE;
- }
- e->input++;
- SKIP_WHITE(e->input);
- }
- else {
- /* Skip the separating comma. */
- if (*e->input != ',') {
- slang_info_log_error (e->state->elog, "preprocess error: ',' expected.");
- return GL_FALSE;
- }
- e->input++;
- SKIP_WHITE(e->input);
- }
- }
- }
-
- /* Expand the macro. Use its parameters as a priority symbol list to expand
- * macro parameters correctly. */
- es.output = e->output;
- es.input = slang_string_cstr (&symbol->replacement);
- es.state = e->state;
- slang_string_pushc (e->output, ' ');
- if (!expand (&es, &symbol->parameters))
- return GL_FALSE;
- slang_string_pushc (e->output, ' ');
- return GL_TRUE;
-}
-
-/*
- * Function expand() expands source text from <input> to <output>. The expansion is made using
- * the list passed in <symbols> parameter. It allows us to expand macro formal parameters with
- * actual parameters. The global list of symbols from pp state is used when doing a recursive
- * call of expand().
- */
-
-static GLboolean
-expand (expand_state *e, pp_symbols *symbols)
-{
- while (!IS_NULL(*e->input)) {
- if (IS_FIRST_ID_CHAR(*e->input)) {
- slang_string buffer;
- const char *id;
-
- /* Parse the identifier. */
- slang_string_init (&buffer);
- slang_string_pushc (&buffer, *e->input++);
- while (IS_NEXT_ID_CHAR(*e->input))
- slang_string_pushc (&buffer, *e->input++);
- id = slang_string_cstr (&buffer);
-
- /* Now check if the identifier is special in some way. The "defined" identifier is
- * actually an operator that we must handle here and expand it either to " 0 " or " 1 ".
- * The other identifiers start with "__" and we expand it to appropriate values
- * taken from the preprocessor state. */
- if (_mesa_strcmp (id, "defined") == 0) {
- if (!expand_defined (e, &buffer))
- return GL_FALSE;
- }
- else if (_mesa_strcmp (id, "__LINE__") == 0) {
- slang_string_pushc (e->output, ' ');
- slang_string_pushi (e->output, e->state->line);
- slang_string_pushc (e->output, ' ');
- }
- else if (_mesa_strcmp (id, "__FILE__") == 0) {
- slang_string_pushc (e->output, ' ');
- slang_string_pushi (e->output, e->state->file);
- slang_string_pushc (e->output, ' ');
- }
- else if (_mesa_strcmp (id, "__VERSION__") == 0) {
- slang_string_pushc (e->output, ' ');
- slang_string_pushi (e->output, e->state->version);
- slang_string_pushc (e->output, ' ');
- }
-#if FEATURE_es2_glsl
- else if (_mesa_strcmp (id, "GL_ES") == 0 ||
- _mesa_strcmp (id, "GL_FRAGMENT_PRECISION_HIGH") == 0) {
- slang_string_pushc (e->output, ' ');
- slang_string_pushi (e->output, '1');
- slang_string_pushc (e->output, ' ');
- }
-#endif
- else {
- pp_symbol *symbol;
-
- /* The list of symbols from <symbols> take precedence over the list from <state>.
- * Note that in some cases this is the same list so avoid double look-up. */
- symbol = pp_symbols_find (symbols, id);
- if (symbol == NULL && symbols != &e->state->symbols)
- symbol = pp_symbols_find (&e->state->symbols, id);
-
- /* If the symbol was found, recursively expand its definition. */
- if (symbol != NULL) {
- if (!expand_symbol (e, symbol)) {
- slang_string_free (&buffer);
- return GL_FALSE;
- }
- }
- else {
- slang_string_push (e->output, &buffer);
- }
- }
- slang_string_free (&buffer);
- }
- else if (IS_WHITE(*e->input)) {
- slang_string_pushc (e->output, *e->input++);
- }
- else {
- while (!IS_WHITE(*e->input) && !IS_NULL(*e->input) && !IS_FIRST_ID_CHAR(*e->input))
- slang_string_pushc (e->output, *e->input++);
- }
- }
- return GL_TRUE;
-}
-
-static GLboolean
-parse_if (slang_string *output, const byte *prod, GLuint *pi, GLint *result, pp_state *state,
- grammar eid)
-{
- const char *text;
- GLuint len;
-
- text = (const char *) (&prod[*pi]);
- len = _mesa_strlen (text);
-
- if (state->cond.top->effective) {
- slang_string expr;
- GLuint count;
- GLint results[2];
- expand_state es;
-
- /* Expand the expression. */
- slang_string_init (&expr);
- es.output = &expr;
- es.input = text;
- es.state = state;
- if (!expand (&es, &state->symbols))
- return GL_FALSE;
-
- /* Execute the expression. */
- count = execute_expressions (output, eid, (const byte *) (slang_string_cstr (&expr)),
- results, state->elog);
- slang_string_free (&expr);
- if (count != 1)
- return GL_FALSE;
- *result = results[0];
- }
- else {
- /* The directive is dead. */
- *result = 0;
- }
-
- *pi += len + 1;
- return GL_TRUE;
-}
-
-#define ESCAPE_TOKEN 0
-
-#define TOKEN_END 0
-#define TOKEN_DEFINE 1
-#define TOKEN_UNDEF 2
-#define TOKEN_IF 3
-#define TOKEN_ELSE 4
-#define TOKEN_ELIF 5
-#define TOKEN_ENDIF 6
-#define TOKEN_ERROR 7
-#define TOKEN_PRAGMA 8
-#define TOKEN_EXTENSION 9
-#define TOKEN_LINE 10
-
-#define PARAM_END 0
-#define PARAM_PARAMETER 1
-
-#define BEHAVIOR_REQUIRE 1
-#define BEHAVIOR_ENABLE 2
-#define BEHAVIOR_WARN 3
-#define BEHAVIOR_DISABLE 4
-
-#define PRAGMA_NO_PARAM 0
-#define PRAGMA_PARAM 1
-
-
-static GLboolean
-preprocess_source (slang_string *output, const char *source,
- grammar pid, grammar eid,
- slang_info_log *elog,
- const struct gl_extensions *extensions,
- struct gl_sl_pragmas *pragmas)
-{
- static const char *predefined[] = {
- "__FILE__",
- "__LINE__",
- "__VERSION__",
-#if FEATURE_es2_glsl
- "GL_ES",
- "GL_FRAGMENT_PRECISION_HIGH",
-#endif
- NULL
- };
- byte *prod;
- GLuint size, i;
- pp_state state;
-
- if (!grammar_fast_check (pid, (const byte *) (source), &prod, &size, 65536)) {
- grammar_error_to_log (elog);
- return GL_FALSE;
- }
-
- pp_state_init (&state, elog, extensions);
-
- /* add the predefined symbols to the symbol table */
- for (i = 0; predefined[i]; i++) {
- pp_symbol *symbol = NULL;
- symbol = pp_symbols_push(&state.symbols);
- assert(symbol);
- slang_string_pushs(&symbol->name,
- predefined[i], _mesa_strlen(predefined[i]));
- }
-
- i = 0;
- while (i < size) {
- if (prod[i] != ESCAPE_TOKEN) {
- if (state.cond.top->effective) {
- slang_string input;
- expand_state es;
-
- /* Eat only one line of source code to expand it.
- * FIXME: This approach has one drawback. If a macro with parameters spans across
- * multiple lines, the preprocessor will raise an error. */
- slang_string_init (&input);
- while (prod[i] != '\0' && prod[i] != '\n')
- slang_string_pushc (&input, prod[i++]);
- if (prod[i] != '\0')
- slang_string_pushc (&input, prod[i++]);
-
- /* Increment line number. */
- state.line++;
-
- es.output = output;
- es.input = slang_string_cstr (&input);
- es.state = &state;
- if (!expand (&es, &state.symbols))
- goto error;
-
- slang_string_free (&input);
- }
- else {
- /* Condition stack is disabled - keep track on line numbers and output only newlines. */
- if (prod[i] == '\n') {
- state.line++;
- /*pp_annotate (output, "%c", prod[i]);*/
- }
- else {
- /*pp_annotate (output, "%c", prod[i]);*/
- }
- i++;
- }
- }
- else {
- const char *id;
- GLuint idlen;
- GLubyte token;
-
- i++;
- token = prod[i++];
- switch (token) {
-
- case TOKEN_END:
- /* End of source string.
- * Check if all #ifs have been terminated by matching #endifs.
- * On condition stack there should be only the global condition context. */
- if (state.cond.top->endif_required) {
- slang_info_log_error (elog, "end of source without matching #endif.");
- return GL_FALSE;
- }
- break;
-
- case TOKEN_DEFINE:
- {
- pp_symbol *symbol = NULL;
-
- /* Parse macro name. */
- id = (const char *) (&prod[i]);
- idlen = _mesa_strlen (id);
- if (state.cond.top->effective) {
- pp_annotate (output, "// #define %s(", id);
-
- /* If the symbol is already defined, override it. */
- symbol = pp_symbols_find (&state.symbols, id);
- if (symbol == NULL) {
- symbol = pp_symbols_push (&state.symbols);
- if (symbol == NULL)
- goto error;
- slang_string_pushs (&symbol->name, id, idlen);
- }
- else {
- pp_symbol_reset (symbol);
- }
- }
- i += idlen + 1;
-
- /* Parse optional macro parameters. */
- while (prod[i++] != PARAM_END) {
- pp_symbol *param;
-
- id = (const char *) (&prod[i]);
- idlen = _mesa_strlen (id);
- if (state.cond.top->effective) {
- pp_annotate (output, "%s, ", id);
- param = pp_symbols_push (&symbol->parameters);
- if (param == NULL)
- goto error;
- slang_string_pushs (&param->name, id, idlen);
- }
- i += idlen + 1;
- }
-
- /* Parse macro replacement. */
- id = (const char *) (&prod[i]);
- idlen = _mesa_strlen (id);
- if (state.cond.top->effective) {
- slang_string replacement;
- expand_state es;
-
- pp_annotate (output, ") %s", id);
-
- slang_string_init(&replacement);
- slang_string_pushs(&replacement, id, idlen);
-
- /* Expand macro replacement. */
- es.output = &symbol->replacement;
- es.input = slang_string_cstr(&replacement);
- es.state = &state;
- if (!expand(&es, &state.symbols)) {
- slang_string_free(&replacement);
- goto error;
- }
- slang_string_free(&replacement);
- }
- i += idlen + 1;
- }
- break;
-
- case TOKEN_UNDEF:
- id = (const char *) (&prod[i]);
- i += _mesa_strlen (id) + 1;
- if (state.cond.top->effective) {
- pp_symbol *symbol;
-
- pp_annotate (output, "// #undef %s", id);
- /* Try to find symbol with given name and remove it. */
- symbol = pp_symbols_find (&state.symbols, id);
- if (symbol != NULL)
- if (!pp_symbols_erase (&state.symbols, symbol))
- goto error;
- }
- break;
-
- case TOKEN_IF:
- {
- GLint result;
-
- /* Parse #if expression end execute it. */
- pp_annotate (output, "// #if ");
- if (!parse_if (output, prod, &i, &result, &state, eid))
- goto error;
-
- /* Push new condition on the stack. */
- if (!pp_cond_stack_push (&state.cond, state.elog))
- goto error;
- state.cond.top->current = result ? GL_TRUE : GL_FALSE;
- state.cond.top->else_allowed = GL_TRUE;
- state.cond.top->endif_required = GL_TRUE;
- pp_cond_stack_reevaluate (&state.cond);
- }
- break;
-
- case TOKEN_ELSE:
- /* Check if #else is alloved here. */
- if (!state.cond.top->else_allowed) {
- slang_info_log_error (elog, "#else without matching #if.");
- goto error;
- }
-
- /* Negate current condition and reevaluate it. */
- state.cond.top->current = !state.cond.top->current;
- state.cond.top->else_allowed = GL_FALSE;
- pp_cond_stack_reevaluate (&state.cond);
- if (state.cond.top->effective)
- pp_annotate (output, "// #else");
- break;
-
- case TOKEN_ELIF:
- /* Check if #elif is alloved here. */
- if (!state.cond.top->else_allowed) {
- slang_info_log_error (elog, "#elif without matching #if.");
- goto error;
- }
-
- /* Negate current condition and reevaluate it. */
- state.cond.top->current = !state.cond.top->current;
- pp_cond_stack_reevaluate (&state.cond);
-
- if (state.cond.top->effective)
- pp_annotate (output, "// #elif ");
-
- {
- GLint result;
-
- /* Parse #elif expression end execute it. */
- if (!parse_if (output, prod, &i, &result, &state, eid))
- goto error;
-
- /* Update current condition and reevaluate it. */
- state.cond.top->current = result ? GL_TRUE : GL_FALSE;
- pp_cond_stack_reevaluate (&state.cond);
- }
- break;
-
- case TOKEN_ENDIF:
- /* Check if #endif is alloved here. */
- if (!state.cond.top->endif_required) {
- slang_info_log_error (elog, "#endif without matching #if.");
- goto error;
- }
-
- /* Pop the condition off the stack. */
- state.cond.top++;
- if (state.cond.top->effective)
- pp_annotate (output, "// #endif");
- break;
-
- case TOKEN_EXTENSION:
- /* Parse the extension name. */
- id = (const char *) (&prod[i]);
- i += _mesa_strlen (id) + 1;
- if (state.cond.top->effective)
- pp_annotate (output, "// #extension %s: ", id);
-
- /* Parse and apply extension behavior. */
- if (state.cond.top->effective) {
- switch (prod[i++]) {
-
- case BEHAVIOR_REQUIRE:
- pp_annotate (output, "require");
- if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
- if (_mesa_strcmp (id, "all") == 0) {
- slang_info_log_error (elog, "require: bad behavior for #extension all.");
- goto error;
- }
- else {
- slang_info_log_error (elog, "%s: required extension is not supported.", id);
- goto error;
- }
- }
- break;
-
- case BEHAVIOR_ENABLE:
- pp_annotate (output, "enable");
- if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
- if (_mesa_strcmp (id, "all") == 0) {
- slang_info_log_error (elog, "enable: bad behavior for #extension all.");
- goto error;
- }
- else {
- slang_info_log_warning (elog, "%s: enabled extension is not supported.", id);
- }
- }
- break;
-
- case BEHAVIOR_WARN:
- pp_annotate (output, "warn");
- if (!pp_ext_set (&state.ext, id, GL_TRUE)) {
- if (_mesa_strcmp (id, "all") != 0) {
- slang_info_log_warning (elog, "%s: enabled extension is not supported.", id);
- }
- }
- break;
-
- case BEHAVIOR_DISABLE:
- pp_annotate (output, "disable");
- if (!pp_ext_set (&state.ext, id, GL_FALSE)) {
- if (_mesa_strcmp (id, "all") == 0) {
- pp_ext_disable_all (&state.ext);
- }
- else {
- slang_info_log_warning (elog, "%s: disabled extension is not supported.", id);
- }
- }
- break;
-
- default:
- assert (0);
- }
- }
- break;
-
- case TOKEN_PRAGMA:
- {
- GLint have_param;
- const char *pragma, *param;
-
- pragma = (const char *) (&prod[i]);
- i += _mesa_strlen(pragma) + 1;
- have_param = (prod[i++] == PRAGMA_PARAM);
- if (have_param) {
- param = (const char *) (&prod[i]);
- i += _mesa_strlen(param) + 1;
- }
- else {
- param = NULL;
- }
- pp_pragma(pragmas, pragma, param);
- }
- break;
-
- case TOKEN_LINE:
- id = (const char *) (&prod[i]);
- i += _mesa_strlen (id) + 1;
-
- if (state.cond.top->effective) {
- slang_string buffer;
- GLuint count;
- GLint results[2];
- expand_state es;
-
- slang_string_init (&buffer);
- state.line++;
- es.output = &buffer;
- es.input = id;
- es.state = &state;
- if (!expand (&es, &state.symbols))
- goto error;
-
- pp_annotate (output, "// #line ");
- count = execute_expressions (output, eid,
- (const byte *) (slang_string_cstr (&buffer)),
- results, state.elog);
- slang_string_free (&buffer);
- if (count == 0)
- goto error;
-
- state.line = results[0] - 1;
- if (count == 2)
- state.file = results[1];
- }
- break;
- }
- }
- }
-
- /* Check for missing #endifs. */
- if (state.cond.top->endif_required) {
- slang_info_log_error (elog, "#endif expected but end of source found.");
- goto error;
- }
-
- grammar_alloc_free(prod);
- pp_state_free (&state);
- return GL_TRUE;
-
-error:
- grammar_alloc_free(prod);
- pp_state_free (&state);
- return GL_FALSE;
-}
-
-
-/**
- * Remove the continuation characters from the input string.
- * This is the very first step in preprocessing and is effective
- * even inside comment blocks.
- * If there is a whitespace between a backslash and a newline,
- * this is not considered as a line continuation.
- * \return GL_TRUE for success, GL_FALSE otherwise.
- */
-static GLboolean
-_slang_preprocess_backslashes(slang_string *output,
- const char *input)
-{
- while (*input) {
- if (input[0] == '\\') {
- /* If a newline follows, eat the backslash and the newline. */
- if (input[1] == '\r') {
- if (input[2] == '\n') {
- input += 3;
- } else {
- input += 2;
- }
- } else if (input[1] == '\n') {
- if (input[2] == '\r') {
- input += 3;
- } else {
- input += 2;
- }
- } else {
- /* Leave the backslash alone. */
- slang_string_pushc(output, *input++);
- }
- } else {
- slang_string_pushc(output, *input++);
- }
- }
- return GL_TRUE;
-}
-
-
-/**
- * Run preprocessor on source code.
- * \param extensions indicates which GL extensions are enabled
- * \param output the post-process results
- * \param input the input text
- * \param elog log to record warnings, errors
- * \param extensions out extension settings
- * \param pragmas in/out #pragma settings
- * \return GL_TRUE for success, GL_FALSE for error
- */
-GLboolean
-_slang_preprocess_directives(slang_string *output,
- const char *input,
- slang_info_log *elog,
- const struct gl_extensions *extensions,
- struct gl_sl_pragmas *pragmas)
-{
- grammar pid, eid;
- GLboolean success;
- slang_string without_backslashes;
-
- pid = grammar_load_from_text ((const byte *) (slang_pp_directives_syn));
- if (pid == 0) {
- grammar_error_to_log (elog);
- return GL_FALSE;
- }
- eid = grammar_load_from_text ((const byte *) (slang_pp_expression_syn));
- if (eid == 0) {
- grammar_error_to_log (elog);
- grammar_destroy (pid);
- return GL_FALSE;
- }
-
- slang_string_init(&without_backslashes);
- success = _slang_preprocess_backslashes(&without_backslashes, input);
-
- if (0) {
- _mesa_printf("Pre-processed shader:\n");
- _mesa_printf("%s", slang_string_cstr(&without_backslashes));
- _mesa_printf("----------------------\n");
- }
-
- if (success) {
- success = preprocess_source(output,
- slang_string_cstr(&without_backslashes),
- pid,
- eid,
- elog,
- extensions,
- pragmas);
- }
-
- slang_string_free(&without_backslashes);
- grammar_destroy (eid);
- grammar_destroy (pid);
-
- if (0) {
- _mesa_printf("Post-processed shader:\n");
- _mesa_printf("%s", slang_string_cstr(output));
- _mesa_printf("----------------------\n");
- }
-
- return success;
-}
-
diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h
deleted file mode 100644
index f344820dae..0000000000
--- a/src/mesa/shader/slang/slang_preprocess.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 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.
- */
-
-#ifndef SLANG_PREPROCESS_H
-#define SLANG_PREPROCESS_H
-
-#include "slang_compile.h"
-#include "slang_log.h"
-
-
-extern GLboolean
-_slang_preprocess_version (const char *, GLuint *, GLuint *, slang_info_log *);
-
-extern GLboolean
-_slang_preprocess_directives(slang_string *output, const char *input,
- slang_info_log *,
- const struct gl_extensions *extensions,
- struct gl_sl_pragmas *pragmas);
-
-#endif /* SLANG_PREPROCESS_H */