Update parser

This commit is contained in:
2026-02-22 09:21:51 +11:00
parent 929482d7d4
commit c94e5ba4cc
4 changed files with 33 additions and 1 deletions

View File

@@ -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)

View File

@@ -40,7 +40,7 @@ exit
// -- PARSER --
#include "src/parser/SolsNode.c"
#include "src/parser/parser.c"
// -- CODEGEN --

5
src/parser/parser.c Normal file
View File

@@ -0,0 +1,5 @@
#include "parser.h"
ResultType(SolsParser, charptr) createSolsParser(SolsTokens* input) {
return Error(SolsParser, charptr, "Work in progress");
}

View File

@@ -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