35 lines
725 B
C++

#ifndef SCANNER_HH
#define SCANNER_HH
#include "token.hh"
#include <cstddef>
#include <vector>
#include <string>
#include <unordered_map>
struct Scanner {
Scanner(const std::string &code);
std::vector<Token> scan_tokens();
bool is_at_end();
bool is_digit(char c);
bool is_alpha(char c);
bool is_alphanumeric(char c);
void scan_token();
char advance();
bool match(char expected);
char peek();
char peek_next();
void add_token(TokenType type);
void add_token(TokenType type, Object literal);
void string();
void number();
void identifier();
std::string code;
std::vector<Token> tokens;
std::size_t start, current, line;
std::unordered_map<std::string, TokenType> keywords;
};
#endif