org.sintef.mofscript.parser
Class MofScriptModelChecker

java.lang.Object
  extended by org.sintef.mofscript.parser.MofScriptModelChecker
Direct Known Subclasses:
MofScriptUMLModelChecker

public class MofScriptModelChecker
extends java.lang.Object

Semantic checker for MOFScript

Author:
Jon Oldevik

Field Summary
protected  java.util.Hashtable _currentCreatedTypes
           
protected  TransformationRule _currentRule
           
protected  java.lang.String _currentRuleType
           
protected  MofScriptErrorManager _errorMgr
           
protected  ExecutionManager _execMgr
           
protected  java.util.Hashtable _fileDeclarations
           
protected  java.util.Hashtable _importedTransformations
           
protected  boolean _metamodelsOk
           
protected  java.util.Hashtable _postCheckReferences
           
protected  java.util.Hashtable _ruleDeclarations
           
protected  MOFScriptTransformation _transformation
           
protected  TransformationProxy _transformationProxy
           
protected  MOFScriptSpecification _transformationSpec
           
protected  java.util.Stack _variableStack
           
static int SOURCE_METAMODEL
           
static int TARGET_METAMODEL
           
 
Constructor Summary
MofScriptModelChecker()
          Default constructor
 
Method Summary
 void addImportedTransformation(java.lang.String importName, java.lang.String importUri, MOFScriptTransformation importedTr)
          Add imported transformations
 boolean addSourceMetaModel(MOFScriptParameter param)
           
protected  MofScriptParseError booleanFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if boolean function is OK
 void checkExpression(Expression exp)
          Checks an expression
 void checkMetaModels()
          sets the source and target metamodels from transformation objects
 void checkParameter(MOFScriptParameter parameter)
          Checks a domain (a parameter) to the rule
protected  MofScriptParseError checkParameterUsage(java.lang.String fName, FunctionCall fc, int requiredParamCount)
          Checks the parameters usage Used where for locked number of parameters
protected  MofScriptParseError checkParameterUsage(java.lang.String fName, FunctionCall fc, int lowerCount, int upperCount)
          Checks the numbers of parameters
 void checkReference(Reference ref)
          Checks the refrence
 void checkReferenceName(java.lang.String refName, MOFScriptObject checkObj)
          Checks the refrence name
protected  MofScriptParseError checkRuleContext(MOFScriptParameter parameter)
          Checks the context of a rule
 void checkStatement(MOFScriptStatement statement, boolean postCheck)
          Checks a statement within a rule
 void checkTransformationRule(TransformationRule rule, boolean postCheck)
          Checks a transformation rule for type usages, rule invocations etc
protected  java.lang.String checkType(java.lang.String dtype, MOFScriptObject checkObject)
           
 void checkVariableDeclaration(VariableDeclaration varDecl)
          Checks properties of the transformation
protected  MofScriptParseError checkVariableUsage(VariableDeclaration var, java.lang.String functionCalled, FunctionCall fc)
          Check if the usage of a variable (e.g. a Hashtable var) is legal
 void clear()
          Clears all stored values
 java.lang.String findGlobalParameter(java.lang.String name)
          Returns the type name of the parameter if it exists
 VariableDeclaration findGlobalVariables(MOFScriptTransformation transformation, java.lang.String name)
          Finds global variables
 java.lang.Object findVariable(java.lang.String name)
          Find a variable either globally or locally
 int getErrorCount()
          Gets the error count
 MofScriptErrorManager getErrorManager()
          Gets the error manager
 java.util.Iterator getErrors()
          Gets the errors
 org.eclipse.emf.ecore.EClassifier getMetaModelClassifier(org.eclipse.emf.ecore.EPackage model, java.lang.String classifierName)
          Looks for a classifier for a metamodel package Looks recursively into sub packages
protected  org.eclipse.emf.ecore.EClassifier getMetaModelReference(java.lang.String refName)
          Gets a meta model reference
 boolean getMetaModelsOK()
           
protected  VariableDeclaration getTempVar()
           
 MOFScriptTransformation getTransformationModel()
           
 TransformationProxy getTransformationProxy()
          returns the current transformation model
 MOFScriptSpecification getTransformationSpecification()
           
protected  MofScriptParseError hashtableFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if a Hashtable function is OK
protected  MofScriptParseError integerFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if integer function is OK
 boolean isSuperTransformation(MOFScriptTransformation transformation, MOFScriptTransformation possibleSuper)
           
protected  MofScriptParseError listFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if a list function is OK
 void postCheck()
          Semantic checks of the complete model
