Class FSM2DFAParser<I,A extends MutableDFA<Integer,I>>
- java.lang.Object
-
- net.automatalib.serialization.fsm.parser.AbstractFSMParser<I>
-
- net.automatalib.serialization.fsm.parser.FSM2DFAParser<I,A>
-
- Type Parameters:
I- the input typeA- the parsed automaton type
- All Implemented Interfaces:
ModelDeserializer<A>
public final class FSM2DFAParser<I,A extends MutableDFA<Integer,I>> extends AbstractFSMParser<I> implements ModelDeserializer<A>
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 StringACCEPT_INDEX_NOT_FOUNDstatic StringACCEPT_NOT_FOUNDstatic StringACCEPT_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 voidcheckDataDefinitions(StreamTokenizer streamTokenizer)Checks the data definition by ensuring the index in the state vector containing acceptance information is defined.protected voidcheckStateVectors(StreamTokenizer streamTokenizer)Does nothing.protected voidcheckTransitions(StreamTokenizer streamTokenizer)Do nothing.static <I> ModelDeserializer<CompactDFA<I>>getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)Constructs aModelDeserializerthat reads aDFAdescription and writes it into aCompactDFA, limited to the specified input symbols.static <I,A extends MutableDFA<Integer,I>>
ModelDeserializer<A>getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue, AutomatonCreator<A,I> creator)Constructs aModelDeserializerthat reads aDFAdescription and writes it into a givenMutableDFA, limited to the specified input symbols.static <I> ModelDeserializer<CompactDFA<I>>getParser(Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)protected voidparseDataDefinition(StreamTokenizer streamTokenizer)Parse a data definition.protected voidparseStateVector(StreamTokenizer streamTokenizer)Parse a state vector.protected voidparseTransition(StreamTokenizer streamTokenizer)Parse a transition by searching the current line for the source state, target state and the input.AreadModel(InputStream is)-
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, FormatException
Parse a data definition.This line is only parsed when we still have to find
acceptIndex, andacceptValue.- Specified by:
parseDataDefinitionin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the data definition is illegal.IOException- seeStreamTokenizer.nextToken().FormatException- when the FSM source is invalid.
-
checkDataDefinitions
protected void checkDataDefinitions(StreamTokenizer streamTokenizer) throws FormatException
Checks the data definition by ensuring the index in the state vector containing acceptance information is defined.- Specified by:
checkDataDefinitionsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the acceptance information could not be found.FormatException- when the FSM source is invalid.
-
parseStateVector
protected void parseStateVector(StreamTokenizer streamTokenizer) throws IOException, FormatException
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:
parseStateVectorin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the current line is an illegal state vector.IOException- seeStreamTokenizer.nextToken().FormatException- when the FSM source is invalid.
-
checkStateVectors
protected void checkStateVectors(StreamTokenizer streamTokenizer)
Does nothing.- Specified by:
checkStateVectorsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
parseTransition
protected void parseTransition(StreamTokenizer streamTokenizer) throws IOException, FormatException
Parse a transition by searching the current line for the source state, target state and the input.- Specified by:
parseTransitionin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the current line is an illegal transition.IOException- seeStreamTokenizer.nextToken().FormatException- when the FSM source is invalid.
-
checkTransitions
protected void checkTransitions(StreamTokenizer streamTokenizer)
Do nothing.- Specified by:
checkTransitionsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
readModel
public A readModel(InputStream is) throws IOException, FormatException
- Specified by:
readModelin interfaceModelDeserializer<I>- Throws:
IOExceptionFormatException
-
getParser
public static <I> ModelDeserializer<CompactDFA<I>> getParser(Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
- Type Parameters:
I- input symbol type- Parameters:
inputParser- the transformer of String representatives to alphabet symbolsacceptingDataValue- the label identifying the accepting variable nameacceptingDataVariableName- the label identifying the accepting variable value- Returns:
- a
ModelDeserializerthat reads aDFAdescription
-
getParser
public static <I> ModelDeserializer<CompactDFA<I>> getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue)
Constructs aModelDeserializerthat reads aDFAdescription and writes it into aCompactDFA, limited to the specified input symbols.- Type Parameters:
I- input symbol type- Parameters:
targetInputs- the collection of symbols the parsing should be constrained to (may benullif unconstrained)inputParser- the transformer of String representatives to alphabet symbolsacceptingDataValue- the label identifying the accepting variable nameacceptingDataVariableName- the label identifying the accepting variable value- Returns:
- a
ModelDeserializerthat reads aDFAdescription
-
getParser
public static <I,A extends MutableDFA<Integer,I>> ModelDeserializer<A> getParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, String acceptingDataVariableName, String acceptingDataValue, AutomatonCreator<A,I> creator)
Constructs aModelDeserializerthat reads aDFAdescription and writes it into a givenMutableDFA, limited to the specified input symbols.- Type Parameters:
I- input symbol typeA- (concrete) automaton type- Parameters:
targetInputs- the collection of symbols the parsing should be constrained to (may benullif unconstrained)inputParser- the transformer of String representatives to alphabet symbolsacceptingDataValue- the label identifying the accepting variable nameacceptingDataVariableName- the label identifying the accepting variable valuecreator- the creator to construct the concrete automaton instance- Returns:
- a
ModelDeserializerthat reads aDFAdescription
-
-