Next / Previous / Contents / Shipman's homepage

17.20. Txny.__scanEquivalentAlt(): Scan a direct-equivalent line

nomcompile3
# - - -    T x n y . _ _ s c a n E q u i v a l e n t A l t

    def __scanEquivalentAlt ( self, scan, code ):
        '''Scan a direct-equivalent alt forms line.

          [ (scan is a Scan instance) and
            (code is a stripped, uppercased bird code) ->
              if (code+ALT_EQUIVALENT+(line in scan) is a valid
              alt forms equivalent line ->
                scan  :=  scan advanced to end of line
                self  :=  self with binding added made from that line
              else ->
                scan  :=  scan advanced not past end of line
                Log()  +:=  error message(s)
                raise SyntaxError ]
        '''

Here's a typical direct equivalent line that exemplifies the format. This line says that code LBCCHI, which is based on the name “Labrador Boreal Chickadee”, is a synonym for BORCHI, Boreal Chickadee.

lbcchi=borchi Chickadee, Labrador Brown-capped

Hence, since scan is positioned just after the “=”, our job is to parse the other code, skip blanks, then parse the English name, and then attempt to add a new EqBind to the symbol table for the first code.

nomcompile3
        #-- 1--
        # [ if the line in scan starts with a valid bird code,
        #   right-padded to abbrMod.ABBR_L ->
        #       scan  :=  scan advanced by abbrMod.ABBR_L
        #       otherCode  :=  the bird code, stripped and uppercased
        #     else ->
        #       Log()  +:=  error message(s)
        #       raise SyntaxError ]
        otherCode = self.__scanAbbr ( scan )

        #-- 2 --
        # [ scan  :=  scan advanced to end of line
        #   eng  :=  balance of line in scan, stripped ]
        eng = scan.tab(-1).strip()

For the logic that creates the binding and attempts to add it to the symbol table, see Section 17.21, “Txny.__bindEquivalentAlt(): Create an equivalence binding”.

nomcompile3
        #-- 3 --
        # [ if an equivalence binding for (code) to (otherCode) is
        #   valid ->
        #     self.abTab  +:=  that new binding using English name (eng)
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__bindEquivalentAlt ( scan, code, otherCode, eng )