diff options
| author | Cori Barker <coribarker2@gmail.com> | 2026-02-22 22:24:27 +0000 |
|---|---|---|
| committer | Cori Barker <coribarker2@gmail.com> | 2026-02-22 22:24:27 +0000 |
| commit | 5c1f937a7eb7a9cc9cd86cb69b3263f41f24408f (patch) | |
| tree | 46154166a56f9a074c5b75dbb1a1b9560908b8f1 /include/parser.hpp | |
| parent | 2cfc45ff22cd9b6166de3cf963aceede21b358aa (diff) | |
Partially completed lots of changes, refactoring most of the files
Diffstat (limited to 'include/parser.hpp')
| -rw-r--r-- | include/parser.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/parser.hpp b/include/parser.hpp new file mode 100644 index 0000000..f986ce2 --- /dev/null +++ b/include/parser.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "lexer/token.hpp" +#include "parser/ast_node.hpp" + +#include <vector> + +class Parser { +public: + explicit Parser(const std::vector<Token>& tokens); + std::unique_ptr<Program> parse(); + +private: + std::vector<Token> tokens_; + int position_; + + std::unique_ptr<ASTNode> parseStatement(); + std::unique_ptr<ASTNode> parseExpression(); + std::unique_ptr<ASTNode> parseAddSub(); + std::unique_ptr<ASTNode> parseMulDiv(); + std::unique_ptr<ASTNode> parsePrimary(); + std::unique_ptr<ASTNode> parseDeclaration(); + std::unique_ptr<ASTNode> parseAssignment(); + Token advance(); + Token peek(); + bool isAtEnd(); + void error(std::string s); +}; |
