2024-01-14 06:11:26 -05:00
|
|
|
// 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
|
|
|
|
|
2023-05-13 13:24:57 -04:00
|
|
|
#include "xsk/gsc/common/types.hpp"
|
2023-01-23 17:31:08 -05:00
|
|
|
|
|
|
|
namespace xsk::gsc
|
|
|
|
{
|
|
|
|
|
|
|
|
class lexer
|
|
|
|
{
|
|
|
|
context const* ctx_;
|
2023-01-30 07:48:27 -05:00
|
|
|
lookahead reader_;
|
2023-01-23 17:31:08 -05:00
|
|
|
location loc_;
|
2023-01-30 07:48:27 -05:00
|
|
|
usize buflen_;
|
|
|
|
spacing spacing_;
|
2023-01-23 17:31:08 -05:00
|
|
|
bool indev_;
|
2023-01-30 07:48:27 -05:00
|
|
|
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);
|
2023-01-30 07:48:27 -05:00
|
|
|
auto lex() -> token;
|
2023-01-23 17:31:08 -05:00
|
|
|
|
|
|
|
private:
|
2023-01-30 07:48:27 -05:00
|
|
|
auto push(char c) -> void;
|
2023-01-23 17:31:08 -05:00
|
|
|
auto advance() -> void;
|
2023-01-30 07:48:27 -05:00
|
|
|
auto linewrap() -> void;
|
2023-01-23 17:31:08 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xsk::gsc
|