Fixed scripts using syntax like $self

This commit is contained in:
smallmodel 2024-04-09 23:22:45 +02:00
parent 2bf1144a14
commit dc60cb45b2
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
4 changed files with 23 additions and 13 deletions

View file

@ -294,7 +294,7 @@ identifier
;
listener_identifier
: identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); }
: identifier_prim { $$ = node_listener($1, TOKPOS(@1)); }
| TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; }
;

View file

@ -342,3 +342,12 @@ sval_u node6(int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_
return val;
}
sval_u node_listener(sval_u val1, sval_u val2)
{
if (!str::icmp(val1.stringValue, "self")) {
return node2(ENUM_listener, node1_(method_self), val2);
} else {
return node2(ENUM_string, val1, val2);
}
}

View file

@ -101,6 +101,18 @@ enum parseStage_e {
PS_BODY_END
};
enum {
method_game,
method_level,
method_local,
method_parm,
method_self,
method_group,
method_owner,
method_field,
method_array,
};
void parsetree_freeall();
void parsetree_init();
size_t parsetree_length();
@ -124,6 +136,7 @@ sval_u node3(int type, sval_u val1, sval_u val2, sval_u val3);
sval_u node4(int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4);
sval_u node5(int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5);
sval_u node6(int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5, sval_u val6);
sval_u node_listener(sval_u val1, sval_u val2);
typedef struct parse_pos_s {
int sourcePos;

View file

@ -32,18 +32,6 @@ class ScriptVariable;
typedef void (*ScriptDisplayTokenFunc)(const char *type, const char *name);
enum {
method_game,
method_level,
method_local,
method_parm,
method_self,
method_group,
method_owner,
method_field,
method_array,
};
typedef struct scriptmacro {
str name;
str parameters;