mirror of
https://github.com/mrkite/regs.git
synced 2024-11-29 04:49:16 +00:00
35 lines
545 B
C
35 lines
545 B
C
|
/** @copyright 2020 Sean Kasun */
|
||
|
#pragma once
|
||
|
|
||
|
#include <string>
|
||
|
|
||
|
enum TokenType {
|
||
|
END, ENUM, NUMBER, SYMBOL, STRING, STRUCT, UNION, VAR,
|
||
|
};
|
||
|
|
||
|
struct Token {
|
||
|
TokenType type;
|
||
|
std::string asStr;
|
||
|
char asSym = 0;
|
||
|
int32_t asNum = 0;
|
||
|
std::string filename;
|
||
|
int curLine;
|
||
|
bool expect(char ch);
|
||
|
bool expect(const char *chs);
|
||
|
};
|
||
|
|
||
|
struct File {
|
||
|
char *p;
|
||
|
char *prev;
|
||
|
char *end;
|
||
|
std::string name;
|
||
|
int curLine;
|
||
|
|
||
|
Token token();
|
||
|
void reset();
|
||
|
|
||
|
private:
|
||
|
void skipWhitespace();
|
||
|
TokenType checkKeywords(std::string keyword);
|
||
|
};
|