start rewriting the parser to return with error messages so errors can be caught
This commit is contained in:
@@ -2,26 +2,28 @@
|
||||
#define PARSER_H
|
||||
|
||||
#include "../dynamic_array/darray.h"
|
||||
#include "../err.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define SWITCH_OPERATIONS case TOKEN_AND:\
|
||||
case TOKEN_OR:\
|
||||
case TOKEN_NOT_IN:\
|
||||
case TOKEN_IN:\
|
||||
case TOKEN_LE:\
|
||||
case TOKEN_GE:\
|
||||
case TOKEN_LT:\
|
||||
case TOKEN_GT:\
|
||||
case TOKEN_NE:\
|
||||
case TOKEN_EQ:\
|
||||
case TOKEN_PLUS:\
|
||||
case TOKEN_MINUS:\
|
||||
case TOKEN_MODULO:\
|
||||
case TOKEN_STAR:\
|
||||
case TOKEN_FLOORDIV:\
|
||||
case TOKEN_SLASH:\
|
||||
case TOKEN_CARET:
|
||||
#define SWITCH_OPERATIONS \
|
||||
case TOKEN_AND: \
|
||||
case TOKEN_OR: \
|
||||
case TOKEN_NOT_IN: \
|
||||
case TOKEN_IN: \
|
||||
case TOKEN_LE: \
|
||||
case TOKEN_GE: \
|
||||
case TOKEN_LT: \
|
||||
case TOKEN_GT: \
|
||||
case TOKEN_NE: \
|
||||
case TOKEN_EQ: \
|
||||
case TOKEN_PLUS: \
|
||||
case TOKEN_MINUS: \
|
||||
case TOKEN_MODULO: \
|
||||
case TOKEN_STAR: \
|
||||
case TOKEN_FLOORDIV: \
|
||||
case TOKEN_SLASH: \
|
||||
case TOKEN_CARET:
|
||||
|
||||
typedef struct LinkedList LinkedList;
|
||||
|
||||
@@ -43,24 +45,29 @@ typedef enum {
|
||||
AST_FUNCTION
|
||||
} ValueType;
|
||||
|
||||
extern const char* ValueTypeNames[];
|
||||
extern const char *ValueTypeNames[];
|
||||
|
||||
typedef struct {
|
||||
ValueType type;
|
||||
void *data;
|
||||
} ParsedValue;
|
||||
|
||||
void parser(char *file, DArray *parsed, DArray *tokens, bool inline_flag);
|
||||
typedef struct {
|
||||
ArErr err;
|
||||
ParsedValue *value;
|
||||
} ParsedValueReturn;
|
||||
|
||||
ParsedValue *parse_token_full(char *file, DArray *tokens, size_t *index,
|
||||
bool inline_flag, bool process_operations);
|
||||
ArErr parser(char *file, DArray *parsed, DArray *tokens, bool inline_flag);
|
||||
|
||||
ParsedValue *parse_token(char *file, DArray *tokens, size_t *index,
|
||||
ParsedValueReturn parse_token_full(char *file, DArray *tokens, size_t *index,
|
||||
bool inline_flag, bool process_operations);
|
||||
|
||||
ParsedValueReturn parse_token(char *file, DArray *tokens, size_t *index,
|
||||
bool inline_flag);
|
||||
|
||||
void free_parsed(void *ptr);
|
||||
|
||||
void error_if_finished(char *file,DArray *tokens, size_t *index);
|
||||
void error_if_finished(char *file, DArray *tokens, size_t *index);
|
||||
|
||||
size_t skip_newlines_and_indents(DArray *tokens, size_t *index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user