Handle preceding operators for pipe defaults
This commit is contained in:
13
glsl_ext.c
13
glsl_ext.c
@@ -330,7 +330,7 @@ void ext_process(struct glsl_ext* ext, const char* f) {
|
|||||||
int state = LINE_START;
|
int state = LINE_START;
|
||||||
size_t macro_start_idx, arg_start_idx, cbuf_idx, bbuf_idx;
|
size_t macro_start_idx, arg_start_idx, cbuf_idx, bbuf_idx;
|
||||||
size_t line = 1;
|
size_t line = 1;
|
||||||
bool quoted = false, arg_start, b_sep = false, b_spc = false;
|
bool quoted = false, arg_start, b_sep = false, b_spc = false, b_pre = true;
|
||||||
int b_br = 0;
|
int b_br = 0;
|
||||||
char cbuf[9];
|
char cbuf[9];
|
||||||
char bbuf[256];
|
char bbuf[256];
|
||||||
@@ -417,6 +417,7 @@ void ext_process(struct glsl_ext* ext, const char* f) {
|
|||||||
state = BIND;
|
state = BIND;
|
||||||
b_sep = false;
|
b_sep = false;
|
||||||
b_spc = false;
|
b_spc = false;
|
||||||
|
b_pre = true;
|
||||||
b_br = 0;
|
b_br = 0;
|
||||||
bbuf_idx = 0;
|
bbuf_idx = 0;
|
||||||
continue;
|
continue;
|
||||||
@@ -480,9 +481,11 @@ void ext_process(struct glsl_ext* ext, const char* f) {
|
|||||||
else goto handle_bind; /* continue reading if nested */
|
else goto handle_bind; /* continue reading if nested */
|
||||||
}
|
}
|
||||||
case ' ': if (b_br <= 0) b_spc = true; /* flag a non-braced space */
|
case ' ': if (b_br <= 0) b_spc = true; /* flag a non-braced space */
|
||||||
case '#':
|
case '#': case '+': case '-':
|
||||||
if (b_sep) goto handle_bind; /* handle color syntax only for defaults */
|
case '!': case '~': case '&':
|
||||||
else goto emit_bind; /* if '#' is encountered, skip to emit */
|
if (b_sep && (b_br > 0 || b_pre))
|
||||||
|
goto handle_bind; /* handle precede syntax only for defaults */
|
||||||
|
else goto emit_bind; /* if encountered, skip to emit */
|
||||||
case ':': b_sep = true;
|
case ':': b_sep = true;
|
||||||
handle_bind: /* use character for binding syntax */
|
handle_bind: /* use character for binding syntax */
|
||||||
case 'a' ... 'z':
|
case 'a' ... 'z':
|
||||||
@@ -491,6 +494,8 @@ void ext_process(struct glsl_ext* ext, const char* f) {
|
|||||||
case '_': {
|
case '_': {
|
||||||
if (b_spc && b_br <= 0)
|
if (b_spc && b_br <= 0)
|
||||||
goto emit_bind; /* skip non-braced characters after space: `@sym:vec4 c` */
|
goto emit_bind; /* skip non-braced characters after space: `@sym:vec4 c` */
|
||||||
|
if (b_sep && at != ':')
|
||||||
|
b_pre = false;
|
||||||
bbuf[bbuf_idx] = at;
|
bbuf[bbuf_idx] = at;
|
||||||
++bbuf_idx;
|
++bbuf_idx;
|
||||||
if (bbuf_idx >= sizeof(bbuf) - 1)
|
if (bbuf_idx >= sizeof(bbuf) - 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user