diff options
Merge commit '6e19bb560d474736d45f5be011ff0830c7019991' as 'spasm'
1 files changed, 70 insertions, 0 deletions
| -rw-r--r-- | spasm/src/asm/lexer.hpp | 70 |
diff --git a/spasm/src/asm/lexer.hpp b/spasm/src/asm/lexer.hpp new file mode 100644 index 0000000..ece4a07 --- /dev/null +++ b/spasm/src/asm/lexer.hpp @@ -0,0 +1,70 @@ +#ifndef LEXER_HPP +#define LEXER_HPP + +#include <iostream> + +#include "token.hpp" + +namespace SpasmImpl +{ +// ! Namespace for all classes and functions dealing with assembler +namespace ASM +{ +//! Namespace for all lexical analisys classes +namespace Lexer +{ +/*! +** Class for lexers for the assembler-like language for spasm +*/ +class Lexer +{ + public: + Lexer(std::istream&, size_t = 4096); + ~Lexer(); + bool tokenize(TokenStream&); + + //! fills the buffer called when the lexer needs more data + void read(size_t = 1); + void buffer_init(); + + private: + Lexer(const Lexer&); + Lexer& operator=(const Lexer&); + + void buffer_grow(size_t); + + //! input stream for the lexer + std::istream* file; + + //! buffer for the lexer + char* buffer; + + //! size of the buffer + size_t buffer_size; + + //! cursor for re2c generated lexer + char* cursor; + + //! limit for re2c generated lexer + char* limit; + + //! marker for re2c generated lexer + char* marker; + + //! pointer to the start of the just recognized token + char* token_start; + + //! saves the state of the lexer + unsigned int state; + + //! current char + char yych; + + //! number of current line + size_t lineno; +}; +} // namespace Lexer +} // namespace ASM +} // namespace SpasmImpl + +#endif |
