Next / Previous / Contents / Shipman's homepage

17.28. Txny.__finalCheck(): Verify correctness of the symbol table

nomcompile3
# - - -   T x n y . _ _ f i n a l C h e c k

    def __finalCheck ( self ):
        '''Insure that all codes have been defined.

          [ if self.abTab contains no undefined codes ->
              I
            else ->
              Log()  +:=  error message(s)
              raise IOError ]
        '''

The generator that presents each symbol table for inspection is described in Section 24.4, “AbTab.__iter__(): Generate all symbol table entries”. For each symbol table entry, we inspect the .binding attribute; if it is None, no definition for this symbol was encountered in the input, which is an error.

We'll check the error count from the Log() singleton before and after this pass through the symbol table; if it has changed, there was at least one error, and we terminate after a final message.

nomcompile3
        #-- 1 --
        # [ errCount  :=  error count from Log() ]
        errCount = Log().count()

        #-- 2 --
        # [ Log()  +:=  error messages about undefined entries
        #       in self.abTab, if any ]
        for abSym in self.abTab:
            if abSym.binding is None:
                Log().error ( "Undefined bird code '%s'." %
                              abSym.abbr )

        #-- 3 --
        netErrCount = errCount - Log().count()
        if netErrCount > 0:
            raise IOError ( "Terminated due to undefined bird codes." )