DFA foundation finished

This commit is contained in:
joachimschmidt557 2019-02-06 21:28:40 +01:00
parent 2407dce1a6
commit bb70c3df19
5 changed files with 287 additions and 13 deletions

25
DFA.fs Normal file
View file

@ -0,0 +1,25 @@
module DFA
open System
type State = { name: String }
type DFA = {
sigma: Char list
states: State list
delta: State -> Char -> State
beginState: State
acceptingStates: State list
}
let processChar (dfa: DFA) (state: State) (char: Char) =
dfa.delta state char
let rec processCharArray (dfa: DFA) (state: State) (charArr: Char list) =
match charArr with
| [] -> state
| _ -> processCharArray dfa (processChar dfa state charArr.Head) charArr.Tail
let acceptsWord (dfa: DFA) (word: String) =
dfa.acceptingStates
|> List.contains (processCharArray dfa dfa.beginState (Seq.toList word))

View file

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>fsharp_finite_automata</RootNamespace>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RootNamespace>fsharp_finite_automata</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="DFA.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
</Project>

2
obj/fsac.cache Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Target Name="_Inspect_FscArgs"
Condition=" '$(IsCrossTargetingBuild)' != 'true' "
DependsOnTargets="ResolveReferences;CoreCompile">
<Message Text="%(FscCommandLineArgs.Identity)" Importance="High" />
<WriteLinesToFile
Condition=" '$(_Inspect_FscArgs_OutFile)' != '' "
File="$(_Inspect_FscArgs_OutFile)"
Lines="@(FscCommandLineArgs -> '%(Identity)')"
Overwrite="true"
Encoding="UTF-8"/>
<!-- WriteLinesToFile doesnt create the file if @(FscCommandLineArgs) is empty -->
<Touch
Condition=" '$(_Inspect_FscArgs_OutFile)' != '' "
Files="$(_Inspect_FscArgs_OutFile)"
AlwaysCreate="True" />
</Target>
<Target Name="_Inspect_GetResolvedProjectReferences"
Condition=" '$(IsCrossTargetingBuild)' != 'true' "
DependsOnTargets="ResolveProjectReferencesDesignTime">
<Message Text="%(_MSBuildProjectReferenceExistent.FullPath)" Importance="High" />
<Message Text="%(_MSBuildProjectReferenceExistent.SetTargetFramework)" Importance="High" />
<WriteLinesToFile
Condition=" '$(_Inspect_GetResolvedProjectReferences_OutFile)' != '' "
File="$(_Inspect_GetResolvedProjectReferences_OutFile)"
Lines="@(_MSBuildProjectReferenceExistent -> 'ProjectReferenceFullPath=%(FullPath);%(SetTargetFramework)')"
Overwrite="true"
Encoding="UTF-8"/>
<!-- WriteLinesToFile doesnt create the file if @(_MSBuildProjectReferenceExistent) is empty -->
<Touch
Condition=" '$(_Inspect_GetResolvedProjectReferences_OutFile)' != '' "
Files="$(_Inspect_GetResolvedProjectReferences_OutFile)"
AlwaysCreate="True" />
</Target>
<Target Name="_Inspect_GetProperties_CrossGen"
Condition=" '$(IsCrossTargetingBuild)' == 'true' "
>
<ItemGroup>
<_Inspect_GetProperties_OutLines Include="P0">
<PropertyName>TargetPath</PropertyName>
<PropertyValue>$(TargetPath)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P1">
<PropertyName>IsCrossTargetingBuild</PropertyName>
<PropertyValue>$(IsCrossTargetingBuild)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P2">
<PropertyName>TargetFrameworks</PropertyName>
<PropertyValue>$(TargetFrameworks)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P3">
<PropertyName>OutputType</PropertyName>
<PropertyValue>$(OutputType)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P4">
<PropertyName>IsTestProject</PropertyName>
<PropertyValue>$(IsTestProject)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P5">
<PropertyName>Configuration</PropertyName>
<PropertyValue>$(Configuration)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P6">
<PropertyName>IsPackable</PropertyName>
<PropertyValue>$(IsPackable)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P7">
<PropertyName>TargetFramework</PropertyName>
<PropertyValue>$(TargetFramework)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P8">
<PropertyName>TargetFrameworkIdentifier</PropertyName>
<PropertyValue>$(TargetFrameworkIdentifier)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P9">
<PropertyName>TargetFrameworkVersion</PropertyName>
<PropertyValue>$(TargetFrameworkVersion)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P10">
<PropertyName>MSBuildAllProjects</PropertyName>
<PropertyValue>$(MSBuildAllProjects)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P11">
<PropertyName>ProjectAssetsFile</PropertyName>
<PropertyValue>$(ProjectAssetsFile)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P12">
<PropertyName>RestoreSuccess</PropertyName>
<PropertyValue>$(RestoreSuccess)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P13">
<PropertyName>Configurations</PropertyName>
<PropertyValue>$(Configurations)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P14">
<PropertyName>TargetFrameworks</PropertyName>
<PropertyValue>$(TargetFrameworks)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P15">
<PropertyName>RunArguments</PropertyName>
<PropertyValue>$(RunArguments)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P16">
<PropertyName>RunCommand</PropertyName>
<PropertyValue>$(RunCommand)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P17">
<PropertyName>IsPublishable</PropertyName>
<PropertyValue>$(IsPublishable)</PropertyValue>
</_Inspect_GetProperties_OutLines></ItemGroup>
<Message Text="%(_Inspect_GetProperties_OutLines.PropertyName)=%(_Inspect_GetProperties_OutLines.PropertyValue)" Importance="High" />
<WriteLinesToFile
Condition=" '$(_Inspect_GetProperties_OutFile)' != '' "
File="$(_Inspect_GetProperties_OutFile)"
Lines="@(_Inspect_GetProperties_OutLines -> '%(PropertyName)=%(PropertyValue)')"
Overwrite="true"
Encoding="UTF-8"/>
</Target>
<Target Name="_Inspect_GetProperties_NotCrossGen"
Condition=" '$(IsCrossTargetingBuild)' != 'true' "
DependsOnTargets="ResolveReferences" >
<ItemGroup>
<_Inspect_GetProperties_OutLines Include="P0">
<PropertyName>TargetPath</PropertyName>
<PropertyValue>$(TargetPath)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P1">
<PropertyName>IsCrossTargetingBuild</PropertyName>
<PropertyValue>$(IsCrossTargetingBuild)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P2">
<PropertyName>TargetFrameworks</PropertyName>
<PropertyValue>$(TargetFrameworks)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P3">
<PropertyName>OutputType</PropertyName>
<PropertyValue>$(OutputType)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P4">
<PropertyName>IsTestProject</PropertyName>
<PropertyValue>$(IsTestProject)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P5">
<PropertyName>Configuration</PropertyName>
<PropertyValue>$(Configuration)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P6">
<PropertyName>IsPackable</PropertyName>
<PropertyValue>$(IsPackable)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P7">
<PropertyName>TargetFramework</PropertyName>
<PropertyValue>$(TargetFramework)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P8">
<PropertyName>TargetFrameworkIdentifier</PropertyName>
<PropertyValue>$(TargetFrameworkIdentifier)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P9">
<PropertyName>TargetFrameworkVersion</PropertyName>
<PropertyValue>$(TargetFrameworkVersion)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P10">
<PropertyName>MSBuildAllProjects</PropertyName>
<PropertyValue>$(MSBuildAllProjects)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P11">
<PropertyName>ProjectAssetsFile</PropertyName>
<PropertyValue>$(ProjectAssetsFile)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P12">
<PropertyName>RestoreSuccess</PropertyName>
<PropertyValue>$(RestoreSuccess)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P13">
<PropertyName>Configurations</PropertyName>
<PropertyValue>$(Configurations)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P14">
<PropertyName>TargetFrameworks</PropertyName>
<PropertyValue>$(TargetFrameworks)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P15">
<PropertyName>RunArguments</PropertyName>
<PropertyValue>$(RunArguments)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P16">
<PropertyName>RunCommand</PropertyName>
<PropertyValue>$(RunCommand)</PropertyValue>
</_Inspect_GetProperties_OutLines>
<_Inspect_GetProperties_OutLines Include="P17">
<PropertyName>IsPublishable</PropertyName>
<PropertyValue>$(IsPublishable)</PropertyValue>
</_Inspect_GetProperties_OutLines></ItemGroup>
<Message Text="%(_Inspect_GetProperties_OutLines.PropertyName)=%(_Inspect_GetProperties_OutLines.PropertyValue)" Importance="High" />
<WriteLinesToFile
Condition=" '$(_Inspect_GetProperties_OutFile)' != '' "
File="$(_Inspect_GetProperties_OutFile)"
Lines="@(_Inspect_GetProperties_OutLines -> '%(PropertyName)=%(PropertyValue)')"
Overwrite="true"
Encoding="UTF-8"/>
</Target>
<Target Name="_Inspect_GetProperties"
DependsOnTargets="_Inspect_GetProperties_CrossGen;_Inspect_GetProperties_NotCrossGen" />
</Project>