protected  void postCheckExpression(Expression exp)
          Post checking, when all rules can be resolved...
protected  void postCheckFunctionCall(FunctionCall fc)
          Perform post check of a function call
protected  void postCheckUnresolvedReferences()
          Iterators through unresolved references and looks for them again.
 void printErrors()
          Prints the errors to system.out
protected  MofScriptParseError realFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if real function is OK
protected  void setExtendsRelation(MOFScriptTransformation transformation, java.util.Hashtable trHierarchy)
          Set the extend relation
 boolean setTargetMetaModel(java.lang.String targetMM)
          Sets the target metamodel
 void setTransformationModel(MOFScriptTransformation transformation)
           
 void setTransformationSpecification(MOFScriptSpecification trModel)
           
protected  MofScriptParseError stringFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if a string function is OK
protected  MofScriptParseError systemFunctionOk(java.lang.String functionCalled, FunctionCall fc)
          Checks if a system function is OK
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE_METAMODEL

public static int SOURCE_METAMODEL

TARGET_METAMODEL

public static int TARGET_METAMODEL

_transformationProxy

protected TransformationProxy _transformationProxy

_transformationSpec

protected MOFScriptSpecification _transformationSpec

_transformation

protected MOFScriptTransformation _transformation

_execMgr

protected ExecutionManager _execMgr

_errorMgr

protected MofScriptErrorManager _errorMgr

_variableStack

protected java.util.Stack _variableStack

_ruleDeclarations

protected java.util.Hashtable _ruleDeclarations

_fileDeclarations

protected java.util.Hashtable _fileDeclarations

_currentCreatedTypes

protected java.util.Hashtable _currentCreatedTypes

_importedTransformations

protected java.util.Hashtable _importedTransformations

_currentRuleType

protected java.lang.String _currentRuleType

_currentRule

protected TransformationRule _currentRule

_metamodelsOk

protected boolean _metamodelsOk

_postCheckReferences

protected java.util.Hashtable _postCheckReferences
Constructor Detail

MofScriptModelChecker

public MofScriptModelChecker()
Default constructor

Method Detail

getTransformationProxy

public TransformationProxy getTransformationProxy()
returns the current transformation model

Returns:

setTransformationSpecification

public void setTransformationSpecification(MOFScriptSpecification trModel)
Parameters:
trModel -

getTransformationSpecification

public MOFScriptSpecification getTransformationSpecification()
Returns:
the transformation specification

setTransformationModel

public void setTransformationModel(MOFScriptTransformation transformation)
Parameters:
transformation -

getTransformationModel

public MOFScriptTransformation getTransformationModel()

clear

public void clear()
Clears all stored values


getMetaModelsOK

public boolean getMetaModelsOK()
Returns:

checkMetaModels

public void checkMetaModels()
sets the source and target metamodels from transformation objects


addSourceMetaModel

public boolean addSourceMetaModel(MOFScriptParameter param)
Parameters:
param -
Returns:

setTargetMetaModel

public boolean setTargetMetaModel(java.lang.String targetMM)
Sets the target metamodel

Parameters:
targetMetaModel -

checkVariableDeclaration

public void checkVariableDeclaration(VariableDeclaration varDecl)
Checks properties of the transformation


getMetaModelClassifier

public org.eclipse.emf.ecore.EClassifier getMetaModelClassifier(org.eclipse.emf.ecore.EPackage model,
                                                                java.lang.String classifierName)
Looks for a classifier for a metamodel package Looks recursively into sub packages

Parameters:
model -
classifierName -
Returns:

checkTransformationRule

public void checkTransformationRule(TransformationRule rule,
                                    boolean postCheck)
Checks a transformation rule for type usages, rule invocations etc


getMetaModelReference

protected org.eclipse.emf.ecore.EClassifier getMetaModelReference(java.lang.String refName)
Gets a meta model reference

Parameters:
refName -
Returns:

checkRuleContext

protected MofScriptParseError checkRuleContext(MOFScriptParameter parameter)
Checks the context of a rule

Parameters:
parameter -

checkParameter

public void checkParameter(MOFScriptParameter parameter)
Checks a domain (a parameter) to the rule

Parameters:
domain -

checkType

protected java.lang.String checkType(java.lang.String dtype,
                                     MOFScriptObject checkObject)
Parameters:
dtype - Full name of the type
Returns:
Value of type without any prefix

checkStatement

public void checkStatement(MOFScriptStatement statement,
                           boolean postCheck)
Checks a statement within a rule

Parameters:
statement -

findGlobalParameter

