Class FSM2MealyParserAlternating<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>
-
- net.automatalib.serialization.fsm.parser.FSM2MealyParserAlternating<I,O,A>
-
- Type Parameters:
I- the input typeO- the output typeA- the parsed automaton type
- All Implemented Interfaces:
ModelDeserializer<A>
public final class FSM2MealyParserAlternating<I,O,A extends MutableMealyMachine<Integer,I,?,O>> extends AbstractFSM2MealyParser<I,O,A>
Parses a Mealy machine with alternating edge semantics from an FSM source.Some factory methods accept an
Outputobject. This is used as follows. If the Mealy machine that is read from the FSM file has no defined output symbol after an input word. The last output symbol is taken fromOutput.computeOutput(Iterable). If a factory method is used that does not accept anOutputobject an exception is thrown when the FSM does not define an output symbol after an input word. Furthermore, ifOutput.computeOutput(Iterable)returnsnullan exception is throws as well.A use case where supplying an
Outputobject is necessary is when one is model checking with monitors. With alternating semantics the model checker can conclude the monitor is in a rejecting state after an input symbol (and hence every output symbol is incorrect). To construct an input-enabled Mealy machine this parser needs to know the correct output symbol. Note that this situation does not arise with synchronous semantics.
-
-
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 StringINPUT_HAS_NO_OUTPUTstatic StringPARTIAL_FSM-
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 voidcheckTransitions(StreamTokenizer streamTokenizer)Creates the actual Mealy machine transitions.static <E> ModelDeserializer<CompactMealy<E,E>>getParser(@Nullable Collection<? extends E> targetInputs, @Nullable Output<E,Word<E>> output, Function<String,E> edgeParser)Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.static <I,O>
ModelDeserializer<CompactMealy<I,O>>getParser(@Nullable Collection<? extends I> targetInputs, @Nullable Output<I,Word<O>> output, Function<String,I> inputParser, Function<String,O> outputParser)Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.static <I,O,A extends MutableMealyMachine<Integer,I,?,O>>
ModelDeserializer<A>getParser(@Nullable Collection<? extends I> targetInputs, @Nullable Output<I,Word<O>> output, Function<String,I> inputParser, Function<String,O> outputParser, AutomatonCreator<A,I> creator)Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into a givenMutableMealyMachine.static <E> ModelDeserializer<CompactMealy<E,E>>getParser(Function<String,E> edgeParser)Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.static <I,O>
ModelDeserializer<CompactMealy<I,O>>getParser(Function<String,I> inputParser, Function<String,O> outputParser)Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.protected voidparseTransition(StreamTokenizer streamTokenizer)Parse a transition.-
Methods inherited from class net.automatalib.serialization.fsm.parser.AbstractFSM2MealyParser
checkDataDefinitions, checkStateVectors, getOutputParser, getStates, getTransitions, parseDataDefinition, parseMealy, parseStateVector, readModel
-
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
-
PARTIAL_FSM
public static final String PARTIAL_FSM
- See Also:
- Constant Field Values
-
INPUT_HAS_NO_OUTPUT
public static final String INPUT_HAS_NO_OUTPUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseTransition
protected void parseTransition(StreamTokenizer streamTokenizer) throws IOException, FormatException
Parse a transition.- Specified by:
parseTransitionin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the FSM source is invalid.IOException- seeStreamTokenizer.nextToken().FormatException- when the FSM source is invalid.
-
checkTransitions
protected void checkTransitions(StreamTokenizer streamTokenizer) throws FormatException
Creates the actual Mealy machine transitions.- Specified by:
checkTransitionsin classAbstractFSMParser<I>- Parameters:
streamTokenizer- tokenizer containing the input- Throws:
net.automatalib.serialization.fsm.parser.FSMFormatException- when the Mealy machine is partial.FormatException- when the FSM source is invalid.
-
getParser
public static <E> ModelDeserializer<CompactMealy<E,E>> getParser(Function<String,E> edgeParser)
Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.- Type Parameters:
E- symbol type- Parameters:
edgeParser- the transformer of String representatives to (same-typed) input/output symbols- Returns:
- a
ModelDeserializerthat reads aMealyMachinedescription
-
getParser
public static <I,O> ModelDeserializer<CompactMealy<I,O>> getParser(Function<String,I> inputParser, Function<String,O> outputParser)
Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.- Type Parameters:
I- input symbol typeO- output symbol type- Parameters:
inputParser- the transformer of String representatives to input alphabet symbolsoutputParser- the transformer of String representatives to output alphabet symbols- Returns:
- a
ModelDeserializerthat reads aMealyMachinedescription
-
getParser
public static <E> ModelDeserializer<CompactMealy<E,E>> getParser(@Nullable Collection<? extends E> targetInputs, @Nullable Output<E,Word<E>> output, Function<String,E> edgeParser)
Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.- Type Parameters:
E- symbol type- Parameters:
targetInputs- the collection of symbols the parsing should be constrained to (may benullif unconstrained)output- the output object from which determines the transition outputsedgeParser- the transformer of String representatives to (same-typed) input/output symbols- Returns:
- a
ModelDeserializerthat reads aMealyMachinedescription
-
getParser
public static <I,O> ModelDeserializer<CompactMealy<I,O>> getParser(@Nullable Collection<? extends I> targetInputs, @Nullable Output<I,Word<O>> output, Function<String,I> inputParser, Function<String,O> outputParser)
Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into aCompactMealy.- Type Parameters:
I- input symbol typeO- output symbol type- Parameters:
targetInputs- the collection of symbols the parsing should be constrained to (may benullif unconstrained)output- the output object from which determines the transition outputsinputParser- the transformer of String representatives to input alphabet symbolsoutputParser- the transformer of String representatives to output alphabet symbols- Returns:
- a
ModelDeserializerthat reads aMealyMachinedescription
-
getParser
public static <I,O,A extends MutableMealyMachine<Integer,I,?,O>> ModelDeserializer<A> getParser(@Nullable Collection<? extends I> targetInputs, @Nullable Output<I,Word<O>> output, Function<String,I> inputParser, Function<String,O> outputParser, AutomatonCreator<A,I> creator)
Constructs aModelDeserializerthat reads aMealyMachinedescription and writes it into a givenMutableMealyMachine.- Type Parameters:
I- input symbol typeO- output symbol typeA- (concrete) automaton type- Parameters:
targetInputs- the collection of symbols the parsing should be constrained to (may benullif unconstrained)output- the output object from which determines the transition outputsinputParser- the transformer of String representatives to input alphabet symbolsoutputParser- the transformer of String representatives to output alphabet symbolscreator- the creator to construct the concrete automaton instance- Returns:
- a
ModelDeserializerthat reads aMealyMachinedescription
-
-