Package cruise.umple.compiler
Class UmpleInternalParser
java.lang.Object
cruise.umple.compiler.Parser
cruise.umple.compiler.UmpleInternalParser
- All Implemented Interfaces:
UmpleParser
public class UmpleInternalParser extends Parser implements UmpleParser
This is our internal parser implementation for the Umple language. It uses
a generic Parser that can read an external EBNF grammar file, and then populate
an abstract syntax tree.
The work of the UmpleInternalParser is
a) The grammar definition (defined externally in *.grammar files)
b) Analyzing the AST to populate an Umple meta model instance
c) Delegating to our code generator to produce the necessary artifacts (i.e. Java / PHP / Ruby code)
Please refer to UmpleInternalParser_Code.ump for implementation details.
NEW CLASS****************************************
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
This is a mixin feature of Umple. The Content of following class will be added automatically to core parse.
---------------------------------end----------------------------------------
----------------------------------------------------------------------------
---------------------------------Start--------------------------------------
NEW CLASS****************************************
Internal invocation for internal umple parser in order to invoke walkers calls which
can instantiate the analysis if required
Internal invocation for internal umple parser in order to invoke walkers calls which
can instantiate the analysis if required
Copyright: All contributers to the Umple Project.
This file is made available subject to the open source license found at:
http://umple.org/license
This file analyzses require statement tokens to populate Requiregraph for Umple model.
Please refer to UmpleInternalParser.ump for more details.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UmpleInternalParser.Strictness
-
Constructor Summary
Constructors Constructor Description UmpleInternalParser()
UmpleInternalParser(UmpleModel aModel)
UmpleInternalParser(java.lang.String aName, UmpleModel aModel, RuleBasedParser aParser)
-
Method Summary
Modifier and Type Method Description boolean
addAllowedMessage(java.lang.Integer aAllowedMessage)
boolean
addDisallowedMessage(java.lang.Integer aDisallowedMessage)
boolean
addExpectedMessage(java.lang.Integer aExpectedMessage)
void
addExtendsTo(Token classifierToken, UmpleClassifier aClassifier, java.util.Map<UmpleClassifier,java.util.List<java.lang.String>> unlinkedExtends, java.util.Map<UmpleClassifier,java.util.List<Token>> unlinkedExtendsTokens)
Takes an Umple classifier and analyzes a classifier token to add classifiers which extend it.boolean
addIgnoredMessage(java.lang.Integer aIgnoredMessage)
boolean
addMessagesToExpect(ErrorType aMessagesToExpect)
boolean
addMessagesToExpectAt(ErrorType aMessagesToExpect, int index)
boolean
addOrMoveMessagesToExpectAt(ErrorType aMessagesToExpect, int index)
boolean
addOrMoveParsedNameSpaceAt(NameSpace aParsedNameSpace, int index)
boolean
addOrMoveWarningsToIgnoreAt(ErrorType aWarningsToIgnore, int index)
boolean
addParsedNameSpace(NameSpace aParsedNameSpace)
boolean
addParsedNameSpaceAt(NameSpace aParsedNameSpace, int index)
boolean
addToGeneratedMethodMap(java.util.HashSet<java.lang.String> generatedMethods, java.lang.String className, CodeTranslator t, java.lang.String translatingLabel, Attribute aAttr)
boolean
addWarningsToIgnore(ErrorType aWarningsToIgnore)
boolean
addWarningsToIgnoreAt(ErrorType aWarningsToIgnore, int index)
boolean
allowMessage(java.lang.Integer id)
ParseResult
analyze(boolean shouldGenerate)
void
analyzeFeatureModel()
void
analyzeInvariants()
void
analyzeParseResult()
void
analyzeRequireStatement(Token t, int analysisStep)
void
analyzeToplevelException(Token token)
void
analyzeTraceCaseActivationToken(UmpleClass aClass, Token token)
void
analyzeTraceCaseToken(UmpleClass aClass, Token token)
Analyzes trace case token and its subtokens (i.e.void
checkDefaultedNameConflict()
void
createFeatureModelSegment(FeatureNode sourceFeature, TokenTree tokenTree, boolean isSubFeature)
This method takes a require-st as a token tree and then it generates its segment in the feature modelFeatureNode
createTargetFeature(TokenTree treeNode, FeatureNode sourceFeature, boolean isSubFeature)
this method generates a new feature and links it with a source feature based on its token in the TokenTree.void
delete()
boolean
disallowMessage(java.lang.Integer id)
boolean
expectMessage(java.lang.Integer id)
java.util.Map<Association,java.lang.Integer>
getAfixmlAttributeCount()
java.util.Map<Association,java.util.List<Token>>
getAfixmlLastIntilialization()
java.util.ArrayList<java.lang.String>
getAllMethodNames(UmpleClass uClass)
java.lang.Integer
getAllowedMessage(int index)
java.lang.Integer[]
getAllowedMessages()
java.lang.String
getCurrentPackageName()
java.lang.Integer
getDisallowedMessage(int index)
java.lang.Integer[]
getDisallowedMessages()
java.lang.Integer
getExpectedMessage(int index)
java.lang.Integer[]
getExpectedMessages()
java.util.Map<Attribute,java.lang.Integer>
getFixmlAttributeCount()
java.util.Map<Attribute,Token>
getFixmlLastIntilialization()
java.lang.Integer
getIgnoredMessage(int index)
java.lang.Integer[]
getIgnoredMessages()
Position
getLastassocPosition()
NameSpace
getLastParsedNameSpace()
java.util.List<ErrorType>
getMessagesToExpect()
List of errors or warnings to expect.ErrorType
getMessagesToExpect(int index)
UmpleTestCase
getMethodTestCase(UmpleClass aClass, java.lang.String meth)
UmpleModel
getModel()
The Umple meta model which will be populated based on what was parsed.MethodTraceItem
getMte()
boolean
getOutputUmpleSource()
boolean
getPackageNameUsed()
NameSpace
getParsedNameSpace(int index)
java.util.List<NameSpace>
getParsedNameSpaces()
List of parsed namespaces.java.util.Map<java.lang.String,java.lang.Boolean>
getParsedUmpfiles()
The key is to store names of parsed umple files.RuleBasedParser
getParser()
Postfix
getPost()
java.lang.String
getRedefinePackageName()
java.util.ArrayList<Token>
getRequireStatementTokensAsList(Token requireStatementToken, java.util.List<java.lang.String> acceptedTokensList)
This method filters unwanted tokens & changes the form of require-statement argument from nested tokens, as the parser does, to list of tokens.UmpleInternalParser.Strictness
getStrictness()
java.lang.String
getStrictnessFullName()
TraceCase
getTca()
AttributeTraceItem
getTraceAttr()
AssociationTraceItem
getTracedAssoc()
TraceDirective
getTraceDirective()
int
getTraceFlagId()
java.util.List<ErrorType>
getWarningsToIgnore()
List of warnings to allow and ignore Used to suppress warnings that we do not care aboutErrorType
getWarningsToIgnore(int index)
boolean
hasAllowedMessages()
boolean
hasDisallowedMessages()
boolean
hasExpectedMessages()
boolean
hasIgnoredMessages()
boolean
hasMessagesToExpect()
boolean
hasParsedNameSpaces()
boolean
hasWarningsToIgnore()
boolean
ignoreMessage(java.lang.Integer id)
int
indexOfAllowedMessage(java.lang.Integer aAllowedMessage)
int
indexOfDisallowedMessage(java.lang.Integer aDisallowedMessage)
int
indexOfExpectedMessage(java.lang.Integer aExpectedMessage)
int
indexOfIgnoredMessage(java.lang.Integer aIgnoredMessage)
int
indexOfMessagesToExpect(ErrorType aMessagesToExpect)
int
indexOfParsedNameSpace(NameSpace aParsedNameSpace)
int
indexOfWarningsToIgnore(ErrorType aWarningsToIgnore)
boolean
isOutputUmpleSource()
boolean
isPackageNameUsed()
static int
minimumNumberOfMessagesToExpect()
static int
minimumNumberOfParsedNameSpaces()
static int
minimumNumberOfWarningsToIgnore()
boolean
modelOnly()
boolean
noExtraCode()
int
numberOfAllowedMessages()
int
numberOfDisallowedMessages()
int
numberOfExpectedMessages()
int
numberOfIgnoredMessages()
int
numberOfMessagesToExpect()
int
numberOfParsedNameSpaces()
int
numberOfWarningsToIgnore()
ParseResult
parse(java.lang.String ruleName, java.lang.String input)
Parses input based on a rule.ParseResult
parse(java.lang.String ruleName, java.lang.String input, java.lang.String fileName, Position position, int lineNumber, int offset)
boolean
reAnalyze()
This MIXSET contains common code used by Template & Strcture.void
reAnalyze(boolean re)
boolean
removeAllowedMessage(java.lang.Integer aAllowedMessage)
boolean
removeDisallowedMessage(java.lang.Integer aDisallowedMessage)
boolean
removeExpectedMessage(java.lang.Integer aExpectedMessage)
boolean
removeIgnoredMessage(java.lang.Integer aIgnoredMessage)
boolean
removeMessagesToExpect(ErrorType aMessagesToExpect)
boolean
removeParsedNameSpace(NameSpace aParsedNameSpace)
boolean
removeWarningsToIgnore(ErrorType aWarningsToIgnore)
boolean
setAfixmlAttributeCount(java.util.Map<Association,java.lang.Integer> aAfixmlAttributeCount)
boolean
setAfixmlLastIntilialization(java.util.Map<Association,java.util.List<Token>> aAfixmlLastIntilialization)
boolean
setCurrentPackageName(java.lang.String aCurrentPackageName)
void
setFailedPosition(Position position, int errorCode, java.lang.String... messages)
------------------------ PRIVATE METHODS ------------------------ When an error occurs, set the failed position and mark the compile as NOT successfulboolean
setFixmlAttributeCount(java.util.Map<Attribute,java.lang.Integer> aFixmlAttributeCount)
boolean
setFixmlLastIntilialization(java.util.Map<Attribute,Token> aFixmlLastIntilialization)
boolean
setLastassocPosition(Position aLastassocPosition)
boolean
setLastParsedNameSpace(NameSpace aLastParsedNameSpace)
boolean
setModel(UmpleModel aModel)
boolean
setMte(MethodTraceItem aMte)
boolean
setOutputUmpleSource(boolean aOutputUmpleSource)
boolean
setPackageNameUsed(boolean aPackageNameUsed)
boolean
setParsedUmpfiles(java.util.Map<java.lang.String,java.lang.Boolean> aParsedUmpfiles)
boolean
setParser(RuleBasedParser aParser)
boolean
setPost(Postfix aPost)
boolean
setRedefinePackageName(java.lang.String aRedefinePackageName)
boolean
setTca(TraceCase aTca)
boolean
setTraceAttr(AttributeTraceItem aTraceAttr)
boolean
setTracedAssoc(AssociationTraceItem aTracedAssoc)
boolean
setTraceDirective(TraceDirective aTraceDirective)
boolean
setTraceFlagId(int aTraceFlagId)
Methods inherited from class cruise.umple.compiler.Parser
addCouple, addCoupleAt, addGrammarRule, addOrMoveCoupleAt, addOrMoveRuleAt, addRule, addRule, addRuleAt, addRulesInFile, genRuleHtml, genRuleLezer, getCouple, getCouples, getFilename, getGrammarRule, getGrammarRules, getName, getParseResult, getRootToken, getRule, getRule, getRules, getToken, getTokens, hasCouples, hasGrammarRules, hasRules, hasTokens, indexOf, indexOfCouple, indexOfGrammarRule, indexOfRule, minimumNumberOfCouples, minimumNumberOfRules, numberOfCouples, numberOfGrammarRules, numberOfRules, numberOfTokens, removeCouple, removeGrammarRule, removeRule, reset, setFilename, setName, setParseResult, setRootToken, toGrammar, toGrammarHtml, toGrammarLezer, toGrammarNoStyle, toGrammarParts, toGrammarParts, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface cruise.umple.compiler.UmpleParser
getParseResult, getRootToken, setFilename, toGrammar
-
Constructor Details
-
UmpleInternalParser
-
UmpleInternalParser
public UmpleInternalParser() -
UmpleInternalParser
-
-
Method Details
-
setCurrentPackageName
public boolean setCurrentPackageName(java.lang.String aCurrentPackageName) -
setRedefinePackageName
public boolean setRedefinePackageName(java.lang.String aRedefinePackageName) -
setPackageNameUsed
public boolean setPackageNameUsed(boolean aPackageNameUsed) -
setOutputUmpleSource
public boolean setOutputUmpleSource(boolean aOutputUmpleSource) -
setModel
- Specified by:
setModel
in interfaceUmpleParser
-
setParser
-
setLastParsedNameSpace
-
addAllowedMessage
public boolean addAllowedMessage(java.lang.Integer aAllowedMessage) -
removeAllowedMessage
public boolean removeAllowedMessage(java.lang.Integer aAllowedMessage) -
addIgnoredMessage
public boolean addIgnoredMessage(java.lang.Integer aIgnoredMessage) -
removeIgnoredMessage
public boolean removeIgnoredMessage(java.lang.Integer aIgnoredMessage) -
addDisallowedMessage
public boolean addDisallowedMessage(java.lang.Integer aDisallowedMessage) -
removeDisallowedMessage
public boolean removeDisallowedMessage(java.lang.Integer aDisallowedMessage) -
addExpectedMessage
public boolean addExpectedMessage(java.lang.Integer aExpectedMessage) -
removeExpectedMessage
public boolean removeExpectedMessage(java.lang.Integer aExpectedMessage) -
setLastassocPosition
-
setFixmlLastIntilialization
-
setFixmlAttributeCount
public boolean setFixmlAttributeCount(java.util.Map<Attribute,java.lang.Integer> aFixmlAttributeCount) -
setAfixmlLastIntilialization
public boolean setAfixmlLastIntilialization(java.util.Map<Association,java.util.List<Token>> aAfixmlLastIntilialization) -
setAfixmlAttributeCount
public boolean setAfixmlAttributeCount(java.util.Map<Association,java.lang.Integer> aAfixmlAttributeCount) -
setTraceFlagId
public boolean setTraceFlagId(int aTraceFlagId) -
setTraceDirective
-
setTraceAttr
-
setTracedAssoc
-
setMte
-
setTca
-
setPost
-
setParsedUmpfiles
public boolean setParsedUmpfiles(java.util.Map<java.lang.String,java.lang.Boolean> aParsedUmpfiles) -
getCurrentPackageName
public java.lang.String getCurrentPackageName() -
getRedefinePackageName
public java.lang.String getRedefinePackageName() -
getPackageNameUsed
public boolean getPackageNameUsed() -
getOutputUmpleSource
public boolean getOutputUmpleSource() -
getModel
The Umple meta model which will be populated based on what was parsed.- Specified by:
getModel
in interfaceUmpleParser
-
getParser
-
getLastParsedNameSpace
-
getAllowedMessage
public java.lang.Integer getAllowedMessage(int index) -
getAllowedMessages
public java.lang.Integer[] getAllowedMessages() -
numberOfAllowedMessages
public int numberOfAllowedMessages() -
hasAllowedMessages
public boolean hasAllowedMessages() -
indexOfAllowedMessage
public int indexOfAllowedMessage(java.lang.Integer aAllowedMessage) -
getIgnoredMessage
public java.lang.Integer getIgnoredMessage(int index) -
getIgnoredMessages
public java.lang.Integer[] getIgnoredMessages() -
numberOfIgnoredMessages
public int numberOfIgnoredMessages() -
hasIgnoredMessages
public boolean hasIgnoredMessages() -
indexOfIgnoredMessage
public int indexOfIgnoredMessage(java.lang.Integer aIgnoredMessage) -
getDisallowedMessage
public java.lang.Integer getDisallowedMessage(int index) -
getDisallowedMessages
public java.lang.Integer[] getDisallowedMessages() -
numberOfDisallowedMessages
public int numberOfDisallowedMessages() -
hasDisallowedMessages
public boolean hasDisallowedMessages() -
indexOfDisallowedMessage
public int indexOfDisallowedMessage(java.lang.Integer aDisallowedMessage) -
getExpectedMessage
public java.lang.Integer getExpectedMessage(int index) -
getExpectedMessages
public java.lang.Integer[] getExpectedMessages() -
numberOfExpectedMessages
public int numberOfExpectedMessages() -
hasExpectedMessages
public boolean hasExpectedMessages() -
indexOfExpectedMessage
public int indexOfExpectedMessage(java.lang.Integer aExpectedMessage) -
getLastassocPosition
-
getFixmlLastIntilialization
-
getFixmlAttributeCount
-
getAfixmlLastIntilialization
-
getAfixmlAttributeCount
-
getTraceFlagId
public int getTraceFlagId() -
getTraceDirective
-
getTraceAttr
-
getTracedAssoc
-
getMte
-
getTca
-
getPost
-
getParsedUmpfiles
public java.util.Map<java.lang.String,java.lang.Boolean> getParsedUmpfiles()The key is to store names of parsed umple files. The value is to specify if fully parsed file (true) or partially (false). -
isPackageNameUsed
public boolean isPackageNameUsed() -
isOutputUmpleSource
public boolean isOutputUmpleSource() -
getStrictnessFullName
public java.lang.String getStrictnessFullName() -
getStrictness
-
modelOnly
public boolean modelOnly() -
noExtraCode
public boolean noExtraCode() -
allowMessage
public boolean allowMessage(java.lang.Integer id) -
ignoreMessage
public boolean ignoreMessage(java.lang.Integer id) -
disallowMessage
public boolean disallowMessage(java.lang.Integer id) -
expectMessage
public boolean expectMessage(java.lang.Integer id) -
getParsedNameSpace
-
getParsedNameSpaces
List of parsed namespaces. This is used to check the use of parsed namespaces. -
numberOfParsedNameSpaces
public int numberOfParsedNameSpaces() -
hasParsedNameSpaces
public boolean hasParsedNameSpaces() -
indexOfParsedNameSpace
-
getMessagesToExpect
-
getMessagesToExpect
List of errors or warnings to expect. It is an error if they do not occur. This is used to set up test cases for the presence of certain messages -
numberOfMessagesToExpect
public int numberOfMessagesToExpect() -
hasMessagesToExpect
public boolean hasMessagesToExpect() -
indexOfMessagesToExpect
-
getWarningsToIgnore
-
getWarningsToIgnore
List of warnings to allow and ignore Used to suppress warnings that we do not care about -
numberOfWarningsToIgnore
public int numberOfWarningsToIgnore() -
hasWarningsToIgnore
public boolean hasWarningsToIgnore() -
indexOfWarningsToIgnore
-
minimumNumberOfParsedNameSpaces
public static int minimumNumberOfParsedNameSpaces() -
addParsedNameSpace
-
removeParsedNameSpace
-
addParsedNameSpaceAt
-
addOrMoveParsedNameSpaceAt
-
minimumNumberOfMessagesToExpect
public static int minimumNumberOfMessagesToExpect() -
addMessagesToExpect
-
removeMessagesToExpect
-
addMessagesToExpectAt
-
addOrMoveMessagesToExpectAt
-
minimumNumberOfWarningsToIgnore
public static int minimumNumberOfWarningsToIgnore() -
addWarningsToIgnore
-
removeWarningsToIgnore
-
addWarningsToIgnoreAt
-
addOrMoveWarningsToIgnoreAt
-
delete
public void delete() -
parse
Description copied from class:Parser
Parses input based on a rule.- Specified by:
parse
in interfaceUmpleParser
- Overrides:
parse
in classParser
- Parameters:
ruleName
- The rule to parse based on.input
- The textual input to parse (such as that from the Umple file).- Returns:
- The result of the parsing.
-
parse
public ParseResult parse(java.lang.String ruleName, java.lang.String input, java.lang.String fileName, Position position, int lineNumber, int offset) -
analyze
- Specified by:
analyze
in interfaceUmpleParser
-
setFailedPosition
------------------------ PRIVATE METHODS ------------------------ When an error occurs, set the failed position and mark the compile as NOT successful -
analyzeParseResult
public void analyzeParseResult() -
analyzeInvariants
public void analyzeInvariants() -
addExtendsTo
public void addExtendsTo(Token classifierToken, UmpleClassifier aClassifier, java.util.Map<UmpleClassifier,java.util.List<java.lang.String>> unlinkedExtends, java.util.Map<UmpleClassifier,java.util.List<Token>> unlinkedExtendsTokens)Takes an Umple classifier and analyzes a classifier token to add classifiers which extend it.- Parameters:
classifierToken
- The token to be analyzed to add subclasses to the specified Umple classifier.aClassifier
- The Umple classifier for which subclasses will be added.
-
getAllMethodNames
-
analyzeToplevelException
-
checkDefaultedNameConflict
public void checkDefaultedNameConflict() -
addToGeneratedMethodMap
public boolean addToGeneratedMethodMap(java.util.HashSet<java.lang.String> generatedMethods, java.lang.String className, CodeTranslator t, java.lang.String translatingLabel, Attribute aAttr) -
reAnalyze
public boolean reAnalyze()This MIXSET contains common code used by Template & Strcture. -
reAnalyze
public void reAnalyze(boolean re) -
analyzeTraceCaseToken
Analyzes trace case token and its subtokens (i.e. trace directive tokens) -
analyzeTraceCaseActivationToken
-
analyzeRequireStatement
-
createTargetFeature
public FeatureNode createTargetFeature(TokenTree treeNode, FeatureNode sourceFeature, boolean isSubFeature)this method generates a new feature and links it with a source feature based on its token in the TokenTree. It return null if either treeNode or source feature is null. -
createFeatureModelSegment
public void createFeatureModelSegment(FeatureNode sourceFeature, TokenTree tokenTree, boolean isSubFeature)This method takes a require-st as a token tree and then it generates its segment in the feature model -
getRequireStatementTokensAsList
public java.util.ArrayList<Token> getRequireStatementTokensAsList(Token requireStatementToken, java.util.List<java.lang.String> acceptedTokensList)This method filters unwanted tokens & changes the form of require-statement argument from nested tokens, as the parser does, to list of tokens. -
analyzeFeatureModel
public void analyzeFeatureModel() -
getMethodTestCase
-