mini-llvm 0.1.0
Loading...
Searching...
No Matches
Lexer.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <exception>
6#include <memory>
7#include <optional>
8#include <string>
9#include <utility>
10#include <vector>
11
14
15namespace mini_llvm::ir {
16
17class LexException : public std::exception {
18public:
19 LexException(std::string message, const char *location)
20 : message_(std::move(message)), location_(location) {}
21
22 const std::string &message() const & {
23 return message_;
24 }
25
26 std::string &&message() && {
27 return std::move(message_);
28 }
29
30 const char *location() const {
31 return location_;
32 }
33
34 const char *what() const noexcept override {
35 return "LexException";
36 }
37
38private:
39 std::string message_;
40 const char *location_;
41};
42
44public:
45 explicit Lexer(const char *current);
46
48
49 Lexer(Lexer &&) noexcept;
50 Lexer &operator=(Lexer &&) noexcept;
51
52 std::optional<Token> lastToken();
54
55private:
56 class Impl;
57
58 std::unique_ptr<Impl> impl_;
59};
60
61MINI_LLVM_EXPORT std::vector<Token> lex(const char *source);
62
63} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
const char * location() const
Definition Lexer.h:30
std::string && message() &&
Definition Lexer.h:26
LexException(std::string message, const char *location)
Definition Lexer.h:19
const char * what() const noexcept override
Definition Lexer.h:34
const std::string & message() const &
Definition Lexer.h:22
Lexer(Lexer &&) noexcept
Lexer(const char *current)
std::optional< Token > lastToken()
Definition Argument.h:13
MINI_LLVM_EXPORT std::vector< Token > lex(const char *source)
Definition Token.h:15