Next / Previous / Contents / Shipman's homepage

17.18. Txny.__scanHigherAlt(): Scan a higher-taxon line

# - - -   T x n y . _ _ s c a n H i g h e r A l t

    def __scanHigherAlt ( self, scan, code ):
        '''Process an alt forms line assigning a code to a higher taxon.

          [ (scan is a Scan instance) and
            (code is a bird code) ->
              if (code+ALT_HIGHER+(line in scan)) is a valid
              alt forms higher taxon line ->
                scan  :=  scan advanced to end of line
                self.abTab  +:=  binding for code to the scientific
                    name on that line
              else ->
                scan  :=  scan advanced no further than end of line
                Log()  +:=  error message(s)
                raise SyntaxError ]

The purpose of this line type in the alt forms file is to connect a code to a specific taxon of a higher rank than species. Here are two example lines from the specification. The first defines code ALBATR as family Diomedeidae, some species of albatross. The second defines code ACCIPIas a synonym for genus Accipiter; in order to properly italicize the genus name, it is enclosed in underbars.

albatr Diomedeidae/albatross sp.
accipi Accipiter/_Accipiter_ sp.

We tolerate (and ignore) any amount of whitespace before or after either of these delimiting slashes. For the regular expression that matches a slash plus any amount of preceding and following whitespace, see Section 6.24, “SLASH_RE.

        #-- 1 --
        # [ if there is a slash remaining on the line in scan ->
        #     scan  :=  scan advanced past the first "/" and
        #               any trailing whitespace
        #     sci  :=  characters up to the first "/", minus
        #              leading and trailing whitespace
        #   else ->
        #     scan  :=  scan advanced no further than end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        slashPos = scan.upToRe ( SLASH_RE )
        if slashPos is None:
            scan.syntax ( "There must be a '/' separating the "
                "scientific and English names." )
        sci = ( slashPos )
        scan.tabReMatch ( SLASH_RE )

At this point we should be at the beginning of the English name field, which extends through the end of the line.

        #-- 2 --
        # [ scan  :=  scan moved to the end of the line
        #   eng  :=  balance of line in scan, without leading or trailing
        #            whitespace ]
        eng =

For the function that checks the English name for validity, see Section 30, “validateEng(): Validate an English name”.

        #-- 3 --
        # [ if eng is a valid English name field ->
        #     I
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        validateEng(scan, eng)

For the logic that creates the symbol table entry, see Section 17.19, “Txny.__bindHigherAlt(): Bind a higher-taxon code”.

        #-- 4 --
        # [ if sci is defined in self.__sciMap ->
        #     self.abTab  :=  self.abTab with a standard binding
        #         for code with sci=(sci), and eng=(eng)
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__bindHigherAlt ( scan, code, sci, eng )