14class Lexer :
public fe::Lexer<3, Lexer> {
15 using Super = fe::Lexer<3, Lexer>;
20 Lexer(
AST&, std::istream&,
const fs::path*
path =
nullptr, std::ostream* md =
nullptr);
23 const fs::path*
path()
const {
return loc_.path; }
28 auto res = Super::next();
30 if (res == fe::utf8::EoF) {
34 bool success = fe::utf8::encode(*md_, res);
35 assert_unused(success);
41 Tok tok(
Tok::Tag tag) {
return {loc_, tag}; }
45 std::optional<Tok> parse_lit();
46 void parse_digits(
int base = 10);
47 bool parse_exp(
int base = 10);
49 bool start_md()
const {
return ahead(0) ==
'/' && ahead(1) ==
'/' && ahead(2) ==
'/'; }
50 void emit_md(
bool start_of_file =
false);
52 if (md_) *md_ <<
"```\n";
58 fe::SymMap<Tok::Tag> keywords_;
60 friend class fe::Lexer<3,
Lexer>;
Lexer(AST &, std::istream &, const fs::path *path=nullptr, std::ostream *md=nullptr)
Creates a lexer to read *.mim files (see Lexical Structure).