Jump to content

Books on interpreter construction


Recommended Posts

  • 4 weeks later...

It really depends on what kind of language you're trying to write and what kind of interpreter you're trying to write.

 

The very first thing you'll need to do is scan/parse the input you're trying to interpret into some kind of abstract form. This will require learning a little bit about languages.

 

I learned how to do this from the Definitive ANTLR Reference. ANTLR is a parser generator tool written in Java, although the book contains a good introduction to languages and language recognition in general. After you read the section on languages you'll hopefully understand the differences between regular and context-free languages, both of which you'll need to understand if you wish to write or generate a scanner and parser.

 

There's several tools to generate scanners and parsers. ANTLR is certainly one, but more common ones are lex and yacc (or their modern successors flex and bison). The parser will spit out input programs in an abstract, tree-structured form, known as an Abstract Syntax Tree.

 

Once you have your program represented as AST, there's several strategies to interpreting it. The most straightforward is to use a tool like LLVM to compile your language to machine code.

 

Here's a tutorial on making your own language using LLVM:

 

http://llvm.org/docs/tutorial/LangImpl1.html

 

Oh, have I mentioned I'm making my own language? :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.