using double everywhere

This commit is contained in:
hugogogo
2026-05-01 10:42:45 +02:00
parent 2eeed8580f
commit 7519b8e615
7 changed files with 78 additions and 133 deletions

View File

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

View File

@@ -7,14 +7,13 @@
typedef enum
{
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_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_type;
typedef struct
@@ -23,7 +22,6 @@ typedef struct
union
{
char value_char;
int value_int;
double value_double;
};
} token;

View File

@@ -18,25 +18,14 @@ typedef enum
TERM_MINUS, // -
} term_sign;
typedef enum
{
TYPE_INT, // "123"
TYPE_DOUBLE, // "123.456"
} coefficient_type;
typedef struct
{
term_position position;
term_sign sign;
coefficient_type coefficient_type;
union
{
int coefficient_int;
double coefficient_double;
};
double coefficient;
int exponent;
} term;
int parse(token *tokens, term *terms);
int parse(token *tokens, term *terms, int terms_count_max);
#endif