I know that javacc can generate code, written in java, which can analyse your code (in a language that you create it's grammar). What I really need, is to generate the java code itself.For example, let's say I write this in my grammar:
show "hello world" (let's say this is in my language)
and then, I want the javacc to turn this line, into:
system.out.println("hello world");
and later I would compile this "generated" java code, and run it, and see the output.
Actually, the purpose is to create a language, which can produce xml files automatically in it. I was thinking of using javacc and some xml parser like dom. But I really don't know if it's a good way to go.
Many many thanks in advance.
Check out Xtext. It generates Java source from your own language.
Xtext is a framework for development of programming languages and domain specific languages.
It covers all aspects of a complete language infrastructure, from parsers, over linker, compiler or interpreter to fully-blown top-notch Eclipse IDE integration. It comes with good defaults for all these aspects and at the same time every single aspect can be tailored to your needs.