#pragma once #include "AST/NumberNode.h" #include "AST/SumNode.h" #include "Error.h" #include "Lexer.h" #include "Result.h" #include "sapphirepch.h" /* Parser class for the Sapphire compiler. */ class Parser { private: Parser(const TokenStream& tokens); TokenStream tokens; int index = -1; int advance(); Token* current_token; Result factor(); Result expr(); Result term(); public: /* Construct a new Parser with the given TokenStream. */ static std::shared_ptr new_parser(const TokenStream& tokens); /* Parse the stored TokenStream and return the top-level node of the result Abstract Syntax Tree. */ std::shared_ptr parse(); };