title: Can I use ANTLR for both two-way parsing/generating?
body: <p>I need to both parse incoming messages and generate outgoing messages in EDIFACT format (basically a structured delimited format).</p>
  
  <p>I would like to have a Java model that will be generated by parsing a message.  Then I would like to use the same model to create an instance and generate a message.</p>
  
  <p>The first half is fine, I've used ANTLR before to go from raw -> Java objects.  But I've never done the reverse, or if I have it's been custom.</p>
  
  <p>Does ANTLR support generating using a grammar or is it really just a parse-only tool?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Expansion - I want to define two things ideally.  A grammar that describes the raw message (EDIFACT in this case but pretend it's CSV if you like).  And a Java object model.</p>
  
  <p>I know I can write an ANTLR grammar to get from the raw -> Java model.  e.g. Parsing a SQL string -> Java model which I've done before.  But I need to go the other way as well ideally without changing the grammar.</p>
  
  <p>If you liken it to JAXB (XML world), I really want JAXB for EDIFACT (rather than XML).</p>