Next / Previous / Contents / Shipman's homepage

24.1. AbTab.addAbbr(): Create a symbol table entry or find an existing one

nomcompile3
# - - -   A b T a b . a d d A b b r

    def addAbbr ( self, abbr ):
        '''Make sure the symbol table has this code.
        '''
        #-- 1 --
        key = abbr.strip().upper()

        #-- 2 --
        # [ if abbr is in self ->
        #       return the corresponding AbSym
        #   else -> I ]
        try:
            return self[key]
        except KeyError:
            pass

See Section 25, “class AbSym: One symbol table entry” for the constructor interface.

nomcompile3
        #-- 2 --
        # [ self.__abbrMap[key]  :=  a new, unbound AbSym entry
        #                            for code (key) ]
        self.__abbrMap[key] = result = AbSym ( key )

        #-- 3 --
        return result