| |
---|
| | |
---|
| | # Program Information |
---|
| | |
---|
| | PROGNAME = "tconfpy" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.148 2004/03/27 00:56:25 tundra Exp $" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.149 2004/03/27 01:24:34 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | WarnMsgs = [] # Place to store and return warnings |
---|
| | LiteralLines = [] # Place to store and return unprocessed lines |
---|
| | |
---|
| | |
---|
| | CondStack = [True,] # Conditional stack |
---|
| | CondStack = [["", True,]] # Conditional stack |
---|
| | TotalLines = 0 # Total number of lines parsed |
---|
| | |
---|
| | |
---|
| | ########## |
---|
| |
---|
| | Messages["eSTRINGSHORT"] = FILENUM + "Right-Hand-Side, '%s' Shorter Than Min Allowed Length, %s, For Variable '%s'" |
---|
| | Messages["eTYPEBAD"] = FILENUM + "Type Mismatch. '%s' Must Be Assigned Values Of Type %s Only" |
---|
| | Messages["eVALLARGE"] = FILENUM + "%s Is Larger Than The Maximum Allowed, %s, For Variable '%s'" |
---|
| | Messages["eVARNAMESPC"] = FILENUM + "Variable Names May Not Contain Whitespace" |
---|
| | Messages["eVARNONAME"] = FILENUM + "Variable Name Evaluates To Null String. Not Permitted" |
---|
| | Messages["eVARNONAME"] = FILENUM + "Variable Name Evaluates To Null String. Not Permitted" |
---|
| | Messages["eVALSMALL"] = FILENUM + "%s Is Smaller Than The Minimum Allowed, %s, For Variable '%s'" |
---|
| | Messages["eVARREADONLY"] = FILENUM + "Variable '%s' Is Read-Only. Cannot Change Its Value" |
---|
| | Messages["eVARUNDEF"] = FILENUM + "Attempt To Reference Undefined Variable '%s'" |
---|
| | |
---|
| |
---|
| | ErrMsgs = [] |
---|
| | WarnMsgs = [] |
---|
| | LiteralLines = [] |
---|
| | |
---|
| | CondStack = [True,] # Always has one entry as a sentinel |
---|
| | CondStack = [["", True],] # Always has one entry as a sentinel |
---|
| | TotalLines = 0 |
---|
| | |
---|
| | # Add any passed symbols to the SymbolTable |
---|
| | |
---|
| |
---|
| | ##### |
---|
| | |
---|
| | if line.strip() in (LITERAL, ENDLITERAL): |
---|
| | |
---|
| | if not CondStack[-1]: |
---|
| | if not CondStack[-1][1]: |
---|
| | if DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| | return |
---|
| | |
---|
| |
---|
| | |
---|
| | # Error, if there are more .endifs than conditionals |
---|
| | if not CondStack: |
---|
| | ErrorMsg("eENDIFEXTRA", (cfgfile, linenum)) |
---|
| | CondStack.append(False) # Restore sentinel & inhibit further parsing |
---|
| | CondStack.append(["", False]) # Restore sentinel & inhibit further parsing |
---|
| | |
---|
| | if DEBUG: |
---|
| | DebugMsg("dPARSEDLINE", (cfgfile, linenum, orig, line)) |
---|
| | |
---|
| |
---|
| | if line == DELIML+DELIMR or (len(VarRef.findall(line)) == 1 and \ |
---|
| | line[0] == DELIML and line[-1] == DELIMR and\ |
---|
| | line.count(DELIML) == line.count(DELIMR) == 1): |
---|
| | |
---|
| | if not CondStack[-1]: |
---|
| | if not CondStack[-1][1]: |
---|
| | if DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| | return |
---|
| | |
---|
| |
---|
| | ##### |
---|
| | |
---|
| | elif FIRSTTOK == INCLUDE: |
---|
| | |
---|
| | if not CondStack[-1]: |
---|
| | if not CondStack[-1][1]: |
---|
| | if DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| | return |
---|
| | |
---|
| |
---|
| | |
---|
| | # Set parser state based on a successful conditional test |
---|
| | # But it has to be ANDed with the state of the enclosing block |
---|
| | |
---|
| | enclosing = CondStack[-1] |
---|
| | CondStack.append(condstate and enclosing) |
---|
| | enclosing = CondStack[-1][1] |
---|
| | CondStack.append([IF, condstate and enclosing]) |
---|
| | |
---|
| | # Now reflect this in the parsed line |
---|
| | line = sTRUE |
---|
| | if not condstate: |
---|
| |
---|
| | # definition/assignment. |
---|
| | |
---|
| | elif EQUAL in line: |
---|
| | |
---|
| | if not CondStack[-1]: |
---|
| | if not CondStack[-1][1]: |
---|
| | if DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| | return |
---|
| | |
---|
| |
---|
| | # For all numeric types, the test is to see if the new |
---|
| | # value is one of the ones enumerated in LegalVals. |
---|
| | # |
---|
| | # For strings, LegalVals is presumed to contain a list |
---|
| | # of regular expressions. The test is to compile each |
---|
| | # of regular expressions. The test is to compile |
---|
| | each |
---|
| | # regex and see if any match the new value. |
---|
| | |
---|
| | if update and lv: |
---|
| | |
---|
| |
---|
| | |