changed subtypes for tags

This commit is contained in:
hugogogo
2026-05-02 10:25:25 +02:00
parent a250a170cb
commit 3977e6a6bb
4 changed files with 104 additions and 79 deletions

View File

@@ -139,35 +139,72 @@
* PROPOSITION 3
*/
// typedef enum
// {
// TOKEN_VARIABLE, // x, y, etc.
// TOKEN_NUMBER, // int or double
// TOKEN_POWER, // ^ or **
// TOKEN_SIGN, // + or -
// TOKEN_FACTOR, // * or / or :
// TOKEN_EQUAL, // =
// TOKEN_END // null (end of input)
// } token_type;
//
// typedef enum
// {
// TOKEN_NO_SUBTYPE,
// // NUMBER
// TOKEN_NUMBER_INT,
// TOKEN_NUMBER_DOUBLE,
// // SIGN
// TOKEN_SIGN_PLUS,
// TOKEN_SIGN_MINUS,
// // FACTOR
// TOKEN_FACTOR_MULTIPLICATION,
// TOKEN_FACTOR_DIVISION,
// } token_subtype;
//
// typedef struct
// {
// token_type type;
// token_subtype subtype;
// union
// {
// char value_char;
// double value_double;
// };
// } token;
/**
* PROPOSITION 4
*/
typedef enum
{
TOKEN_VARIABLE, // x, y, etc.
TOKEN_NUMBER, // int or double
TOKEN_POWER, // ^ or **
TOKEN_SIGN, // + or -
TOKEN_FACTOR, // * or / 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_PLUS, // +
TOKEN_SIGN_MINUS, // -
TOKEN_FACTOR_MULT, // *
TOKEN_FACTOR_DIV, // / or :
TOKEN_EQUAL, // =
TOKEN_END // null (end of input)
} token_type;
typedef enum
{
TOKEN_NO_SUBTYPE,
// NUMBER
TOKEN_NUMBER_INT,
TOKEN_NUMBER_DOUBLE,
// SIGN
TOKEN_SIGN_PLUS,
TOKEN_SIGN_MINUS,
// FACTOR
TOKEN_FACTOR_MULTIPLICATION,
TOKEN_FACTOR_DIVISION,
} token_subtype;
TOKEN_NO_TAG,
TOKEN_NUMBER,
TOKEN_SIGN,
TOKEN_FACTOR,
} token_tag;
typedef struct
{
token_type type;
token_subtype subtype;
token_tag tag;
union
{
char value_char;