At the November 2014 DesertPy meeting I learned about ANTLR the parser generator and thought that would be the proper way to approach writing a parser for the labels of NASA’s PDS3 file format. I spent some time and read The Definitive ANTLR 4 Reference (affiliate link) and have pieced together a grammar that works fairly well at this point.

The ANTLR grammar and corresponding generated Python parser are Open Source, BSD Licensed and are available on GitHub:

If you are interested in using this, I’d love help coming up with more sample PDS label snippets to make sure everything is working. Check out the data directory that contains my sample PDS labels to see what I’ve missed. Also note that there is one known bug in the grammar related to handling strings.

Right now, there is no usable application code other than the parser generated by ANTLR. I am starting the Python application level code now and hopeful to get something working soon.

PS - Many thanks to Ian for giving that ANTLR presentation.