fauton
Version:
A library to test any finite automaton with arbitrary alphabets
89 lines (88 loc) • 2.63 kB
TypeScript
export interface InputFiniteAutomaton {
append?: string;
alphabets: (string | number)[];
label: string;
description?: string;
start_state: string | number;
final_states: (string | number)[];
states: (string | number)[];
transitions: Record<string | number, (Array<string | number> | (string | number) | null)[] | 'loop'>;
epsilon_transitions?: Record<string, (string | number)[]>;
}
export interface TransformedFiniteAutomaton {
append?: string;
alphabets: string[];
label: string;
description?: string;
start_state: string;
final_states: string[];
states: string[];
transitions: Record<string, Record<string, string[]>>;
epsilon_transitions: null | Record<string, string[]>;
}
export declare type IAutomatonTestLogicFn = (inputString: string, automatonTestResult: boolean) => boolean;
export interface IFiniteAutomaton {
testLogic: IAutomatonTestLogicFn;
automaton: TransformedFiniteAutomaton;
automatonId: string;
}
export interface FiniteAutomatonTestInfo {
falsePositives: number;
falseNegatives: number;
truePositives: number;
trueNegatives: number;
}
export declare type TFiniteAutomatonType = 'deterministic' | 'non-deterministic' | 'epsilon';
export interface GraphNode {
name: string;
state: string;
symbol: null | string;
children: GraphNode[];
depth: number;
string: string;
}
export interface IOutputFiles {
case: boolean;
incorrect: boolean;
correct: boolean;
input: boolean;
aggregate: boolean;
accepted: boolean;
rejected: boolean;
}
export declare type InputStringOption = {
type: 'generate';
random?: {
total: number;
minLength: number;
maxLength: number;
};
combo?: undefined | null;
outputFiles?: Partial<IOutputFiles>;
} | {
type: 'generate';
combo: {
maxLength: number;
startLength?: number;
};
random?: undefined | null;
outputFiles?: Partial<IOutputFiles>;
} | {
type: 'file';
filePath: string;
outputFiles?: Partial<IOutputFiles>;
} | {
type: 'custom';
inputs: string[];
outputFiles?: Partial<IOutputFiles>;
};
export declare type GeneratedAutomatonOptions = Partial<Pick<Pick<IFiniteAutomaton, 'automaton'>['automaton'], 'label' | 'description'> & {
separator: string;
}>;
export declare type TMergeOperation = 'or' | 'and' | 'not';
export interface IRegularExpression {
alphabets: string[];
regex: RegExp;
label: string;
description?: string;
}