40 YUME_ASSERT(other.file ==
file,
"Cannot add locations in different files");
41 auto [min_begin_line, min_begin_col] =
43 auto [max_end_line, max_end_col] = std::max(std::pair{
end_line,
end_col}, std::pair{other.end_line, other.end_col});
44 return Loc{min_begin_line, min_begin_col, max_end_line, max_end_col,
file};
49 if (
file !=
nullptr) {
50 if (
auto filename =
string{
file}; filename.front() ==
'<' && filename.back() ==
'>') {
54 ss << fs::path(
file).stem().native();
94 case Word:
return "Word";
95 case Skip:
return "Skip";
96 case Symbol:
return "Symbol";
97 case Literal:
return "Literal";
98 case Number:
return "Number";
99 case Char:
return "Char";
100 case Separator:
return "Separator";
101 case EndOfFile:
return "End of File";
112 [[nodiscard]]
auto is_a(
const std::pair<Type, Atom>& type_atom)
const ->
bool {
113 return type == type_atom.first &&
payload == type_atom.second;
121 friend auto operator<<(llvm::raw_ostream& os,
const Token& token) -> llvm::raw_ostream&;
130auto tokenize(std::istream& in,
const string& source_file) -> vector<Token>;
auto tokenize_preserve_skipped(std::istream &in, const string &source_file) -> vector< Token >
Consume the contents of the input stream and create corresponding tokens, preserving every token,...
auto tokenize(std::istream &in, const string &source_file) -> vector< Token >
Consume the contents of the input stream and create corresponding tokens, ignoring insignificant whit...
Represents a location in source code, as a range starting at a line and column and ending at some oth...
auto to_string() const -> string
auto valid() const -> bool
auto single() const -> Loc
Return a new Loc which refers to the first character of the current Loc.
constexpr auto operator<=>(const Loc &other) const noexcept=default
constexpr auto operator+(const Loc &other) const noexcept -> Loc
Create a new location representing the "union" of two locations.
A categorized token in source code, created by the tokenizer. These tokens are consumed by the lexer.
constexpr Token(Type type, Payload payload, int i, Loc loc) noexcept
constexpr Token(Type type, Payload payload) noexcept
static auto constexpr type_name(Type type) -> const char *
friend auto operator<<(llvm::raw_ostream &os, const Token &token) -> llvm::raw_ostream &
constexpr Token(Type type)
auto is_a(const std::pair< Type, Atom > &type_atom) const -> bool
#define YUME_ASSERT(assertion, message)