Class FSM2DFAParser<I>
- java.lang.Object
-
- net.automatalib.serialization.fsm.parser.AbstractFSMParser<I>
-
- net.automatalib.serialization.fsm.parser.FSM2DFAParser<I>
-
- Type Parameters:
I
- the input type
- All Implemented Interfaces:
ModelDeserializer<CompactDFA<I>>
public final class FSM2DFAParser<I> extends AbstractFSMParser<I> implements ModelDeserializer<CompactDFA<I>>
Parses an FSM to a DFA.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.automatalib.serialization.fsm.parser.AbstractFSMParser
AbstractFSMParser.Part
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCEPT_INDEX_NOT_FOUND
static String
ACCEPT_NOT_FOUND
static String
ACCEPT_VALUE_NOT_FOUND
-
Fields inherited from class net.automatalib.serialization.fsm.parser.AbstractFSMParser
EXPECT_CHAR, EXPECT_IDENTIFIER, EXPECT_NUMBER, EXPECT_STRING, NO_SUCH_STATE, NON_DETERMINISM_DETECTED, targetInputs
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkDataDefinitions(StreamTokenizer streamTokenizer)
Checks the data definition by ensuring the index in the state vector containing acceptance information is defined.protected void
checkStateVectors(StreamTokenizer streamTokenizer)
Does nothing.protected void
checkTransitions(StreamTokenizer streamTokenizer)
Do nothing.static <I> FSM2DFAParser<I>
getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
static <I> FSM2DFAParser<I>
getParser(Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
protected void
parseDataDefinition(StreamTokenizer streamTokenizer)
Parse a data definition.protected void
parseStateVector(StreamTokenizer streamTokenizer)
Parse a state vector.protected void
parseTransition(StreamTokenizer streamTokenizer)
Parse a transition by searching the current line for the source state, target state and the input.CompactDFA<I>
readModel(InputStream is)
Reads the contents from the given input stream and de-serializes it into a model instance.-
Methods inherited from class net.automatalib.serialization.fsm.parser.AbstractFSMParser
getInputParser, getInputs, getPartLineNumber, getStreamTokenizer, parse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.automatalib.serialization.ModelDeserializer
readModel, readModel, readModel
-
-
-
-
Field Detail
-
ACCEPT_NOT_FOUND
public static final String ACCEPT_NOT_FOUND
- See Also:
- Constant Field Values
-
ACCEPT_VALUE_NOT_FOUND
public static final String ACCEPT_VALUE_NOT_FOUND
- See Also:
- Constant Field Values
-
ACCEPT_INDEX_NOT_FOUND
public static final String ACCEPT_INDEX_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseDataDefinition
protected void parseDataDefinition(StreamTokenizer streamTokenizer) throws IOException
Parse a data definition.This line is only parsed when we still have to find
acceptIndex
, andacceptValue
.- Specified by:
parseDataDefinition
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input- Throws:
FSMFormatException
- when the data definition is illegal.IOException
- seeStreamTokenizer.nextToken()
.
-
checkDataDefinitions
protected void checkDataDefinitions(StreamTokenizer streamTokenizer)
Checks the data definition by ensuring the index in the state vector containing acceptance information is defined.- Specified by:
checkDataDefinitions
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input- Throws:
FSMFormatException
- when the acceptance information could not be found.
-
parseStateVector
protected void parseStateVector(StreamTokenizer streamTokenizer) throws IOException
Parse a state vector.This method will only search for whether the state is accepting or not. The state index will be equal to the current
AbstractFSMParser.getPartLineNumber()
.- Specified by:
parseStateVector
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input- Throws:
FSMFormatException
- when the current line is an illegal state vector.IOException
- seeStreamTokenizer.nextToken()
.
-
checkStateVectors
protected void checkStateVectors(StreamTokenizer streamTokenizer)
Does nothing.- Specified by:
checkStateVectors
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input
-
parseTransition
protected void parseTransition(StreamTokenizer streamTokenizer) throws IOException
Parse a transition by searching the current line for the source state, target state and the input.- Specified by:
parseTransition
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input- Throws:
FSMFormatException
- when the current line is an illegal transition.IOException
- seeStreamTokenizer.nextToken()
.
-
checkTransitions
protected void checkTransitions(StreamTokenizer streamTokenizer)
Do nothing.- Specified by:
checkTransitions
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input
-
readModel
public CompactDFA<I> readModel(InputStream is) throws IOException
Description copied from interface:ModelDeserializer
Reads the contents from the given input stream and de-serializes it into a model instance.Note: the input stream will not be closed.
- Specified by:
readModel
in interfaceModelDeserializer<I>
- Parameters:
is
- the input stream to read data from- Returns:
- the de-serialized model
- Throws:
IOException
- if an error occurred while reading from the stream
-
getParser
public static <I> FSM2DFAParser<I> getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
-
getParser
public static <I> FSM2DFAParser<I> getParser(Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
-
-