Attributes of a BaseCompiler object
include:
The .scan attribute is a Scan object that we use to manage
reading through the input file. This object has
facilities for reporting error messages along with a
line number and a pointer to the position where
the error occurred.
Attribute .pageHeader is initially
None. Every time we see a page header
line go by, we store a PageHeader
object representing that page header into this
attribute.
The .prefix attribute is also
initially None, and it is reset to
None every time we see a page header
go by. When we see a prefix line, a Prefix object representing that line is
stored in this attribute. The processing of new-band
lines will access this attribute to get the first
seven digits of the band number.
The .oldEncounter attribute is
initially None. Each time we finish
processing an encounter record and yield a BaseEncounter record representing that
record, we also save a reference to the BaseEncounter object in this attribute, so
that a subsequent line using single-column ditto can
examine the value of the corresponding column from
the previous record.
State/Invariants:
.scan:
[ a Scan object reading from file fileName ]
.pageHeader:
[ if any valid page header lines have been read ->
a PageHeader object representing that last valid
page header line
else -> None ]
.prefix:
[ if any prefix lines have been seen since the last valid
page header line ->
a Prefix object representing that line
else -> None ]
.oldEncounter:
[ if any valid encounter lines have been since the last
page header line ->
a BaseEncounter record representing that line
else -> None ]
'''