diff --git a/src/lexer/lex.c b/src/lexer/lex.c index c94a9cc..7d6a61e 100644 --- a/src/lexer/lex.c +++ b/src/lexer/lex.c @@ -248,7 +248,7 @@ int real_lex(Lexer *l, Token *t) { // return./ if (starts_operator(init)) { while (valid_operator_sequence(t->contents)) { - t->contents[pos++] = (c = lexer_getchar(l->fp)); + t->contents[pos++] = (c = lexer_getchar(l)); } // We've ended! // Can we reduce this code duplication from above in a smart way? diff --git a/src/parser/cst.h b/src/parser/cst.h index 3184cf5..f68ec16 100644 --- a/src/parser/cst.h +++ b/src/parser/cst.h @@ -7,7 +7,7 @@ #pragma once -#include "list.h" +#include // A list of all node types. typedef enum { diff --git a/src/parser/parse.c b/src/parser/parse.c index 5a7190c..6176d52 100644 --- a/src/parser/parse.c +++ b/src/parser/parse.c @@ -2,12 +2,14 @@ * */ -#include -#include -#include #include // calloc #include // strcmp #include // isdigit + +#include +#include +#include +#include #include int parse(const char *filename) { @@ -95,3 +97,30 @@ int parse(const char *filename) { } int parse_simple_main_func() {} + +/** + * Proper parsing code below -- producing a concrete syntax tree from a file. + * Each of these functions will probably reference the others numerous times. + */ + +int parse_expr(Lexer* l, Expression* ex) { + // TODO (just a literal or a function call for now). +} + +int parse_funccall(Lexer* l, Expression* ex) { + // TODO +} + +int parse_blockstmt(Lexer* l, BlockStatement* bs) { + // TODO +} + +int parse_funcdecl(Lexer* l, FunctionDeclaration* fd) { + // TODO +} + +// Parse function -- takes a lexer and produces a concrete syntax tree. Fill the +// struct which we have given with the data. +int make_cst(Lexer* l, ConcreteFileTree* tree) { + // TODO +}