gsc-tool/include/xsk/gsc/lexer.hpp

34 lines
651 B
C++
Raw Normal View History

// Copyright 2024 xensik. All rights reserved.
2023-01-23 17:31:08 -05:00
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
#include "xsk/gsc/common/types.hpp"
2023-01-23 17:31:08 -05:00
namespace xsk::gsc
{
class lexer
{
context const* ctx_;
lookahead reader_;
2023-01-23 17:31:08 -05:00
location loc_;
usize buflen_;
spacing spacing_;
2023-01-23 17:31:08 -05:00
bool indev_;
std::array<char, 0x1000> buffer_;
2023-01-23 17:31:08 -05:00
public:
lexer(context const* ctx, std::string const& name, char const* data, usize size);
auto lex() -> token;
2023-01-23 17:31:08 -05:00
private:
auto push(char c) -> void;
2023-01-23 17:31:08 -05:00
auto advance() -> void;
auto linewrap() -> void;
2023-01-23 17:31:08 -05:00
};
} // namespace xsk::gsc