init parser
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
#ifndef COMPUTORV1_H
|
||||
#define COMPUTORV1_H
|
||||
|
||||
#include "libft.h"
|
||||
#include "lexer.h"
|
||||
#include "parser.h"
|
||||
#include "errors.h"
|
||||
#include <stdio.h> // tmp for printf, for float debug
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
#include "libft.h"
|
||||
#include "errors.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TOKEN_VARIABLE, // x, y, etc.
|
||||
@@ -24,6 +28,6 @@ typedef struct
|
||||
};
|
||||
} token;
|
||||
|
||||
void lexerize(const char *input, token *tokens);
|
||||
int lexerize(const char *input, token *tokens);
|
||||
|
||||
#endif
|
||||
27
headers/parser.h
Normal file
27
headers/parser.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "libft.h"
|
||||
#include "lexer.h"
|
||||
#include "errors.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TERM_LEFT, // a in "a = b"
|
||||
TERM_RIGHT, // b in "a = b"
|
||||
} term_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
term_type type;
|
||||
union
|
||||
{
|
||||
char value_char;
|
||||
int value_int;
|
||||
double value_double;
|
||||
};
|
||||
} term;
|
||||
|
||||
int parse(token *tokens, term *terms);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user