parse sign

This commit is contained in:
hugogogo
2026-05-01 22:39:15 +02:00
parent 416d170ed2
commit bcbd3b2abb
6 changed files with 117 additions and 31 deletions

View File

@@ -9,8 +9,9 @@ typedef enum
ERROR_UNKNOWN_TOKEN = -1,
ERROR_NUMBER_TOO_BIG = -2,
ERROR_PARSING = -3,
ERROR_TOKEN_POSITION = -4,
} program_error;
int stop_errors(int err, const char *details);
int stop_errors(program_error err, const char *details);
#endif

View File

@@ -7,13 +7,14 @@
typedef enum
{
TOKEN_VARIABLE, // x, y, etc.
TOKEN_NUMBER, // int or double -> all converted into double
TOKEN_POWER, // ^ or **
TOKEN_SIGN, // + or -
TOKEN_FACTOR, // * or /
TOKEN_EQUAL, // =
TOKEN_END // null (end of input)
TOKEN_VARIABLE, // x, y, etc.
TOKEN_NUMBER_INT, // int
TOKEN_NUMBER_DOUBLE, // double
TOKEN_POWER, // ^ or **
TOKEN_SIGN, // + or -
TOKEN_FACTOR, // * or /
TOKEN_EQUAL, // =
TOKEN_END // null (end of input)
} token_type;
typedef struct
@@ -22,6 +23,7 @@ typedef struct
union
{
char value_char;
int value_int;
double value_double;
};
} token;