-1

I have in my hands a Java project that has a parser for some language. And it works very nice to read and parse. But I would like to know if using ANTLR I can also get the other way around, like given a the Java Object go to the string representation of this same object in the language that the parser was built for?

So if I had a CSV parser, I would like to go from the java Object to a CSV file(or string that represents the file).

Not sure if ANTLR is the way to do that.

Arruda
  • 862
  • 1
  • 12
  • 24

1 Answers1

0

How can any tool know what the CSV representation of a given object is? Not even the CSV parser knows this. It can only take a CSV input and see if that matches any predefined rule.

ANTLR certainly is not a tool for that. It is a parser generator that takes a grammar of a language and creates recognition classes (a lexer and a parser at the bare minimum) out of it. That's it and ANTLR very good at it.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181