#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #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 operator>>(std::vector current_stack, const operation& next_op); std::optional try_parse_int32(const std::string& str); std::optional try_parse_int64(const std::string& str); struct parser_context { std::vector> types; std::vector> operations; std::vector> procedures; [[nodiscard]] std::shared_ptr lookup_type(const std::string&) const; [[nodiscard]] std::shared_ptr lookup_operation(const std::string&) const; }; struct generate_context { lexed_output lexer; parser_context parser; std::vector> procedures; }; using success_t = bool; std::tuple>> interpret(interpreter_stack, generate_context, std::string ); std::optional try_parse_int32(const std::string& str); generate_context parse(parser_context, const lexed_output&); std::vector generate(const generate_context&); parser_context register_integers(parser_context); template parser_context register_i32_operations(parser_context); bool type_check( const parser_context& parser_state, const lexed_output& lexer_state, const std::vector& consumed_stream, std::vector execution_input, const std::vector& execution_output, const std::vector>& sub_bodies ); }