embedding java code in auto generated code

rblasch@web.de (Ronald Blaschke)
1 Feb 2001 17:49:16 -0500

          From comp.compilers

Related articles
embedding java code in auto generated code rblasch@web.de (2001-02-01)
Re: embedding java code in auto generated code eeide@cs.utah.edu (Eric Eide) (2001-02-04)
Re: embedding java code in auto generated code joachim_d@gmx.de (Joachim Durchholz) (2001-02-25)
| List of all articles for this month |

From: rblasch@web.de (Ronald Blaschke)
Newsgroups: comp.compilers
Date: 1 Feb 2001 17:49:16 -0500
Organization: Compilers Central
Keywords: Java, question
Posted-Date: 01 Feb 2001 17:49:16 EST

Hi!


I would like to embed some java code blocks in automatically generated code:


bind (myVariable) {
    class = "java.lang.Integer";
    value = 0;
}


execute {
    // some java code in here
}


This should be compiled into something like this:


public class Unknown {
    public void run() {
        java.lang.Integer myVariable = new java.lang.Integer(0);


        // some java code (from execute) in here
    }
}


So, I would like to have some java code block in my execute. There is
no need to parse it, but I think it would be simpler to do so, for the
end of the execute block must be found. The java code block should
be identical to the one in the source (including comments and white spaces),
but this is no must. The generated code would then be compiled with javac.


Has anyone ever done this? Any other hints, pointers, etc?


The generated program must be written in java, so javaCC or antlr seem to
be first choice; but any other would also do fine.


Any help is greatly appreciated,
Ron


Post a followup to this message

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