add in as an operator

This commit is contained in:
2025-06-11 02:29:14 +01:00
parent 406c57c296
commit f8207702e1
5 changed files with 58 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ int yywrap(void * unused_param) {
"^=" { return TOKEN_ASSIGN_CARET; }
"not"[ \t]+"in" { return TOKEN_NOT_IN; }
"in" { return TOKEN_IN; }
"&&" { return TOKEN_AND; }
"||" { return TOKEN_OR; }
"<=" { return TOKEN_LE; }
@@ -65,7 +66,6 @@ int yywrap(void * unused_param) {
"null" { return TOKEN_NULL; }
"delete" { return TOKEN_DELETE; }
"not" { return TOKEN_NOT; }
"in" { return TOKEN_IN; }
"try" { return TOKEN_TRY; }
"catch" { return TOKEN_CATCH; }
@@ -86,11 +86,11 @@ int yywrap(void * unused_param) {
return TOKEN_STRING;
}
\-?((([0-9]+(\.[0-9]+)?)|(\.[0-9]+))(e((\-|\+)?([0-9]+(\.[0-9]+)?)))?) {
((([0-9]+(\.[0-9]+)?)|(\.[0-9]+))(e((\-|\+)?([0-9]+(\.[0-9]+)?)))?) {
return TOKEN_NUMBER;
}
\n { return TOKEN_NEW_LINE; }
"\n" { return TOKEN_NEW_LINE; }
[ \t]+ {
GET_STATE

View File

@@ -34,7 +34,8 @@ typedef enum {
TOKEN_GE, // >=
TOKEN_EQ, // ==
TOKEN_NE, // !=
TOKEN_NOT_IN, // not in (Usually treated like a comparison)
TOKEN_NOT_IN, // not in
TOKEN_IN, // in
TOKEN_AND, // &&
TOKEN_OR, // ||
@@ -57,7 +58,6 @@ typedef enum {
TOKEN_NULL,
TOKEN_DELETE,
TOKEN_NOT,
TOKEN_IN,
TOKEN_TRY,
TOKEN_CATCH,

View File

@@ -12,7 +12,7 @@ ParsedValue *parse_assign(char *file, DArray *tokens, ParsedValue *assign_to,
Token *token = darray_get(tokens, *index);
switch (assign_to->type) {
case AST_IDENTIFIER:
case AST_ASSIGN:
case AST_ACCESS:
break;
case AST_CALL:;
ParsedCall *call = assign_to->data;

View File

@@ -8,6 +8,7 @@
#define SWITCH_OPERATIONS case TOKEN_AND:\
case TOKEN_OR:\
case TOKEN_NOT_IN:\
case TOKEN_IN:\
case TOKEN_LE:\
case TOKEN_GE:\
case TOKEN_LT:\