A few steps:
First, build the lexer and parser. This is really easy to do with common tools such as lex and yacc, or using a more modern framework such as Antlr (which is what I recommend). These tools will generate source code for your target language that you can then compile and include in your project.
The lexer and parser will build the internal representation of the source file. There are a few different ways of approaching this:
- In the bytecode model, the source file is compiled into a low-level internal language, for which you write a bytecode interpreter that directly executes the operations. This is the way that Perl and the .NET languages work, for example.
- In the object tree model, the source file is compiled into an object tree where every object knows how to execute itself. Once parsing is completed, you just call
Exec()
on the root object (which in turn calls Exec()
on its children, etc.). This is basically the method that I use for my interpreted domain-specific language Phonix.