Put the generated driver where we got the input

This commit is contained in:
Douglas Clowes
2014-01-30 17:22:09 +11:00
parent 172e69f9e3
commit c2c7128245

View File

@@ -25,6 +25,7 @@
# should some hset commands be hupdate commands?
#
import os
import ply.lex as lex
import ply.yacc as yacc
@@ -215,8 +216,9 @@ def p_driver(p):
p[0] = [{ 'Driver' : {p[2] : p[4]}}]
if Verbose:
print "Driver:", p[0]
global PathName
global TheDrivers
TheDrivers[p[2]] = p[4]
TheDrivers[p[2]] = p[4] + [{'PathName':PathName}]
def p_driver_block(p):
'driver_block : LBRACE driver_statement_list RBRACE'
@@ -1204,8 +1206,10 @@ def generate_driver(MyDriver):
global NumberOfLinesOut
global fdo
NumberOfLinesOut = 0
filename = "sct_%s.tcl" % MyDriver['name']
fdo = open(filename, 'w')
full_filename = filename = "sct_%s.tcl" % MyDriver['name']
if 'PathName' in MyDriver:
full_filename = os.path.join(MyDriver['PathName'], filename)
fdo = open(full_filename, 'w')
put_preamble(MyDriver)
put_standard_code(MyDriver)
if 'driveable' in MyDriver:
@@ -1244,7 +1248,8 @@ def process_drivers(TheDrivers):
if DriverDump or Verbose:
dump_driver(MyDriver)
def process_source(source_file):
def process_source(source_files):
global PathName
global TheDrivers
global NumberOfLinesIn
@@ -1261,12 +1266,15 @@ def process_source(source_file):
#
yaccer = yacc.yacc()
fd = open(source_file, 'r')
data = fd.read()
fd.close()
NumberOfLinesIn = data.count('\n')
print 'Consumed file %s with %d lines' % (source_file, NumberOfLinesIn)
yaccer.parse(data)
for source_file in source_files:
PathName = os.path.realpath(os.path.abspath(os.path.dirname(source_file)))
fd = open(source_file, 'r')
data = fd.read()
fd.close()
NumberOfLinesIn = data.count('\n')
print 'Consumed file %s with %d lines' % (source_file, NumberOfLinesIn)
yaccer.parse(data)
process_drivers(TheDrivers)
def main():
@@ -1297,8 +1305,9 @@ def main():
Verbose = True
else:
Verbose = False
for source_file in args.driver_source:
process_source(source_file)
source_files = args.driver_source
if source_files:
process_source(source_files)
if __name__ == "__main__":
main()