This method processes a page header line. It is a concrete method, but may be replaced for compilers that have a different page header format.
# - - - B a s e C o m p i l e r . s c a n P a g e H e a d e r - - -
def scanPageHeader(self):
'''Process a page header line.
[ the line in self.scan is a page header line advanced
past the initial PAGE_SYMBOL ->
if the line in self.scan is a valid page header line ->
self.scan := self.scan advanced no further than
end of line
yield a PageHeader object representing that line
else ->
Log() +:= error message(s) ]
'''
The logic that parses a page header line is a static
method of the PageHeader class; see Section 24, “class PageHeader: Page header line
object”. We could have made the
constructor itself do the parsing, but that could make it
harder to write a constructor with different logic. See
Section 24.2, “PageHeader.scanLine(): Scan a page
header line”.
#-- 1 --
# [ if the line in self.scan is a valid page header line ->
# self.pageHeader := a new PageHeader object representing
# that line
# else ->
# Log() +:= error message(s)
# In any case ->
# self.scan := self.scan advanced no further than
# end of line ]
try:
self.pageHeader = PageHeader.scanLine(self, self.scan)
except SyntaxError:
pass
To maintain the invariant that prefix lines and the value of self.oldEncounter persist only until the
next page header line, we set both those values back to their
initial state of None.
#-- 2 --
self.prefix = self.oldEncounter = None