HI Interpreter

closed account (E86M92yv)
I wrote a little interpreter for windows. It does not support much.

+ Functions not allowed
+ Structures not allowed
+ Overloaded functions not supported
+ Postfix (++) not supported
+ New keyword not supported
+ Const keyword not supported
+ Static keyword not supported
+ Initializer list not supported
+ No error checking
+ You have to manually destroy the object. Call MyStruct::__destroy().
+ urany operator ! not supported
+ operator () not supported (e.g : if(cin) or if (cin >> a)). Use if(cin.fail()) instead

However, it can only support :
std::cout, std::wcout, std::cin, std::wcin, std::cerr, std::wcerr, std::clog, std::wclog

std::string, std::wstring
std::istream, std::ostream, std::iostream
std::ifstream, std::ofstream, std::fstream
std::istringstream, std::ostringstream, std::stringstream
std::stringbuf, std::filebuf, std::streambuf

std::getline()

std::setw(), std::boolalpha (manipulator)

Some basic functions (printf)
Some mathematical functions (sin cos)
Some Windows functions (MessageBoxA)
Some variable types (int char double)

A structure is supported :
HIStruct_01
Members :
HIStruct_01::display()
HIStruct_01::setA()
HIStruct_01::setB()
HIStruct_01::setC()
HIStruct_01::setD()

double a, b, c, d; (public)

The interpreter is done for. So here is my link :
http://www.mediafire.com/download/87zua0ufoz6n169/12345.zip

You use the interpreter to write something like this :
Enter code : int a;

Enter code : a = 22;

Enter code : cout << a;

The only test file is "test.txt"

You can write simple for-while loop too. Make sure the code is grammatically correct.

I'd hear your suggestions. I need to restructure my intepreter. Your input is appreciated.

Regards,
Last edited on
I'm going to start reporting every superfluous post you make, gentleguy. I encourage others to do likewise.
Please ignore gentleguy, jakatta.

Is there a particular reason you don't wish to release the source for that interpreter? It would make giving feedback on, for example, the interpreter's structure a lot easier.

-Albatross
closed account (E86M92yv)
I basically hate doing everything on a C++ complier.
I wrote this interpreter earlier without much knowledge. And my interpreter does not support many platforms.
I want to learn everything fast using my interpreter alone.
This may be my last project for life and all.

It is easier to run a sample code I generate in split second with a c++ interpreter rather than create every project for it. I don't need a 7-8 Gb IDE. Just an interpreter dozen of Mb (at most) will do the job.

I also hate exe. I don't want to generate multiple exe(s), just a single exe will do the job. And the rest is .cpp.
Well, people are afraid of testing exe just because it may contain viruses right? No problem. I predicted it would be like that anyway.
About the source code, I am not making it open source because it is something I treasure for life. But half of it can be released, though until my intepreter becomes mature and stable.
But I guarantee my interpreter can support what I have listed. Someone please be so nice to test it. Is it a good start?
There already exist C++ interpreters. Open source ones, too, and they implement pretty much the entire language.
To name an example, I bundle a C++ JIT with my image viewer application to support image filters written in C++. Behind the scenes, the code uses libclang to support compilation and dynamic loading.
I don't mean to sound negative, but unless your closed source interpreter has some extremely special feature, like amazing performance or debugging support, it's worthless. We live in the post-Clang era. Literally anyone can grab the Clang source, build one of the examples, and have a C++ JIT up and running in minutes. And that's a JIT; the performance of the compiled input program is the same as if you had compiled it with the command line compiler.

Windows binaries: https://github.com/Helios-vmg/Borderless/releases
Code to interface with libclang: https://github.com/Helios-vmg/Borderless/tree/master/src/plugin-core/Cpp
Sample program: https://github.com/Helios-vmg/Borderless/blob/master/samples/FSD.cpp (it's literally just C++ with a couple custom headers)

EDIT: To clarify, I'm saying it's worthless to Random J. Hacker. Your code may have worth to you, but given the choice between a Clang-based JIT and your interpreter, no one else would choose your implementation under any circumstances.
Last edited on
Like Helios said, there are already many C++ interpreters. One I can think of off the top of my head is CERN's Cling interpreter.

But that being said, there can be a great amount of learning that can come with doing it yourself. Having it been done before (and by so many people) means you can get far more valuable input than were it never attempted before. People know what methods are good and what ones aren't. I don't think I've ever heard someone say "It's been done before, don't bother trying".
If you want to make it, then by all means do so, and use the input you can get from the community to help you learn and improve it.

And ignore the input of people who don't have your learning interest at mind. You're likely to get critical feedback, but it will only be to help you better your skills.
Topic archived. No new replies allowed.