Next / Previous / Contents / Shipman's homepage

17.12. Txny.__addCodes(): Set up symbol table entries for a standard form

nomcompile3
# - - -   T x n y . _ _ a d d C o d e s

    def __addCodes ( self, scan, taxon ):
        '''Add symbol table entries for a new taxon.

          [ (scan is a Scan instance) and
            (taxon is a Taxon instance) ->
              if the bindings for the code(s) from taxon are consistent
              with the state of self ->
                  self.abTab  +:=  those bindings
              else ->
                Log()  +:=  error message(s)
                raise SyntaxError ]
        '''

Higher-level taxa don't have codes; eliminate this case.

nomcompile3
        #-- 1 --
        if taxon.canon is None:
            return

There are two cases for the addition of symbol table entries for this taxon. Of course the addition may fail due to conflicts with existing bindings.

nomcompile3
        #-- 2 --
        # [ if taxon.disamb is None ->
        #     if a StdBind binding for taxon.canon can be
        #     combined with self.abTab ->
        #       self.abTab  +:=  a StdBind binding for taxon.canon
        #     else ->
        #       Log()  +:=  error message(s)
        #       raise SyntaxError
        #   else ->
        #     if a StdBind binding for taxon.disamb and a
        #     CollBind binding for taxon.canon can be combined
        #     with self.abTab ->
        #       self.abTab  +:=  a StdBind binding for taxon.disamb
        #           and a CollBind binding for taxon.canon
        #     else ->
        #       Log()  +:=  error message(s)
        #       raise SyntaxError ]
        if taxon.disamb is None:
            self.__addCodeStd ( scan, taxon, taxon.canon )
        else:
            self.__addCodeColl ( scan, taxon )