Changes in contrib/arch/hadlbppp.py [af6cad4:28f4adb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
raf6cad4 r28f4adb 42 42 "Print usage syntax" 43 43 44 print "%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname45 print 46 print "--bp Dump original Behavior Protocols (dChecker, BPSlicer)"47 print "--ebp Dump Extended Behavior Protocols (bp2promela)"48 print "--adl Dump Architecture Description Language (modified SOFA ADL/CDL)"49 print "--dot Dump Dot architecture diagram (GraphViz)"50 print "--nop Do not dump anything (just input files syntax check)"51 print 44 print("%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname) 45 print() 46 print("--bp Dump original Behavior Protocols (dChecker, BPSlicer)") 47 print("--ebp Dump Extended Behavior Protocols (bp2promela)") 48 print("--adl Dump Architecture Description Language (modified SOFA ADL/CDL)") 49 print("--dot Dump Dot architecture diagram (GraphViz)") 50 print("--nop Do not dump anything (just input files syntax check)") 51 print() 52 52 53 53 def tabs(cnt): … … 163 163 result.append(tokens[i]) 164 164 else: 165 print "%s: Syntax error in tentative statement" % name165 print("%s: Syntax error in tentative statement" % name) 166 166 else: 167 print "%s: Expected '{' for tentative statement" % name167 print("%s: Expected '{' for tentative statement" % name) 168 168 else: 169 169 result.append(tokens[i]) … … 231 231 result.append(tokens[i]) 232 232 else: 233 print "%s: Syntax error in alternative statement" % name233 print("%s: Syntax error in alternative statement" % name) 234 234 else: 235 print "%s: Expected '{' for alternative statement body" % name235 print("%s: Expected '{' for alternative statement body" % name) 236 236 else: 237 print "%s: At least one pattern and one replacement required for alternative statement" % name237 print("%s: At least one pattern and one replacement required for alternative statement" % name) 238 238 else: 239 print "%s: Expected '(' for alternative statement head" % name239 print("%s: Expected '(' for alternative statement head" % name) 240 240 else: 241 241 result.append(tokens[i]) … … 269 269 result.append(tokens[i]) 270 270 else: 271 print "%s: Unexpected end of protocol" % name271 print("%s: Unexpected end of protocol" % name) 272 272 273 273 i += 1 … … 349 349 elif (token == ")"): 350 350 if (indent < base_indent): 351 print "%s: Too many parentheses" % name351 print("%s: Too many parentheses" % name) 352 352 353 353 indent -= 1 … … 358 358 elif (token == "}"): 359 359 if (indent < base_indent): 360 print "%s: Too many parentheses" % name360 print("%s: Too many parentheses" % name) 361 361 362 362 indent -= 1 … … 370 370 371 371 if (indent > base_indent): 372 print "%s: Missing parentheses" % name372 print("%s: Missing parentheses" % name) 373 373 374 374 output = output.strip() … … 405 405 result.extend(inherited_protocols(supiface)) 406 406 else: 407 print "%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])407 print("%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])) 408 408 409 409 return result … … 459 459 protocols.append(proto) 460 460 else: 461 print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])461 print("%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])) 462 462 463 463 if (opt_bp): 464 outf = file(outname, "w")464 outf = open(outname, "w") 465 465 outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0)) 466 466 outf.close() 467 467 468 468 if (opt_ebp): 469 outf = file(outname, "w")469 outf = open(outname, "w") 470 470 outf.write(parse_ebp(frame['name'], outname, merge_bp(initialization, finalization, protocols), 0)) 471 471 outf.close() … … 514 514 515 515 if (opt_bp): 516 outf = file(outname, "w")516 outf = open(outname, "w") 517 517 outf.write("NULL") 518 518 outf.close() 519 519 520 520 if (opt_ebp): 521 outf = file(outname, "w")521 outf = open(outname, "w") 522 522 outf.write("component null {\n\tbehavior {\n\t\tNULL\n\t}\n}") 523 523 outf.close() … … 587 587 insts.append({'var': "%s_%s" % (prefix, inst['var']), 'frame': subframe}) 588 588 else: 589 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])589 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 590 590 591 591 if ('bind' in arch): … … 612 612 613 613 if (arch is None): 614 print "Unable to find system architecture"614 print("Unable to find system architecture") 615 615 return 616 616 … … 634 634 insts.append({'var': inst['var'], 'frame': subframe}) 635 635 else: 636 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])636 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 637 637 638 638 if ('bind' in arch): … … 642 642 if ('delegate' in arch): 643 643 for delegate in arch['delegate']: 644 print "Unable to delegate interface in system architecture"644 print("Unable to delegate interface in system architecture") 645 645 break 646 646 647 647 if ('subsume' in arch): 648 648 for subsume in arch['subsume']: 649 print "Unable to subsume interface in system architecture"649 print("Unable to subsume interface in system architecture") 650 650 break 651 651 … … 654 654 outname = os.path.join(outdir, "%s.archbp" % arch['name']) 655 655 if ((opt_bp) or (opt_ebp)): 656 outf = file(outname, "w")656 outf = open(outname, "w") 657 657 else: 658 658 outf = None … … 709 709 710 710 if (not os.path.isfile(path)): 711 print "%s: Unable to include file %s" % (inname, path)711 print("%s: Unable to include file %s" % (inname, path)) 712 712 return "" 713 713 else: … … 716 716 nested_root = root 717 717 718 inf = file(path, "r")718 inf = open(path, "r") 719 719 720 720 raw = preproc_adl(inf.read(), inarg) … … 733 733 if (POST_INC in context): 734 734 if (token != "]"): 735 print "%s: Expected ]" % inname735 print("%s: Expected ]" % inname) 736 736 737 737 context.remove(POST_INC) … … 774 774 if (NULL in context): 775 775 if (token != ";"): 776 print "%s: Expected ';' in frame '%s'" % (inname, frame)776 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 777 777 else: 778 778 output += "%s\n" % token … … 798 798 799 799 if ('finalization' in frame_properties[frame]): 800 print "%s: Finalization protocol for frame '%s' already defined" % (inname, frame)800 print("%s: Finalization protocol for frame '%s' already defined" % (inname, frame)) 801 801 else: 802 802 frame_properties[frame]['finalization'] = bp … … 832 832 833 833 if ('initialization' in frame_properties[frame]): 834 print "%s: Initialization protocol for frame '%s' already defined" % (inname, frame)834 print("%s: Initialization protocol for frame '%s' already defined" % (inname, frame)) 835 835 else: 836 836 frame_properties[frame]['initialization'] = bp … … 866 866 867 867 if ('protocol' in frame_properties[frame]): 868 print "%s: Protocol for frame '%s' already defined" % (inname, frame)868 print("%s: Protocol for frame '%s' already defined" % (inname, frame)) 869 869 else: 870 870 frame_properties[frame]['protocol'] = bp … … 889 889 if (FIN in context): 890 890 if (token != ";"): 891 print "%s: Expected ';' in frame '%s'" % (inname, frame)891 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 892 892 else: 893 893 output += "%s" % token … … 898 898 if (VAR in context): 899 899 if (not identifier(token)): 900 print "%s: Variable name expected in frame '%s'" % (inname, frame)900 print("%s: Variable name expected in frame '%s'" % (inname, frame)) 901 901 else: 902 902 if (not frame in frame_properties): … … 919 919 else: 920 920 if (not identifier(token)): 921 print "%s: Interface name expected in frame '%s'" % (inname, frame)921 print("%s: Interface name expected in frame '%s'" % (inname, frame)) 922 922 else: 923 923 arg0 = token … … 930 930 if (FIN in context): 931 931 if (token != ";"): 932 print "%s: Expected ';' in frame '%s'" % (inname, frame)932 print("%s: Expected ';' in frame '%s'" % (inname, frame)) 933 933 else: 934 934 output += "%s" % token … … 939 939 if (VAR in context): 940 940 if (not identifier(token)): 941 print "%s: Variable name expected in frame '%s'" % (inname, frame)941 print("%s: Variable name expected in frame '%s'" % (inname, frame)) 942 942 else: 943 943 if (not frame in frame_properties): … … 960 960 else: 961 961 if (not identifier(token)): 962 print "%s: Interface name expected in frame '%s'" % (inname, frame)962 print("%s: Interface name expected in frame '%s'" % (inname, frame)) 963 963 else: 964 964 arg0 = token … … 970 970 if (token == "}"): 971 971 if (indent != 2): 972 print "%s: Wrong number of parentheses in frame '%s'" % (inname, frame)972 print("%s: Wrong number of parentheses in frame '%s'" % (inname, frame)) 973 973 else: 974 974 indent = 0 … … 1010 1010 continue 1011 1011 1012 print "%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)1012 print("%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)) 1013 1013 continue 1014 1014 … … 1027 1027 continue 1028 1028 1029 print "%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)1029 print("%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)) 1030 1030 1031 1031 continue 1032 1032 1033 1033 if (not identifier(token)): 1034 print "%s: Expected frame name" % inname1034 print("%s: Expected frame name" % inname) 1035 1035 else: 1036 1036 frame = token … … 1050 1050 if (NULL in context): 1051 1051 if (token != ";"): 1052 print "%s: Expected ';' in interface '%s'" % (inname, interface)1052 print("%s: Expected ';' in interface '%s'" % (inname, interface)) 1053 1053 else: 1054 1054 output += "%s\n" % token … … 1074 1074 1075 1075 if ('protocol' in iface_properties[interface]): 1076 print "%s: Protocol for interface '%s' already defined" % (inname, interface)1076 print("%s: Protocol for interface '%s' already defined" % (inname, interface)) 1077 1077 else: 1078 1078 iface_properties[interface]['protocol'] = bp … … 1094 1094 if (FIN in context): 1095 1095 if (token != ";"): 1096 print "%s: Expected ';' in interface '%s'" % (inname, interface)1096 print("%s: Expected ';' in interface '%s'" % (inname, interface)) 1097 1097 else: 1098 1098 output += "%s" % token … … 1124 1124 if (PAR_LEFT in context): 1125 1125 if (token != "("): 1126 print "%s: Expected '(' in interface '%s'" % (inname, interface)1126 print("%s: Expected '(' in interface '%s'" % (inname, interface)) 1127 1127 else: 1128 1128 output += "%s" % token … … 1133 1133 1134 1134 if (not identifier(token)): 1135 print "%s: Method identifier expected in interface '%s'" % (inname, interface)1135 print("%s: Method identifier expected in interface '%s'" % (inname, interface)) 1136 1136 else: 1137 1137 output += "%s" % token … … 1142 1142 if (token == "}"): 1143 1143 if (indent != 2): 1144 print "%s: Wrong number of parentheses in interface '%s'" % (inname, interface)1144 print("%s: Wrong number of parentheses in interface '%s'" % (inname, interface)) 1145 1145 else: 1146 1146 indent = 0 … … 1163 1163 continue 1164 1164 1165 print "%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)1165 print("%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)) 1166 1166 continue 1167 1167 … … 1183 1183 continue 1184 1184 1185 print "%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)1185 print("%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)) 1186 1186 continue 1187 1187 1188 1188 if (EXTENDS in context): 1189 1189 if (not identifier(token)): 1190 print "%s: Expected inherited interface name in interface head '%s'" % (inname, interface)1190 print("%s: Expected inherited interface name in interface head '%s'" % (inname, interface)) 1191 1191 else: 1192 1192 output += "%s " % token … … 1218 1218 continue 1219 1219 1220 print "%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)1220 print("%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)) 1221 1221 continue 1222 1222 1223 1223 if (not identifier(token)): 1224 print "%s: Expected interface name" % inname1224 print("%s: Expected interface name" % inname) 1225 1225 else: 1226 1226 interface = token … … 1240 1240 if (NULL in context): 1241 1241 if (token != ";"): 1242 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1242 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1243 1243 else: 1244 1244 output += "%s\n" % token … … 1254 1254 if (FIN in context): 1255 1255 if (token != ";"): 1256 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1256 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1257 1257 else: 1258 1258 output += "%s" % token … … 1264 1264 if (VAR in context): 1265 1265 if (not descriptor(token)): 1266 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1266 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1267 1267 else: 1268 1268 if (not architecture in arch_properties): … … 1283 1283 if (TO in context): 1284 1284 if (token != "to"): 1285 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1285 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1286 1286 else: 1287 1287 output += "%s " % token … … 1292 1292 1293 1293 if (not identifier(token)): 1294 print "%s: Expected interface name in architecture '%s'" % (inname, architecture)1294 print("%s: Expected interface name in architecture '%s'" % (inname, architecture)) 1295 1295 else: 1296 1296 output += "%s " % token … … 1303 1303 if (FIN in context): 1304 1304 if (token != ";"): 1305 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1305 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1306 1306 else: 1307 1307 output += "%s" % token … … 1313 1313 if (VAR in context): 1314 1314 if (not identifier(token)): 1315 print "%s: Expected interface name in architecture '%s'" % (inname, architecture)1315 print("%s: Expected interface name in architecture '%s'" % (inname, architecture)) 1316 1316 else: 1317 1317 if (not architecture in arch_properties): … … 1332 1332 if (TO in context): 1333 1333 if (token != "to"): 1334 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1334 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1335 1335 else: 1336 1336 output += "%s " % token … … 1341 1341 1342 1342 if (not descriptor(token)): 1343 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1343 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1344 1344 else: 1345 1345 output += "%s " % token … … 1352 1352 if (FIN in context): 1353 1353 if (token != ";"): 1354 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1354 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1355 1355 else: 1356 1356 output += "%s" % token … … 1362 1362 if (VAR in context): 1363 1363 if (not descriptor(token)): 1364 print "%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)1364 print("%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)) 1365 1365 else: 1366 1366 if (not architecture in arch_properties): … … 1381 1381 if (TO in context): 1382 1382 if (token != "to"): 1383 print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)1383 print("%s: Expected 'to' in architecture '%s'" % (inname, architecture)) 1384 1384 else: 1385 1385 output += "%s " % token … … 1390 1390 1391 1391 if (not descriptor(token)): 1392 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)1392 print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)) 1393 1393 else: 1394 1394 output += "%s " % token … … 1401 1401 if (FIN in context): 1402 1402 if (token != ";"): 1403 print "%s: Expected ';' in architecture '%s'" % (inname, architecture)1403 print("%s: Expected ';' in architecture '%s'" % (inname, architecture)) 1404 1404 else: 1405 1405 output += "%s" % token … … 1411 1411 if (VAR in context): 1412 1412 if (not identifier(token)): 1413 print "%s: Expected instance name in architecture '%s'" % (inname, architecture)1413 print("%s: Expected instance name in architecture '%s'" % (inname, architecture)) 1414 1414 else: 1415 1415 if (not architecture in arch_properties): … … 1429 1429 1430 1430 if (not identifier(token)): 1431 print "%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)1431 print("%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)) 1432 1432 else: 1433 1433 output += "%s " % token … … 1439 1439 if (token == "}"): 1440 1440 if (indent != 1): 1441 print "%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)1441 print("%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)) 1442 1442 else: 1443 1443 indent -= 1 … … 1468 1468 continue 1469 1469 1470 print "%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)1470 print("%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)) 1471 1471 continue 1472 1472 … … 1487 1487 1488 1488 if (not word(token)): 1489 print "%s: Expected word in architecture head '%s'" % (inname, architecture)1489 print("%s: Expected word in architecture head '%s'" % (inname, architecture)) 1490 1490 else: 1491 1491 output += "%s " % token … … 1494 1494 1495 1495 if (not identifier(token)): 1496 print "%s: Expected architecture name" % inname1496 print("%s: Expected architecture name" % inname) 1497 1497 else: 1498 1498 architecture = token … … 1514 1514 if (SYSTEM in context): 1515 1515 if (token != "architecture"): 1516 print "%s: Expected 'architecture'" % inname1516 print("%s: Expected 'architecture'" % inname) 1517 1517 else: 1518 1518 output += "%s " % token … … 1541 1541 continue 1542 1542 1543 print "%s: Unknown token '%s'" % (inname, token)1543 print("%s: Unknown token '%s'" % (inname, token)) 1544 1544 1545 1545 inf.close() … … 1575 1575 1576 1576 if ((output != "") and (opt_adl)): 1577 outf = file(outname, "w")1577 outf = open(outname, "w") 1578 1578 outf.write(output) 1579 1579 outf.close() … … 1633 1633 merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1) 1634 1634 else: 1635 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])1635 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1636 1636 1637 1637 if ('bind' in arch): … … 1728 1728 1729 1729 if (arch is None): 1730 print "Unable to find system architecture"1730 print("Unable to find system architecture") 1731 1731 return 1732 1732 1733 1733 if (opt_dot): 1734 1734 outname = os.path.join(outdir, "%s.dot" % arch['name']) 1735 outf = file(outname, "w")1735 outf = open(outname, "w") 1736 1736 1737 1737 outf.write("digraph {\n") … … 1752 1752 merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1) 1753 1753 else: 1754 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])1754 print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])) 1755 1755 1756 1756 if ('bind' in arch): … … 1784 1784 if ('delegate' in arch): 1785 1785 for delegate in arch['delegate']: 1786 print "Unable to delegate interface in system architecture"1786 print("Unable to delegate interface in system architecture") 1787 1787 break 1788 1788 1789 1789 if ('subsume' in arch): 1790 1790 for subsume in arch['subsume']: 1791 print "Unable to subsume interface in system architecture"1791 print("Unable to subsume interface in system architecture") 1792 1792 break 1793 1793 … … 1826 1826 pass 1827 1827 else: 1828 print "Error: Unknown command line option '%s'" % arg1828 print("Error: Unknown command line option '%s'" % arg) 1829 1829 return 1830 1830 1831 1831 if ((opt_bp) and (opt_ebp)): 1832 print "Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols"1832 print("Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols") 1833 1833 return 1834 1834 1835 1835 path = os.path.abspath(sys.argv[-1]) 1836 1836 if (not os.path.isdir(path)): 1837 print "Error: <OUTPUT> is not a directory"1837 print("Error: <OUTPUT> is not a directory") 1838 1838 return 1839 1839
Note:
See TracChangeset
for help on using the changeset viewer.