-4

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.

2 Answers2

0

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.

Community
  • 1
  • 1
rzymek
  • 9,064
  • 2
  • 45
  • 59
0

JavaCC puts no limitation on what your parser generates. If you want it to output Java code, go right ahead.

Theodore Norvell
  • 15,366
  • 6
  • 31
  • 45