- #pragma once
- #include <charconv>
- #include <concepts>
- #include <functional>
- #include <memory>
- #include <optional>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <variant>
- #include <vector>
-
- #include "molasses/lexer.h"
- #include "parser_types.h"
-
-
- enum class architecture_t {
- x86_64_linux,
- x86_linux
- };
-
- #if defined(__x86_64__) && __linux__
- constexpr architecture_t architecture = architecture_t::x86_64_linux;
- constexpr size_t architecture_ptr_size = 8;
- #elif defined(__i386) || defined(__i386__) || defined(i386) && __linux__
- constexpr architecture_t architecture = architecture_t::x86_linux;
- constexpr size_t architecture_ptr_size = 4;
- #endif
-
- namespace molasses {
- std::vector<std::string> operator>>(std::vector<std::string> current_stack, const operation& next_op);
-
- struct parser_context {
- std::vector<std::shared_ptr<type>> types;
- std::vector<std::shared_ptr<operation>> operations;
- std::vector<std::shared_ptr<procedure_operation>> procedures;
-
- [[nodiscard]] std::shared_ptr<type> lookup_type(const std::string&) const;
- [[nodiscard]] std::shared_ptr<operation> lookup_operation(const std::string&) const;
- };
-
- struct generate_context {
- lexed_output lexer;
- parser_context parser;
- std::vector<std::shared_ptr<procedure_operation>> procedures;
- };
-
- std::optional<int32_t> try_parse_int32(const std::string& str);
-
- generate_context parse(parser_context, const lexed_output&);
- std::vector<std::string> generate(const generate_context&);
-
- parser_context register_integers(parser_context);
-
- template<architecture_t Arch = architecture>
- parser_context register_i32_operations(parser_context);
-
- bool type_check(const parser_context&, const lexed_output&, const std::vector<symbol>&, std::vector<std::string> execution_input, const std::vector<std::string>& execution_output);
- }
-
|