Check function code for balanced parentheses, brackets, and braces
This commit is contained in:
@ -825,6 +825,30 @@ def adjust_group(MyGroup):
|
||||
if Verbose:
|
||||
print 'post adjust_group', MyGroup
|
||||
|
||||
def check_func_code(MyDriver):
|
||||
for name in MyDriver['Funcs']:
|
||||
#print name
|
||||
left_paren_count = 0
|
||||
right_paren_count = 0
|
||||
left_brack_count = 0
|
||||
right_brack_count = 0
|
||||
left_brace_count = 0
|
||||
right_brace_count = 0
|
||||
for idx, line in enumerate(MyDriver['Funcs'][name]['text']):
|
||||
#print "%4d:" % (idx + 1), line
|
||||
left_paren_count += line.count('(')
|
||||
right_paren_count += line.count(')')
|
||||
left_brack_count += line.count('[')
|
||||
right_brack_count += line.count(']')
|
||||
left_brace_count += line.count('{')
|
||||
right_brace_count += line.count('}')
|
||||
if left_paren_count != right_paren_count:
|
||||
PrintPostError("Warning: Mismatched Parens in function %s (%d != %d)" % (name, left_paren_count, right_paren_count))
|
||||
if left_brack_count != right_brack_count:
|
||||
PrintPostError("Warning: Mismatched Brackets in function %s (%d != %d)" % (name, left_brack_count, right_brack_count))
|
||||
if left_brace_count != right_brace_count:
|
||||
PrintPostError("Warning: Mismatched Braces in function %s (%d != %d)" % (name, left_brace_count, right_brace_count))
|
||||
|
||||
def build_driver(MyDriver, TheTree):
|
||||
if Verbose:
|
||||
print "TheTree:", TheTree
|
||||
@ -1752,6 +1776,7 @@ def process_drivers(TheDrivers):
|
||||
MyDriver['Permlink'] = {}
|
||||
MyDriver['Deferred'] = []
|
||||
build_driver(MyDriver, TheDrivers[driver])
|
||||
check_func_code(MyDriver)
|
||||
if Verbose:
|
||||
print "MyDriver:", MyDriver['name'], '=', MyDriver
|
||||
if DriverDump or Verbose:
|
||||
|
Reference in New Issue
Block a user