1 #ifndef TAN_READER_READER_H
2 #define TAN_READER_READER_H
4 #include "base/container.h"
13 void open(
const str &filename);
14 void from_string(
const str &code);
17 [[nodiscard]]
size_t size()
const {
return _lines.size(); }
22 [[nodiscard]] str
get_line(
size_t index)
const;
23 [[nodiscard]]
char at(
const SrcLoc &ptr)
const;
56 [[nodiscard]] str get_filename()
const;
60 str _filename =
"memory";
78 bool operator==(
const SrcLoc &other)
const;
79 bool operator!=(
const SrcLoc &other)
const;
80 bool operator<=(
const SrcLoc &other)
const;
81 bool operator<(
const SrcLoc &other)
const;
82 bool operator>(
const SrcLoc &other)
const;
100 SourceSpan(
const SourceFile *src, uint32_t start_line, uint32_t start_col, uint32_t end_line, uint32_t end_col);
103 [[nodiscard]]
const SrcLoc &start()
const;
104 [[nodiscard]]
const SrcLoc &end()
const;
bool is_cursor_valid(const SrcLoc &c) const
Check if a cursor is in bound.
SrcLoc begin() const
The start of source file (inclusive).
str get_line(size_t index) const
Return source at a specific line.
str substr(const SrcLoc &start) const
Get a substring from start to the end of the current line.
SrcLoc end() const
The end of source file (exclusive).
size_t size() const
Return the number of lines of code of the current file.
SrcLoc forward(SrcLoc c)
Return a copy of code_ptr that points to the next character.
A span of source code tokens, inclusive on both ends.