blob: 825dfdd7c4628e45a78093993ba028c1bb78261f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#ifndef WILLOWC_INCLUDE_PARSER_HPP
#define WILLOWC_INCLUDE_PARSER_HPP
#include <tokenizer.hpp>
#include <ast.hpp>
#include <optional>
#include <memory>
#include <vector>
namespace willowc {
class Parser {
std::string_view buf;
std::vector<TokenKind> kinds;
std::vector<std::size_t> starts;
Tokenizer tokenizer;
std::size_t pos;
public:
Parser(std::string_view buf) : buf(buf), tokenizer(buf) {}
std::optional<std::unique_ptr<ModuleAST>> parse();
TokenKind kind() const { return kinds[pos]; }
std::size_t start() const { return starts[pos]; }
};
} // namespace willowc
#endif // WILLOWC_INCLUDE_PARSER_HPP
|