|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmapss.dif.language.sablecc.analysis.AnalysisAdapter
mapss.dif.language.sablecc.analysis.DepthFirstAdapter
mapss.dif.language.LanguageAnalysis
public class LanguageAnalysis
This is the analysis class for implementing the DIF compiler for DIF
version 0.2. For learning how to compile DIF files see Reader
.
SABLECC uses this class to define the actions during parse of a DIF file.
None of the public methods that have "in" and "out" prefixes in this class are for users. Although they are public this is just because SABLECC generated Java files should be able to use those methods.
Behavior of the DIF compiler for converting a DIF file to a graph is defined by the code in this class. This analysis only recognizes the graphs that has the "dif" keyword as the graph type and the runtime type of the graph returned is DIFGraph.
If a different type of graph is needed, a new Analysis extending this one can be written. In the new analysis all protected methods should be overridden in a proper way.
The Reader
pre-scans all related dif files and input all hierarchies
by externalHierarchies(java.util.Collection)
. See Reader
and
package documentation for more information on this package.
Please refer to Compiler.grammar for DIF V0.2 language grammar.
DIFGraph
,
DIFHierarchy
Field Summary | |
---|---|
protected DIFGraph |
_graph
The graph in the current hierarchy. |
protected java.util.HashMap |
_hierarchies
|
protected DIFHierarchy |
_hierarchy
The current hierarchy. |
protected DIFHierarchy |
_subHierarchy
Current sub-hierarchy in the refinement block. |
Constructor Summary | |
---|---|
LanguageAnalysis()
|
Method Summary | |
---|---|
protected boolean |
_acceptableSubHierarchy(DIFHierarchy hierarchy)
Returns true if a hierarchy can be a sub-hierarchy of the current one. |
protected void |
_checkKeyword(java.lang.String name)
Check to see if the name conflicts with keyword. |
protected mocgraph.Edge |
_getEmptyEdge(mocgraph.Node source,
mocgraph.Node sink)
Should return an empty edge that can be used in the graph that is constructed. |
protected DIFGraph |
_getEmptyGraph()
Should return an empty graph of the type that is going to be constructed with this analysis. |
protected mocgraph.Node |
_getEmptyNode()
Should return an empty node that can be used in the graph that is constructed. |
protected java.lang.String |
_getKeyword()
Should return the DIF keyword associated with this analysis type. |
protected java.lang.String |
_getName(PName name)
|
protected void |
_processBuiltinAttribute(java.lang.String id,
java.lang.Object object,
java.lang.Object value,
DIFHierarchy hierarchy)
For each built-in attribute, the derived classes need to override the _processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy) method in order
to handle the built-in functions. |
protected void |
_setComputationAttribute(java.lang.Object object,
java.lang.Object value,
DIFGraph graph)
Common method for built-in attribute or actor attribute "computation". |
void |
externalHierarchies(java.util.Collection externalHierarchies)
This method provides additional hierarchies to the analyzer to scan through for finding the subgraphs needed in the refinements. |
DIFHierarchy |
getHierarchy()
Returns the hierarchy read with this analysis. |
java.lang.String |
getKeyword()
Returns the DIF keyword of the graph type that is handled by this analysis ("dif" for this implementation). |
void |
inAActorBlock(AActorBlock parseNode)
For each node representing an actor of design tool's library, an actor block is necessary to specify the attributes of that actor. |
void |
inAArrayValue(AArrayValue parseNode)
|
void |
inABasedonExpression(ABasedonExpression parseNode)
|
void |
inABlankParameterExpression(ABlankParameterExpression parseNode)
|
void |
inABooleanValue(ABooleanValue parseNode)
|
void |
inABuiltinAttributeBlock(ABuiltinAttributeBlock parseNode)
For built-in attributes, the derived classes need to override the _processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy) method
in order to handle the built-in functions. |
void |
inAClosedClosedRange(AClosedClosedRange parseNode)
|
void |
inAClosedOpenRange(AClosedOpenRange parseNode)
|
void |
inAComplexMatrixValue(AComplexMatrixValue parseNode)
|
void |
inAComplexValue(AComplexValue parseNode)
|
void |
inAConcatenatedStringValue(AConcatenatedStringValue parseNode)
|
void |
inADiscreteRange(ADiscreteRange parseNode)
|
void |
inADiscreteRangeNumberTail(ADiscreteRangeNumberTail parseNode)
|
void |
inADoubleValue(ADoubleValue parseNode)
|
void |
inAEdgeDefinition(AEdgeDefinition parseNode)
|
void |
inAGraphBlock(AGraphBlock parseNode)
Parse a graph definition: dataflow model and graph name. |
void |
inAIdlistAttributeExpression(AIdlistAttributeExpression parseNode)
|
void |
inAInputInterfaceExpression(AInputInterfaceExpression parseNode)
|
void |
inAIntegerValue(AIntegerValue parseNode)
|
void |
inANodeIdentifierTail(ANodeIdentifierTail parseNode)
|
void |
inANodePortDefinition(ANodePortDefinition parseNode)
|
void |
inANodesTopologyList(ANodesTopologyList parseNode)
|
void |
inANumericMatrixValue(ANumericMatrixValue parseNode)
|
void |
inAOpenClosedRange(AOpenClosedRange parseNode)
|
void |
inAOpenOpenRange(AOpenOpenRange parseNode)
|
void |
inAOutputInterfaceExpression(AOutputInterfaceExpression parseNode)
|
void |
inAParamsRefinementExpression(AParamsRefinementExpression parseNode)
Set the value of the sub-parameter to the parameter in this graph. |
void |
inAPlainPortDefinition(APlainPortDefinition parseNode)
|
void |
inAPortsRefinementExpression(APortsRefinementExpression parseNode)
|
void |
inARangeParameterExpression(ARangeParameterExpression parseNode)
|
void |
inAReferenceActorExpression(AReferenceActorExpression parseNode)
|
void |
inAReferenceAttributeExpression(AReferenceAttributeExpression parseNode)
|
void |
inARefinementDefinition(ARefinementDefinition parseNode)
For each supernode-to-subgraph mapping, it is necessary to specify a refinement block. |
void |
inAReflistActorExpression(AReflistActorExpression parseNode)
|
void |
inASubelementAssignAttributeExpression(ASubelementAssignAttributeExpression parseNode)
|
void |
inAUserDefinedAttributeBlock(AUserDefinedAttributeBlock parseNode)
|
static boolean |
isKeyWord(java.lang.String word)
Checks if a string is a keyword in DIF. |
void |
outAArrayValue(AArrayValue parseNode)
|
void |
outARangeParameterExpression(ARangeParameterExpression parseNode)
|
void |
outAValueActorExpression(AValueActorExpression parseNode)
|
void |
outAValueAttributeExpression(AValueAttributeExpression parseNode)
|
void |
outAValueParameterExpression(AValueParameterExpression parseNode)
|
Methods inherited from class mapss.dif.language.sablecc.analysis.AnalysisAdapter |
---|
caseEOF, caseTActor, caseTAttribute, caseTBasedon, caseTBlank, caseTColon, caseTComma, caseTComment, caseTDot, caseTDouble, caseTEdges, caseTEqual, caseTFalse, caseTGraph, caseTIdentifier, caseTInputs, caseTInteger, caseTInterface, caseTLBkt, caseTLPar, caseTLSqr, caseTNodes, caseTOutputs, caseTParameter, caseTPlus, caseTRBkt, caseTRefinement, caseTRPar, caseTRSqr, caseTSemicolon, caseTSQte, caseTString, caseTStringIdentifier, caseTStringTail, caseTTopology, caseTTrue, defaultCase, getIn, getOut, setIn, setOut |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DIFGraph _graph
protected DIFHierarchy _hierarchy
protected java.util.HashMap _hierarchies
protected DIFHierarchy _subHierarchy
Constructor Detail |
---|
public LanguageAnalysis()
Method Detail |
---|
public void externalHierarchies(java.util.Collection externalHierarchies)
externalHierarchies
- A collection of Hierarchies.public DIFHierarchy getHierarchy()
public java.lang.String getKeyword()
public static boolean isKeyWord(java.lang.String word)
word
- A string to be checked.
public void inAGraphBlock(AGraphBlock parseNode)
Reader
pre-scans all related dif files and input all
hierarchies by externalHierarchies(java.util.Collection)
.
Therefore, this method do not have to put _hierarchy
into _hierarchies. According to the previous compiled
DIFHierarchies, _hierarchies, we check that the current graph
(hierarchy) use the predefined name or not. The name of DIFGraph
and DIFHierarchy is set to the same as parseNode.getName().getText().
inAGraphBlock
in class DepthFirstAdapter
public void inABasedonExpression(ABasedonExpression parseNode)
inABasedonExpression
in class DepthFirstAdapter
public void inANodesTopologyList(ANodesTopologyList parseNode)
inANodesTopologyList
in class DepthFirstAdapter
public void inANodeIdentifierTail(ANodeIdentifierTail parseNode)
inANodeIdentifierTail
in class DepthFirstAdapter
public void inAEdgeDefinition(AEdgeDefinition parseNode)
inAEdgeDefinition
in class DepthFirstAdapter
public void inAInputInterfaceExpression(AInputInterfaceExpression parseNode)
inAInputInterfaceExpression
in class DepthFirstAdapter
public void inAOutputInterfaceExpression(AOutputInterfaceExpression parseNode)
inAOutputInterfaceExpression
in class DepthFirstAdapter
public void inAPlainPortDefinition(APlainPortDefinition parseNode)
inAPlainPortDefinition
in class DepthFirstAdapter
public void inANodePortDefinition(ANodePortDefinition parseNode)
inANodePortDefinition
in class DepthFirstAdapter
public void inABlankParameterExpression(ABlankParameterExpression parseNode)
inABlankParameterExpression
in class DepthFirstAdapter
public void outAValueParameterExpression(AValueParameterExpression parseNode)
outAValueParameterExpression
in class DepthFirstAdapter
public void inARangeParameterExpression(ARangeParameterExpression parseNode)
inARangeParameterExpression
in class DepthFirstAdapter
public void inAClosedClosedRange(AClosedClosedRange parseNode)
inAClosedClosedRange
in class DepthFirstAdapter
public void inAOpenClosedRange(AOpenClosedRange parseNode)
inAOpenClosedRange
in class DepthFirstAdapter
public void inAClosedOpenRange(AClosedOpenRange parseNode)
inAClosedOpenRange
in class DepthFirstAdapter
public void inAOpenOpenRange(AOpenOpenRange parseNode)
inAOpenOpenRange
in class DepthFirstAdapter
public void inADiscreteRange(ADiscreteRange parseNode)
inADiscreteRange
in class DepthFirstAdapter
public void inADiscreteRangeNumberTail(ADiscreteRangeNumberTail parseNode)
inADiscreteRangeNumberTail
in class DepthFirstAdapter
public void outARangeParameterExpression(ARangeParameterExpression parseNode)
outARangeParameterExpression
in class DepthFirstAdapter
public void inARefinementDefinition(ARefinementDefinition parseNode)
inARefinementDefinition
in class DepthFirstAdapter
public void inAPortsRefinementExpression(APortsRefinementExpression parseNode)
inAPortsRefinementExpression
in class DepthFirstAdapter
public void inAParamsRefinementExpression(AParamsRefinementExpression parseNode)
inAParamsRefinementExpression
in class DepthFirstAdapter
public void inABuiltinAttributeBlock(ABuiltinAttributeBlock parseNode)
_processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy)
method
in order to handle the built-in functions.
inABuiltinAttributeBlock
in class DepthFirstAdapter
public void inAUserDefinedAttributeBlock(AUserDefinedAttributeBlock parseNode)
inAUserDefinedAttributeBlock
in class DepthFirstAdapter
public void outAValueAttributeExpression(AValueAttributeExpression parseNode)
outAValueAttributeExpression
in class DepthFirstAdapter
public void inAReferenceAttributeExpression(AReferenceAttributeExpression parseNode)
inAReferenceAttributeExpression
in class DepthFirstAdapter
public void inASubelementAssignAttributeExpression(ASubelementAssignAttributeExpression parseNode)
inASubelementAssignAttributeExpression
in class DepthFirstAdapter
public void inAIdlistAttributeExpression(AIdlistAttributeExpression parseNode)
inAIdlistAttributeExpression
in class DepthFirstAdapter
public void inAActorBlock(AActorBlock parseNode)
An attribute of an actor can specify the parameter value of that actor. In this case, the attribute id is the parameter id and the attribute value is the parameter value.
An attribute can also specify the connection of the node (actor). In this case, the attribute id is the port id or argument id and the attribute value is the connected object's id.
All actor attributes and their value are stored as node attributes in DIF.
inAActorBlock
in class DepthFirstAdapter
public void outAValueActorExpression(AValueActorExpression parseNode)
outAValueActorExpression
in class DepthFirstAdapter
public void inAReferenceActorExpression(AReferenceActorExpression parseNode)
inAReferenceActorExpression
in class DepthFirstAdapter
public void inAReflistActorExpression(AReflistActorExpression parseNode)
inAReflistActorExpression
in class DepthFirstAdapter
public void inAIntegerValue(AIntegerValue parseNode)
inAIntegerValue
in class DepthFirstAdapter
public void inADoubleValue(ADoubleValue parseNode)
inADoubleValue
in class DepthFirstAdapter
public void inAComplexValue(AComplexValue parseNode)
inAComplexValue
in class DepthFirstAdapter
public void inANumericMatrixValue(ANumericMatrixValue parseNode)
inANumericMatrixValue
in class DepthFirstAdapter
public void inAComplexMatrixValue(AComplexMatrixValue parseNode)
inAComplexMatrixValue
in class DepthFirstAdapter
public void inAConcatenatedStringValue(AConcatenatedStringValue parseNode)
inAConcatenatedStringValue
in class DepthFirstAdapter
public void inABooleanValue(ABooleanValue parseNode)
inABooleanValue
in class DepthFirstAdapter
public void inAArrayValue(AArrayValue parseNode)
inAArrayValue
in class DepthFirstAdapter
public void outAArrayValue(AArrayValue parseNode)
outAArrayValue
in class DepthFirstAdapter
protected boolean _acceptableSubHierarchy(DIFHierarchy hierarchy)
hierarchy
- Sub hierarchy to add.
protected void _checkKeyword(java.lang.String name)
protected mocgraph.Edge _getEmptyEdge(mocgraph.Node source, mocgraph.Node sink)
source
- Source node for the edge.sink
- Sink node for the edge.
protected DIFGraph _getEmptyGraph()
protected mocgraph.Node _getEmptyNode()
protected java.lang.String _getKeyword()
protected java.lang.String _getName(PName name)
protected void _processBuiltinAttribute(java.lang.String id, java.lang.Object object, java.lang.Object value, DIFHierarchy hierarchy) throws DIFLanguageException
_processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy)
method in order
to handle the built-in functions. There are two situations to use
use method.
In the first case, this method processes the given built-in
attribute of the object.
The object is an Edge/Node/Port in the graph or hierarchy.
Note that in this case, this built-in attribute belongs to
object and _processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy)
set the
attribute of that object.
The most common situation to use built-in attribute is production,
consumption, delay, and computation.
In the second case, _processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy)
can also be
used to assign or refer elements in graph or hierarchy.
In details, object is the target object and value is the
source object. object and value can be either Edge/Node
/Port/DIFParameter according to the overrided
_processBuiltinAttribute(java.lang.String, java.lang.Object, java.lang.Object, mapss.dif.DIFHierarchy)
.
This method should first validate all input arguments and then performs its task.
id
- Name of the attribute being processed.object
- An Edge/Node/Port in the graph/hierarchy.value
- Containing the value of the attribute or the
refered value(instance) of the object.hierarchy
- The graph to which the dif file is being read.
DIFLanguageException
protected void _setComputationAttribute(java.lang.Object object, java.lang.Object value, DIFGraph graph) throws DIFLanguageException
object
- The node.value
- The String contains the computation.graph
-
DIFLanguageException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |