Hydrogen/include/types.hpp

37 lines
864 B
C++

#pragma once
#include <string>
#include <vector>
#include "syntax/token.h"
struct scanner_cursor_t {
std::string source;
std::string::size_type current;
std::string::size_type guard;
int length;
int line; // 扫描器当前所在的行
int column; // 扫描器当前所在的列
char space_prev; // 记录空行,注释前的上一个字符
char space_next;
};
struct module_t {
std::string source;
scanner_cursor_t s_cursor;
std::vector<token_t> token_list;
module_t(std::string source)
: source(source) {
s_cursor.source = source;
s_cursor.line = 1;
s_cursor.column = 1;
s_cursor.length = 0;
s_cursor.current = 0;
s_cursor.guard = 0;
s_cursor.space_prev = '\0';
s_cursor.space_next = '\0';
}
};