Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
How do I create my own programming language and a compiler for it

Note: This is not a possible duplicate; it is more specified.

What is the first step into making your own programming language? Is it something you jump into, or are there steps you must take? Thanks!

share|improve this question
Maybe not too helpful, but I recommend going through sites.google.com/site/steveyegge2/blog-rants (Steve Yegge's blog), and steve-yegge.blogspot.com/ (Steve Yegge's other blog). –  KK. Oct 24 '11 at 13:20
Learn as many programming languages as you can. That way you will learn from their concepts as well as their mistakes. Why be content with dwarfs, when you can stand on the shoulder of giants? –  sbi Oct 24 '11 at 13:54
Hi perl.j, if you haven't found an answer that helps you yet, you'll want to offer a bounty. Creating duplicate questions is not the way to get more answers. –  user8 Oct 31 '11 at 22:53
@MarkTrapp: Thanks for the advice. But How can I get this question re-opened. –  Dynamic Oct 31 '11 at 23:18
@ChrisF : Can I get this re-opened? –  Dynamic Nov 15 '11 at 11:19
show 4 more comments

marked as duplicate by Jonas, FrustratedWithFormsDesigner, Glenn Nelson, ChrisF Oct 24 '11 at 14:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers

My first suggestion would be to Read the Dragon Book by Aho. http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886

share|improve this answer
If you want to scare a beginner off straight away, that's the right book. If you want to become versed in all the equally usable parsing techniques, and do not care about the rest of the compilation chain - start with this book. Otherwise you'd need more modern and more practical texts. –  SK-logic Oct 24 '11 at 10:15
add comment

ANTLR is a good starting point. It's a language generating framework, similar to Lex and Yacc. There's a gui called ANTLRWorks that simplifies the process.

In the .NET world there the Dynamic Language Runtime which can be used to generate code in the .NET world. I've written an expression language called Zentrum that generates code using the DLR. It will show you how to parse and execute statically and dynamically typed expressions.

share|improve this answer
add comment

If you are on Unix/Linux, you can get information about dedicated tools: lex, yacc and bison.

share|improve this answer
Would you please explain? –  Dynamic Oct 24 '11 at 10:24
lex is a lexical analyzer generator. yacc stands for Yet Another Compiler Compiler. bison is the GNU yacc. All these tools make life easier when it comes to build a new language and its associated compiler. –  mouviciel Oct 24 '11 at 10:27
@perl.j: You can use JavaCC for Java. –  Jonas Oct 24 '11 at 10:50
@perl.j, you can use all that tools on windows too –  SK-logic Oct 24 '11 at 12:00
flex and byacc/bison for scanning and parsing (actually, I prefer ragel to flex). treecc for AST-node handling, maybe. llvm for back-end code generation - the kaleidoscope tutorial is easy enough to follow IMO. If you want to generate high-level code (e.g. C), one shortcut is to use XSLT templates for some of that, using a library like libxslt. All of these tools and libraries (in recent versions) should work with *nix and Windows. –  Steve314 Oct 24 '11 at 13:13
show 5 more comments

Take a look:


It seems that it is not an easy solution.

share|improve this answer
I understand it isn't easy. But who says everything I do can't be difficult... –  Dynamic Oct 24 '11 at 10:07
In fact, it is much easier than it is commonly portrayed, especially with the modern tools. Of course, C++ is one of the worst possible choices of an implementation language, but even with it, the problem is not nearly as big as people would think. Take a look at the Kaleidoscope tutorial of the LLVM project - it is fairly trivial but yet quite a capable language. –  SK-logic Oct 24 '11 at 10:18
@SK-logic: Would you mind explaining how I may get started with making one? –  Dynamic Oct 24 '11 at 10:22
@perl.j, follow the tutorial: llvm.org/docs/tutorial (and, of course, read an introductory book, like Grune, "Modern Compilers Design"). –  SK-logic Oct 24 '11 at 10:25
@SK-logic - I'm a big fan of the Grune book, and of llvm. I'm not sure I agree with "one of the worst possible choices", though. Objective CAML or Haskell may be better for someone with the right skillset. C# and Python both have interesting features. But there's so many reliable tools written for C and C++, with so much good information out there. The worst thing using C++ is probably that you end up dealing with a lot of C-style code. –  Steve314 Oct 24 '11 at 13:23
show 1 more comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.