WIP NFA & DFA validation

This commit is contained in:
joachimschmidt557 2019-02-06 21:46:02 +01:00
parent bb70c3df19
commit a6ff817156
4 changed files with 30 additions and 2 deletions

11
DFA.fs
View file

@ -12,6 +12,17 @@ type DFA = {
acceptingStates: State list
}
let validateDFA (dfa:DFA) =
let allAcceptingStatesAreStates =
dfa.acceptingStates
|> List.map (fun x -> List.contains x dfa.states)
|> List.filter (fun x -> not x)
|> List.length < 1
List.contains dfa.beginState dfa.states ||
allAcceptingStatesAreStates
let processChar (dfa: DFA) (state: State) (char: Char) =
dfa.delta state char

16
NFA.fs Normal file
View file

@ -0,0 +1,16 @@
module NFA
open System
type State = { name: String }
type NFA = {
sigma: Char list
states: State list
delta: State -> Char -> State list
beginState: State
acceptingStates: State list
}
let processChar (nfa: NFA) (state: State) (char: Char) =
nfa.delta state char

View file

@ -6,6 +6,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="DFA.fs" />
<Compile Include="NFA.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
</Project>

File diff suppressed because one or more lines are too long