diff --git a/tconfpy.py b/tconfpy.py index 692d071..0c5a675 100755 --- a/tconfpy.py +++ b/tconfpy.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "tconfpy" -RCSID = "$Id: tconfpy.py,v 1.153 2004/03/31 22:40:02 tundra Exp $" +RCSID = "$Id: tconfpy.py,v 1.154 2004/04/01 20:38:03 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -56,7 +56,7 @@ MSGPROMPT = "%s>" FILENUM = "[File: %s Line: %s] " # Display filename and linenum -NOLINENUM = "---" # Use as line number when none is needed +ATEOF = "EOF" # Use as line number when at EOF PTR = " ---> " # Textual pointer for debug output @@ -138,6 +138,26 @@ TotalLines = 0 # Total number of lines parsed +##### +# Dummy Object Used To Return Parsing Results +##### + +# This is done so the caller only needs to know the name of +# each result set, not its position in the list of returned items + + +class RetObj(object): + + def __init__(self): + self.SymTable = {} + self.Errors = [] + self.Warnings = [] + self.Debug = [] + self.Literals = [] + +# End of 'RetObj' + + ########## # Symbol Table ########## @@ -368,6 +388,8 @@ WarnMsgs = [] LiteralLines = [] + retobj = RetObj() + CondStack = [["", True],] # Always has one entry as a sentinel TotalLines = 0 @@ -449,18 +471,24 @@ finalcond = len(CondStack) if finalcond != 1: - ErrorMsg("eENDIFMISS", (cfgfile, NOLINENUM, finalcond-1)) + ErrorMsg("eENDIFMISS", (cfgfile, ATEOF, finalcond-1)) # Make sure we ended any literal processing properly if INLITERAL: - WarningMsg("wENDLITMISS", (cfgfile, NOLINENUM)) + WarningMsg("wENDLITMISS", (cfgfile, ATEOF)) # Return the parsing results if DEBUG: DebugMsg("dNUMLINES", (cfgfile, TotalLines)) - return (SymTable, ErrMsgs, WarnMsgs, DebugMsgs, LiteralLines) + retobj.SymTable = SymTable + retobj.Errors = ErrMsgs + retobj.Warnings = WarnMsgs + retobj.Debug = DebugMsgs + retobj.Literals = LiteralLines + + return retobj # End of 'ParseConfig()' @@ -1151,6 +1179,7 @@ __all__ = ["ParseConfig", + "RetObj", "TYPE_BOOL", "TYPE_COMPLEX", "TYPE_FLOAT",