Class Parser
java.lang.Object
cruise.umple.compiler.Parser
- Direct Known Subclasses:
ContentParser, JsonParser, UmpleInternalParser
Parses an Umple file (.ump) based on grammar rules.
As parsing is going on "tokens" will be created and linked together in a hierarchy fashion based on what was parsed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddCoupleAt(Couple aCouple, int index) booleanaddGrammarRule(String aGrammarRule) booleanaddOrMoveCoupleAt(Couple aCouple, int index) booleanaddOrMoveRuleAt(Rule aRule, int index) booleanvoidbooleanintaddRulesInFile(String filenameOrResourcePath) voiddelete()voidgenRuleHtml(String ruleName, StringBuilder answer, String cleanedUpRule, int hasMinus, int hasHash) voidgenRuleLezer(String ruleName, StringBuilder answer, String cleanedUpRule, int hasMinus, int hasHash) getCouple(int index) The Umple file (.ump) that will be parsed.getGrammarRule(int index) String[]getName()default 'program'The results of the parsing, and any errors/warning messages will be stored here.Every parser makes use of "tokens" that are built up based on what is parsed.getRule(int index) getRules()A parser can have many "rules", likewise each rule can be part of many "parsers"; hence many-to-many.getToken(int index) booleanbooleanbooleanhasRules()booleanintintindexOfCouple(Couple aCouple) intindexOfGrammarRule(String aGrammarRule) intindexOfRule(Rule aRule) static intstatic intintintintintParses input based on a rule.booleanremoveCouple(Couple aCouple) booleanremoveGrammarRule(String aGrammarRule) booleanremoveRule(Rule aRule) reset()booleansetFilename(String aFilename) booleanbooleansetParseResult(ParseResult aParseResult) booleansetRootToken(Token aRootToken) Default grammar generation to htmlUsed to generate a nice html representation for the user manualUsed to generate a lezer grammar.toGrammarParts(String rulesToOutput) Default grammar output to html formattoGrammarParts(String rulesToOutput, String grammarFormat) Converts specific Umple rules to an alternative format If rulesToOutput is empty then all rules are outputtoString()toString(StringBuffer stringSoFar, Token currentToken) Output the parse tree.
-
Constructor Details
-
Parser
-
Parser
-
-
Method Details
-
setFilename
-
setName
-
addGrammarRule
-
removeGrammarRule
-
setParseResult
-
setRootToken
-
getFilename
The Umple file (.ump) that will be parsed. -
getName
default 'program' -
getGrammarRule
-
getGrammarRules
-
numberOfGrammarRules
public int numberOfGrammarRules() -
hasGrammarRules
public boolean hasGrammarRules() -
indexOfGrammarRule
-
getParseResult
The results of the parsing, and any errors/warning messages will be stored here. -
getRootToken
Every parser makes use of "tokens" that are built up based on what is parsed. In the end it looks almost like a "tree". This is the starting token for which everything will be built off of (sub-tokens). -
getRule
-
getRules
-
numberOfRules
public int numberOfRules() -
hasRules
public boolean hasRules() -
indexOfRule
-
getCouple
-
getCouples
-
numberOfCouples
public int numberOfCouples() -
hasCouples
public boolean hasCouples() -
indexOfCouple
-
minimumNumberOfRules
public static int minimumNumberOfRules() -
addRule
-
removeRule
-
addRuleAt
-
addOrMoveRuleAt
-
minimumNumberOfCouples
public static int minimumNumberOfCouples() -
addCouple
-
removeCouple
-
addCoupleAt
-
addOrMoveCoupleAt
-
delete
public void delete() -
reset
-
getRule
-
toString
-
toGrammarNoStyle
-
toGrammar
Default grammar generation to html -
toGrammarHtml
Used to generate a nice html representation for the user manual -
toGrammarLezer
Used to generate a lezer grammar. See https://lezer.codemirror.net/docs/guide/#writing-a-grammar -
toGrammarParts
-
toGrammarParts
-
genRuleHtml
public void genRuleHtml(String ruleName, StringBuilder answer, String cleanedUpRule, int hasMinus, int hasHash) -
genRuleLezer
public void genRuleLezer(String ruleName, StringBuilder answer, String cleanedUpRule, int hasMinus, int hasHash) -
toString
Output the parse tree. The code originally here has been refactored to Token class -
addRulesInFile
-
addRule
-
parse
Parses input based on a rule.- 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.
-
getToken
-
getTokens
-
numberOfTokens
public int numberOfTokens() -
hasTokens
public boolean hasTokens() -
indexOf
-