org.eclipse.ocl.parser
Class OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

java.lang.Object
  extended by org.eclipse.ocl.lpg.AbstractAnalyzer
      extended by org.eclipse.ocl.parser.AbstractOCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
          extended by org.eclipse.ocl.parser.OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

public class OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
extends AbstractOCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

The OCLAnalyzer performs semantic analysis on a CST produced by an OCLParser to create the OCL AST. It is necessary that syntactic parsing and semantic analysis are performed in two steps because LPG is a bottom up parser and cannot provide enough contextual information to create the AST on the first pass.


Field Summary
 
Fields inherited from class org.eclipse.ocl.parser.AbstractOCLAnalyzer
environmentFactory, oclFactory, uml
 
Constructor Summary
OCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
          Construct an OCL semantic analyzer with default syntactic and lexical parsers all operating within a given environment.
OCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment, String text)
          Construct an OCL semantic analyzer with default syntactic and lexical parsers all operating within a given environment.
OCLAnalyzer(OCLParser parser)
          Construct an OCL semantic analyzer that will use a given parser to perform syntactic and lexical analysis.
 
Method Summary
 OCLParser getParser()
           
 OCLExpression<C> parseAST(OCLExpressionCS cst, ConstraintKind constraintType)
          Parses the specified concrete syntax model to an abstract syntax model.
 CSTNode parseConcreteSyntax()
          Performs a concrete-syntax parser and throws ParserException if any parse errors are encountered.
 CT parseInitOrDerValueCS()
          Parses the input as an InitOrDerValueCS.
 CT parseInvOrDefCS()
          Parses the input as an InvOrDefCS.
 List<CT> parsePackageDeclarationCS(List<CT> constraints)
          Parses the input as a PackageDeclarationCS.
 CT parsePrePostOrBodyDeclCS()
          Parses the input as a PrePostOrBodyDeclCS.
 Variable<C,PM> parseVariableDeclarationCS(boolean addToEnvironment)
          Parses the input as a VariableDeclarationCS.
 
Methods inherited from class org.eclipse.ocl.parser.AbstractOCLAnalyzer
booleanLiteralExpCS, checkNotReflexive, classifierContextDeclCS, collectionLiteralExpCS, collectionLiteralPartCS, collectionTypeCS, collectionTypeIdentifierCS, contextDeclCS, createClassifierContext, createDummyInvalidLiteralExp, createImplicitCollect, createOperationContext, createPackageContext, createPropertyContext, defCS, enumLiteralExpCS, equalName, genOperationCallExp, genVariableDeclaration, getBagType, getBoolean, getCollectionKind, getCollectionSourceExpression, getCollectionType, getCommonSuperType, getElementType, getLoopBody, getOCLEnvironment, getOclVoid, getOperationMessageType, getOrderedSetType, getSequenceType, getSetType, getSignalMessageType, getStandardLibrary, getTupleType, getTypeType, ifExpCS, initASTMapping, initOrDerValueCS, integerLiteralExpCS, invalidLiteralExpCS, invCS, invOrDefCS, isEscaped, isIdentifierOrKeyword, iterateExpCS, iteratorExpCS, letExpCS, letExpCSRecursive, literalExpCS, lookupAssociationClassReference, lookupClassifier, lookupImplicitSourceForOperation, lookupOperation, lookupProperty, lookupSignal, lookupState, loopExpCS, messageExpCS, modelPropertyCallExpCS, nullLiteralExpCS, oclExpressionCS, operationCallExpCS, operationContextDeclCS, operationCS, operationString, packageDeclarationCS, parametersCS, prePostOrBodyDeclCS, primitiveLiteralExpCS, primitiveTypeCS, propertyCallExpCS, propertyContextCS, qualifiersCS, realLiteralExpCS, setQualifiers, simpleNameCS, stateExpCS, stringLiteralExpCS, tupleLiteralExpCS, tupleLiteralPartCS, tupleLiteralPartListCS, tupleTypeCS, typeCS, typeCS, unescape, unlimitedNaturalLiteralExpCS, variableDeclarationCS, variableDeclarationListCS, variableExpCS
 
Methods inherited from class org.eclipse.ocl.lpg.AbstractAnalyzer
computeInputString, dumpTokens, ERROR, ERROR, ERROR, formatClass, formatEClassName, formatName, formatPath, formatPath, formatQualifiedName, formatString, formatType, getCharOffset, getEnvironment, getFormatter, getLexer, getTraceFlag, initialize, initialize, initPropertyPositions, initStartEndPositions, initTypePositions, makeName, makeString, setCharacterOffset, setFileName, setTab, setTraceFlag, TRACE, TRACE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OCLAnalyzer

public OCLAnalyzer(OCLParser parser)
Construct an OCL semantic analyzer that will use a given parser to perform syntactic and lexical analysis.

Parameters:
parser - the syntactic (and lexical) parser

OCLAnalyzer

public OCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
Construct an OCL semantic analyzer with default syntactic and lexical parsers all operating within a given environment.

Parameters:
environment - the symbolic and problem handling environment

OCLAnalyzer

public OCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment,
                   String text)
Construct an OCL semantic analyzer with default syntactic and lexical parsers all operating within a given environment. Then prime the analyzer by performing keyword and lexical parsing of the given source text.

Parameters:
environment - the symbolic and problem handling environment
text - the source text for analysis
Method Detail

getParser

public OCLParser getParser()
Overrides:
getParser in class AbstractOCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

parseConcreteSyntax

public CSTNode parseConcreteSyntax()
Performs a concrete-syntax parser and throws ParserException if any parse errors are encountered.

Returns:
the parsed CST, or null if it could not be parsed

parseAST

public OCLExpression<C> parseAST(OCLExpressionCS cst,
                                 ConstraintKind constraintType)
Parses the specified concrete syntax model to an abstract syntax model.

Parameters:
cst - the OCL concrete syntax model
constraintType - the kind of constraint to parse
Returns:
the OCL expression, if it successfully parsed

parsePackageDeclarationCS

public List<CT> parsePackageDeclarationCS(List<CT> constraints)
Parses the input as a PackageDeclarationCS.

Parameters:
constraints -
Returns:
the parsed constraints (as many as could be parsed)

parseInvOrDefCS

public CT parseInvOrDefCS()
Parses the input as an InvOrDefCS.

Returns:
the parsed OCL constraint, or null if it could not be parsed

parsePrePostOrBodyDeclCS

public CT parsePrePostOrBodyDeclCS()
Parses the input as a PrePostOrBodyDeclCS.

Returns:
the parsed OCL constraint, or null if it could not be parsed

parseInitOrDerValueCS

public CT parseInitOrDerValueCS()
Parses the input as an InitOrDerValueCS.

Returns:
the parsed OCL constraint, or null if it could not be parsed

parseVariableDeclarationCS

public Variable<C,PM> parseVariableDeclarationCS(boolean addToEnvironment)
Parses the input as a VariableDeclarationCS.

Parameters:
addToEnvironment - boolean whether or not to add the the parsed variable to the environment
Returns:
the parsed variable declaration, or null if it could not be parsed

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.