mini-llvm
0.1.0
Toggle main menu visibility
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
12
#include "
mini-llvm/ir_reader/Token.h
"
13
#include "
mini-llvm/utils/Compiler.h
"
14
15
namespace
mini_llvm::ir
{
16
17
class
LexException
:
public
std::exception {
18
public
:
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
38
private
:
39
std::string message_;
40
const
char
*location_;
41
};
42
43
class
MINI_LLVM_EXPORT
Lexer
{
44
public
:
45
explicit
Lexer
(
const
char
*current);
46
47
~Lexer
();
48
49
Lexer
(
Lexer
&&) noexcept;
50
Lexer
&operator=(
Lexer
&&) noexcept;
51
52
std::optional<
Token
>
lastToken
();
53
Token
nextToken
();
54
55
private:
56
class Impl;
57
58
std::unique_ptr<Impl> impl_;
59
};
60
61
MINI_LLVM_EXPORT
std::vector<
Token
>
lex
(const
char
*source);
62
63
}
// namespace mini_llvm::ir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
Token.h
mini_llvm::ir::LexException::location
const char * location() const
Definition
Lexer.h:30
mini_llvm::ir::LexException::message
std::string && message() &&
Definition
Lexer.h:26
mini_llvm::ir::LexException::LexException
LexException(std::string message, const char *location)
Definition
Lexer.h:19
mini_llvm::ir::LexException::what
const char * what() const noexcept override
Definition
Lexer.h:34
mini_llvm::ir::LexException::message
const std::string & message() const &
Definition
Lexer.h:22
mini_llvm::ir::Lexer::Lexer
Lexer(Lexer &&) noexcept
mini_llvm::ir::Lexer::Lexer
Lexer(const char *current)
mini_llvm::ir::Lexer::~Lexer
~Lexer()
mini_llvm::ir::Lexer::lastToken
std::optional< Token > lastToken()
mini_llvm::ir::Lexer::nextToken
Token nextToken()
mini_llvm::ir
Definition
Argument.h:13
mini_llvm::ir::lex
MINI_LLVM_EXPORT std::vector< Token > lex(const char *source)
mini_llvm::ir::Token
Definition
Token.h:15
include
mini-llvm
ir_reader
Lexer.h
Generated by
1.17.0