#ifndef COMDEL_LEXER_H #define COMDEL_LEXER_H #include "parsecontext.h" #include "presult.h" #include "sourceerror.h" #include "token.h" #include #include #include struct LexerResult { std::vector tokens; std::vector errors; }; class ComdelLexer { enum Radix { BIN_NUMBER = 2, DEC_NUMBER = 10, HEX_NUMBER = 16 }; std::string source; std::vector tokens; std::vector errors; ParseContext* parseContext; unsigned fileId; public: ComdelLexer(std::string fileName, std::string source, ParseContext* parseContext); LexerResult tokenize(); private: void skipWhitespace(); unsigned takeNumberInRadix(Radix radix); unsigned takeHexColor(); bool digitIsValid(char ch, Radix radix); Radix takeRadix(); PResult nextTokenType(); Position tokenBegin; Position position; char ch; void skipComment(); bool skipMultilineComment(); PResult takeString(); PResult takeRawString(); void bump(unsigned count = 1); char peek(); bool eof(); }; #endif // COMDEL_LEXER_H