C # Interpreted Language

I want to write an interpreted language in C #, where do I start? I know how I would do it using weighted string parsing, but what's the correct way?

+1


source to share


3 answers


This can be a pretty tricky attempt to get it right.

If you have little knowledge of compiler theory, you should start reading about it first.
Just by using "funny string parsing", if I understand the term correctly, you will not succeed at all.



The first basic step is to write a grammar for the language that defines the valid syntax for the language.
A tool like ANTLR will help you collect the pieces, but I would suggest reading the Book of the Dragon as it is the canonical starting point to get up to speed on this matter.

+8


source


If you want to build an interpreted language in .NET DLR is the way to go - check out the Martin Maly LOLCODE sample at http://www.iunknown.com/2007/11/lolcode-on-dlr.html



Edit: Here's another link with more information from Scott Hanselman: http://www.hanselman.com/blog/TheWeeklySourceCode11LOLCodeDLREdition.aspx

+3


source


Checkout the Phoenix compiler from Microsoft. This will provide many of the tools needed to build a compiler targeting native or managed environments. Among these tools, we will optimize the back end.

Cyknus's second suggestion for reading Aho Sethi and Ulman "The Book of the Dragon" ( Wikipedia , Amazon ).

RGR

0


source







All Articles