diff options
| author | Fuwn <[email protected]> | 2022-07-03 19:44:59 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-07-03 19:44:59 -0700 |
| commit | 9ab0f74aa643dc5d27508e9b2043f0c476f8f928 (patch) | |
| tree | 28865c9003efc06615258a965b1d766386fb8805 /src/parser.hh | |
| parent | fix(cli): initialise padding (diff) | |
| download | cait-9ab0f74aa643dc5d27508e9b2043f0c476f8f928.tar.xz cait-9ab0f74aa643dc5d27508e9b2043f0c476f8f928.zip | |
chore(ninja): rename src_dir
Diffstat (limited to 'src/parser.hh')
| -rw-r--r-- | src/parser.hh | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/parser.hh b/src/parser.hh deleted file mode 100644 index 4c10a28..0000000 --- a/src/parser.hh +++ /dev/null @@ -1,90 +0,0 @@ -// This file is part of Cait <https://github.com/Fuwn/cait>. -// Copyright (C) 2022-2022 Fuwn <[email protected]> -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// -// Copyright (C) 2022-2022 Fuwn <[email protected]> -// SPDX-License-Identifier: GPL-3.0-only - -#ifndef PARSER_HH -#define PARSER_HH - -#include <exception> -#include <stdexcept> - -#include "lexer.hh" -#include "node.hh" - -namespace cait { - -using node_tree = std::vector<node::node_set>; - -class parser_exception : public std::runtime_error { -public: - explicit parser_exception(const std::string &); - virtual auto x() -> void; -}; - -struct token_bundle { -private: - using token_t = token; - -public: - std::size_t &j; - token_t &token; - std::vector<token_t> &parsed_token_line; - std::vector<token_t> &token_line; - - token_bundle(std::size_t &, token_t &, std::vector<token_t> &, - std::vector<token_t> &); -}; - -// https://stackoverflow.com/a/25652548/14452787 -template <typename T> struct range_t { -private: - T _begin, _end; - -public: - range_t(T, T); - T begin(); - T end(); -}; - -// https://stackoverflow.com/a/25652548/14452787 -template <typename T> range_t<T> range(T, T); - -class parser { -private: - token_tree _tree; - node_tree _nodes; - - auto fix_tree(token_tree &) -> void; - auto prune_empty_token_lines() -> void; - static auto token_parse_build_declaration(token_bundle) -> void; - static auto token_parse_rule_variable(token_bundle) -> void; - static auto token_parse_include_subninja_declaration(token_bundle) -> void; - static auto token_parse_default_declaration(token_bundle) -> void; - static auto token_parse_rule_pool_declaration(token_bundle) -> void; - static auto token_parse_assignment_operator(token_bundle) -> void; - -public: - explicit parser(token_tree &); - [[nodiscard]] auto tree() const noexcept -> const token_tree &; - [[nodiscard]] auto nodes() const noexcept -> const node_tree &; - auto generate_nodes(const std::string &, - const std::vector<std::string> &) noexcept(false) -> void; -}; - -} // namespace cait - -#endif // PARSER_HH |