How to make a new scripting language in C++ ?...I need: parser,scanner,grammar,included functions,syntax.Where I can start?. I think I use JavaScript/PHP syntax.

Recommended Answers

All 5 Replies

I know you like ambitious projects:

I am going to make OS. And I need help with GUI...how to make an GUI ?...I am not on Windows so CreateWindowEx() doesn't exist.

But I suggest starting of with the easy stuff, hehe. :D

:-)...yes...:-)...I have ideas so I need to ask to you ;-)

This is a C++ forum, ask questions about C++. If you want to talk about software design in general (for instance, what merits your script will have compared to the other scripts already available), go to the Computer Science forum.. I guess.

Anyway, first define your script on paper. How will scripters create variables? How will scripters add them together?

Then write an interpreter that picks a file (or lines anyway) and parses them.

For instance, if you decided that people create integers with "int <name> = <val>;", you can decide to create a map<string, int> which will hold the users and then add one int when such a line is read.

How to make a new scripting language in C++ ?...I need: parser,scanner,grammar,included functions,syntax.Where I can start?. I think I use JavaScript/PHP syntax.

Just before you start to design grammars (the language grammar is the same thing as the language syntax ;)), scanners, parsers, libraries etc - it's a good idea to design A NEW scripting (or what else) LANGUAGE per se. Design before implement...

It's especially valued proposal if "make a new scripting language in C++" means "implement new scripting language interpreter (or JIT compiler, or both) in C++"... or in C... or in Java... or in NEW SCRIPTING LANGUAGE...

Now it looks like I don't know what is it but I want to implement this The Great Nothing in C++!
Probably, the only reasonable reaction is:
Good luck! ( return 0; in C and C++)...

Well, I guess the kid is ready to slash the mountain.
You basically want to write your own language.
There is a Bible for Compiler writing which called Dragon Book.
http://en.wikipedia.org/wiki/21st_Century_Compilers
It is a vast book. If you are dedicated to write a language, you should pay a price, i.e. Read the book.

commented: Very good information and link :) +36
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.