Fixed length data, the Canadian Well Logging Society and JavaCC

The Canadian Well Logging Society (CWLS) does log analysis of well data. The well logs are specified in the LAS format, which is more or less a fixed length data file with various sections. Here's an example file and here's a representative snippet:

#MNEM   .UNIT              Data                 Description of
#----   -----  ------------------------------   -----------------
#
 STRT   .F                         10180.0000  :START DEPTH
 STOP   .F                         10414.0000  :STOP DEPTH
 STEP   .F                             1.0000  :STEP
 NULL   .                             -999.25  :NULL VALUE
 COMP   .      Cramer Oil                      :COMPANY
 WELL   .      #36-16 State                    :WELL
 LOC    .      SE SE 36-47N-71W                :LOCATION
 CNTY   .      Campbell                        :COUNTY

I've written a small JJTree grammar (JJDoc'd HTML for the grammar is here) that parses the LAS format and forms it into an abstract syntax tree (AST). Here's an example of the structure that this JJTree grammar produces:

>DataFile
> VersionSection
>  VersionLine
>  WrapLine
>  CreationLine
> WellInformationSection
>  StartLine
>  StopLine
>  StepLine
>  NullLine

This could be useful in all sorts of ways when combined with a a program that traverses the AST and does something with the appropriate nodes. For example, you could graph the resistance as the well depth changes, or display the temperature changes, you could display well locations on a map, or you could use this parser as a front end for moving the well data into a relational database.

Here's the grammar and some supporting code (las.jar, source code); to use it, just do:

java -classpath las.jar LAS some_data_file.las

Some notes on the grammar:

This program is BSD licensed; if you find it helpful or interesting, pick up my JavaCC book!