This article was originally posted on JRoller in 2013. The content is still valid, though the referenced JavaCC version is not outdated. This blog describes how to parse a text file containing a home grown language into a POJOS using JJTree. The approach could be used to describe a specific topic (domain specific language, short DSL) or parse a specific data format. The complete code could be found on Bitbucket https://bitbucket.org/skfcz/jroller The Task In my actual case I want to describe the structure of a binary file and then generate the POJOs, the parser and (in the distant future) the writer for that format. The format used to describe the structure looks like this: /** * The Segment header ... */ segment LSGSegment { { segmentType: 1, compressed: true}; /** Base Node Element */ entity BaseNodeElement extends ElementHeader { ObjectTypeID : 0x10dd1035, 0x2...