views:

62

answers:

1

So I have a a text file that looks something like this:

public >ret method(>input ){
    //do something with input
    .
    .
    .
    //return something of type >ret
}

I want to be able to type something like:

HelloWorld is a method that prints "hello world" using nothing as input 
    and returns nothing.  

The program does HelloWorld once.

and the program then finds the specification for the print function and generates a hello world program etc. That all works fine.

My problem is that I want to also be able to say something like:

An Agent is an object that has a name, which is a String.

and it would create an object with a String name as instance variable.

Main Question:

How do I store all these types? Say I want to do something like create a function that takes the output of another function which has user defined type. Its a pretty simple question but I'm wondering what the best way to do it is.

Secondary questions: Should I generate all these objects and what not and THEN write the source code or should I do it incrementally?

Thanks in advance.

+1  A: 

If I understand correctly, you are trying to write some kind of specification to code parser (or generator)? You might look into something like Antlr (http://www.antlr.org/) to create your grammar and parser or even something like EasyB (http://easyb.org/), which has something similar used for generating tests.

Hope this isn't too far off the mark. Good luck.

cjstehno