GFN on DLR

Over the past few weeks I have been developing a version of Joel Pobar’s GFN language that utilizes the DLR framework. I have modified Joel’s grammar for the GFN language to make it similar to that of Visual Basic grammar. Here is the updated grammar


<stmt> := Dim <ident> = <expr>
    | <ident> = <expr>
    | For <ident> = <expr> To <expr> <stmt> End
    | Read <ident>
    | Print <expr>


<expr> := <string>
    | <int>
    | <bin_expr>
    | <ident>


<bin_expr> := <expr> <bin_op> <expr>
<bin_op> := + | – | * | /


<ident> := <char> <ident_rest>*
<ident_rest> := <char> | <digit>


<int> := <digit>+
<digit> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9


<string> := ” <string_elem>* ”
<string_elem> := <any char other than “>


 


Through this process I have discovered that developing a language is both an easy and difficult task. I say that it was a difficult task because of the complexity of most examples available on the internet such as IronPython. My rationale behind developing this version of the GFN language is to provide a more simple example of how to develop a language using the Dynamic Language Runtime.


In the coming weeks I will exploring and implementing new features such as user-defined functions, variable scoping, and classes. For those of you who are interested Kathy Kam has already outlined how to incorporate BCL calls from the original GFN source in her blog post Augmenting to the Good For Nothing Compiler.


 


The solution which contains both a C# and VB.Net version of Joel’s code and mine can be found here.


Edit – 1/09/2009 updated source code

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>