Making your own programming language...

Programming, for all ages and all languages.
Andrew_Baker

Re:Making your own programming language...

Post by Andrew_Baker »

If you want to make the language just for practice, and not any particular practical reason, you could make a virtual machine. My Java textbook had a VM as a project throughout the whole book. Basically, you design a virtual computer and its instruction set and let it rip. This would probably fall into scripting languages instead of compiled languages, but if you just need some toy project to sharpen your axe, it would be very manageable, and you could write it in whatever language you wanted.
CrYpTiC

Re:Making your own programming language...

Post by CrYpTiC »

So it would be easier to learn languages inorder to make languages? What langauges do you suggest? Assembly? C++? Perl?
Andrew_Baker

Re:Making your own programming language...

Post by Andrew_Baker »

For raw power, I like C. For clarity, I prefer Python. For sheer arcane weirdness, I prefer AGI. :D
persep

Re:Making your own programming language...

Post by persep »

Andrew_Baker which java textbook do you refer with the VM project?
Andrew_Baker

Re:Making your own programming language...

Post by Andrew_Baker »

I just double-checked, and I couldn't find that project in any of my language texts. This leads me to wonder where I *did* see that project. It wasn't complicated or anything. All it did was accept data from a CLI or file, tokenize it, put it in a stack, and then used a few control structures (predominantly a switch statement for the tokens) to execute the script/code.

I DO know that a similar technique was demonstrated in Bjarne Stroustrop's The C++ Programming Language, but that was for a Reverse Polish Calculator. This exercise was very similar to the VM I originally referenced.

But now that's bugging me... Where DID I see that project?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

-- Stu --
lacrymology

Re:Making your own programming language...

Post by lacrymology »

My advise would be to first read whatever you can get your hands on about:

Lex and Yacc

or

Flex and Bison

or

JavaCC

These tools allow you to worry about the grammar of your language first without having to worry about building your own scanner and parser. With a useable grammar you can have a basic parser up and verifying your language within (relatively) no time. If you want to then write your own parser, then you can go back and write it in any language that you'd like (Lex, Yacc, Flex, and Bison use C).

The point is, don't immerse yourself in programming assembly parsers right now... take it slowly and start from the grammar. Once you have a sensible solution there, then start worrying about the full blown implementation.

-m

CrYpTiC wrote: I've always been interested in making my own programming language, but... where would I start. If you wanted to make your own custom programming language, what would you use to make it? Another language? That's where I've always come to a slump...Any answers will help very much.
Post Reply