42 lines
639 B
C
42 lines
639 B
C
#ifndef PARSER_H
|
|
#define PARSER_H
|
|
|
|
#include "libft.h"
|
|
#include "lexer.h"
|
|
#include "errors.h"
|
|
#include <stdbool.h>
|
|
|
|
typedef enum
|
|
{
|
|
TERM_LEFT, // a in "a = b"
|
|
TERM_RIGHT, // b in "a = b"
|
|
} term_position;
|
|
|
|
typedef enum
|
|
{
|
|
TERM_PLUS, // +
|
|
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;
|
|
};
|
|
int exponent;
|
|
} term;
|
|
|
|
int parse(token *tokens, term *terms);
|
|
|
|
#endif |