Package net.ssehub.easy.dslCore
Class ModelUtility.CutLeadInParser
java.lang.Object
net.ssehub.easy.dslCore.ModelUtility.CutLeadInParser
- Enclosing class:
ModelUtility<E extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.basics.modelManagement.IModel>
Specific "parser" that identifies a position where to cut the headers from the content.
- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate InputStreamprivate intprivate intprivate intprivate StringBuilderprivate intprivate intprivate ModelUtility.Rule[]private ModelUtility.ParseState -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCutLeadInParser(InputStream in, ModelUtility.Rule... rules) Creates a parser instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidanalyze()Analyze a token/constant/value/keyword.private booleanenableAnalysis(char ch) Enables token/symbol analysis, i.e., are we at a meaningful separator (in CODE).private ModelUtility.ParseStatehandleAsterisk(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when an asterisk is found.private ModelUtility.ParseStatehandleBackSlash(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a backslash is found.private ModelUtility.ParseStateHandles the state transitions for an escape character.private ModelUtility.ParseStatehandleOut(char ch, ModelUtility.ParseState nextState) Handles fixing or appending toout.private ModelUtility.ParseStatehandleSlash(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a slash is found.private ModelUtility.ParseStatehandleStringStart(ModelUtility.ParseState stringState, ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a string starts.private voidMatches the rules.private Stringparse()Parse the text and cut it.private ModelUtility.ParseStatereset(int pos) Resets the parser for a new top-level unit.
-
Field Details
-
in
-
out
-
rules
-
state
-
lastStart
private int lastStart -
lastEndMatch
private int lastEndMatch -
ruleIndex
private int ruleIndex -
parts
-
nestingLevel
private int nestingLevel -
parLevel
private int parLevel -
emit
private boolean emit
-
-
Constructor Details
-
CutLeadInParser
Creates a parser instance.- Parameters:
in- the input stream to analyze/cutrules- the rules
-
-
Method Details
-
handleEscape
Handles the state transitions for an escape character.- Parameters:
state- the actual state- Returns:
- the next state, may be
state
-
handleStringStart
private ModelUtility.ParseState handleStringStart(ModelUtility.ParseState stringState, ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a string starts.- Parameters:
stringState- the state representing the stringstate- the actual statenextState- the next state to become active with the next character- Returns:
- the next state, may be
nextState
-
handleAsterisk
private ModelUtility.ParseState handleAsterisk(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when an asterisk is found.- Parameters:
state- the actual statenextState- the next state to become active with the next character- Returns:
- the next state, may be
nextState
-
handleSlash
private ModelUtility.ParseState handleSlash(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a slash is found.- Parameters:
state- the actual statenextState- the next state to become active with the next character- Returns:
- the next state, may be
nextState
-
handleBackSlash
private ModelUtility.ParseState handleBackSlash(ModelUtility.ParseState state, ModelUtility.ParseState nextState) Handles the state transitions when a backslash is found.- Parameters:
state- the actual statenextState- the next state to become active with the next character- Returns:
- the next state, may be
nextState
-
parse
Parse the text and cut it.- Returns:
- the inital or modified text
- Throws:
IOException- if reading a character fails
-
reset
Resets the parser for a new top-level unit.- Parameters:
pos- the next position oflastStartandlastEndMatch.- Returns:
- the next state
-
handleOut
Handles fixing or appending toout.- Parameters:
ch- the actual characternextState- the next state- Returns:
nextState
-
enableAnalysis
private boolean enableAnalysis(char ch) Enables token/symbol analysis, i.e., are we at a meaningful separator (in CODE).- Parameters:
ch- the actual character- Returns:
truefor enable analysis,falseelse
-
analyze
private void analyze()Analyze a token/constant/value/keyword. -
matchRules
private void matchRules()Matches the rules.
-