Stax
Programming language
Loading...
Searching...
No Matches
parser.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
stax/utils/result.hpp
>
4
#include <string>
5
6
#include "
ast.hpp
"
7
#include "
stax/lexer/lexer.hpp
"
8
#include "
stax/lexer/tokens.hpp
"
9
10
namespace
stax::parser
{
11
12
DEFINE_ERROR
(
"stax::parser"
, Error, Syntax, InvalidToken, ExpectedToken)
13
14
class
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
ast.hpp
stax::lexer::Lexer
Definition
lexer.hpp:19
stax::parser::Parser
Definition
parser.hpp:14
lexer.hpp
stax::parser
Definition
parser.cpp:5
stax::result_t
boost::outcome_v2::result< T, result::Err, boost::outcome_v2::policy::terminate > result_t
Definition
result.hpp:66
result.hpp
DEFINE_ERROR
#define DEFINE_ERROR(module_name, name,...)
Definition
result.hpp:91
tokens.hpp
staxlib
include
stax
parser
parser.hpp
Generated by
1.10.0