| |
---|
| | |
---|
| | # Program Information |
---|
| | |
---|
| | PROGNAME = "tconfpy" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.147 2004/03/25 10:43:45 tundra Exp $" |
---|
| | RCSID = "$Id: tconfpy.py,v 1.148 2004/03/27 00:56:25 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | |
---|
| | |
---|
| | # Regular Expressions |
---|
| | |
---|
| | reVARREF = r"\%s.+?\%s" % (DELIML, DELIMR) # Variable reference |
---|
| | VarRef = re.compile(reVARREF) |
---|
| | reVARWHITE = r".*\s+.*" |
---|
| | reVARILLEGAL = r"\%s(%s)%s" % (DELIML, reVARWHITE, DELIMR) # Variable reference with spaces in it |
---|
| | reVARREF = r"\%s.+?\%s" % (DELIML, DELIMR) # Variable reference |
---|
| | |
---|
| | VarWhite = re.compile(reVARWHITE) |
---|
| | VarIllegal = re.compile(reVARILLEGAL) |
---|
| | VarRef = re.compile(reVARREF) |
---|
| | |
---|
| | |
---|
| | ########### |
---|
| | # Literals |
---|
| |
---|
| | Messages["eSTRINGLONG"] = FILENUM + "Right-Hand-Side, '%s' Longer Than Max Allowed Length, %s, For Variable '%s'" |
---|
| | 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["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'" |
---|
| | |
---|
| |
---|
| | ##### |
---|
| | # Namespace Processing |
---|
| | ##### |
---|
| | |
---|
| | if line == DELIML+DELIMR or (len(VarRef.findall(line)) == 1 and line[0] == DELIML and line[-1] == DELIMR): |
---|
| | 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 DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| |
---|
| | return |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Handle New Variable Declaration/Assignment |
---|
| | # Handle Variable Declaration/Assignment |
---|
| | ##### |
---|
| | |
---|
| | # If we got here it means that none of the conditional forms |
---|
| | # were found, so the only thing left might be a variable |
---|
| |
---|
| | if DEBUG: |
---|
| | DebugMsg("dLINEIGNORE", (cfgfile, linenum, orig, dNOTINCLUDE)) |
---|
| | return |
---|
| | |
---|
| | |
---|
| | # Catch attempts to use whitespace within variable names or references |
---|
| | |
---|
| | if VarIllegal.findall(line) or VarWhite.findall(line.split(EQUAL)[0].strip()): |
---|
| | ErrorMsg("eVARNAMESPC", (cfgfile, linenum)) |
---|
| | return |
---|
| | |
---|
| | # Catch attempts to dereference without name |
---|
| | |
---|
| | if line.count(DELIML + DELIMR): |
---|
| | ErrorMsg("eVARNONAME", (cfgfile, linenum)) |
---|
| | return |
---|
| | |
---|
| | # Do any necessary variable dereferencing |
---|
| | line, ref_ok = DerefVar(line, cfgfile, linenum) |
---|
| | |
---|
| | # Only do this if all var references were valid |
---|
| |
---|
| | l = line[:e].strip() |
---|
| | r = line[e+1:].strip() |
---|
| | |
---|
| | |
---|
| | # Suppress attempts to set null-named variables |
---|
| | |
---|
| | if not l: |
---|
| | ErrorMsg("eVARNONAME", (cfgfile, linenum)) |
---|
| | |
---|
| | # Suppress any attempt to change a RO variable |
---|
| | |
---|
| | if l in SymTable and not SymTable[l].Writeable: |
---|
| | |
---|
| | elif l in SymTable and not SymTable[l].Writeable: |
---|
| | ErrorMsg("eVARREADONLY", (cfgfile, linenum, l)) |
---|
| | |
---|
| | # Load variable into the symbol table |
---|
| | else: |
---|
| |
---|
| | |