Re: .NET Compiler for Interactive Fiction

Neelakantan Krishnaswami <neelk@alum.mit.edu>
24 Feb 2003 17:43:17 -0500

          From comp.compilers

Related articles
.NET Compiler for Interactive Fiction david.cornelson@iflibrary.com (David A. Cornelson) (2003-02-21)
Re: .NET Compiler for Interactive Fiction marcov@toad.stack.nl (Marco van de Voort) (2003-02-24)
Re: .NET Compiler for Interactive Fiction neelk@alum.mit.edu (Neelakantan Krishnaswami) (2003-02-24)
Re: .NET Compiler for Interactive Fiction david.cornelson@iflibrary.com (David A. Cornelson) (2003-03-09)
Re: .NET Compiler for Interactive Fiction tbandrow@unitedsoftworks.com (2003-03-09)
Re: .NET Compiler for Interactive Fiction neelk@alum.mit.edu (Neelakantan Krishnaswami) (2003-03-14)
Re: .NET Compiler for Interactive Fiction lars@bearnip.com (2003-03-14)
Re: .NET Compiler for Interactive Fiction david.cornelson@iflibrary.com (David A. Cornelson) (2003-03-14)
Re: .NET Compiler for Interactive Fiction marcov@toad.stack.nl (Marco van de Voort) (2003-03-14)
[24 later articles]
| List of all articles for this month |
From: Neelakantan Krishnaswami <neelk@alum.mit.edu>
Newsgroups: comp.compilers
Date: 24 Feb 2003 17:43:17 -0500
Organization: AT&T Broadband
References: 03-02-125
Keywords: design
Posted-Date: 24 Feb 2003 17:43:17 EST

David A. Cornelson <david.cornelson@iflibrary.com> wrote:
>
> But this is sort of a funny project, because the new language doesn't
> necessarily need to be complete. The idea (im my mind), is to build a syntax
> that authors can use to create a world model and the logic of the world
> model. The emphasis is on text, not objects.
>
> ....they would want to write something like this (just an example):
>
> class Kitchen : IF Room {
> description: "This is the kitchen.";
> go_east: LivingRoom;
> }
>
> ....and even this seems like too much "programming" to me....
>
> I'm trying to determine if there is a way to build a language syntax
> that is more english-oriented.


It sounds like what you want is a macro system, that takes a domain-
specific syntax and expands it into C# code. The tool that is probably
best suited for your needs is Claus Brabrand's metafront. Here's an
example of how you could use it to define a foreach statement in Java:


    language ForEach extends Java {
        Statement[foreach] -->
            foreach( <Type> <Identifier> in <Expression> ) <Statement> ;
    }


    morph ForEach2Java: ForEach ==> Java {
        Statement[foreach](T,I,E,S) T()=>T,E()=>E,S()=>S ==>
          << {
                    Iterator iterator = (<E>).iterator();
                    while (iterator.hasNext()) {
                            <T> <I> = (<T>) iterator.next();
                            <S>
                    }
                } >>
    }


It operates in terms of grammars, unlike the C preprocessor, so your
extensions look and behave naturally. Plus programmers can "dip into"
your host language if your DSL isn't powerful enough. I don't think it
comes with a C# grammar predefined, but it does have a Java grammar,
which you could probably use as a model to make a C# parser.


You can find it at: <http://www.brics.dk/metafront/>
--
Neel Krishnaswami
neelk@alum.mit.edu


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.