diff --git a/README.md b/README.md index d2dcbef..fbe750a 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,9 @@ bash build.c - [x] Basic types (int, double, string, bool, char) - [ ] Advanced types (fun(...), template(...), object(...)) - [x] Lex identifiers + +- [ ] Parser + - [x] Create structure to hold nodes + - [ ] Start parsing tree + - [ ] (this will be updated soon) diff --git a/build.c b/build.c index 0ad320b..30aa71f 100755 --- a/build.c +++ b/build.c @@ -40,7 +40,7 @@ exit // -- PARSER -- #include "src/parser/SolsNode.c" - +#include "src/parser/parser.c" // -- CODEGEN -- diff --git a/src/parser/parser.c b/src/parser/parser.c new file mode 100644 index 0000000..74740c1 --- /dev/null +++ b/src/parser/parser.c @@ -0,0 +1,5 @@ +#include "parser.h" + +ResultType(SolsParser, charptr) createSolsParser(SolsTokens* input) { + return Error(SolsParser, charptr, "Work in progress"); +} diff --git a/src/parser/parser.h b/src/parser/parser.h index aee73f5..d67fd06 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -2,5 +2,27 @@ #define PARSER_H #include "SolsNode.h" +#include "../lexer/SolsToken.h" +#include "../include/error.h" + +// Holds information about the parser. +// .input is lexed tokens, produced by a lexer. +// .current is the token currently being parsed. +// .output is the final product of the parser. +// .currentParent points to the current node being processed +typedef struct SolsParser { + SolsTokens* input; + size_t current; + SolsNode output; + SolsNode* currentParent; +} SolsParser; + +Result(SolsParser, charptr); + +// Creates a SolsParser. +// Returns: +// Success: Constructed SolsParser +// Failure: char* detailing what went wrong (usually memory failure) +ResultType(SolsParser, charptr) createSolsParser(SolsTokens* input); #endif