seriously disabled Posted June 16, 2008 Posted June 16, 2008 Do you know some books who teach you how to write interpreters?
Adrian Posted July 8, 2008 Posted July 8, 2008 Read up on Extended Backus–Naur Form (EBNF). There are many Programming Language Concept books out there that have many examples on how to do that.
bascule Posted July 8, 2008 Posted July 8, 2008 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?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now