2#include "symbol_table.hpp"
5#include <boost/spirit/include/lex_lexertl.hpp>
6#include <boost/bind.hpp>
7#include <boost/ref.hpp>
10using BaseLexer = boost::spirit::lex::lexertl::lexer<>;
11using Iterator =
typename BaseLexer::iterator_type;
22 symbol_table::TokenID
type;
30 Lex(std::string
input,
bool from_string);
75 size_t context_lines = 2,
76 size_t max_line_width = 40,
77 size_t window_width = 20);
83 symbol_table::TokenID
type;
88 std::vector<Token> tokens_;
static std::string format_error_window(const std::string &input, size_t pos, size_t &out_err_line, size_t &out_err_col, size_t context_lines=2, size_t max_line_width=40, size_t window_width=20)
Generate a formatted snippet around an error location.
Definition lexer.cpp:65
std::string input_
Complete contents of the input file.
Definition lexer.hpp:16
std::string filename_
Path of the file being lexed.
Definition lexer.hpp:15
Token Next()
Retrieves the next token from input string in a lazy way.
Definition lexer.cpp:167
std::string & input()
Access the raw input buffer.
Definition lexer.cpp:163
Lex(std::string input, bool from_string)
Definition lexer.cpp:12
Internal helper: a regex pattern and its associated token type.
Definition lexer.hpp:82
std::string regex
The regex used to match and extract the token.
Definition lexer.hpp:84
symbol_table::TokenID type
Token ID for this pattern.
Definition lexer.hpp:83
Represents a single token produced by the lexer.
Definition lexer.hpp:21
size_t pos
Byte-offset in the input where this token starts.
Definition lexer.hpp:23
symbol_table::TokenID type
Token ID.
Definition lexer.hpp:22