Next / Previous / Contents / Shipman's homepage

76.3. Maps2004Encounter.scanTail()

This method handles all the fields following the net field in the MAPS 2004 format, since all those fields, including the alignment field, are different from the MAPS 2006 protocol. For this tail format, see the specification.

baseclasses.py
# - - -   M a p s 2 0 0 4 E n c o u n t e r . s c a n T a i l   - - -

    def scanTail(self, scan):
        '''Scan the 2004 MAPS encounter record tail section.

          [ if the line in scan starts with a valid MAPS
            2004 tail section ->
              scan  :=  scan advanced to end of line
              self  :=  self with values from the tail stored using
                        attribute names from self.OUT_FIELD_LIST
            else ->
              scan   :=   scan advanced no further than end of line
              Log()  +:=  error message(s)
              raise SyntaxError ]
        '''

We start our scan just after the net field. If the next character is the LONG_TAIL_CUE character, we process the extended tail section by calling Section 76.5, “Maps2004Encounter.scanLongTail().

baseclasses.py
        #-- 1 --
        # [ if the line in scan is (LONG_TAIL_CUE + (a valid
        #   extended tail)) ->
        #     scan  :=  scan advanced to end of line
        #     self  :=  self with values from that tail stored
        #         using attribute names from self.OUT_FIELD_LIST
        #     return
        #   else if the line in scan starts with LONG_TAIL_CUE
        #   but not followed by a valid extended tail ->
        #     scan   :=   scan advanced not past end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError
        #   else -> I ]
        if  scan.match(LONG_TAIL_CUE):
            scan.move(1)
            self.scanLongTail(scan)
            return

This leaves us with the short-tail case. The next column may be ALIGNMENT_CHAR, which has no semantic association; or, in the MAPS 2004 protocol, it may instead be OLD_PULL_INPUT, in which case we set the PULLED_ATTR field to OLD_PULL_OUTPUT. See Section 76.4, “Maps2004Encounter.scanOldAlign(): Scan old alignment or feather-pulled field”.

baseclasses.py
        #-- 2 --
        # [ if the line in scan starts with ALIGNMENT_CHAR ->
        #     scan  :=  scan advanced 1
        #   else if the line in scan starts with OLD_PULL_INPUT ->
        #     scan  :=  scan advanced 1
        #     self.(PULLED_ATTR)  :=  OLD_PULL_OUTPUT
        #   else ->
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        self.scanOldAlign(scan)

The line can legally end here. If the line is not exhausted, the only valid thing that can occur is a disposition character, for which we call DispositionField.scanField(). There had better not be anything after that.

baseclasses.py
        #-- 3 --
        # [ if scan is at end of line ->
        #     return
        #   else -> I ]
        if  scan.atEndLine():
            return

See Section 69.1, “DispositionField.scanField().

baseclasses.py
        #-- 4 --
        #   if the line in scan starts with a valid disposition
        #   code ->
        #     scan  :=  scan advanced past that code
        #     self  :=  self with that disposition code stored
        #         in DISPOSITION_ATTR
        #   else ->
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        DispositionField.scanField(self, scan, DISPOSITION_ATTR)

        #-- 5 --
        if  not scan.atEndLine():
            scan.syntax("Expecting end of line.")