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

Appease Google's Mobile-friendly status on some pages

parent a0f45ecd
This diff is collapsed.
// $ANTLR 2.7.7 (20120126): aadl.g -> AadlParserTokenTypes.txt$
AadlParser // output token vocab name
PACKAGE="package"=4
END="end"=5
SEMI=6
PUBLIC="public"=7
PRIVATE="private"=8
IDENT=9
DOUBLECOLON=10
NONE="none"=11
THREAD="thread"=12
EXTENDS="extends"=13
GROUP="group"=14
PROCESS="process"=15
SYSTEM="system"=16
SUBPROGRAM="subprogram"=17
DATA="data"=18
PROCESSOR="processor"=19
MEMORY="memory"=20
BUS="bus"=21
DEVICE="device"=22
DOT=23
IMPL="implementation"=24
FEATURES="features"=25
COLON=26
REFINED="refined"=27
TO="to"=28
PROVIDES="provides"=29
REQUIRES="requires"=30
REFINES="refines"=31
TYPE="type"=32
SUBCOMPONENTS="subcomponents"=33
ANNEX="annex"=34
ANNEX_TEXT=35
PROPERTY="property"=36
SET="set"=37
IS="is"=38
BOOLEAN="aadlboolean"=39
STRING="aadlstring"=40
ENUMERATION="enumeration"=41
LPAREN=42
COMMA=43
RPAREN=44
UNITS="units"=45
ASSIGN=46
STAR=47
REAL="aadlreal"=48
INTEGER="aadlinteger"=49
DOTDOT=50
PLUS=51
MINUS=52
NUMERIC_LIT=53
RANGE="range"=54
OF="of"=55
CLASSIFIER="classifier"=56
REFERENCE="reference"=57
CONNECTIONS="connections"=58
SERVER="server"=59
ACCESS="access"=60
INHERIT="inherit"=61
APPLIES="applies"=62
ALL="all"=63
MODE="mode"=64
PORT="port"=65
EVENT="event"=66
FLOW="flow"=67
PARAMETER="parameter"=68
LIST="list"=69
CONSTANT="constant"=70
DELTA="delta"=71
PROPERTIES="properties"=72
LCURLY=73
RCURLY=74
ASSIGNPLUS=75
VALUE="value"=76
IN="in"=77
BINDING="binding"=78
OR="or"=79
AND="and"=80
TRUE="true"=81
FALSE="false"=82
NOT=83
STRING_LITERAL=84
CALLS="calls"=85
MODES="modes"=86
INITIAL="initial"=87
LTRANS=88
RTRANS=89
ARROW=90
OUT="out"=91
INVERSE="inverse"=92
DARROW=93
FLOWS="flows"=94
SOURCE="source"=95
SINK="sink"=96
PATH="path"=97
AADLSPEC=98
NOTT="not"=99
TRANSITIONS="transitions"=100
HASH=101
DIGIT=102
EXPONENT=103
INT_EXPONENT=104
EXTENDED_DIGIT=105
BASED_INTEGER=106
BASE=107
ESC=108
HEX_DIGIT=109
WS=110
SL_COMMENT=111
all: makeParser runTest
makeParser: AadlParser.py
AadlParser.py: aadl.g
rm -f AadlLexer.py AadlParser.py
runantlr -o . aadl.g || { echo You need to apt-get install antlr ; exit 1 ; }
runTest:
./antlr.main.py < PierreToyExampleSystem.aadl
PACKAGE Functional_view
PUBLIC
SUBPROGRAM Dispatcher
FEATURES
TC : IN PARAMETER DataTypes::T_TC;
END Dispatcher;
SUBPROGRAM IMPLEMENTATION Dispatcher.AADL
CALLS {
TC_Parser : SUBPROGRAM TC_Parser.AADL;
Tc_1 : SUBPROGRAM TC.POS;
Tc_2 : SUBPROGRAM TC.PRO;
};
CONNECTIONS
PARAMETER TC -> TC_Parser.TC;
PARAMETER TC_Parser.Param -> Tc_1.POS;
PARAMETER TC_Parser.Param -> Tc_2.POS;
PROPERTIES
Source_Language => "Lustre";
END Dispatcher.AADL;
SUBPROGRAM TC_Parser
FEATURES
TC : IN PARAMETER DataTypes::T_TC;
Id : OUT PARAMETER DataTypes::T_POS;
Param : OUT PARAMETER DataTypes::T_POS;
PROPERTIES
Source_Language => "Lustre";
END TC_Parser;
SUBPROGRAM IMPLEMENTATION TC_Parser.AADL
END TC_Parser.AADL;
SUBPROGRAM TC
FEATURES
POS : IN PARAMETER DataTypes::T_POS;
END TC;
SUBPROGRAM IMPLEMENTATION TC.POS
CALLS {
Write : SUBPROGRAM Write.AADL;
};
CONNECTIONS
PARAMETER POS -> Write.POS;
END TC.POS;
SUBPROGRAM IMPLEMENTATION TC.PRO
CALLS {
Boost_Order : SUBPROGRAM Boost_Order.AADL;
};
CONNECTIONS
PARAMETER POS -> Boost_Order.POS;
END TC.PRO;
SUBPROGRAM Write
FEATURES
POS : IN PARAMETER DataTypes::T_POS;
END Write;
SUBPROGRAM Boost_Order
FEATURES
POS : IN PARAMETER DataTypes::T_POS;
END Boost_Order;
END Functional_view;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
aadl2glueC : B mappers -generate code that convert from/to ASN1SCC
"""
from .aadl2glueC import main
__version__ = 1.0
This diff is collapsed.
#
# (C) Semantix Information Technologies.
#
# Semantix Information Technologies is licensing the code of the
# Data Modelling Tools (DMT) in the following dual-license mode:
#
# Commercial Developer License:
# The DMT Commercial Developer License is the suggested version
# to use for the development of proprietary and/or commercial software.
# This version is for developers/companies who do not want to comply
# with the terms of the GNU Lesser General Public License version 2.1.
#
# GNU LGPL v. 2.1:
# This version of DMT is the one to use for the development of
# applications, when you are willing to comply with the terms of the
# GNU Lesser General Public License version 2.1.
#
# Note that in both cases, there are no charges (royalties) for the
# generated code.
#
'''
This is the implementation of the code mapper for Ada code.
As initially envisioned, ASSERT technology is not supposed
to support manually-made systems. A migration path, however,
that allows legacy hand-written code and modelling-tool
generated code to co-exist, can be beneficial in allowing
for a smooth transition. To that end, this backend (as well as
the C one) are written.
This is a backend for Semantix's code generator B (aadl2glueC).
Ada is a member of the asynchronous "club" (SDL, etc);
The subsystem developer (or rather, the APLC developer) is using
native Ada code to work with code generated by modelling tools.
To that end, this backend creates "glue" functions for input and
output parameters, which have Ada callable interfaces.
'''
# from commonPy.utility import panic
# from recursiveMapper import RecursiveMapper
# from asynchronousTool import ASynchronousToolGlueGenerator
from . import c_B_mapper
isAsynchronous = True
adaBackend = None
cBackend = None
def Version():
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
#
# class FromDumpableCtoASN1SCC(RecursiveMapper):
# def __init__(self):
# self.uniqueID = 0
# def UniqueID(self):
# self.uniqueID += 1
# return self.uniqueID
# def DecreaseUniqueID(self):
# self.uniqueID -= 1
# def MapInteger(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapReal(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapBoolean(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapOctetString(self, srcCVariable, destVar, _, __, ___):
# lines = []
# lines.append("{\n")
# lines.append(" int i;\n")
# lines.append(" for(i=0; i<%s.length; i++)\n" % srcCVariable)
# lines.append(" %s.arr[i] = %s.content[i];\n" % (destVar, srcCVariable))
# lines.append(" %s.nCount = %s.length;\n" % (destVar, srcCVariable))
# lines.append("}\n")
# return lines
# def MapEnumerated(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapSequence(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# for child in node._members:
# lines.extend(
# self.Map(
# "%s.%s" % (srcCVariable, self.CleanName(child[0])),
# destVar + "." + self.CleanName(child[0]),
# child[1],
# leafTypeDict,
# names))
# return lines
# def MapSet(self, srcCVariable, destVar, node, leafTypeDict, names):
# return self.MapSequence(srcCVariable, destVar, node, leafTypeDict, names)
# def MapChoice(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# childNo = 0
# for child in node._members:
# childNo += 1
# lines.append("%sif (%s.choiceIdx == %d) {\n" %
# (self.maybeElse(childNo), srcCVariable, childNo))
# lines.extend([' '+x for x in self.Map(
# "%s.u.%s" % (srcCVariable, self.CleanName(child[0])),
# destVar + ".u." + self.CleanName(child[0]),
# child[1],
# leafTypeDict,
# names)])
# lines.append(" %s.kind = %s_PRESENT;\n" % (destVar, self.CleanName(child[0])))
# lines.append("}\n")
# return lines
# def MapSequenceOf(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# lines.append("{\n")
# uniqueId = self.UniqueID()
# lines.append(" int i%s;\n" % uniqueId)
# lines.append(" for(i%s=0; i%s<%s.length; i%s++) {\n" % (uniqueId, uniqueId, srcCVariable, uniqueId))
# lines.extend([" " + x for x in self.Map(
# "%s.content[i%s]" % (srcCVariable, uniqueId),
# "%s.arr[i%s]" % (destVar, uniqueId),
# node._containedType,
# leafTypeDict,
# names)])
# lines.append(" }\n")
# lines.append(" %s.nCount = %s.length;\n" % (destVar, srcCVariable))
# lines.append("}\n")
# self.DecreaseUniqueID()
# return lines
# def MapSetOf(self, srcCVariable, destVar, node, leafTypeDict, names):
# return self.MapSequenceOf(srcCVariable, destVar, node, leafTypeDict, names)
#
# class FromASN1SCCtoDumpableC(RecursiveMapper):
# def __init__(self):
# self.uniqueID = 0
# def UniqueID(self):
# self.uniqueID += 1
# return self.uniqueID
# def DecreaseUniqueID(self):
# self.uniqueID -= 1
# def MapInteger(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapReal(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapBoolean(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapOctetString(self, srcCVariable, destVar, _, __, ___):
# lines = []
# lines.append("{\n")
# lines.append(" int i;\n")
# lines.append(" for(i=0; i<%s.nCount; i++)\n" % srcCVariable)
# lines.append(" %s.content[i] = %s.arr[i];\n" % (destVar, srcCVariable))
# lines.append(" %s.length = %s.nCount;\n" % (destVar, srcCVariable))
# lines.append("}\n")
# return lines
# def MapEnumerated(self, srcCVariable, destVar, _, __, ___):
# return ["%s = %s;\n" % (destVar, srcCVariable)]
# def MapSequence(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# for child in node._members:
# lines.extend(
# self.Map(
# "%s.%s" % (srcCVariable, self.CleanName(child[0])),
# destVar + "." + self.CleanName(child[0]),
# child[1],
# leafTypeDict,
# names))
# return lines
# def MapSet(self, srcCVariable, destVar, node, leafTypeDict, names):
# return self.MapSequence(srcCVariable, destVar, node, leafTypeDict, names)
# def MapChoice(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# childNo = 0
# for child in node._members:
# childNo += 1
# lines.append("%sif (%s.kind == %s_PRESENT) {\n" %
# (self.maybeElse(childNo), srcCVariable, self.CleanName(child[0])))
# lines.extend([' '+x for x in self.Map(
# "%s.u.%s" % (srcCVariable, self.CleanName(child[0])),
# destVar + ".u." + self.CleanName(child[0]),
# child[1],
# leafTypeDict,
# names)])
# lines.append(" %s.choiceIdx = %d;\n" % (destVar, childNo))
# lines.append("}\n")
# return lines
# def MapSequenceOf(self, srcCVariable, destVar, node, leafTypeDict, names):
# lines = []
# lines.append("{\n")
# uniqueId = self.UniqueID()
# lines.append(" int i%s;\n" % uniqueId)
# lines.append(" for(i%s=0; i%s<%s.nCount; i%s++) {\n" % (uniqueId, uniqueId, srcCVariable, uniqueId))
# lines.extend([" " + x for x in self.Map(
# "%s.arr[i%s]" % (srcCVariable, uniqueId),
# "%s.content[i%s]" % (destVar, uniqueId),
# node._containedType,
# leafTypeDict,
# names)])
# lines.append(" }\n")
# lines.append(" %s.length = %s.nCount;\n" % (destVar, srcCVariable))
# lines.append("}\n")
# self.DecreaseUniqueID()
# return lines
# def MapSetOf(self, srcCVariable, destVar, node, leafTypeDict, names):
# return self.MapSequenceOf(srcCVariable, destVar, node, leafTypeDict, names)
#
# class Ada_GlueGenerator(ASynchronousToolGlueGenerator):
# def __init__(self):
# ASynchronousToolGlueGenerator.__init__(self)
# self.FromDumpableCtoASN1SCC = FromDumpableCtoASN1SCC()
# self.FromASN1SCCtoDumpableC = FromASN1SCCtoDumpableC()
# self.Ada_HeaderFile = None
# self.Ada_SourceFile = None
# self.definedTypes = {}
# def Version(self):
# print "Code generator: " + "$Id: ada_B_mapper.py 2382 2012-06-22 08:35:33Z ttsiodras $"
# def HeadersOnStartup(self, unused_asnFile, unused_outputDir, unused_maybeFVname):
# if self.useOSS:
# self.C_HeaderFile.write("#include \"%s.oss.h\" // OSS generated\n\n" % self.asn_name)
# self.C_SourceFile.write("\nextern OssGlobal *g_world;\n\n")
# self.C_HeaderFile.write("#include \"%s.h\" // Space certified compiler generated\n\n" % self.asn_name)
# self.C_HeaderFile.write("#include \"DumpableTypes.h\"\n\n")
# def Encoder(self, nodeTypename, node, leafTypeDict, names, encoding):
# if encoding.lower() not in self.supportedEncodings:
# panic(str(self.__class__) + ": in (%s), encoding can be one of %s (not '%s')" %
# (nodeTypename, self.supportedEncodings, encoding))
#
# # Definition of the standard encoding function (same interface as the C mapper )
# cBackend.Encoder(nodeTypename, node, leafTypeDict, names, encoding)
# # End standard encoding function
#
# # in order not to duplicate conversion functions, skip the rest if encoding is native
# if encoding.lower() == "native":
# return
#
# if not self.definedTypes.has_key(nodeTypename):
# self.definedTypes[nodeTypename] = 1
# # Declare/define the C stub variable (one per ASN.1 type)
# self.C_HeaderFile.write("\n/* --- Staging var for %s --- */\n" % (nodeTypename))
#
# tmpTypeName = "asn1Scc%s" % self.CleanNameAsToolWants(nodeTypename)
# tmpVarName = "asn1scc"
# tmpSpName = "Ada_to_SCC_%s" % \
# self.CleanNameAsToolWants(nodeTypename)
#
# self.C_HeaderFile.write(
# "void %s(GT__%s *ada, %s *%s);\n" %
# (tmpSpName,
# self.CleanNameAsToolWants(nodeTypename),
# tmpTypeName,
# tmpVarName))
# self.C_SourceFile.write(
# "void %s(GT__%s *ada, %s *%s)\n{\n" %
# (tmpSpName,
# self.CleanNameAsToolWants(nodeTypename),
# tmpTypeName,
# tmpVarName))
#
# lines = self.FromDumpableCtoASN1SCC.Map(
# "(*ada)",
# "(*asn1scc)",
# node,
# leafTypeDict,
# names)
# lines = [" "+x for x in lines]
#
# self.C_SourceFile.write("".join(lines))
# self.C_SourceFile.write("}\n\n")
#
# def Decoder(self, nodeTypename, node, leafTypeDict, names, encoding):
# if encoding.lower() not in self.supportedEncodings:
# panic(str(self.__class__) + ": in (%s), encoding can be one of %s (not '%s')" %
# (nodeTypename, self.supportedEncodings, encoding))
#
# # Definition of the standard decoding function (same interface as the C mapper )
# cBackend.Decoder(nodeTypename, node, leafTypeDict, names, encoding)
# # End standard decoding function
#
# if encoding.lower() == "native":
# return
#
# tmpTypeName = "asn1Scc%s" % self.CleanNameAsToolWants(nodeTypename)
# tmpVarName = "asn1scc"
# tmpSpName = "SCC_to_Ada_%s" % self.CleanNameAsToolWants(nodeTypename)
#
# # Create C function that does the encoding
# self.C_HeaderFile.write(
# "void %s(%s *%s, GT__%s *ada);\n" %
# (tmpSpName,
# tmpTypeName,
# tmpVarName,
# self.CleanNameAsToolWants(nodeTypename)))
# self.C_SourceFile.write(
# "void %s(%s *%s, GT__%s *ada)\n{\n" %
# (tmpSpName,
# tmpTypeName,
# tmpVarName,
# self.CleanNameAsToolWants(nodeTypename)))
#
# lines = self.FromASN1SCCtoDumpableC.Map(
# "(*asn1scc)",
# "(*ada)",
# node,
# leafTypeDict,
# names)
# lines = [" "+x for x in lines]
#
# self.C_SourceFile.write("".join(lines))
# self.C_SourceFile.write("}\n\n")
#
# def OnShutdown(self, modelingLanguage, asnFile, maybeFVname):
# ASynchronousToolGlueGenerator.OnShutdown(self, modelingLanguage, asnFile, maybeFVname)
def OnStartup(unused_modelingLanguage, asnFile, outputDir, maybeFVname, useOSS):
global cBackend
# 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada)
# we no longer need these Ada-specific Dumpable structures.
#global adaBackend
#adaBackend = Ada_GlueGenerator()
cBackend = c_B_mapper.C_GlueGenerator()
#adaBackend.OnStartup(modelingLanguage, asnFile, outputDir, maybeFVname, useOSS)
cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)
def OnBasic(nodeTypename, node, leafTypeDict, names):
cBackend.OnBasic(nodeTypename, node, leafTypeDict, names)
def OnSequence(nodeTypename, node, leafTypeDict, names):
cBackend.OnSequence(nodeTypename, node, leafTypeDict, names)
def OnSet(nodeTypename, node, leafTypeDict, names):
cBackend.OnSet(nodeTypename, node, leafTypeDict, names) # pragma: nocover
def OnEnumerated(nodeTypename, node, leafTypeDict, names):
cBackend.OnEnumerated(nodeTypename, node, leafTypeDict, names)
def OnSequenceOf(nodeTypename, node, leafTypeDict, names):
cBackend.OnSequenceOf(nodeTypename, node, leafTypeDict, names)
def OnSetOf(nodeTypename, node, leafTypeDict, names):
cBackend.OnSetOf(nodeTypename, node, leafTypeDict, names) # pragma: nocover
def OnChoice(nodeTypename, node, leafTypeDict, names):
cBackend.OnChoice(nodeTypename, node, leafTypeDict, names)
def OnShutdown(unused_modelingLanguage, asnFile, maybeFVname):
cBackend.OnShutdown("C", asnFile, maybeFVname)
#!/usr/bin/env python
from . import AadlLexer
from . import AadlParser
import commonPy.aadlAST
import commonPy.utility
import antlr
import sys
def main():
if len(sys.argv)>1:
L = AadlLexer.Lexer(sys.argv[1])
else:
L = AadlLexer.Lexer()
P = AadlParser.Parser(L)
P.setFilename(L.getFilename())
try:
P.aadl_specification()
except antlr.ANTLRException as e:
commonPy.utility.panic("Error: %s\n" % (str(e)))
SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:]
SystemsAndImplementations.extend(commonPy.aadlAST.g_threadImplementations[:])
SystemsAndImplementations.extend(commonPy.aadlAST.g_processImplementations[:])
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)
for param in sp._params:
print("\t", end=' ')
if isinstance(param, commonPy.aadlAST.InParam):
print("IN", end=' ')
elif isinstance(param, commonPy.aadlAST.OutParam):
print("OUT", end=' ')
elif isinstance(param, commonPy.aadlAST.InOutParam):
print("INOUT", end=' ')
if isinstance(param._signal, commonPy.aadlAST.Signal):
print("\t", param._id, ":", param._signal._asnFilename, param._signal._asnNodename, "(", param._sourceElement._encoding, ")")
else:
print("\t", param._id, ":", param._signal, "(", param._sourceElement._encoding, ")")
print()
if len(sp._connections):
print("\tConnections:")
for pair in sp._connections:
print("\t\tfrom", pair._from._componentId+':'+pair._from._portId, "to", pair._to._componentId+':'+pair._to._portId)
print()
if __name__ == "__main__":
main()
This diff is collapsed.
This diff is collapsed.
../commonPy
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
../commonPy/recursiveMapper.py
\ No newline at end of file
This diff is collapsed.