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

Appease Google's Mobile-friendly status on some pages

parent a0f45ecd
This source diff could not be displayed because it is too large. You can view the blob instead.
// $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
// vim: set expandtab:
options {
language=Python;
}
{
from commonPy.aadlAST import *
from commonPy.utility import panic
import commonPy.configMT
global g_currentPackage
g_currentPackage = ""
}
class AadlParser extends Parser;
options {
buildAST=false;
k=4;
// codeGenBitsetTestThreshold=999;
defaultErrorHandler=false;
}
aadl_specification
:
(aadl_declaration)+
EOF
;
aadl_declaration
:
( component_classifier | port_group_type | annex_library | package_spec | property_set )
;
component_classifier
:
( thread_type | thread_implementation
| thread_group_type | thread_group_implementation
| system_type | system_implementation
| data_type | data_implementation
| subprogram_type | subprogram_implementation
| process_type | process_implementation
| processor_type | processor_implementation
| memory_type | memory_implementation
| bus_type | bus_implementation
| device_type | device_implementation
)
;
package_file
:
fl:PACKAGE p=package_name
(
(public_part (private_part)?)
|
private_part
)
END p=package_name sl:SEMI
EOF
;
package_spec
:
fl:PACKAGE p=package_name {
global g_currentPackage
g_currentPackage = p
//print "Currently parsing package", g_currentPackage
}
( (public_part ( private_part )?) | private_part )
END pn=package_name sl:SEMI
;
public_part
:
PUBLIC package_items
;
private_part
:
PRIVATE package_items
;
package_items
:
( package_item)+ ( propertyAssociations )?
;
package_item
:
component_classifier | port_group_type | annex_library
;
package_name returns [ pkgId ]
:
{
pkgId = ""
}
id:IDENT { pkgId = id.getText() } ( DOUBLECOLON id2:IDENT { pkgId += "::" + id2.getText() } )*
;
// note: we recognize none by the appropriate subclause object without content
none_stmt
:
NONE SEMI
;
thread_type
:
THREAD id:IDENT {
//print "Now defining THREAD", id.getText()
//print threadFeatures
if not commonPy.configMT.g_bOnlySubprograms:
sp = ApLevelContainer(id.getText())
g_apLevelContainers[id.getText()] = sp }
(EXTENDS unique_type_name )?
( threadFeatures=featuresThread {
if not commonPy.configMT.g_bOnlySubprograms:
for threadFeature in threadFeatures:
if threadFeature == None: continue
if not g_signals.has_key(threadFeature._port._type):
// panic("Line %d: Referenced datatype (%s) not defined yet" % \
// (id.getLine(),threadFeature._port._type))
signal = threadFeature._port._type
else:
signal = g_signals[threadFeature._port._type]
if threadFeature._port._direction == "IN":
param = InParam(id.getText(), threadFeature._id, signal, threadFeature._port)
elif threadFeature._port._direction == "OUT":
param = OutParam(id.getText(), threadFeature._id, signal, threadFeature._port)
elif threadFeature._port._direction == "INOUT":
param = InOutParam(id.getText(), threadFeature._id, signal, threadFeature._port)
else:
panic("No IN/OUT/INOUT specified!")
sp.AddParam(param)
} )?
( flow_specs )?
( properties=propertyAssociations_no_modes {
if not commonPy.configMT.g_bOnlySubprograms:
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
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:
if property._name[-15:].lower() == "source_language":
stripQuotes = property._propertyExpressionOrList.replace("\"", "")
sp.SetLanguage(stripQuotes)
} )?
( annex_subclause )?
END eid:IDENT sl:SEMI
;
thread_group_type
:
THREAD GROUP id:IDENT
(EXTENDS unique_type_name )?
(featuresThreadGroup)?
( flow_specs )?
( pa=propertyAssociations_no_modes )?
( annex_subclause )?
END eid:IDENT SEMI
;
process_type
:
PROCESS id:IDENT {
if not commonPy.configMT.g_bOnlySubprograms:
sp = ApLevelContainer(id.getText())
g_apLevelContainers[id.getText()] = sp }
(EXTENDS unique_type_name )?
(processFeatures=featuresProcess {
if not commonPy.configMT.g_bOnlySubprograms:
for processFeature in processFeatures:
if processFeature == None: continue
if not g_signals.has_key(processFeature._port._type):
// panic("Line %d: Referenced datatype (%s) not defined yet" % \
// (id.getLine(),processFeature._port._type))
signal = processFeature._port._type
else:
signal = g_signals[processFeature._port._type]
if processFeature._port._direction == "IN":
param = InParam(id.getText(), processFeature._id, signal, processFeature._port)
elif processFeature._port._direction == "OUT":
param = OutParam(id.getText(), processFeature._id, signal, processFeature._port)
elif processFeature._port._direction == "INOUT":
param = InOutParam(id.getText(), processFeature._id, signal, processFeature._port)
else:
panic("No IN/OUT/INOUT specified!")
sp.AddParam(param)
} )?
( flow_specs )?
( properties=propertyAssociations_no_modes {
if not commonPy.configMT.g_bOnlySubprograms:
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
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:
if property._name[-15:].lower() == "source_language":
stripQuotes = property._propertyExpressionOrList.replace("\"", "")
sp.SetLanguage(stripQuotes)
} )?
( annex_subclause )?
END eid:IDENT SEMI
;
system_type
:
SYSTEM id:IDENT
(EXTENDS unique_type_name )?
(fe=featuresSystem {
g_systems[id.getText()]=[x._sp for x in fe if x._direction == "OUT"]
//print "Detected RIs for", id.getText(), g_systems[id.getText()]
} )?
(flow_specs )?
(pa=propertyAssociations_no_modes )?
(annex_subclause )?
END eid:IDENT SEMI
;
subprogram_type
:
SUBPROGRAM id:IDENT {
//print "Now defining SUBPROGRAM", id.getText()
//print f
sp = ApLevelContainer(id.getText())
g_apLevelContainers[id.getText()] = sp }
(EXTENDS unique_type_name )?
(features=featuresSubprogram {
for spFeature in features:
if spFeature == None: continue
if not g_signals.has_key(spFeature._parameter._type):
// panic("Line %d: Referenced datatype (%s) not defined yet" % \
// (id.getLine(),spFeature._parameter._type))
signal = spFeature._parameter._type
else:
signal = g_signals[spFeature._parameter._type]
if spFeature._parameter._direction == "IN":
param = InParam(id.getText(), spFeature._id, signal, spFeature._parameter)
elif spFeature._parameter._direction == "OUT":
param = OutParam(id.getText(), spFeature._id, signal, spFeature._parameter)
elif spFeature._parameter._direction == "INOUT":
param = InOutParam(id.getText(), spFeature._id, signal, spFeature._parameter)
else:
panic("No IN/OUT/INOUT specified!")
sp.AddParam(param)
} )?
( flow_specs )?
( properties=propertyAssociations_no_modes {
if properties != None:
if not g_apLevelContainers.has_key(id.getText()):
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:
if property._name[-15:].lower() == "source_language":
stripQuotes = property._propertyExpressionOrList.replace("\"", "")
sp.SetLanguage(stripQuotes)
} )?
( annex_subclause )?
END eid:IDENT SEMI
;
data_type
:
DATA id:IDENT
(EXTENDS unique_type_name )?
(featuresData)?
( panms=propertyAssociations_no_modes {
//print "Data definition of", id.getText(), panms
asnFilename = ""
asnNodename = ""
asnSize = -1
for prop in panms:
if prop._name.lower() == "source_text": asnFilename = prop._propertyExpressionOrList[1:-1]
elif prop._name.lower() == "type_source_name": asnNodename = prop._propertyExpressionOrList[1:-1]
elif prop._name.lower() == "source_data_size":
try:
asnSize = int(prop._propertyExpressionOrList)
except:
panic("Line %d: DATA (%s) must have source_data_size be declared as [0-9]B (not '%s')" % (id.getLine(), id.getText(), prop._propertyExpressionOrList))
if asnFilename!="" and asnNodename!="" and asnSize != -1:
s = Signal(asnFilename, asnNodename, asnSize)
g_signals[id.getText()] = s
g_signals[g_currentPackage + "::" + id.getText()] = s
else:
panic("Line %d: DATA (%s) must have Source_Text, Type_Source_Name and Source_Data_Size" % (id.getLine(), id.getText()))
} )?
( annex_subclause )?
END eid:IDENT SEMI
;
processor_type
:
PROCESSOR id:IDENT
(EXTENDS unique_type_name )?
(featuresProcessor)?
( flow_specs )?
( pa=propertyAssociations_no_modes )?
( annex_subclause )?
END eid:IDENT SEMI
;
memory_type
:
MEMORY id:IDENT
(EXTENDS unique_type_name )?
(featuresMemory)?
( pa=propertyAssociations_no_modes )?
( annex_subclause )?
END eid:IDENT SEMI
;
bus_type
:
BUS id:IDENT
(EXTENDS unique_type_name )?
(featuresBus)?
( pa=propertyAssociations_no_modes )?
( annex_subclause )?
END eid:IDENT SEMI
;
device_type
:
DEVICE id:IDENT
(EXTENDS unique_type_name )?
(featuresDevice)?
( flow_specs )?
( pa=propertyAssociations_no_modes )?
( annex_subclause )?
END eid:IDENT SEMI
;
//-------------------------------------------------------------------
// unique type name must refer to a type
// unqiue implemenation name must refer to an implementation
// classifier reference may be incomplete.
// ClassifierReference is an object that has three fields:
// package name, type name, impl name. Any of them can be null
//---------------------------------------------------------------
unique_type_name
:
( pid: IDENT DOUBLECOLON )* tid:IDENT
;
unique_impl_name
:
( pid: IDENT DOUBLECOLON )* tid:IDENT DOT iid:IDENT
;
classifier_reference returns [ classifier ]
:
{
classifier = None
ptid = None
}
(ptid:IDENT DOUBLECOLON )* tid:IDENT {
if ptid != None: classifier = ptid.getText() + "::" + tid.getText()
else: classifier = g_currentPackage + "::" + tid.getText()
}
( DOT iid:IDENT )?
;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ Section 4.4 Component Implementations
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ category specific implementation portion
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
common_component_impl returns [ listOfProperties ]
:
{
listOfProperties = None
}
(mode_subclause)?
( c=containedPropertyAssociations { listOfProperties = c } )?
( annex_subclause )?
;
thread_implementation
:
THREAD IMPL typeid:IDENT DOT defid:IDENT {
if not commonPy.configMT.g_bOnlySubprograms:
if not g_apLevelContainers.has_key(typeid.getText()):
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, ""]) }
(EXTENDS unique_impl_name )?
(refinestypeSubclause)?
(threadSubcomponents )?
(callsSubclause )?
(mesh=connectionsSubclause {
if not commonPy.configMT.g_bOnlySubprograms:
for conn in mesh:
if conn._from._portId == None or conn._to._portId == None:
continue // One of _from,_to are connection_refinements (unsupported)
sp = g_apLevelContainers[typeid.getText()]
sp.AddConnection(conn._from, conn._to) } )?
(flow_impls)?
cci=common_component_impl {
if not commonPy.configMT.g_bOnlySubprograms:
if cci != None:
if not g_apLevelContainers.has_key(typeid.getText()):
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:
if assoc == None: continue
if assoc._name[-15:].lower() == "source_language":
stripQuotes = assoc._value.replace("\"", "")
//sp.SetLanguage(stripQuotes)
g_threadImplementations[-1][2] = stripQuotes
if assoc._name[-15:].lower() == "fv_name":
stripQuotes = assoc._value.replace("\"", "")
//sp.SetLanguage(stripQuotes)
g_threadImplementations[-1][3] = stripQuotes