Commit a0f45ecd authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Major restructuring: 2to3, manual cleanups, module restructure

parent 05ec82b9
This diff is collapsed.
......@@ -498,7 +498,7 @@ class Parser(antlr.LLkParser):
if not commonPy.configMT.g_bOnlySubprograms:
for threadFeature in threadFeatures:
if threadFeature == None: continue
if not g_signals.has_key(threadFeature._port._type):
if threadFeature._port._type not in g_signals:
# panic("Line %d: Referenced datatype (%s) not defined yet" % \
# (id.getLine(),threadFeature._port._type))
signal = threadFeature._port._type
......@@ -538,7 +538,7 @@ class Parser(antlr.LLkParser):
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
if id.getText() not in g_apLevelContainers:
panic("Line %d: THREAD (%s) must first be declared before it is PROPERTIES-ed" % (id.getLine(), id.getText()))
sp = g_apLevelContainers[id.getText()]
for property in properties:
......@@ -583,7 +583,7 @@ class Parser(antlr.LLkParser):
self.match(IDENT)
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: Thread (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
g_threadImplementations.append([typeid.getText(), defid.getText(), sp._language, ""])
......@@ -665,7 +665,7 @@ class Parser(antlr.LLkParser):
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if cci != None:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: THREAD (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
for assoc in cci:
......@@ -1166,7 +1166,7 @@ class Parser(antlr.LLkParser):
if not self.inputState.guessing:
for spFeature in features:
if spFeature == None: continue
if not g_signals.has_key(spFeature._parameter._type):
if spFeature._parameter._type not in g_signals:
# panic("Line %d: Referenced datatype (%s) not defined yet" % \
# (id.getLine(),spFeature._parameter._type))
signal = spFeature._parameter._type
......@@ -1205,7 +1205,7 @@ class Parser(antlr.LLkParser):
properties=self.propertyAssociations_no_modes()
if not self.inputState.guessing:
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
if id.getText() not in g_apLevelContainers:
panic("Line %d: SUBPROGRAM (%s) must first be declared before it is PROPERTIES-ed" % (id.getLine(), id.getText()))
sp = g_apLevelContainers[id.getText()]
for property in properties:
......@@ -1248,7 +1248,7 @@ class Parser(antlr.LLkParser):
defid = self.LT(1)
self.match(IDENT)
if not self.inputState.guessing:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: Subprogram (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
g_subProgramImplementations.append([typeid.getText(), defid.getText(), sp._language, "" ])
......@@ -1317,7 +1317,7 @@ class Parser(antlr.LLkParser):
c=self.common_component_impl()
if not self.inputState.guessing:
if c != None:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: SUBPROGRAM (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
for assoc in c:
......@@ -1372,7 +1372,7 @@ class Parser(antlr.LLkParser):
if not commonPy.configMT.g_bOnlySubprograms:
for processFeature in processFeatures:
if processFeature == None: continue
if not g_signals.has_key(processFeature._port._type):
if processFeature._port._type not in g_signals:
# panic("Line %d: Referenced datatype (%s) not defined yet" % \
# (id.getLine(),processFeature._port._type))
signal = processFeature._port._type
......@@ -1412,7 +1412,7 @@ class Parser(antlr.LLkParser):
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
if id.getText() not in g_apLevelContainers:
panic("Line %d: PROCESS (%s) must first be declared before it is PROPERTIES-ed" % (id.getLine(), id.getText()))
sp = g_apLevelContainers[id.getText()]
for property in properties:
......@@ -1456,7 +1456,7 @@ class Parser(antlr.LLkParser):
self.match(IDENT)
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: Process (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
g_processImplementations.append([typeid.getText(), defid.getText(), sp._language, ""])
......@@ -1527,7 +1527,7 @@ class Parser(antlr.LLkParser):
if not self.inputState.guessing:
if not commonPy.configMT.g_bOnlySubprograms:
if cci != None:
if not g_apLevelContainers.has_key(typeid.getText()):
if typeid.getText() not in g_apLevelContainers:
panic("Line %d: PROCESS (%s) must first be declared before it is implemented" % (typeid.getLine(), typeid.getText()))
sp = g_apLevelContainers[typeid.getText()]
for assoc in cci:
......@@ -5400,7 +5400,7 @@ class Parser(antlr.LLkParser):
pass
s=self.signed_aadlnumeric()
self.match(DOTDOT)
except antlr.RecognitionException, pe:
except antlr.RecognitionException as pe:
synPredMatched415 = False
self.rewind(_m415)
self.inputState.guessing -= 1
......@@ -5586,7 +5586,7 @@ class Parser(antlr.LLkParser):
pass
self.signed_aadlnumeric()
self.match(DOTDOT)
except antlr.RecognitionException, pe:
except antlr.RecognitionException as pe:
synPredMatched443 = False
self.rewind(_m443)
self.inputState.guessing -= 1
......@@ -5954,7 +5954,7 @@ class Parser(antlr.LLkParser):
self.match(LPAREN)
pe1=self.property_expression()
self.match(COMMA)
except antlr.RecognitionException, pe:
except antlr.RecognitionException as pe:
synPredMatched501 = False
self.rewind(_m501)
self.inputState.guessing -= 1
......@@ -6013,7 +6013,7 @@ class Parser(antlr.LLkParser):
pass
self.property_name_constant_reference()
self.match(DOTDOT)
except antlr.RecognitionException, pe:
except antlr.RecognitionException as pe:
synPredMatched510 = False
self.rewind(_m510)
self.inputState.guessing -= 1
......@@ -6189,7 +6189,7 @@ class Parser(antlr.LLkParser):
pass
self.signed_constant()
self.match(DOTDOT)
except antlr.RecognitionException, pe:
except antlr.RecognitionException as pe:
synPredMatched527 = False
self.rewind(_m527)
self.inputState.guessing -= 1
......@@ -7672,259 +7672,259 @@ _tokenNames = [
### generate bit set
def mk_tokenSet_0():
### var1
data = [ 85907705872L, 2L, 0L, 0L]
data = [ 85907705872, 2, 0, 0]
return data
_tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
### generate bit set
def mk_tokenSet_1():
### var1
data = [ 17188229120L, 2L, 0L, 0L]
data = [ 17188229120, 2, 0, 0]
return data
_tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
### generate bit set
def mk_tokenSet_2():
### var1
data = [ 576L, 528L, 0L, 0L]
data = [ 576, 528, 0, 0]
return data
_tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
### generate bit set
def mk_tokenSet_3():
### var1
data = [ 2359808L, 22L, 0L, 0L]
data = [ 2359808, 22, 0, 0]
return data
_tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
### generate bit set
def mk_tokenSet_4():
### var1
data = [ 1152921504674234880L, 2L, 0L, 0L]
data = [ 1152921504674234880, 2, 0, 0]
return data
_tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
### generate bit set
def mk_tokenSet_5():
### var1
data = [ 10748416L, 67108886L, 0L, 0L]
data = [ 10748416, 67108886, 0, 0]
return data
_tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
### generate bit set
def mk_tokenSet_6():
### var1
data = [ 576L, 8704L, 0L, 0L]
data = [ 576, 8704, 0, 0]
return data
_tokenSet_6 = antlr.BitSet(mk_tokenSet_6())
### generate bit set
def mk_tokenSet_7():
### var1
data = [ 4621924670705238592L, 0L]
data = [ 4621924670705238592, 0]
return data
_tokenSet_7 = antlr.BitSet(mk_tokenSet_7())
### generate bit set
def mk_tokenSet_8():
### var1
data = [ 4620719605961196096L, 8320L, 0L, 0L]
data = [ 4620719605961196096, 8320, 0, 0]
return data
_tokenSet_8 = antlr.BitSet(mk_tokenSet_8())
### generate bit set
def mk_tokenSet_9():
### var1
data = [ 4621845505868038720L, 8192L, 0L, 0L]
data = [ 4621845505868038720, 8192, 0, 0]
return data
_tokenSet_9 = antlr.BitSet(mk_tokenSet_9())
### generate bit set
def mk_tokenSet_10():
### var1
data = [ 4611712406706455104L, 8192L, 0L, 0L]
data = [ 4611712406706455104, 8192, 0, 0]
return data
_tokenSet_10 = antlr.BitSet(mk_tokenSet_10())
### generate bit set
def mk_tokenSet_11():
### var1
data = [ 16888498602639872L, 0L]
data = [ 16888498602639872, 0]
return data
_tokenSet_11 = antlr.BitSet(mk_tokenSet_11())
### generate bit set
def mk_tokenSet_12():
### var1
data = [ 16888498602639936L, 128L, 0L, 0L]
data = [ 16888498602639936, 128, 0, 0]
return data
_tokenSet_12 = antlr.BitSet(mk_tokenSet_12())
### generate bit set
def mk_tokenSet_13():
### var1
data = [ 67109472L, 0L]
data = [ 67109472, 0]
return data
_tokenSet_13 = antlr.BitSet(mk_tokenSet_13())
### generate bit set
def mk_tokenSet_14():
### var1
data = [ 16914886881706496L, 128L, 0L, 0L]
data = [ 16914886881706496, 128, 0, 0]
return data
_tokenSet_14 = antlr.BitSet(mk_tokenSet_14())
### generate bit set
def mk_tokenSet_15():
### var1
data = [ 9033587533808128L, 0L]
data = [ 9033587533808128, 0]
return data
_tokenSet_15 = antlr.BitSet(mk_tokenSet_15())
### generate bit set
def mk_tokenSet_16():
### var1
data = [ 15788986974863936L, 0L]
data = [ 15788986974863936, 0]
return data
_tokenSet_16 = antlr.BitSet(mk_tokenSet_16())
### generate bit set
def mk_tokenSet_17():
### var1
data = [ 15788986974863968L, 0L]
data = [ 15788986974863968, 0]
return data
_tokenSet_17 = antlr.BitSet(mk_tokenSet_17())
### generate bit set
def mk_tokenSet_18():
### var1
data = [ 800L, 4195328L, 0L, 0L]
data = [ 800, 4195328, 0, 0]
return data
_tokenSet_18 = antlr.BitSet(mk_tokenSet_18())
### generate bit set
def mk_tokenSet_19():
### var1
data = [ 17179869728L, 4195328L, 0L, 0L]
data = [ 17179869728, 4195328, 0, 0]
return data
_tokenSet_19 = antlr.BitSet(mk_tokenSet_19())
### generate bit set
def mk_tokenSet_20():
### var1
data = [ 159882184826524160L, 1970176L, 0L, 0L]
data = [ 159882184826524160, 1970176, 0, 0]
return data
_tokenSet_20 = antlr.BitSet(mk_tokenSet_20())
### generate bit set
def mk_tokenSet_21():
### var1
data = [ 10146293301133824L, 1019904L, 0L, 0L]
data = [ 10146293301133824, 1019904, 0, 0]
return data
_tokenSet_21 = antlr.BitSet(mk_tokenSet_21())
### generate bit set
def mk_tokenSet_22():
### var1
data = [ 161034473020823040L, 2068480L, 0L, 0L]
data = [ 161034473020823040, 2068480, 0, 0]
return data
_tokenSet_22 = antlr.BitSet(mk_tokenSet_22())
### generate bit set
def mk_tokenSet_23():
### var1
data = [ 159895378966057472L, 1048576L, 0L, 0L]
data = [ 159895378966057472, 1048576, 0, 0]
return data
_tokenSet_23 = antlr.BitSet(mk_tokenSet_23())
### generate bit set
def mk_tokenSet_24():
### var1
data = [ 4621836709775032896L, 12288L, 0L, 0L]
data = [ 4621836709775032896, 12288, 0, 0]
return data
_tokenSet_24 = antlr.BitSet(mk_tokenSet_24())
### generate bit set
def mk_tokenSet_25():
### var1
data = [ 4628596524719277920L, 4224000L, 0L, 0L]
data = [ 4628596524719277920, 4224000, 0, 0]
return data
_tokenSet_25 = antlr.BitSet(mk_tokenSet_25())
### generate bit set
def mk_tokenSet_26():
### var1
data = [ 159877786780013056L, 1048576L, 0L, 0L]
data = [ 159877786780013056, 1048576, 0, 0]
return data
_tokenSet_26 = antlr.BitSet(mk_tokenSet_26())
### generate bit set
def mk_tokenSet_27():
### var1
data = [ 4398046511104L, 921600L, 0L, 0L]
data = [ 4398046511104, 921600, 0, 0]
return data
_tokenSet_27 = antlr.BitSet(mk_tokenSet_27())
### generate bit set
def mk_tokenSet_28():
### var1
data = [ 4611690416473899072L, 1028096L, 0L, 0L]
data = [ 4611690416473899072, 1028096, 0, 0]
return data
_tokenSet_28 = antlr.BitSet(mk_tokenSet_28())
### generate bit set
def mk_tokenSet_29():
### var1
data = [ 4611708026108248928L, 5239808L, 0L, 0L]
data = [ 4611708026108248928, 5239808, 0, 0]
return data
_tokenSet_29 = antlr.BitSet(mk_tokenSet_29())
### generate bit set
def mk_tokenSet_30():
### var1
data = [ 4611778394860787552L, 5241858L, 0L, 0L]
data = [ 4611778394860787552, 5241858, 0, 0]
return data
_tokenSet_30 = antlr.BitSet(mk_tokenSet_30())
### generate bit set
def mk_tokenSet_31():
### var1
data = [ 4621845505868038720L, 12288L, 0L, 0L]
data = [ 4621845505868038720, 12288, 0, 0]
return data
_tokenSet_31 = antlr.BitSet(mk_tokenSet_31())
### generate bit set
def mk_tokenSet_32():
### var1
data = [ 4772720508888126304L, 6190080L, 0L, 0L]
data = [ 4772720508888126304, 6190080, 0, 0]
return data
_tokenSet_32 = antlr.BitSet(mk_tokenSet_32())
### generate bit set
def mk_tokenSet_33():
### var1
data = [ 4772790877632321376L, 6290562L, 0L, 0L]
data = [ 4772790877632321376, 6290562, 0, 0]
return data
_tokenSet_33 = antlr.BitSet(mk_tokenSet_33())
### generate bit set
def mk_tokenSet_34():
### var1
data = [ 8796093022272L, 637542912L, 0L, 0L]
data = [ 8796093022272, 637542912, 0, 0]
return data
_tokenSet_34 = antlr.BitSet(mk_tokenSet_34())
### generate bit set
def mk_tokenSet_35():
### var1
data = [ 64L, 67117568L, 0L, 0L]
data = [ 64, 67117568, 0, 0]
return data
_tokenSet_35 = antlr.BitSet(mk_tokenSet_35())
### generate bit set
def mk_tokenSet_36():
### var1
data = [ 8388672L, 8704L, 0L, 0L]
data = [ 8388672, 8704, 0, 0]
return data
_tokenSet_36 = antlr.BitSet(mk_tokenSet_36())
......@@ -4,6 +4,6 @@
"""
aadl2glueC : B mappers -generate code that convert from/to ASN1SCC
"""
from aadl2glueC import main
from .aadl2glueC import main
__version__ = 1.0
......@@ -91,8 +91,8 @@ import commonPy.aadlAST
import commonPy.cleanupNodes
#import aadlParser
import AadlLexer
import AadlParser
from . import AadlLexer
from . import AadlParser
import antlr
......@@ -192,11 +192,11 @@ of each SUBPROGRAM param.'''
P.setFilename(L.getFilename())
try:
P.aadl_specification()
except antlr.ANTLRException, e: # pragma: no cover
except antlr.ANTLRException as e: # pragma: no cover
panic("Error in file '%s': %s\n" % (e.fileName, str(e))) # pragma: no cover
# Resolve signal definitions over all input AADL files
for subProgramName, subProgram in commonPy.aadlAST.g_apLevelContainers.iteritems():
for subProgramName, subProgram in commonPy.aadlAST.g_apLevelContainers.items():
inform("Resolving data definitions in subprogram %s..." % subProgramName)
for param in subProgram._params:
if not isinstance(param._signal, commonPy.aadlAST.Signal):
......@@ -268,7 +268,7 @@ def main():
ParseAADLfilesAndResolveSignals()
uniqueDataFiles = {}
for sp in commonPy.aadlAST.g_apLevelContainers.values():
for sp in list(commonPy.aadlAST.g_apLevelContainers.values()):
for param in sp._params:
uniqueDataFiles.setdefault(param._signal._asnFilename, {})
uniqueDataFiles[param._signal._asnFilename].setdefault(sp._language, [])
......@@ -282,8 +282,8 @@ def main():
# panic("There are no data references anywhere in the given AADL files. Aborting...")
# sys.exit(0)
if len(uniqueDataFiles.keys()) != 0:
commonPy.asnParser.ParseAsnFileList(uniqueDataFiles.keys())
if len(list(uniqueDataFiles.keys())) != 0:
commonPy.asnParser.ParseAsnFileList(list(uniqueDataFiles.keys()))
for asnFile in uniqueDataFiles:
tmpNames = {}
......@@ -296,7 +296,7 @@ def main():
copy.copy(commonPy.asnParser.g_leafTypeDict)] # map from Typename to leafType
inform("Checking that all base nodes have mandatory ranges set in %s..." % asnFile)
for node in tmpNames.values():
for node in list(tmpNames.values()):
verify.VerifyRanges(node, commonPy.asnParser.g_names)
# # For each ASN.1 grammar file referenced in the system level description
......
......@@ -40,7 +40,7 @@ output parameters, which have Ada callable interfaces.
# from recursiveMapper import RecursiveMapper
# from asynchronousTool import ASynchronousToolGlueGenerator
import c_B_mapper
from . import c_B_mapper
isAsynchronous = True
adaBackend = None
......@@ -48,7 +48,7 @@ cBackend = None
def Version():
print "Code generator: " + "$Id: ada_B_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $" # pragma: no cover
print("Code generator: " + "$Id: ada_B_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $") # pragma: no cover
# All the ada B mapper is now Obsolete, we are using ASN1SCC for Dumpables
#
......
#!/usr/bin/env python
import AadlLexer
import AadlParser
from . import AadlLexer
from . import AadlParser
import commonPy.aadlAST
import commonPy.utility
import antlr
......@@ -17,7 +17,7 @@ def main():
try:
P.aadl_specification()
except antlr.ANTLRException, e:
except antlr.ANTLRException as e:
commonPy.utility.panic("Error: %s\n" % (str(e)))
SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:]
......@@ -26,25 +26,25 @@ def main():
for si in SystemsAndImplementations:
sp, sp_impl, modelingLanguage, fv_name = si[0], si[1], si[2], si[3]
sp = commonPy.aadlAST.g_apLevelContainers[sp]
print sp._id+"."+sp_impl, "(", modelingLanguage, ") FV_name:", fv_name
print(sp._id+"."+sp_impl, "(", modelingLanguage, ") FV_name:", fv_name)
for param in sp._params:
print "\t",
print("\t", end=' ')
if isinstance(param, commonPy.aadlAST.InParam):
print "IN",
print("IN", end=' ')
elif isinstance(param, commonPy.aadlAST.OutParam):
print "OUT",
print("OUT", end=' ')
elif isinstance(param, commonPy.aadlAST.InOutParam):
print "INOUT",
print("INOUT", end=' ')
if isinstance(param._signal, commonPy.aadlAST.Signal):
print "\t", param._id, ":", param._signal._asnFilename, param._signal._asnNodename, "(", param._sourceElement._encoding, ")"
print("\t", param._id, ":", param._signal._asnFilename, param._signal._asnNodename, "(", param._sourceElement._encoding, ")")
else:
print "\t", param._id, ":", param._signal, "(", param._sourceElement._encoding, ")"
print
print("\t", param._id, ":", param._signal, "(", param._sourceElement._encoding, ")")
print()
if len(sp._connections):
print "\tConnections:"
print("\tConnections:")
for pair in sp._connections:
print "\t\tfrom", pair._from._componentId+':'+pair._from._portId, "to", pair._to._componentId+':'+pair._to._portId
print
print("\t\tfrom", pair._from._componentId+':'+pair._from._portId, "to", pair._to._componentId+':'+pair._to._portId)
print()
if __name__ == "__main__":
main()
......@@ -144,7 +144,7 @@ class ASynchronousToolGlueGenerator:
self.typesToWorkOn[nodeTypename]=[node, leafTypeDict, names]
def OnShutdown(self, unused_modelingLanguage, unused_asnFile, unused_maybeFVname):
for nodeTypename, value in self.typesToWorkOn.items():
for nodeTypename, value in list(self.typesToWorkOn.items()):
inform(str(self.__class__) + "Really working on " + nodeTypename)
(node, leafTypeDict, names) = value
self.Common(nodeTypename, node, leafTypeDict, names)
......
......@@ -40,14 +40,14 @@ from commonPy.utility import panic
from commonPy.asnAST import sourceSequenceLimit, isSequenceVariable, targetSequenceLimit
from commonPy.recursiveMapper import RecursiveMapper
from asynchronousTool import ASynchronousToolGlueGenerator
from .asynchronousTool import ASynchronousToolGlueGenerator
isAsynchronous = True