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

java.lang.Object
  extended by org.eclipse.gmt.umlx.cst.parser.AbstractParser
      extended by org.eclipse.gmt.umlx.ocl.cst.parser.AbstractOCLParser<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
          extended by org.eclipse.gmt.umlx.ocl.cst.parser.OCLParser<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
All Implemented Interfaces:
org.eclipse.gmt.umlx.cst.parser.LexerErrorHandler, org.eclipse.gmt.umlx.cst.parser.ParserErrorHandler
Direct Known Subclasses:
OCLFileParser

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

The OCLLpgParser parses an OCL expression into a CST. Once the CST is created, the OCLParser walks the CST and creates the OCL AST. It is necessary that this be done in two steps because LPG is a bottom up parser and cannot provide enough contextual information to create the AST on the first pass.

Author:
Christian Vogt (cvogt) This is a replacement for OCLParser with a distinct name to avoid classpath problems when the original exists.

Field Summary
 
Fields inherited from class org.eclipse.gmt.umlx.ocl.cst.parser.AbstractOCLParser
errorMessages
 
Constructor Summary
OCLParser(org.eclipse.ocl.Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
           
OCLParser(OCLLexer lexStream, org.eclipse.ocl.Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
           
 
Method Summary
 org.eclipse.ocl.expressions.OCLExpression<C> parseAST(org.eclipse.ocl.internal.cst.OCLExpressionCS cst, org.eclipse.ocl.helper.ConstraintKind constraintType)
          Parses the specified concrete syntax model to an abstract syntax model.
 org.eclipse.ocl.internal.cst.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.
 java.util.List<CT> parsePackageDeclarationCS(java.util.List<CT> constraints)
          Parses the input as a PackageDeclarationCS.
 CT parsePrePostOrBodyDeclCS()
          Parses the input as a PrePostOrBodyDeclCS.
 org.eclipse.ocl.expressions.Variable<C,PM> parseVariableDeclarationCS(boolean addToEnvironment)
          Parses the input as a VariableDeclarationCS.
 
Methods inherited from class org.eclipse.gmt.umlx.ocl.cst.parser.AbstractOCLParser
equalName, isEscaped, isIdentifierOrKeyword, unescape
 
Methods inherited from class org.eclipse.gmt.umlx.cst.parser.AbstractParser
computeInputString, computeInputString, dumpTokens, ERROR, flushErrors, formatClass, formatEClassName, formatName, formatPath, formatPath, formatString, formatType, getCharOffset, getErrorHandler, getInputChars, getLexStream, getMonitor, getPrsStream, getTraceFlag, isCancelled, lexerError, parserError, setCharacterOffset, setErrorHandler, setFileName, setInputChars, setInputReader, setMonitor, setTab, setTraceFlag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OCLParser

public OCLParser(org.eclipse.ocl.Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)

OCLParser

public OCLParser(OCLLexer lexStream,
                 org.eclipse.ocl.Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
Method Detail

parseInitOrDerValueCS

public final CT parseInitOrDerValueCS()
                               throws org.eclipse.ocl.ParserException
Parses the input as an InitOrDerValueCS.

Parameters:
property - the constrained EStructuralFeature
Returns:
the parsed OCL constraint
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression

parseInvOrDefCS

public final CT parseInvOrDefCS()
                         throws org.eclipse.ocl.ParserException
Parses the input as an InvOrDefCS.

Returns:
the parsed OCL constraint
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression

parsePackageDeclarationCS

public java.util.List<CT> parsePackageDeclarationCS(java.util.List<CT> constraints)
                                             throws org.eclipse.ocl.ParserException
Parses the input as a PackageDeclarationCS.

Parameters:
constraints -
Returns:
the parsed constraints
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression

parsePrePostOrBodyDeclCS

public final CT parsePrePostOrBodyDeclCS()
                                  throws org.eclipse.ocl.ParserException
Parses the input as a PrePostOrBodyDeclCS.

Parameters:
operation - the constrained EOperation
Returns:
the parsed OCL constraint
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression

parseVariableDeclarationCS

public final org.eclipse.ocl.expressions.Variable<C,PM> parseVariableDeclarationCS(boolean addToEnvironment)
                                                                            throws org.eclipse.ocl.ParserException
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
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression

parseAST

public org.eclipse.ocl.expressions.OCLExpression<C> parseAST(org.eclipse.ocl.internal.cst.OCLExpressionCS cst,
                                                             org.eclipse.ocl.helper.ConstraintKind constraintType)
                                                      throws org.eclipse.ocl.ParserException
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
Throws:
org.eclipse.ocl.ParserException - any exception thrown in parsing

parseConcreteSyntax

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

Returns:
the parsed CST
Throws:
org.eclipse.ocl.ParserException - if unable to parse the expression