public java.lang.String findGlobalParameter(java.lang.String name)
Returns the type name of the parameter if it exists

Parameters:
exp -

findGlobalVariables

public VariableDeclaration findGlobalVariables(MOFScriptTransformation transformation,
                                               java.lang.String name)
Finds global variables

Parameters:
name -
Returns:

findVariable

public java.lang.Object findVariable(java.lang.String name)
Find a variable either globally or locally

Parameters:
exp -

checkExpression

public void checkExpression(Expression exp)
Checks an expression

Parameters:
exp -

checkReference

public void checkReference(Reference ref)
Checks the refrence

Parameters:
ref -

checkReferenceName

public void checkReferenceName(java.lang.String refName,
                               MOFScriptObject checkObj)
Checks the refrence name

Parameters:
refName -
checkObj -

postCheck

public void postCheck()
               throws MofScriptModelException
Semantic checks of the complete model

Throws:
MofScriptModelException

postCheckUnresolvedReferences

protected void postCheckUnresolvedReferences()
Iterators through unresolved references and looks for them again. Occurs when a transformation uses a reference from a super trans.


postCheckExpression

protected void postCheckExpression(Expression exp)
Post checking, when all rules can be resolved...

Parameters:
exp -

postCheckFunctionCall

protected void postCheckFunctionCall(FunctionCall fc)
Perform post check of a function call

Parameters:
fc -

isSuperTransformation

public boolean isSuperTransformation(MOFScriptTransformation transformation,
                                     MOFScriptTransformation possibleSuper)
Parameters:
transformation -
possibleSuper -
Returns:
true if a transformation is a supertype of another

setExtendsRelation

protected void setExtendsRelation(MOFScriptTransformation transformation,
                                  java.util.Hashtable trHierarchy)
Set the extend relation

Parameters:
transformation -
trHierarchy -

addImportedTransformation

public void addImportedTransformation(java.lang.String importName,
                                      java.lang.String importUri,
                                      MOFScriptTransformation importedTr)
Add imported transformations

Parameters:
importName -
importUri -
importedTr -

getTempVar

protected VariableDeclaration getTempVar()
Returns:
a temp variabel declaration

checkVariableUsage

protected MofScriptParseError checkVariableUsage(VariableDeclaration var,
                                                 java.lang.String functionCalled,
                                                 FunctionCall fc)
Check if the usage of a variable (e.g. a Hashtable var) is legal

Parameters:
var -
functionCalled -
Returns:
MOFScriptParseError if not ok

systemFunctionOk

protected MofScriptParseError systemFunctionOk(java.lang.String functionCalled,
                                               FunctionCall fc)
Checks if a system function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

stringFunctionOk

protected MofScriptParseError stringFunctionOk(java.lang.String functionCalled,
                                               FunctionCall fc)
Checks if a string function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

listFunctionOk

protected MofScriptParseError listFunctionOk(java.lang.String functionCalled,
                                             FunctionCall fc)
Checks if a list function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

hashtableFunctionOk

protected MofScriptParseError hashtableFunctionOk(java.lang.String functionCalled,
                                                  FunctionCall fc)
Checks if a Hashtable function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

booleanFunctionOk

protected MofScriptParseError booleanFunctionOk(java.lang.String functionCalled,
                                                FunctionCall fc)
Checks if boolean function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

realFunctionOk

protected MofScriptParseError realFunctionOk(java.lang.String functionCalled,
                                             FunctionCall fc)
Checks if real function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

integerFunctionOk

protected MofScriptParseError integerFunctionOk(java.lang.String functionCalled,
                                                FunctionCall fc)
Checks if integer function is OK

Parameters:
functionCalled -
fc -
Returns:
MOFScriptParseError if not ok

checkParameterUsage

protected MofScriptParseError checkParameterUsage(java.lang.String fName,
                                                  FunctionCall fc,
                                                  int requiredParamCount)
Checks the parameters usage Used where for locked number of parameters

Parameters:
fName -
fc -
requiredParamCount -
Returns:

checkParameterUsage

protected MofScriptParseError checkParameterUsage(java.lang.String fName,
                                                  FunctionCall fc,
                                                  int lowerCount,
                                                  int upperCount)
Checks the numbers of parameters

Parameters:
fName -
fc -
lowerCount -
upperCount -
Returns:

printErrors

public void printErrors()
Prints the errors to system.out


getErrorManager

public MofScriptErrorManager getErrorManager()
Gets the error manager

Returns:

getErrorCount

public int getErrorCount()
Gets the error count

Returns:

getErrors

public java.util.Iterator getErrors()
Gets the errors

Returns: