Next / Previous / Contents / Shipman's homepage

74.10. BaseEncounter.scanLongNew(): Scan long new-band line

This method processes a G format encounter line. For the format of this line, see the specification.

baseclasses.py
# - - -   B a s e E n c o u n t e r . s c a n L o n g N e w   - - -

    def scanLongNew(self, scan):
        '''Scan a long new-band encounter line.

          [ scan is a Scan object ->
              if CAPTURE_LONG_NEW + (line in scan) is a valid long new
              band encounter line in the context of self.compiler ->
                scan  :=  scan advanced to end of line
                self  :=  self with all fields from that line added
                    using names in self.OUT_FIELD_LIST, and its
                    CAPTURE_CODE_ATTR changed to CAPTURE_NEW_BAND
              else ->
                scan   :=   scan advanced no further than end of line
                Log()  +:=  error messages
                raise SyntaxError ]
        '''

First, we parse the band number; see Section 32.4, “BandNoField.scanField()

baseclasses.py
        #-- 1 -
        # [ if scan starts with a valid band number field in
        #   the context of self.compiler ->
        #     scan  :=  scan advanced past that field
        #     self  :=  self with the band number stored in
        #               attribute BAND_NO_ATTR
        #   else ->
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        BandNoField.scanField(self, scan, BAND_NO_ATTR)

Parsing of the body and tail sections is done by Section 74.13, “BaseEncounter.scanBody(): Scan encounter line body and tail sections”.

baseclasses.py
        #-- 2 --
        # [ if scan contains a valid encounter body and tail in
        #   the context of self ->
        #     scan  :=  scan advanced to end of line
        #     self  :=  self with all fields from that line added
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.scanBody(scan)

        #-- 3 --
        # [ self.(CAPTURE_CODE_ATTR)  :=  CAPTURE_NEW_BAND ]
        setattr(self, CAPTURE_CODE_ATTR,
                CaptureCodeField(self, CAPTURE_NEW_BAND))