Package net.ssehub.easy.dslCore
Class ModelUtility.Rule
java.lang.Object
net.ssehub.easy.dslCore.ModelUtility.Rule
- Enclosing class:
ModelUtility<E extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.basics.modelManagement.IModel>
Cutoff parser rule. All rules are matched in sequence until no rule matches. This is the cutoff point.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a non-optional single-match rule with self-setting follows.Creates rule with self-setting follows.Creates a non-optional single-match rule.Creates rule. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanDoes this rule match at all.private voidClears a matchedpartslist.static ModelUtility.Rule[]instantiate(ModelUtility.Rule... rules) Shortcut default instantiation of rules.static ModelUtility.Rule[]instantiate(ModelUtility.Rule[] rules, boolean copy) Returnsrulesor an instantiated rule sequence to be used for matching iffollowsis not defined - then fill it with the firsts of the next rules until a mandatory rule comes up.private booleanisMulti()May this rule match multiple times?private booleanIs this rule optional?private booleanDoes this rule match on the given collected parts.private voidsetFollows(String follows) Sets the follow symbols.private String[]Splits symbols.toString()
-
Field Details
-
firsts
-
follows
-
optional
private boolean optional -
multi
private boolean multi -
includesFollows
private boolean includesFollows
-
-
Constructor Details
-
Rule
Creates a non-optional single-match rule.- Parameters:
firsts- the leading keywords, may be multiple alternative ones separated by "|"follows- the follow symbols, may be multiple alternative ones separated by "|", may be null to use the following rules
-
Rule
Creates a non-optional single-match rule with self-setting follows.- Parameters:
firsts- the leading keywords, may be multiple alternative ones separated by "|"
-
Rule
Creates rule with self-setting follows.- Parameters:
firsts- the leading keywords, may be multiple alternative ones separated by "|"optional- is the rule optionalmulti- is this a multiple matching rule
-
Rule
Creates rule.- Parameters:
firsts- the leading keywords, may be multiple alternative ones separated by "|"follows- the follow symbols, may be multiple alternative ones separated by "|", may be null to use the following rulesoptional- is the rule optionalmulti- is this a multiple matching rule
-
-
Method Details
-
setFollows
Sets the follow symbols.- Parameters:
follows- the follow symbols, may be multiple alternative ones separated by "|", may be null to use the following rules
-
split
Splits symbols.- Parameters:
symbols- the symbols given as single or multiple alternative, separated by "|" or null- Returns:
- the splitted symbols, null if
symbolswas null
-
matches
Does this rule match on the given collected parts.- Parameters:
parts- the parts- Returns:
truefor match,falseelse
-
canMatch
Does this rule match at all. Must be consistent withmatches(List).- Parameters:
parts- the parts- Returns:
truefor potential match,falseelse
-
isOptional
private boolean isOptional()Is this rule optional?- Returns:
truefor optional,falseelse
-
isMulti
private boolean isMulti()May this rule match multiple times?- Returns:
truefor multi-match,falseelse
-
instantiate
Returnsrulesor an instantiated rule sequence to be used for matching iffollowsis not defined - then fill it with the firsts of the next rules until a mandatory rule comes up.- Parameters:
rules- the rulescopy- whether the original array and rules shall be returned or whether a new array with potentially the same or instantiated rules shall be returned- Returns:
- this or an intantiated version
-
instantiate
Shortcut default instantiation of rules.- Parameters:
rules- the rules to be instantiated- Returns:
- the instantiated rules
-
clear
Clears a matchedpartslist.- Parameters:
parts- the parts to clear
-
toString
-