Class AbstractFSM2MealyParser<I,O,A extends MutableMealyMachine<Integer,I,?,O>>
- java.lang.Object
-
- net.automatalib.serialization.fsm.parser.AbstractFSMParser<I>
-
- net.automatalib.serialization.fsm.parser.AbstractFSM2MealyParser<I,O,A>
-
- Type Parameters:
I- the input type.O- the output type.A- the parsed automaton type
- All Implemented Interfaces:
ModelDeserializer<A>
- Direct Known Subclasses:
FSM2MealyParserAlternating,FSM2MealyParserIO
public abstract class AbstractFSM2MealyParser<I,O,A extends MutableMealyMachine<Integer,I,?,O>> extends AbstractFSMParser<I> implements ModelDeserializer<A>
An FSM parser for Mealy machines. It provides general functionality for both Mealy machines with straightforward edge semantics, and alternating edge semantics.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.automatalib.serialization.fsm.parser.AbstractFSMParser
AbstractFSMParser.Part
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFSM2MealyParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, Function<String,O> outputParser, AutomatonCreator<A,I> creator)Constructs a new AbstractFSM2MealyParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckDataDefinitions(StreamTokenizer streamTokenizer)We do not need to check data definitions.protected voidcheckStateVectors(StreamTokenizer streamTokenizer)We do not check the state vectors.protected Function<String,O>getOutputParser()Gets the Function that transforms strings from the FSM source to actual output.protected SortedSet<Integer>getStates()Gets the sorted set of states for the Mealy machine.protected Map<Pair<Integer,I>,Pair<O,Integer>>getTransitions()Gets the map of transitions for the Mealy machine.protected voidparseDataDefinition(StreamTokenizer streamTokenizer)We do not care about data definitions.protected AparseMealy(Reader reader)protected voidparseStateVector(StreamTokenizer streamTokenizer)Parse a state vector by simply recording the line number in the current part.AreadModel(InputStream is)-
Methods inherited from class net.automatalib.serialization.fsm.parser.AbstractFSMParser
checkTransitions, getInputParser, getInputs, getPartLineNumber, getStreamTokenizer, parse, parseTransition
-
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
-
-
-
-
Constructor Detail
-
AbstractFSM2MealyParser
protected AbstractFSM2MealyParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, Function<String,O> outputParser, AutomatonCreator<A,I> creator)
Constructs a new AbstractFSM2MealyParser.- Parameters:
targetInputs- A collection containing the inputs which should constitute the input alphabet of the parsed automaton. Ifnull, the inputs will be automatically gathered from the read FSM fileinputParser- the input parseroutputParser- the output parser (similar toinputParser)creator- the creator to construct the returned automaton instance
-
-
Method Detail
-
getOutputParser
protected Function<String,O> getOutputParser()
Gets the Function that transforms strings from the FSM source to actual output.- Returns:
- the Function.
-
getTransitions
protected Map<Pair<Integer,I>,Pair<O,Integer>> getTransitions()
Gets the map of transitions for the Mealy machine.- Returns:
- the Map.
-
getStates
protected SortedSet<Integer> getStates()
Gets the sorted set of states for the Mealy machine.- Returns:
- the SortedSet.
-
parseDataDefinition
protected void parseDataDefinition(StreamTokenizer streamTokenizer)
We do not care about data definitions.- Specified by:
parseDataDefinitionin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
checkDataDefinitions
protected void checkDataDefinitions(StreamTokenizer streamTokenizer)
We do not need to check data definitions.- Specified by:
checkDataDefinitionsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
parseStateVector
protected void parseStateVector(StreamTokenizer streamTokenizer)
Parse a state vector by simply recording the line number in the current part.- Specified by:
parseStateVectorin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
checkStateVectors
protected void checkStateVectors(StreamTokenizer streamTokenizer)
We do not check the state vectors.- Specified by:
checkStateVectorsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input
-
parseMealy
protected A parseMealy(Reader reader) throws IOException, FormatException
- Parameters:
reader- the reader providing the contents of the FSM file- Returns:
- the Mealy machine defined in the FSM source.
- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- (seeAbstractFSMParser.parse(Reader)).IOException- (seeAbstractFSMParser.parse(Reader)).FormatException
-
readModel
public A readModel(InputStream is) throws IOException, FormatException
- Specified by:
readModelin interfaceModelDeserializer<I>- Throws:
IOExceptionFormatException
-
-