• #include

    From Mr Flibble@flibble@reddwarf.jmc.corp to comp.lang.c++ on Sat Mar 22 18:04:18 2025
    From Newsgroup: comp.lang.c++

    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
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.c++ on Mon Mar 24 13:44:37 2025
    From Newsgroup: comp.lang.c++

    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

    --- Synchronet 3.20c-Linux NewsLink 1.2