2023-01-23 17:31:08 -05:00
|
|
|
// Copyright 2023 xensik. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a GNU GPLv3 license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-03-02 10:41:32 -05:00
|
|
|
#include "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
|