Class AbstractFSM2MealyParser<I,O>
- java.lang.Object
-
- net.automatalib.serialization.fsm.parser.AbstractFSMParser<I>
-
- net.automatalib.serialization.fsm.parser.AbstractFSM2MealyParser<I,O>
-
- Type Parameters:
I
- the input type.O
- the output type.
- All Implemented Interfaces:
ModelDeserializer<CompactMealy<I,O>>
- Direct Known Subclasses:
FSM2MealyParserAlternating
,FSM2MealyParserIO
public abstract class AbstractFSM2MealyParser<I,O> extends AbstractFSMParser<I> implements ModelDeserializer<CompactMealy<I,O>>
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 protected
AbstractFSM2MealyParser(@Nullable Collection<? extends I> targetInputs, Function<String,I> inputParser, Function<String,O> outputParser)
Constructs a new AbstractFSM2MealyParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkDataDefinitions(StreamTokenizer streamTokenizer)
We do not need to check data definitions.protected void
checkStateVectors(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 void
parseDataDefinition(StreamTokenizer streamTokenizer)
We do not care about data definitions.protected CompactMealy<I,O>
parseMealy(Reader reader)
protected void
parseStateVector(StreamTokenizer streamTokenizer)
Parse a state vector by simply recording the line number in the current part.CompactMealy<I,O>
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
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)
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 file.inputParser
- the input parser (seeAbstractFSMParser.inputParser
).outputParser
- the output parser (similar toinputParser
).
-
-
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:
parseDataDefinition
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input
-
checkDataDefinitions
protected void checkDataDefinitions(StreamTokenizer streamTokenizer)
We do not need to check data definitions.- Specified by:
checkDataDefinitions
in 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:
parseStateVector
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input
-
checkStateVectors
protected void checkStateVectors(StreamTokenizer streamTokenizer)
We do not check the state vectors.- Specified by:
checkStateVectors
in classAbstractFSMParser<I>
- Parameters:
streamTokenizer
- tokenizer containing the input
-
parseMealy
protected CompactMealy<I,O> parseMealy(Reader reader) throws IOException
- Returns:
- the Mealy machine defined in the FSM source.
- Throws:
FSMFormatException
- (seeAbstractFSMParser.parse(Reader)
).IOException
- (seeAbstractFSMParser.parse(Reader)
).
-
readModel
public CompactMealy<I,O> 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
-
-