Create a Programming language

Started by
11 comments, last by GameMasterXL 18 years, 7 months ago
Hey, I have been interested in programming for a little bit now. So, I looked at C++ and am learning that and I am getting kind of far into it. Now, I see lots of new programmers come into this world but they leave fast cause they find a language that is simple to use and everything! Well, I am hoping to make a SIMPLE programming language. I mean simple as in really nothing advanced. Then, when I start desining(sorry, I am not very good at spelling)it I will make some simple stuff. Just to get people a simple language to start out with. Now, I here it is SIMPLE to design a language. Just write it down on a sheet of paper. Then, I here it is HARD to make the language, as you have to create a compiler(I think I herd that.)So, if someone could point me to a tutorial or some possible links that will get me going in the right direction. I am hoping to spend sometime developing it, before I actually start doing the compiler. I want the language to be thoght through very well. So, if someone could point me in the right direction, then that would rock! Thanks, Chad.
Advertisement
Check out bison and flex, which is what I've typically used for this type of thing.

A friend of mine really likes PRECC http://vl.fmnet.info/precc/
Thanks man!


Anyone else?
Boost.Spirit for parsing.
Ok. Here is what I would recommend:

1) Develop simple expression evaluator.
2) Make it have variables, define functions, etc(see my website graphing calc applet)
3) Add code blocks
4) Read the dragon book
5) Go from there
Read up on BNF and attribute grammars. It turns out it's somewhat trivial to write a parser if you formalize the language with BNF.
http://mitpress.mit.edu/sicp/full-text/book/book.html

This will teach you how to write DSL's, domain-specific languages, which are easier to write than a whole new programming language.

If that's not what you want, I suggest a language that has minimal syntax: something like Forth or Lisp would appropriate. Their syntaxes are so dead simple that you shouldn't waste too much time writing it.
Look into GCC front ends. You'll have to write a parser and a converter to GCC's internal formats but it'll handle the rest.
Thanks everyone!

I will look into those links and look into some other stuff. Maybe if I like this idea of doing this I will try to spend a while in making my own REAL programming language that even people who know C++ or VB or something along those lines could pick up and enjoy also. But, I will just have to write this SIMPLE language first. I will look into it!


Chad
Writing a compiler for a programming language is a large and difficult project. To prepare for the big project, start with something smaller -- like something that solves math expressions.

First, with no variables:
    > (4*2^2-4*2*3)/(2^2-3^2)    1.6 
Then add variables:
    > z = (4x^2-4xy)/(x^2-y^2)    > x = 2    > y = 3    >     z = 1.6 
Also, writing an interpreter for your language rather than a compiler would cut out a lot of work.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement