Next / Previous / Contents / Shipman's homepage

74.8. BaseEncounter.scanUnbanded(): Scan unbanded encounter line

This method scans a type U (unbanded) encounter line. For the line's format, see the specification.

baseclasses.py
# - - -   B a s e E n c o u n t e r . s c a n U n b a n d e d   - - -

    def scanUnbanded(self, scan):
        '''Scan an unbanded encounter line.

          [ scan is a Scan object ->
              if CAPTURE_UNBANDED + (line in scan) is a valid
              unbanded 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
              else ->
                scan   :=   scan advanced no further than end of line
                Log()  +:=  error messages
                raise SyntaxError ]
        '''

Unbanded lines start with "U ", with two spaces after the capture code so that these lines line up with adjacent new-band lines. So first we need to verify the presence of that blank suffix.

baseclasses.py
        #-- 1 --
        # [ if scan starts with BLANK_BAND_NO_SUFFIX ->
        #     scan  :=  scan advanced past that string
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        m = scan.tabMatch(BLANK_BAND_NO_SUFFIX)
        if  m is None:
            scan.syntax("Expecting a blank suffix field.")

The rest of the line has exactly the same format as the corresponding parts of a new-band line, so we can use the same parser.

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)