• #include

    From Mr Flibble@21:1/5 to All on Sat Mar 22 18:04:18 2025
    Hi!

    Support for the equivalent of #include has been added to "neos" the
    universal compiler that can compile any programming language:

    class source_package_import : public
    semantic_concept<source_package_import>
    {
    // types
    public:
    using data_type = neolib::string;
    // construction
    public:
    source_package_import() :
    semantic_concept{ "source.package.import", neos::language::emit_type::Infix }
    {
    }
    // emit
    public:
    bool can_fold() const override
    {
    return holds_data();
    }
    bool can_fold(const i_semantic_concept& aRhs) const override
    {
    return aRhs.name() == "source.package.name";
    }
    // emit
    protected:
    void do_fold(i_context& aContext,
    neolib::i_ref_ptr<i_semantic_concept>& aResult) override
    {
    language::source_fragment file{ data<neolib::string>() };
    file.set_imported();
    aContext.load_fragment(file);
    aContext.compiler().compile(std::move(file));
    }
    void do_fold(i_context& aContext, const i_semantic_concept& aRhs, neolib::i_ref_ptr<i_semantic_concept>& aResult) override
    {
    data<neolib::string>() = aRhs.data<neolib::i_string>();
    aResult.reset(this);
    }
    };

    /Flibble

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)