I am wondering if we can define EDIFACT grammar in ANTLR/xText and then generate parser.
If so, are these grammars defined already that we can leverage (open source preferably)?
Are there any open source libraries that can read and write EDIFACT other than Smooks?

- 78,777
- 46
- 231
- 327
-
A couple mentioned [here](http://stackoverflow.com/questions/2794262/is-there-any-good-open-source-edifact-parser-in-java). – Dmitri Feb 09 '12 at 05:17
-
@Dmitri Except smooks, most of them are .Net and few java ones are dead... – Aravind Yarram Feb 09 '12 at 12:52
-
@Pangea what's wrong with smooks? :) – Peter Svensson Feb 09 '12 at 14:45
-
@PeterLiljenberg there is nothing wrong with it. it is excellent. But I am looking for JUST edifact parser libraries or alternatives – Aravind Yarram Feb 09 '12 at 14:51
2 Answers
From a handy book on the subject... (http://books.google.co.uk/books?id=rDbRS6vEG0MC&pg=PA222&lpg=PA222&dq=EDIFACT+bnf&source=bl&ots=pfFYf4nsVv&sig=JXY5HPo7Ka02ji35fjW8R8wFBX8&hl=en&sa=X&ei=05ozT6K5NMO80QWa-ZSLAg&ved=0CGEQ6AEwCA#v=onepage&q=EDIFACT%20bnf&f=false) we have the following section...
, which appears to suggest that it's not a good idea - although depending on what you require you can certainly write one, I would personally find Antlr an easier tool to use (I'm currently writing a lab for Xtext and it's a less forgiving learning curve), but your milage may vary...

- 4,367
- 7
- 33
- 52
I tried this approach (using ANTLR) when I developed bots open source edi translator (http://bots.sourceforge.net). This looked like a good approach, but I did not succeed. My conclusion was that 'parsing' by ANTLR is something very different than 'parsing' an edi-file; the words/concepts sound the same but these are really different worlds. If you are looking for 'grammars'(that is: descriptions of edifact and x12 messages) these can be found in the downloads of the sourceforge page.

- 710
- 4
- 9
-
Hello @eppye, I want to parse X12 EDI file using java , Can i use ANTLR? – GrandPa Dec 04 '18 at 12:02
-
-
@eppye I saw that your new bots library on github in python still use a grammar. Does your vision on grammar changed or you found a better way to do this ? – Mike May 06 '20 at 13:12
-
bots uses grammar - but those grammars are different from what Antler uses. FOr bots a gammar is a description of records and fields. – eppye May 07 '20 at 14:09