XPlor/libs/dsl/lexer.h

32 lines
581 B
C
Raw Normal View History

2026-01-01 22:18:25 -05:00
#ifndef LEXER_H
#define LEXER_H
#include "Token.h"
class Lexer {
public:
explicit Lexer(QString src);
const Token& peek() const { return m_cur; }
Token next(); // consume current and advance
bool match(TokenKind k);
Token expect(TokenKind k, const char* msg);
private:
Token lexOne();
void skipWsAndComments();
QChar ch(int i = 0) const;
void advance(int n = 1);
Token make(TokenKind k, QString t = QString());
QString m_src;
int m_i = 0;
int m_line = 1;
int m_col = 1;
Token m_cur;
};
#endif // LEXER_H