• Re: #include

    From Lynn McGuire@3:633/280.2 to All on Tue Mar 25 05:44:37 2025
    On 3/22/2025 1:04 PM, Mr Flibble wrote:
    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

    But, but, but #include is part of the legacy evil of all programming languages.

    Lynn


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)