Own Programming language

Feb 11, 2012 at 11:39pm
How can I create my own programming language with c++.
Things that I need to know:
How to make the syntax, for example, make
1
2
3
4
void hi()
{
cout << "hi"
}

to:
1
2
3
4
5
start
function hi()
print(string("hi"))
end hi
stop


That was an example syntax of my ow Programming Language.
How can I make my own compiler?
And can I make it non OO?
Feb 12, 2012 at 12:18am
closed account (zb0S216C)
Based on the fact that you want to use C++ as the underlying language, it sounds like you want a scripting language. If that is the case, you should lookup parsing[1]. If not, then you're diving into a whole lot of things, such as:

-Lexical Analysis
-Parse Trees
-Knowledge on computers (RAM, CPU)
-Compiler optimisations
-DMA (if supported)
-Stacks
-Segments
-Pointers (if supported)

...and the list goes on.

Good luck; you're going to need it.

References:
[1] http://en.wikipedia.org/wiki/Parsing


Wazzak
Feb 12, 2012 at 12:18am
Hi,

You might have a look at other Programming language source code written in C( or C++).

For examples, download PHP and JavaScript source code and see how they are coded.

hope it helps
Feb 12, 2012 at 12:40am
@Framework

Thanks, but that's not what i'm looking for. How can I make a basic compiler?
Feb 12, 2012 at 2:03am
@Bartek
I sorry for this, but I took a look at some of your other posts, and I don't think you're quite ready for compiler development. Compiler development requires you to have very good knowledge of how computers work and the utilities the language you're working in has for string manipulation. Take it from a former compiler developer. :/

Also, why exactly would you want to make a new language? What would it offer that current languages don't already?

If you'd like to try it, then I guess you could try, but you might wind up with quite a headache.

-Albatross
Feb 12, 2012 at 2:31am
@Alb, I'm bored...
Feb 12, 2012 at 4:49am
> I'm bored...

Get interested in Boost.Spirit and you could alleviate your boredom (on a fairly long term basis).
http://www.boost.org/doc/libs/1_48_0/libs/spirit/doc/html/spirit/introduction.html

Feb 12, 2012 at 6:46am
for an extremely simple example, try looking into the brainfuck language. It was made to have a ridiculously small compiler.
Feb 12, 2012 at 11:54am
Seriously i wouldn't recomend boost::spirit for a c++ beginner. It's fairly easy to use only with solid c++ skills.

Learn about grammars and AST and try to do a simple interpreter.

Then look at spirit or flex/bison or whatsoever...
Topic archived. No new replies allowed.