Redo the error reporting
This commit is contained in:
@ -64,6 +64,12 @@ Verbose = False
|
||||
DriverDump = False
|
||||
CodeDump = False
|
||||
|
||||
def PrintParseError(message):
|
||||
print message
|
||||
|
||||
def PrintPostError(message):
|
||||
print message
|
||||
|
||||
#
|
||||
# Tokenizer: This recognizes the tokens which can be keywords, identifiers,
|
||||
# numbers or strings plus the punctuation.
|
||||
@ -212,7 +218,8 @@ def t_tcl_newline(t):
|
||||
t.lexer.lineno += t.value.count("\n")
|
||||
|
||||
def t_tcl_error(t):
|
||||
print("Illegal tcl character '%s'" % t.value[0])
|
||||
message = "Illegal tcl character '%s'" % t.value[0]
|
||||
PrintParseError(message)
|
||||
t.lexer.skip(1)
|
||||
|
||||
def t_TEXT_STRING1(t):
|
||||
@ -240,7 +247,8 @@ def t_FLOATER(t):
|
||||
try:
|
||||
t.value = float(t.value)
|
||||
except ValueError:
|
||||
print "Floating value invalid:", t.value
|
||||
message = "Floating value invalid: " + repr(t.value)
|
||||
PrintParseError(message)
|
||||
t.value = 0.0
|
||||
return t
|
||||
|
||||
@ -249,7 +257,8 @@ def t_INTEGER(t):
|
||||
try:
|
||||
t.value = int(t.value)
|
||||
except ValueError:
|
||||
print "Integer value too large:", t.value
|
||||
message = "Integer value too large: " + repr(t.value)
|
||||
PrintParseError(message)
|
||||
t.value = 0
|
||||
return t
|
||||
|
||||
@ -270,7 +279,9 @@ def t_newline(t):
|
||||
t.lexer.lineno += t.value.count("\n")
|
||||
|
||||
def t_error(t):
|
||||
print("Illegal character '%s'" % t.value[0])
|
||||
message = "Illegal character '%s' at line %d" % \
|
||||
(t.value[0], t.lexer.lineno)
|
||||
PrintParseError(message)
|
||||
t.lexer.skip(1)
|
||||
|
||||
#
|
||||
@ -593,7 +604,10 @@ def p_empty(p):
|
||||
pass
|
||||
|
||||
def p_error(t):
|
||||
print("Syntax error at '%s'" % t.value), t
|
||||
message = "Syntax error at line %d" % lexer.lineno
|
||||
message += " " + repr(t)
|
||||
message += " " + repr(t.value)
|
||||
PrintParseError(message)
|
||||
|
||||
#
|
||||
# Utility functions
|
||||
@ -717,7 +731,8 @@ def build_variable(MyDriver, p):
|
||||
MyDriver['Funcs'][MyVar[func]]['type'] = func
|
||||
else:
|
||||
# TODO FIXME error message
|
||||
print 'Error: Function type mismatch: var = ' + str(MyVar) + ', code = ' + str(MyDriver['Funcs'][MyVar[func]]) + ', func = ' + str(func)
|
||||
message = 'Error: Function type mismatch: var = ' + str(MyVar) + ', code = ' + str(MyDriver['Funcs'][MyVar[func]]) + ', func = ' + str(func)
|
||||
PrintPostError(message)
|
||||
MyDriver['Funcs'][MyVar[func]]['reference_count'] += 1
|
||||
if 'permlink' in MyVar:
|
||||
device_type, node_type = MyVar['permlink'].split('.')
|
||||
@ -842,7 +857,9 @@ def build_driver(MyDriver, TheTree):
|
||||
MyDriver[key] = item[key]
|
||||
for item in MyDriver['Permlink']:
|
||||
if len(MyDriver['Permlink'][item]) > 1:
|
||||
print 'Error: duplicate permlink entries for "%s"' % item, MyDriver['Permlink'][item]
|
||||
message = 'Error: duplicate permlink entries for "%s"' % item
|
||||
message += " " + repr(MyDriver['Permlink'][item])
|
||||
PrintPostError(message)
|
||||
if Verbose:
|
||||
print "MyDriver:", MyDriver
|
||||
#
|
||||
@ -1348,7 +1365,8 @@ def put_group(MyDriver, MyGroup):
|
||||
idx = int(device_type[1:])
|
||||
device_type = '[string index ${permlink} %d]' % idx
|
||||
else:
|
||||
print 'Error: permlink required in make_ags'
|
||||
message = 'Error: permlink required in make_ags'
|
||||
PrintPostError(message)
|
||||
if 'make_args' in MyDriver and 'id' in MyDriver['make_args'].split():
|
||||
permlink = device_type + '[format "%02d" ${id}]' + node_type
|
||||
else:
|
||||
|
Reference in New Issue
Block a user