How to customize generation output

Hello, community.

I try to resolve next:

I have concept "A".This concept generates in java classes and txt files. I want when generating "A" concept do next

1. generate java and txt files

2. run java classes and get result as string

3. return this string as output generation concept "A".

I will be graeful to the instruction step by step



Comment actions Permalink

If I understand your scenario right, there's Concept A and a generator for the concept  that produces Java class, and the class can produce some text (e.g. main() {} full of System.out.println). Then, given instance of node<A>, you'd generate the class (with a help of aforementioned generator), and would like to compile generated class in memory, execute it and write the outcome of main() to disk. This doesn't sound like a task for MPS, though technically you can accomplish this with a custom Make Facet or your own make action (pretty much like MPS does for 'Evaluate' in debugger, where it builds an evaluator class, compiles it in memory and executes to get a value evaluated). However, I'd rather ask myself what prevents me from using natural MPS mechanisms to generate stuff and what's so special in the code of main() {}. I.e. why the logic you'd put into the main() of your class can not reside in Concept A's generator or textgen component? Why do you need an extra indirection of an executed Java class?

Comment actions Permalink

I agree with you. I want to use standard MPS mechanisms. I need to reconsider my decision.

In main() I use java library for template engine of concept's A generated txt files. This, as I already understood redundantly

Thanks for the answer

Comment actions Permalink

To me, it looks like you don't need to generate Java class at all, just fire off your template engine from within TextGen for your concept. Unless your template engine needs a physical file on a filesystem, of course.


Please sign in to leave a comment.