Next / Previous / Contents / Shipman's homepage

17.8. Txny.__scanSpTail(): Process a species tail

nomcompile3
# - - -   T x n y . _ _ s c a n S p T a i l

    def __scanSpTail ( self, scan, stdHead ):
        '''Scan the tail portion of a species line.

          [ (scan is a Scan instance) and
            (stdHead is a StdHead instance) ->
              if line in scan contains a valid species tail ->
                scan  :=  scan advanced to end of line
                self.taxaTree  +:=  taxa from stdHead and that tail
                self.abTab  +:=  bindings from stdHead and that tail
              else ->
                scan  :=  scan advanced not past end of line
                self.taxaTree  +:=  taxon from line, if valid
                Log()  +:=  error message(s)
                raise SyntaxError ]              
        '''

The logic that scans the species tail is in Section 22, “class SpTail: Scanner for the species tail”.

nomcompile3
        #-- 1 --
        # [ if the balance of the line in scan is a valid
        #   species tail ->
        #     scan  :=  scan advanced to end of line
        #     spTail  :=  an SpTail instance representing that line
        #   else ->
        #     scan  :=  scan advanced not past end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        spTail = SpTail ( scan )

This line may define up to three taxa: a genus, a subgenus, and a species. See Section 17.9, “Txny.__checkGenus(): Add a new genus?”, Section 17.10, “Txny.__checkSubgenus(): Add a new subgenus?”, and Section 17.11, “Txny.__addSpecies(): Add a new species and its bindings”.

nomcompile3
        #-- 2 --
        # [ if (stdHead, spTail) names an existing genus in
        #   self.taxaTree ->
        #     I
        #   else if that genus can be appended to self.taxaTree ->
        #     self.taxaTree  +:=  that new genus
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__checkGenus ( scan, spTail )

        #-- 3 --
        # [ if ((stdHead, spTail) names no subgenus) or
        #   (that subgenus exists in self.taxaTree) or
        #   (self.hier has no subgenus rank) ->
        #     I
        #   else if that subgenus can be added to self.taxaTree ->
        #       self.taxaTree  +:=  that subgenus
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__checkSubgenus ( scan, spTail )

        #-- 4 --
        # [ if (stdHead, spTail) names a species that can be appended
        #   to self.taxaTree ->
        #     self.taxaTree  +:=  a new Taxon for that species
        #     self.abTab  +:=  bindings from (stdHead, spTail)
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__addSpecies ( scan, stdHead, spTail )