Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 694439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:51:24+00:00 2026-05-14T02:51:24+00:00

In my interpreter I have built-in functions available in the language like print exit

  • 0

In my interpreter I have built-in functions available in the language like print exit input, etc.
These functions can obviously be accessed from inside the language. The interpreter then looks for the corresponding function with the right name in a vector and calls it via a pointer stored with its name.

So I gather all these functions in files like io.cpp, string.cpp, arithmetic.cpp. But I have to add every function to the function list in the interpreter in order for it to be found.

So in these function files I have things like:

void print( arg )
{
     cout << arg.ToString;
}

I’d add this print function to the interpreter function list with:

interpreter.AddFunc( "print", print );
  • But where should I call the interpreter.AddFunc?

I can’t just put it there below the print function as it has to be in a function according to the C++ syntax.

  • Where and how should all the functions be added to the list?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:51:24+00:00Added an answer on May 14, 2026 at 2:51 am

    In each module (io, string, etc.), define a method that registers the module with the interpreter, e.g.:

    void IOModule::Register(Interpreter &interpreter) {
        interpreter.AddFunc( "print", print );
        //...
    }
    

    This can also be a normal function if your module is not implemented in a class.

    Then in your application’s main initialization, call the register method of all modules.

    This approach helps keep things modular: The main application initialization needs to know which modules exist, but the details of which functions are exported are left to the module itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to have real-time access to both interpreter input and error and standard
Two part question: Do browsers have a built-in CSS interpreter like they do for
So, I have installed the pypy pre-built interpreter to my home folder in windows;
I have a constructor that looks like this (in c++): Interpreter::Interpreter() { tempDat ==
In the interpreter for my experimental programming language I have a symbol table. Each
when I write Python code from the interpreter I can type dir() to have
I'm makin' a scripting language interpreter using PHP. I have this code in that
Does Eclipse come with a built-in interpreter? If not is there anything like IDLE
I have successfully built a parser/lexer that creates an AST for my language. Yeah!!
I have an script interpreter that is spawn by a deamon and has to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.