Stax
Programming language
Loading...
Searching...
No Matches
parser.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5
6#include "ast.hpp"
9
10namespace stax::parser {
11
12DEFINE_ERROR("stax::parser", Error, Syntax, InvalidToken, ExpectedToken)
13
14class Parser {
15 public:
16 Parser(const std::string& input);
17
18 auto ParseProgram() -> result_t<Program>;
19
20 private:
21 auto ParseStatement() -> result_t<ast_t>;
22 auto ParseLetStatement() -> result_t<ast_t>;
23
24 auto NextToken() -> result_t<void>;
25
26 auto ExpectPeek(token::Type tok_type) -> result_t<void>;
27
28 std::string input_;
29 lexer::Lexer lexer_;
30
31 token::Token curr_;
32 token::Token peek_;
33};
34
35} // namespace stax::parser
Definition lexer.hpp:19
Definition parser.hpp:14
Definition parser.cpp:5
boost::outcome_v2::result< T, result::Err, boost::outcome_v2::policy::terminate > result_t
Definition result.hpp:66
#define DEFINE_ERROR(module_name, name,...)
Definition result.hpp:91