├── .gitattributes ├── .gitignore ├── JWithATwist.Console ├── App.config ├── AssemblyInfo.fs ├── JWithATwist.Console.fsproj ├── Program.fs └── packages.config ├── JWithATwist.InstallShield ├── JWithATwist.InstallShield.isl └── JWithATwist.InstallShield.isproj ├── JWithATwist.MockInterpreter ├── App.config ├── AssemblyInfo.fs ├── JWithATwist.MockInterpreter.fsproj ├── Program.fs ├── README.md └── packages.config ├── JWithATwist.PerformanceTest ├── App.config ├── AssemblyInfo.fs ├── JWithATwist.PerformanceTest.fsproj ├── PerformanceTest.fs ├── Program.fs ├── TraceEvent.ReadMe.txt ├── TraceEvent.ReleaseNotes.txt ├── _TraceEventProgrammersGuide.docx └── packages.config ├── JWithATwist.Test ├── App.config ├── AssemblyInfo.fs ├── Base.fs ├── Define.fs ├── JWithATwist.Test.fsproj ├── Parser.fs ├── ParserMock.fs ├── Program.fs ├── System.fs └── packages.config ├── JWithATwist.WiX ├── Components.wxs ├── Directories.wxs ├── JWithATwist.WiX.wixproj └── Product.wxs ├── JWithATwist.sln ├── JWithATwist ├── AssemblyInfo.fs ├── Base.fs ├── Define.fs ├── GPLv3.rtf ├── JWithATwist.fsproj ├── JWithATwist.ico ├── JWithATwist.xcf ├── Parser.fs ├── ParserDefinitions.fs ├── ParserInterface.fs ├── ParserMock.fs ├── ParserMockDefinitions.fs ├── ParserMockInterface.fs ├── Todo.fs ├── WixUIBannerBmp.bmp ├── WixUIBannerBmp.xcf ├── WixUIDialogBmp.bmp ├── WixUIDialogBmp.xcf ├── copyright.txt └── packages.config └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /JWithATwist.Console/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /JWithATwist.Console/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | namespace JWithATwist.Console.AssemblyInfo 2 | 3 | open System.Reflection 4 | open System.Runtime.CompilerServices 5 | open System.Runtime.InteropServices 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [] 11 | [] 12 | [] 13 | [] 14 | [] 15 | [] 16 | [] 17 | [] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [] 37 | [] 38 | [] 39 | 40 | do 41 | () -------------------------------------------------------------------------------- /JWithATwist.Console/JWithATwist.Console.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 2.0 8 | 3c623837-231a-47d1-970b-acbfaec4f56a 9 | Exe 10 | JWithATwist.Console 11 | JWithATwist.Console 12 | v4.6 13 | true 14 | 4.4.0.0 15 | JWithATwist.Console 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | 3 26 | AnyCPU 27 | bin\Debug\JWithATwist.Console.XML 28 | true 29 | 30 | 31 | pdbonly 32 | true 33 | true 34 | bin\Release\ 35 | TRACE 36 | 3 37 | AnyCPU 38 | bin\Release\JWithATwist.Console.XML 39 | true 40 | 41 | 42 | 11 43 | 44 | 45 | true 46 | full 47 | false 48 | false 49 | bin\Debug\ 50 | DEBUG;TRACE 51 | 3 52 | bin\Debug\JWithATwist.Console.XML 53 | true 54 | x64 55 | 56 | 57 | pdbonly 58 | true 59 | true 60 | bin\Release\ 61 | TRACE 62 | 3 63 | bin\Release\JWithATwist.Console.XML 64 | true 65 | x64 66 | 67 | 68 | 69 | 70 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets 71 | 72 | 73 | 74 | 75 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsec.dll 89 | True 90 | 91 | 92 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll 93 | True 94 | 95 | 96 | 97 | True 98 | 99 | 100 | 101 | 102 | 103 | JWithATwist 104 | {0f2dada6-c9e9-4b12-8a14-e732166b3458} 105 | True 106 | 107 | 108 | 115 | -------------------------------------------------------------------------------- /JWithATwist.Console/Program.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | 19 | open JWithATwist 20 | open JWithATwist.Parser 21 | open System 22 | open System.Diagnostics 23 | open FParsec 24 | open System.Reflection 25 | 26 | 27 | 28 | 29 | let test p str = 30 | match run p str with 31 | | Success(result, _, rest) -> printfn "Success: %A %A" result rest 32 | | Failure(errorMsg, n, m) -> printfn "Failure: %s %A %A" errorMsg n m 33 | 34 | 35 | [] 36 | let main argv = 37 | 38 | let mutable quit = false 39 | while not quit do 40 | printfn @" 41 | JWithATwist Copyright (C) 2016 Erling Hellenäs 42 | This program comes with ABSOLUTELY NO WARRANTY; for details type `w'. 43 | This is free software, and you are welcome to redistribute it 44 | under certain conditions; type `c' for details. 45 | Type h for help, type return to continue" 46 | let inputStream = Console.ReadLine() 47 | quit <- inputStream.Length=0 48 | match quit with 49 | |false -> 50 | let a = 51 | match inputStream with 52 | |"c" -> 53 | printfn @" 54 | This program is free software: you can redistribute it and/or modify 55 | it under the terms of the GNU General Public License as published by 56 | the Free Software Foundation, either version 3 of the License, or 57 | (at your option) any later version." 58 | () 59 | |"w" -> 60 | printfn @" 61 | This program is distributed in the hope that it will be useful, 62 | but WITHOUT ANY WARRANTY; without even the implied warranty of 63 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 64 | GNU General Public License for more details. " 65 | () 66 | |"h" -> 67 | printfn @" 68 | JWithATwist 69 | JWithATwist is a programming language under development. It has many similarities with J. 70 | You can look at www.jsoftware.com to find out what J is. 71 | You can find the documentation at https://github.com/andrimne/JWithATwist.DocBook/blob/master/target/en/JWithATwistReferenceManual.pdf 72 | " 73 | () 74 | |_ -> 75 | () 76 | () 77 | |true -> 78 | () 79 | 80 | printfn @"JWithATwist. Welcome to write an expression. 81 | Remember - You always need a blank between two syntax elements." 82 | Parser() 83 | 84 | 85 | 86 | //test (pchar '{') "{" 87 | 88 | //Console.ReadLine() |> ignore 89 | 0 // return an integer exit code 90 | -------------------------------------------------------------------------------- /JWithATwist.Console/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /JWithATwist.InstallShield/JWithATwist.InstallShield.isproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Express 6 | 7 | Debug 8 | $(Configuration) 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | JWithATwist 35 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458} 36 | 37 | 38 | JWithATwist.Console 39 | {3C623837-231A-47D1-970B-ACBFAEC4F56A} 40 | 41 | 42 | JWithATwist.MockInterpreter 43 | {5372D991-F152-4941-AA01-3A04FBD87D76} 44 | 45 | 46 | JWithATwist.Test 47 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35} 48 | 49 | 50 | -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | namespace JWithATwist.MockInterpreter.AssemblyInfo 2 | 3 | open System.Reflection 4 | open System.Runtime.CompilerServices 5 | open System.Runtime.InteropServices 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [] 11 | [] 12 | [] 13 | [] 14 | [] 15 | [] 16 | [] 17 | [] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [] 37 | [] 38 | [] 39 | 40 | do 41 | () -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/JWithATwist.MockInterpreter.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 2.0 8 | 5372d991-f152-4941-aa01-3a04fbd87d76 9 | Exe 10 | JWithATwist.MockInterpreter 11 | JWithATwist.MockInterpreter 12 | v4.6 13 | true 14 | 4.4.0.0 15 | JWithATwist.MockInterpreter 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | 3 26 | AnyCPU 27 | bin\Debug\JWithATwist.MockInterpreter.XML 28 | true 29 | 30 | 31 | pdbonly 32 | true 33 | true 34 | bin\Release\ 35 | TRACE 36 | 3 37 | AnyCPU 38 | bin\Release\JWithATwist.MockInterpreter.XML 39 | true 40 | 41 | 42 | 11 43 | 44 | 45 | true 46 | full 47 | false 48 | false 49 | bin\Debug\ 50 | DEBUG;TRACE 51 | 3 52 | bin\Debug\JWithATwist.MockInterpreter.XML 53 | true 54 | x64 55 | 56 | 57 | pdbonly 58 | true 59 | true 60 | bin\Release\ 61 | TRACE 62 | 3 63 | bin\Release\JWithATwist.MockInterpreter.XML 64 | true 65 | x64 66 | 67 | 68 | 69 | 70 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets 71 | 72 | 73 | 74 | 75 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsec.dll 89 | True 90 | 91 | 92 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll 93 | True 94 | 95 | 96 | 97 | True 98 | 99 | 100 | 101 | 102 | 103 | JWithATwist 104 | {0f2dada6-c9e9-4b12-8a14-e732166b3458} 105 | True 106 | 107 | 108 | 115 | -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/Program.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | 19 | open JWithATwist 20 | open JWithATwist.ParserMock 21 | open System 22 | open System.Diagnostics 23 | open FParsec 24 | 25 | let test p str = 26 | match run p str with 27 | | Success(result, _, rest) -> printfn "Success: %A %A" result rest 28 | | Failure(errorMsg, n, m) -> printfn "Failure: %s %A %A" errorMsg n m 29 | 30 | 31 | [] 32 | let main argv = 33 | 34 | let mutable quit = false 35 | while not quit do 36 | printfn @" 37 | JWithATwist Copyright (C) 2016 Erling Hellenäs 38 | This program comes with ABSOLUTELY NO WARRANTY; for details type `w'. 39 | This is free software, and you are welcome to redistribute it 40 | under certain conditions; type `c' for details. 41 | Type h for help, type return to continue" 42 | let inputStream = Console.ReadLine() 43 | quit <- inputStream.Length=0 44 | match quit with 45 | |false -> 46 | let a = 47 | match inputStream with 48 | |"c" -> 49 | printfn @" 50 | This program is free software: you can redistribute it and/or modify 51 | it under the terms of the GNU General Public License as published by 52 | the Free Software Foundation, either version 3 of the License, or 53 | (at your option) any later version." 54 | () 55 | |"w" -> 56 | printfn @" 57 | This program is distributed in the hope that it will be useful, 58 | but WITHOUT ANY WARRANTY; without even the implied warranty of 59 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 | GNU General Public License for more details. " 61 | () 62 | |"h" -> 63 | printfn @" 64 | JWithATwist Mock Parser 65 | JWithATwist is a programming language under development. It has many similarities with J. 66 | You can look at www.jsoftware.com to find out what J is. 67 | This parser is supposed to become the parser for this new language, but the language ele- 68 | ments are only mock objects. You can only work with integers. There are only a few opera- 69 | tions you can use. 70 | I use the J syntax to describe this language. 71 | - NOUN - an n-dimensional array of values where the values are simple data types 72 | like character or integer, but they can also can be other n-dimensional arrays. 73 | - VERB - a function with one or two noun arguments returning a noun. 74 | - ADVERB - an operator with a verb argument and one or two noun arguments, usually 75 | returning a verb. 76 | - CONJUNCTION - an operator with two verb arguments and one or two noun arguments, 77 | normally returning a verb. 78 | - A MONADIC VERB has one argument, a DYADIC VERB has two. Adverbs and conjunctions 79 | are also called monadic or dyadic after their number of noun argments. 80 | The operations in this mock parser: 81 | - Dyadic verb Addition, + 82 | - Dyadic verb Subtraction, - 83 | - Monadic verb Negation, |- 84 | - Monadic adverb, / . This operator is defined u / y <-> y u y. It applies the in- 85 | fix u verb between two copies of the verb argument. + / 1 <-> 1 + 1 <-> 2. 86 | - Dyadic adverb, /- . This operator is defined x u/- y <-> x u y. It applies the 87 | infix u verb between the left and right argument. 1 + /- 1 <-> 1 + 1 <-> 2 88 | - Monadic conjunction, |. . This operator is defined u |. v y <-> u y v y. It app- 89 | lies the infix dyadic verb v between copies of the right argument and the monadic 90 | verb u to the result. |- |. + 1 <-> |- 1 + 1 <-> -2 . 91 | - Dyadic conjunction, . . This operator is defined x u . v y <-> u x v y . It app- 92 | lies the infix dyadic verb v between the left and right arguments and the monadic 93 | verb u to the result. 2 |- . + 5 <-> |- 2 + 5 <-> -7 . 94 | There is no order of precedence between the operations. Execution is from right to left mo- 95 | dified by parenthesis. |- |- |- 1 <-> -1 96 | The language elements are associated to it's arguments like this. 97 | -A monadic verb has one noun argument to the right. Like this: |- 1 . 98 | -A dyadic verb has one noun argument to the left and one to the right. Like this: 99 | 1 + 1 . 100 | -A monadic adverb has a verb argument to the left and a noun argument to the right. 101 | Like this: + / 1 . 102 | -A dyadic adverb has a verb argument to the left, one noun argument to the left 103 | and one to the right. Like this: 1 + /- 1 . 104 | -A monadic conjunction has a verb argument to the left and one to the right, and 105 | one noun argument to the right. Like this: |- |. + 1 . 106 | -A dyadic conjunction has a verb argument to the left and one to the right, and 107 | one noun argument to the left and one to the right. Like this: 1 |- . + 1 108 | -An adverb to the left of a conjunction is together with it's verb the left argu- 109 | ment of the conjunction. Like this in the monadic case: + / |. + 1 . Like this in 110 | the dyadic case: 1 + / . + 1 . 111 | An adverb together with its left verb forms a new verb. A conjunction together with its 112 | right verb and it's left verb or adverb forms a new verb. 113 | Monadic verbs, adverbs and conjunctions create verb trains like this: 114 | |- + / |- |- |. + |- + / |. + |- 1 115 | I use extra blanks to show the separation between verbs. 116 | You always need at least one blank between two syntax elements. 117 | A program is called a NOUN DEFINITION. It is written between curly brackets, like this 118 | { some code } It can contain VERB DEFINITIONS, written between curly brackets where the 119 | first bracket is immediately followed by ! . Like this {! some code } . 120 | A verb definition can contain the NOUN FUNCTIONS - LEFT NOUN and RIGHT NOUN - denoted by 121 | [ and ] . The Left Noun is a placeholder for the noun immediately preceding the verb defi- 122 | nition. The Right Noun is a placeholder for the noun immediately following the verb defini- 123 | tion. 124 | A verb definition containing only Right Nouns forms a monadic verb. A verb definition con- 125 | taining a Left Noun forms a dyadic verb, even if there is no Right Noun. In that case you 126 | are forced to have a noun to the right of the verb definition and this noun is silently ig- 127 | nored. 128 | This is a verb definition of a monadic increment verb {! 1 + ] } . Example of use: 129 | {! 1 + ] } 2 . 130 | This is a verb definition of a dyadic addition verb {! [ + ] } . Example of use : 131 | 1 {! [ + ] } 2 . 132 | Left and Right nouns within brackets are placeholders for the noun arguments to the first 133 | verb definition enclosing the brackets. In this example the Left noun is one and the Right 134 | noun is two: 1 {! ( [ + ] ) + 1 } 2 135 | There is no way to define adverbs and conjunctions in this mock parser. 136 | The verb definitions are very similar to the DIRECT DEFINITION FORM Ken Iverson used at his 137 | lectures, see http://tinyurl.com/npx2umk . 138 | In the present implementation the noun definitions does not add any functional value. 139 | I will use this parser as an argument in a discussion about the J language. I have questio- 140 | ned the syntax of tacit J many times. The answer is always - How should it be instead. This 141 | is how I think it should be. Nearly exactly like normal scripted J. I want to add that if 142 | you add a Left verb and a Right verb to this parser, you could add a verb definition from 143 | verbs which would possibly let you use higher order functions on these verbs. 144 | You could of course also use Left verb and Right verb to define adverbs and conjunctions in 145 | some kind of direct definition form. 146 | The tacit J parser is in many ways similar to this parser. It does not have definitions of 147 | adverbs and conjunctions either. 148 | Some notes on implementation: 149 | - The parser creates a composite compiled .NET function which is executed when the 150 | parsing process is finished. It is more like JIT-compiled than interpreted code. 151 | - The parser is written in F# and with #FParsec. 152 | - In the F# environment you can write code nearly as efficient as in C++. 153 | - The full .NET environment and the rest of the Windows environment, called Windows 154 | RT, is easily available from F#. Integration with the Windows environment is easy. 155 | - In JWithATwist an adverb or conjunction always returns a noun. 156 | 157 | A sample session : 158 | { 1 } 159 | 1 160 | { 1 + 1 } 161 | 2 162 | { ( 1 - 1 ) + 1 } 163 | 1 164 | { ( 1 - 1 ) {! [ + ] } 1 } 165 | 1 166 | { { 1 - 1 } {! [ + ] } 1 } 167 | 1 168 | { + / 1 } 169 | 2 170 | { {! [ + ] } / 1 } 171 | 2 172 | { + / |. + 1 } 173 | 4 174 | { 2 + / . + 1 } 175 | 6 176 | { 2 + / . + |- |- 1 } 177 | 6 178 | { 2 + / . {! [ + ] } |- |- 1 } 179 | 6 180 | { 2 + / . + |- {! |- ] } 1 } 181 | 6 182 | { 2 + /- 3 } 183 | 5 184 | { 5 {! ( [ + ] ) + [ + ] } 7 } 185 | 24 186 | { |- + / |- |. + + / |. + |- 5 } 187 | -80" 188 | () 189 | |_ -> 190 | () 191 | () 192 | |true -> 193 | () 194 | 195 | printfn @"JWithATwist Mock Parser. Welcome to write an expression. 196 | Remember - You always need a blank between two syntax elements." 197 | Parser() 198 | 199 | 200 | 201 | //test (pchar '{') "{" 202 | 203 | //Console.ReadLine() |> ignore 204 | 0 // return an integer exit code 205 | 206 | -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

JWithATwist Mock Interpreter

8 | 9 |

JWithATwist is a programming language under development. It has many similarities with J. You can look at www.jsoftware.com to find out what J is. This interpreter is supposed to become the interpreter for this new language, but the language elements are only mock objects. You can only work with integers. There are only a few operations you can use.

10 | 11 |

I use the J syntax to describe this language.

12 | 13 |
    14 |
  • NOUN - an n-dimensional array of values where the values are simple data types like character or integer, but they can also be other n-dimensional arrays.
  • 15 |
  • VERB - a function with one or two noun arguments returning a noun.
  • 16 |
  • ADVERB - an operator with a verb argument and one or two noun arguments, usually returning a verb.
  • 17 |
  • CONJUNCTION - an operator with two verb arguments and one or two noun arguments, normally returning a verb.
  • 18 |
  • A MONADIC VERB has one argument, a DYADIC VERB has two. Adverbs and conjunctions are also called monadic or dyadic after their number of noun argments.
  • 19 |
20 | 21 |

The operations in this mock interpreter:

22 | 23 |
    24 |
  • Dyadic verb Addition, +
  • 25 |
  • Dyadic verb Subtraction, -
  • 26 |
  • Monadic verb Negation, |-
  • 27 |
  • Monadic adverb, / . This operator is defined u / y <-> y u y. It applies the in-fix u verb between two copies of the argument. + / 1 <-> 1 + 1 <-> 2.
  • 28 |
  • Dyadic adverb, /- . This operator is defined x u/- y <-> x u y. It applies the infix u verb between the left and right argument. 1 + /- 1 <-> 1 + 1 <-> 2
  • 29 |
  • Monadic conjunction, |. . This operator is defined u |. v y <-> u y v y. It applies the infix dyadic verb v between copies of the right argument and the monadic verb u to the result. |- |. + 1 <-> |- 1 + 1 <-> -2 .
  • 30 |
  • Dyadic conjunction, . . This operator is defined x u . v y <-> u x v y . It applies the infix dyadic verb v between the left and right arguments and the monadic verb u to the result. 2 |- . + 5 <-> |- 2 + 5 <-> -7 .
  • 31 |
32 | 33 |

There is no order of precedence between the operations. Execution is from right to left modified by parenthesis. |- |- |- 1 <-> -1

34 | 35 |

The language elements are associated to it's arguments like this:

36 | 37 |
    38 |
  • A monadic verb has one noun argument to the right. Like this: |- 1 .
  • 39 |
  • A dyadic verb has one noun argument to the left and one to the right. Like this: 1 + 1 .
  • 40 |
  • A monadic adverb has a verb argument to the left and a noun argument to the right. Like this: + / 1 .
  • 41 |
  • A dyadic adverb has a verb argument to the left, one noun argument to the left and one to the right. Like this: 1 + /- 1 .
  • 42 |
  • A monadic conjunction has a verb argument to the left and one to the right, and one noun argument to the right. Like this: |- |. + 1 .
  • 43 |
  • A dyadic conjunction has a verb argument to the left and one to the right, and one noun argument to the left and one to the right. Like this: 1 |- . + 1
  • 44 |
  • An adverb to the left of a conjunction is together with it's verb the left argument of the conjunction. Like this in the monadic case: + / |. + 1 . Like this in the dyadic case: 1 + / . + 1 .
  • 45 |
46 |

An adverb together with its left verb forms a new verb. A conjunction together with its right verb and it's left verb or adverb forms a new verb.

47 | 48 |

Monadic verbs, adverbs and conjunctions create verb trains like this:

49 | 50 |
 |-     + /     |-     |- |. +     |-     + / |. +     |- 1
51 | 52 |

I use extra blanks to show the separation between verbs.

53 | 54 |

You always need at least one blank between two syntax elements.

55 | 56 |

A program is called a NOUN DEFINITION. It is written between curly brackets, like this { some code } . It can contain VERB DEFINITIONS, written between curly brackets where the first bracket is immediately followed by ! . Like this {! some code } .

57 | 58 |

A verb definition can contain the NOUN FUNCTIONS - LEFT NOUN and RIGHT NOUN - denoted by [ and ] . The Left Noun is a placeholder for the noun immediately preceding the verb definition. The Right Noun is a placeholder for the noun immediately following the verb definition.

59 | 60 |

A verb definition containing only Right Nouns forms a monadic verb. A verb definition containing a Left Noun forms a dyadic verb, even if there is no Right Noun. In that case you are forced to have a noun to the right of the verb definition and this noun is silently ignored.

61 | 62 |

This is a verb definition of a monadic increment verb {! 1 + ] } . Example of use: {! 1 + ] } 2 .

63 | 64 |

This is a verb definition of a dyadic addition verb {! [ + ] } . Example of use : 1 {! [ + ] } 2 .

65 | 66 |

Left and Right nouns within brackets are placeholders for the noun arguments to the first verb definition enclosing the brackets. In this example the Left noun is one and the Right noun is two: 1 {! ( [ + ] ) + 1 } 2

67 | 68 |

There is no way to define adverbs and conjunctions in this mock parser.

69 | 70 |

The verb definitions are very similar to the DIRECT DEFINITION FORM Ken Iverson used at his lectures, see http://tinyurl.com/npx2umk .

71 | 72 |

In the present implementation the noun definitions does not add any functional value.

73 | 74 |

I will use this interpreter as an argument in a discussion about the J language. I have questioned the syntax of tacit J many times. The answer is always - How should it be instead. This is how I think it should be. Nearly exactly like normal scripted J.

75 |

I want to add that if you add a Left verb and a Right verb to this parser, you could add a definition of a new functional entity with one or two verb arguments and a verb result which would possibly let you use higher order functions on these verbs.

76 | 77 |

You could of course also use Left verb and Right verb to define adverbs and conjunctions in some kind of direct definition form.

78 | 79 |

The tacit J interpreter is in many ways similar to this interpreter. It does not have definitions of adverbs and conjunctions either.

80 | 81 |

Some notes on implementation:

82 | 83 |
    84 |
  • The interpreter creates a composite compiled .NET function which is executed when the interpretation process is finished. It is more like JIT-compiled than interpreted code.
  • 85 |
  • The interpreter is written in F# and with FParsec.
  • 86 |
  • In the F# environment you can write code nearly as efficient as in C++.
  • 87 |
  • The full .NET environment and the rest of the Windows environment, called Windows RT, is easily available from F#. Integration with the Windows environment is easy.
  • 88 |
  • In JWithATwist an adverb or conjunction always returns a noun.
  • 89 |
90 | 91 |

A sample session :
92 | { 1 }
93 | 1
94 | { 1 + 1 }
95 | 2
96 | { ( 1 - 1 ) + 1 }
97 | 1
98 | { ( 1 - 1 ) {! [ + ] } 1 }
99 | 1
100 | { { 1 - 1 } {! [ + ] } 1 }
101 | 1
102 | { + / 1 }
103 | 2
104 | { {! [ + ] } / 1 }
105 | 2
106 | { + / |. + 1 }
107 | 4
108 | { 2 + / . + 1 }
109 | 6
110 | { 2 + / . + |- |- 1 }
111 | 6
112 | { 2 + / . {! [ + ] } |- |- 1 }
113 | 6
114 | { 2 + / . + |- {! |- ] } 1 }
115 | 6
116 | { 2 + /- 3 }
117 | 5
118 | { 5 {! ( [ + ] ) + [ + ] } 7 }
119 | 24
120 | { |- + / |- |. + + / |. + |- 5 }
121 | -80

122 | 123 | 124 | -------------------------------------------------------------------------------- /JWithATwist.MockInterpreter/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | namespace JWithATwist.PerformanceTest.AssemblyInfo 2 | 3 | open System.Reflection 4 | open System.Runtime.CompilerServices 5 | open System.Runtime.InteropServices 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [] 11 | [] 12 | [] 13 | [] 14 | [] 15 | [] 16 | [] 17 | [] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [] 37 | [] 38 | [] 39 | 40 | do 41 | () -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/JWithATwist.PerformanceTest.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 2.0 8 | eed8f820-457b-4871-99c6-5493cfb9463d 9 | Exe 10 | JWithATwist.PerformanceTest 11 | JWithATwist.PerformanceTest 12 | v4.6 13 | true 14 | 4.4.0.0 15 | JWithATwist.PerformanceTest 16 | 17 | 18 | 19 | 20 | 21 | true 22 | full 23 | false 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | 3 28 | AnyCPU 29 | bin\Debug\JWithATwist.PerformanceTest.XML 30 | true 31 | 32 | 33 | pdbonly 34 | true 35 | true 36 | bin\Release\ 37 | TRACE 38 | 3 39 | AnyCPU 40 | bin\Release\JWithATwist.PerformanceTest.XML 41 | true 42 | 43 | 44 | 11 45 | 46 | 47 | true 48 | full 49 | false 50 | false 51 | bin\Debug\ 52 | DEBUG;TRACE 53 | 3 54 | bin\Debug\JWithATwist.PerformanceTest.XML 55 | true 56 | x64 57 | 58 | 59 | pdbonly 60 | true 61 | true 62 | bin\Release\ 63 | TRACE 64 | 3 65 | bin\Release\JWithATwist.PerformanceTest.XML 66 | true 67 | x64 68 | 69 | 70 | 71 | 72 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets 73 | 74 | 75 | 76 | 77 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsec.dll 95 | True 96 | 97 | 98 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll 99 | True 100 | 101 | 102 | ..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.1.0.39\lib\net40\Microsoft.Diagnostics.Tracing.TraceEvent.dll 103 | True 104 | 105 | 106 | 107 | True 108 | 109 | 110 | 111 | ..\packages\System.Console.4.0.0-beta-23225\lib\net46\System.Console.dll 112 | True 113 | 114 | 115 | 116 | ..\packages\System.Diagnostics.Process.4.0.0-beta-23225\lib\net46\System.Diagnostics.Process.dll 117 | True 118 | 119 | 120 | ..\packages\System.IO.FileSystem.4.0.0\lib\net46\System.IO.FileSystem.dll 121 | True 122 | 123 | 124 | ..\packages\System.IO.FileSystem.Primitives.4.0.0\lib\net46\System.IO.FileSystem.Primitives.dll 125 | True 126 | 127 | 128 | 129 | ..\packages\System.Security.SecureString.4.0.0-beta-23409\lib\net46\System.Security.SecureString.dll 130 | True 131 | 132 | 133 | ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll 134 | True 135 | 136 | 137 | ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll 138 | True 139 | 140 | 141 | ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll 142 | True 143 | 144 | 145 | ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll 146 | True 147 | 148 | 149 | ..\packages\Microsoft.DotNet.BuildTools.TestSuite.1.0.0-prerelease-00508-01\lib\netstandard1.0\xunit.execution.dotnet.dll 150 | True 151 | 152 | 153 | ..\packages\Microsoft.DotNet.xunit.performance.run.core.99.99.99-dev\lib\netstandard1.3\xunit.performance.core.dll 154 | True 155 | 156 | 157 | ..\packages\Microsoft.DotNet.xunit.performance.99.99.99-dev\lib\net46\xunit.performance.execution.desktop.dll 158 | True 159 | 160 | 161 | ..\packages\Microsoft.DotNet.xunit.performance.metrics.99.99.99-dev\lib\net46\xunit.performance.metrics.dll 162 | True 163 | 164 | 165 | ..\packages\Microsoft.DotNet.xunit.performance.run.core.99.99.99-dev\lib\netstandard1.3\xunit.performance.run.core.dll 166 | True 167 | 168 | 169 | ..\packages\Microsoft.DotNet.BuildTools.TestSuite.1.0.0-prerelease-00508-01\lib\netstandard1.0\xunit.runner.utility.dotnet.dll 170 | True 171 | 172 | 173 | 174 | 175 | JWithATwist 176 | {0f2dada6-c9e9-4b12-8a14-e732166b3458} 177 | True 178 | 179 | 180 | 181 | 182 | 183 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 184 | 185 | 186 | 187 | 194 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/PerformanceTest.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist.PerformanceTest 19 | 20 | open System 21 | open System.Collections 22 | open System.Collections.Generic 23 | open System.Text 24 | open System.IO 25 | open Microsoft.FSharp.Control 26 | open Xunit 27 | open Xunit.Abstractions 28 | open JWithATwist.Base 29 | open JWithATwist.Define 30 | open JWithATwist.ParserDefinitions 31 | open JWithATwist.ParserInterface 32 | open JWithATwist.Parser 33 | open FParsec 34 | open Microsoft.Xunit.Performance 35 | 36 | module PerformanceTest = 37 | 38 | [] 39 | type ``Performance Tests`` () = 40 | 41 | [] 42 | [] 43 | member x.``Calibration`` (ms) = 44 | for iteration in Benchmark.Iterations do 45 | let g (iteration:BenchmarkIteration) = 46 | use a = iteration.StartMeasurement() 47 | Async.RunSynchronously (async {do! Async.Sleep(ms)} ) 48 | () 49 | g iteration 50 | 51 | 52 | 53 | [] 54 | member x.``Iota`` () = 55 | let noun = JNounDefine @"{ 30000000 }" 56 | let verbMonadic = JVerbMonadicDefine @"{! |i. ] }" 57 | for iteration in Benchmark.Iterations do 58 | let g (iteration:BenchmarkIteration) = 59 | use a = iteration.StartMeasurement() 60 | verbMonadic noun |> ignore 61 | () 62 | g iteration 63 | 64 | 65 | 66 | [] 67 | member x.``Dyadic Rank`` () = 68 | let noun = JNounDefine @"{ 500000 }" 69 | let verbMonadic = JVerbMonadicDefine @"{! ( |i. ] ) + '/ 0 0 / |i. ] }" 70 | for iteration in Benchmark.Iterations do 71 | let g (iteration:BenchmarkIteration) = 72 | use a = iteration.StartMeasurement() 73 | verbMonadic noun |> ignore 74 | () 75 | g iteration 76 | 77 | 78 | 79 | [] 80 | member x.``Monadic Rank`` () = 81 | let noun = JNounDefine @"{ |i. 700000 }" 82 | let verbMonadic = JVerbMonadicDefine @"{! |- |'/ 0 / ] }" 83 | for iteration in Benchmark.Iterations do 84 | let g (iteration:BenchmarkIteration) = 85 | use a = iteration.StartMeasurement() 86 | verbMonadic noun |> ignore 87 | () 88 | g iteration 89 | 90 | 91 | 92 | [] 93 | member x.``Monadic Scalar function`` () = 94 | let noun = JNounDefine @"{ |i. 15000000 }" 95 | let verbMonadic = JVerbMonadicDefine @"{! |- ] }" 96 | for iteration in Benchmark.Iterations do 97 | let g (iteration:BenchmarkIteration) = 98 | use a = iteration.StartMeasurement() 99 | verbMonadic noun |> ignore 100 | () 101 | g iteration 102 | 103 | 104 | [] 105 | member x.``Dyadic Scalar function`` () = 106 | let noun = JNounDefine @"{ |i. 10000000 }" 107 | let verbMonadic = JVerbMonadicDefine @"{! ] + ] }" 108 | for iteration in Benchmark.Iterations do 109 | let g (iteration:BenchmarkIteration) = 110 | use a = iteration.StartMeasurement() 111 | verbMonadic noun |> ignore 112 | () 113 | g iteration 114 | 115 | 116 | [] 117 | member x.``Sort`` () = 118 | let noun = JNounDefine @"{ |i. |- 2000000 }" 119 | let verbMonadic = JVerbMonadicDefine @"{! ( |/: ] ) <- ] }" 120 | for iteration in Benchmark.Iterations do 121 | let g (iteration:BenchmarkIteration) = 122 | use a = iteration.StartMeasurement() 123 | verbMonadic noun |> ignore 124 | () 125 | g iteration 126 | 127 | 128 | 129 | [] 130 | member x.``Handling boxed data`` () = 131 | let xNoun = JNounDefine @"{ 40000 $ 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 }" 132 | let yNoun = JNounDefine @"{ 40000 $ 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 }" 133 | let verbDyadic = JVerbDyadicDefine @" 134 | {! 135 | |> 136 | ( |< |i. 0 ) {! |< ( |> [ ) , |> ] } / 137 | ( 138 | {! 139 | ( |< |, -1 ) {! |< ( 1 + ( |i. 0 ) $ -1 <.- |> [ ) + |i. ] } \ ] 140 | } 141 | {! 142 | ] - 0 , -1 >.- ] 143 | } 144 | {! 145 | ( 1 = ] ) /:: |i. |# ] 146 | } 147 | [ , 1 148 | ) 149 | {! 150 | |< 151 | {! 152 | ( |i. |- |# ] ) <- ] 153 | } 154 | {! 155 | ( |_ 1 = 0 + \ ] ) * ] 156 | } 157 | {! 158 | ( |i. |- |# ] ) <- ] 159 | } 160 | ( |> [ ) <- ] 161 | } '/ 0 1 / ] 162 | }" 163 | for iteration in Benchmark.Iterations do 164 | let g (iteration:BenchmarkIteration) = 165 | use a = iteration.StartMeasurement() 166 | verbDyadic xNoun yNoun |> ignore 167 | () 168 | g iteration 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/Program.fs: -------------------------------------------------------------------------------- 1 | // Learn more about F# at http://fsharp.org 2 | // See the 'F# Tutorial' project for more help. 3 | 4 | [] 5 | let main argv = 6 | printfn "%A" argv 7 | 0 // return an integer exit code 8 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/TraceEvent.ReadMe.txt: -------------------------------------------------------------------------------- 1 |  2 | ************* Welcome to the Microsoft.Diagnostics.Tracing.TraceEvent library! *************** 3 | 4 | This library is designed to make controlling and parsing Event Tracing for Windows (ETW) events easy. 5 | In particular if you are generating events with System.Diagnostics.Tracing.EventSource, this library 6 | makes it easy to process that data. 7 | 8 | ******** PROGRAMMERS GUIDE ******** 9 | 10 | If you are new to TraceEvent, see the _TraceEventProgammersGuide.docx that was installed as part of 11 | your solution when this NuGet package was installed. 12 | 13 | ************ FEEDBACK ************* 14 | 15 | If you have problems, wish to report a bug, or have a suggestion please log your comments on the 16 | .NET Runtime Framework Blog http://blogs.msdn.com/b/dotnet/ under the TraceEvent announcement. 17 | 18 | ********** RELEASE NOTES *********** 19 | 20 | If you are interested what particular features/bug fixes are in this particular version please 21 | see the TraceEvent.RelaseNotes.txt file that is part of this package. It also contains 22 | information about breaking changes (If you use the bcl.codeplex version in the past). 23 | 24 | ************* SAMPLES ************* 25 | 26 | There is a companion NUGET package called Microsoft.Diagnostics.Tracing.TraceEvent.Samples. These 27 | are simple but well commented examples of how to use this library. To get the samples, it is best 28 | to simply create a new Console application, and then reference the Samples package from that App. 29 | The package's README.TXT file tell you how to run the samples. 30 | 31 | ************** BLOGS ************** 32 | 33 | See http://blogs.msdn.com/b/vancem/archive/tags/traceevent/ for useful blog entries on using this 34 | package. 35 | 36 | *********** QUICK STARTS *********** 37 | 38 | The quick-starts below will get you going in a minimum of typing, but please see the WELL COMMENTED 39 | samples in the Samples NUGET package that describe important background and other common scenarios. 40 | 41 | ************************************************************************************************** 42 | ******* Quick Start: Turning on the 'MyEventSource' EventSource and log to MyEventsFile.etl: 43 | 44 | using (var session = new TraceEventSession("SimpleMontitorSession", "MyEventsFile.etl")) // Sessions collect and control event providers. Here we send data to a file 45 | { 46 | var eventSourceGuid = TraceEventProviders.GetEventSourceGuidFromName("MyEventSource"); // Get the unique ID for the eventSouce. 47 | session.EnableProvider(eventSourceGuid); // Turn it on. 48 | Thread.Sleep(10000); // Collect for 10 seconds then stop. 49 | } 50 | 51 | ************************************************************************************************** 52 | ******** Quick Start: Reading MyEventsFile.etl file and printing the events. 53 | 54 | using (var source = new ETWTraceEventSource("MyEtlFile.etl")) // Open the file 55 | { 56 | var parser = new DynamicTraceEventParser(source); // DynamicTraceEventParser knows about EventSourceEvents 57 | parser.All += delegate(TraceEvent data) // Set up a callback for every event that prints the event 58 | { 59 | Console.WriteLine("GOT EVENT: " + data.ToString()); // Print the event. 60 | }; 61 | source.Process(); // Read the file, processing the callbacks. 62 | } // Close the file. 63 | 64 | 65 | ************************************************************************************************************* 66 | ******** Quick Start: Turning on the 'MyEventSource', get callbacks in real time (no files involved). 67 | 68 | using (var session = new TraceEventSession("MyRealTimeSession")) // Create a session to listen for events 69 | { 70 | session.Source.Dynamic.All += delegate(TraceEvent data) // Set Source (stream of events) from session. 71 | { // Get dynamic parser (knows about EventSources) 72 | // Subscribe to all EventSource events 73 | Console.WriteLine("GOT Event " + data); // Print each message as it comes in 74 | }; 75 | 76 | var eventSourceGuid = TraceEventProviders.GetEventSourceGuidFromName("MyEventSource"); // Get the unique ID for the eventSouce. 77 | session.EnableProvider(eventSourceGuid); // Enable MyEventSource. 78 | session.Source.Process(); // Wait for incoming events (forever). 79 | } 80 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/TraceEvent.ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 | Version 1.0.0.3 - Initial release to NuGet, pre-release. 2 | 3 | TraceEvent has been available from the site http://bcl.codeplex.com/wikipage?title=TraceEvent for some time now 4 | this NuGet Version of the library supersedes that one. WHile the 'core' part of the library is unchanged, 5 | we did change lesser used features, and change the namespace and DLL name, which will cause break. We anticipate 6 | it will take an hour or so to 'port' to this version from the old one. Below are specific details on what 7 | has changed to help in this port. 8 | 9 | * The DLL has been renamed from TraceEvent.dll to Microsoft.Diagnostics.Tracing.TraceEvent.dll 10 | * The name spaces for all classes have been changed. The easiest way to port is to simply place 11 | the following using clauses at the top of any file that uses TraceEvent classes 12 | using Microsoft.Diagnostics.Symbols; 13 | using Microsoft.Diagnostics.Tracing; 14 | using Microsoft.Diagnostics.Tracing.Etlx; 15 | using Microsoft.Diagnostics.Tracing.Parsers.Clr; 16 | using Microsoft.Diagnostics.Tracing.Parsers.Kernel; 17 | using Microsoft.Diagnostics.Tracing.Session; 18 | using Microsoft.Diagnostics.Tracing.Stacks; 19 | * Any method with the name RelMSec in it has been changed to be RelativeMSec. The easiest port is to 20 | simply globally rename RelMSec to RelativeMSec 21 | * Any property in the Trace* classes that has the form Max*Index has been renamed to Count. 22 | * A number of methods have been declared obsolete, these are mostly renames and the warning will tell you 23 | how to update them. 24 | * The following classes have been rename 25 | SymPath -> SymbolPath 26 | SymPathElement -> SymbolPathElement 27 | SymbolReaderFlags -> SymbolReaderOptions 28 | * TraceEventSession is now StopOnDispose (it will stop the session when TraceEventSesssion dies), by default 29 | If you were relying on the kernel session living past the process that started it, you must now set 30 | the StopOnDispose explicitly 31 | * There used to be XmlAttrib extensions methods on StringBuilder for use in manifest generated TraceEventParsers 32 | These have been moved to protected members of TraceEvent. The result is that in stead of writing 33 | sb.XmlAttrib(...) you write XmlAttrib(sb, ...) 34 | * References to Pdb in names have been replaced with 'Symbol' to conform to naming guidelines. 35 | 36 | *********************************************************************************************** 37 | Version 1.0.0.4 - Initial stable release 38 | 39 | Mostly this was insuring that the library was cleaned up in preparation 40 | for release the TraceParserGen tool 41 | 42 | Improved the docs, removed old code, fixed some naming convention stuff 43 | 44 | * Additional changes from the PreRelease copy to the first Stable release 45 | 46 | * The arguments to AddCallbackForProviderEvent were reversed!!!! (now provider than event) 47 | * The arguments to Observe(string, string)!!!! (now provider than event) 48 | * Event names for these APIs must include a / between the Task and Opcode names 49 | 50 | * Many Events in KernelTraceEventParser were harmonized to be consistent with other conventions 51 | * Events of the form PageFault* were typically renamed to Memory* 52 | * The 'End' suffix was renamed to 'Stop' (its official name) 53 | * PerfInfoSampleProf -> PerfInfoSample 54 | * PerfInfoSampleProf -> PerfInfoSample 55 | * ReadyThread -> DispatcherReadyThread 56 | * StackWalkTraceData -> StackWalkStackTraceData 57 | * FileIo -> FileIO 58 | * DiskIo -> DiskIO 59 | 60 | * Many Events in SymbolTraceEventParser were harmonized to be consistent with other conventions 61 | * names with Symbol -> ImageID 62 | -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/_TraceEventProgrammersGuide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist.PerformanceTest/_TraceEventProgrammersGuide.docx -------------------------------------------------------------------------------- /JWithATwist.PerformanceTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /JWithATwist.Test/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JWithATwist.Test/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | namespace JWithATwist.Test.AssemblyInfo 2 | 3 | open System.Reflection 4 | open System.Runtime.CompilerServices 5 | open System.Runtime.InteropServices 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [] 11 | [] 12 | [] 13 | [] 14 | [] 15 | [] 16 | [] 17 | [] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [] 37 | [] 38 | [] 39 | 40 | do 41 | () -------------------------------------------------------------------------------- /JWithATwist.Test/Define.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist.Test 19 | 20 | open System 21 | open System.Collections 22 | open System.Collections.Generic 23 | open Xunit 24 | open Xunit.Abstractions; 25 | open JWithATwist.Base 26 | open JWithATwist.Define 27 | 28 | module Define = 29 | 30 | type ``Test JNounDefine:`` () = 31 | [] 32 | member x.``Define J Noun`` () = 33 | let expected = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|1L|] ;} 34 | let actual = JNounDefine @"{ 1 }" 35 | Assert.Equal(expected,actual) 36 | [] 37 | member x.``Domain error`` () = 38 | let f () = 39 | let actual = JNounDefine @"{! [ + ] }" 40 | () 41 | Assert.Throws(f) 42 | [] 43 | member x.``Syntax error`` () = 44 | let f () = 45 | let actual = JNounDefine @"{! [ + ]}" 46 | () 47 | Assert.Throws(f) 48 | 49 | type ``Test JVerbMonadicDefine:`` () = 50 | [] 51 | member x.``Define J Monadic Verb`` () = 52 | let verbMonadic = JVerbMonadicDefine @"{! |- ] } " 53 | let noun = JNounDefine "{ 1 } " 54 | let expected = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|-1L|] ;} 55 | let actual = verbMonadic noun 56 | Assert.Equal(expected,actual) 57 | [] 58 | member x.``Domain error`` () = 59 | let f () = 60 | let actual = JVerbMonadicDefine @"{! [ + ] }" 61 | () 62 | Assert.Throws(f) 63 | [] 64 | member x.``Syntax error`` () = 65 | let f () = 66 | let actual = JVerbMonadicDefine @"{! [ + ]}" 67 | () 68 | Assert.Throws(f) 69 | 70 | type ``Test JVerbDyadicDefine:`` () = 71 | [] 72 | member x.``Define J Dyadic Verb`` () = 73 | let verbDyadic = JVerbDyadicDefine @"{! [ + ] } " 74 | let noun = JNounDefine "{ 1 } " 75 | let expected = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|2L|] ;} 76 | let actual = verbDyadic noun noun 77 | Assert.Equal(expected,actual) 78 | [] 79 | member x.``Domain error`` () = 80 | let f () = 81 | let actual = JVerbDyadicDefine @"{! |- ] }" 82 | () 83 | Assert.Throws(f) 84 | [] 85 | member x.``Syntax error`` () = 86 | let f () = 87 | let actual = JVerbDyadicDefine @"{! [ + ]}" 88 | () 89 | Assert.Throws(f) 90 | 91 | 92 | -------------------------------------------------------------------------------- /JWithATwist.Test/JWithATwist.Test.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | 2.0 9 | d62538f9-589e-4dbd-82a3-44f1c78ade35 10 | Exe 11 | JWithATwist.Test 12 | JWithATwist.Test 13 | v4.6 14 | true 15 | 4.4.0.0 16 | JWithATwist.Test 17 | 18 | 19 | 20 | 21 | 22 | true 23 | full 24 | false 25 | false 26 | bin\Debug\ 27 | DEBUG;TRACE 28 | 3 29 | AnyCPU 30 | bin\Debug\JWithATwist.Test.XML 31 | true 32 | 33 | 34 | pdbonly 35 | true 36 | true 37 | bin\Release\ 38 | TRACE 39 | 3 40 | AnyCPU 41 | bin\Release\JWithATwist.Test.XML 42 | true 43 | 44 | 45 | 11 46 | 47 | 48 | true 49 | full 50 | false 51 | false 52 | bin\Debug\ 53 | DEBUG;TRACE 54 | 3 55 | bin\Debug\JWithATwist.Test.XML 56 | true 57 | x64 58 | 59 | 60 | pdbonly 61 | true 62 | true 63 | bin\Release\ 64 | TRACE 65 | 3 66 | bin\Release\JWithATwist.Test.XML 67 | true 68 | x64 69 | 70 | 71 | 72 | 73 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets 74 | 75 | 76 | 77 | 78 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsec.dll 97 | True 98 | 99 | 100 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll 101 | True 102 | 103 | 104 | 105 | True 106 | 107 | 108 | 109 | 110 | 111 | 112 | ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll 113 | True 114 | 115 | 116 | ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll 117 | True 118 | 119 | 120 | ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll 121 | True 122 | 123 | 124 | ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll 125 | True 126 | 127 | 128 | 129 | 130 | JWithATwist 131 | {0f2dada6-c9e9-4b12-8a14-e732166b3458} 132 | True 133 | 134 | 135 | 136 | 137 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 138 | 139 | 140 | 141 | 148 | -------------------------------------------------------------------------------- /JWithATwist.Test/Program.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | 19 | // Learn more about F# at http://fsharp.org 20 | // See the 'F# Tutorial' project for more help. 21 | open JWithATwist 22 | open JWithATwist.Base 23 | open JWithATwist.Define 24 | 25 | //(* 26 | open JWithATwist.ParserDefinitions 27 | open JWithATwist.ParserInterface 28 | open JWithATwist.Parser 29 | //*) 30 | (* 31 | open J4Mono.ParserMockDefinitions 32 | open J4Mono.ParserMockInterface 33 | open J4Mono.ParserMock 34 | *) 35 | open System 36 | open System.Text 37 | open System.IO 38 | open System.Diagnostics 39 | open FParsec 40 | open Operators.Checked 41 | 42 | let baseEncode baseArray number = 43 | let a = 44 | Array.scanBack 45 | ( 46 | fun dimBase (quo,rem) -> 47 | (quo/dimBase,quo % dimBase) 48 | ) 49 | baseArray 50 | (number,0) 51 | let b = Array.map (fun (quo,rem) -> rem) a 52 | Array.sub b 0 (b.Length-1) 53 | 54 | //let stopWatch = System.Diagnostics.Stopwatch.StartNew() 55 | //stopWatch.Stop() 56 | //printfn "%f" stopWatch.Elapsed.TotalMilliseconds 57 | 58 | 59 | let genRandomNumbers count = 60 | let rnd = System.Random() 61 | seq {for i = 0 to count do yield (rnd.Next ())} 62 | 63 | 64 | (* 65 | let rnd = System.Random() 66 | let count = 10 67 | let a:int [] = Array.zeroCreate count 68 | let i = ref 0 69 | let seti value a i = 70 | Array.set a !i (rnd.Next()) 71 | i := !i + 1 72 | () 73 | let k value = seti value a i 74 | k 1 75 | k 2 76 | *) 77 | 78 | (* 79 | //For each number in the sequence generated by i., where should I put it in the array? 80 | a=:(|3 _3) #:1 81 | q =: 3 _3 <0 82 | r=:((-.q)*a)+(q*|3 _3+q)-q*a 83 | r 84 | 0 1 85 | 3 3#. r 86 | 1 87 | //For each array element, what should I put there? 88 | //For each array index, what element should be delivered if there is no array? 89 | b=:_3 3 90 | b1=:|b 91 | b2=:<:b1 92 | c=:}.|.*/\1,|.b1 93 | q=:b < 0 94 | a=:8 95 | a3=:b1#:a 96 | +/(q*c*b2-a3)+(-.q)*a3 97 | 2 98 | *) 99 | 100 | 101 | 102 | let test p str = 103 | match run p str with 104 | | Success(result, _, rest) -> printfn "Success: %A %A" result rest 105 | | Failure(errorMsg, n, m) -> printfn "Failure: %s %A %A" errorMsg n m 106 | 107 | type a = 108 | { 109 | a:string 110 | b:int 111 | } 112 | 113 | 114 | [] 115 | let main argv = 116 | 117 | //let stopWatch = System.Diagnostics.Stopwatch.StartNew() 118 | //stopWatch.Stop() 119 | //printfn "%f" stopWatch.Elapsed.TotalMilliseconds 120 | (* 121 | 122 | let resultOption = parseAllSpeach @" 123 | { 124 | 100 <.- 125 | ( 40000 $ 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 ) 126 | {! 127 | |> 128 | ( |< |i. 0 ) {! |< ( |> [ ) , |> ] } / 129 | ( 130 | {! 131 | ( |< |, -1 ) {! |< ( 1 + ( |i. 0 ) $ -1 <.- |> [ ) + |i. ] } \ ] 132 | } 133 | {! 134 | ] - 0 , -1 >.- ] 135 | } 136 | {! 137 | ( 1 = ] ) /:: |i. |# ] 138 | } 139 | [ , 1 140 | ) 141 | {! 142 | |< 143 | {! 144 | ( |i. |- |# ] ) <- ] 145 | } 146 | {! 147 | ( |_ 1 = 0 + \ ] ) * ] 148 | } 149 | {! 150 | ( |i. |- |# ] ) <- ] 151 | } 152 | ( |> [ ) <- ] 153 | } '/ 0 1 / ] 154 | } 155 | ( 40000 $ 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 ) 156 | } " 157 | match resultOption with 158 | | Success(result, _, rest) -> 159 | match result with 160 | |[parseResult] -> 161 | match parseResult with 162 | |{Value=TypeNounUnit f} -> 163 | let stopWatch = System.Diagnostics.Stopwatch.StartNew() 164 | printfn "%A" (f ()) 165 | stopWatch.Stop() 166 | printfn "%f" stopWatch.Elapsed.TotalMilliseconds 167 | 168 | |_ -> 169 | printfn "Error" 170 | |_ -> 171 | printfn "Error" 172 | |_ -> 173 | printfn "Error" 174 | *) 175 | 176 | //let stopWatch = System.Diagnostics.Stopwatch.StartNew() 177 | //stopWatch.Stop() 178 | //printfn "%f" stopWatch.Elapsed.TotalMilliseconds 179 | 180 | 181 | 182 | Parser() 183 | (* 184 | let resultOption = parseAllSpeach @"{! 2147483647 * 2 } " 185 | match resultOption with 186 | | Success(result, _, rest) -> 187 | match result with 188 | |[parseResult] -> 189 | match parseResult with 190 | |{Value=TypeNounUnit f} -> 191 | let a = new StringWriter() 192 | Console.SetOut(a) 193 | ParsePrint parseResult 194 | let expected = "Overflow" 195 | let actual = a.ToString() 196 | printfn "%A %A" actual expected 197 | |_ -> 198 | () 199 | |_ -> 200 | () 201 | |_ -> 202 | () 203 | *) 204 | 205 | (* 206 | let count = 10000000 207 | let index = Seq.init count id 208 | let array = Seq.toArray (genRandomNumbers count) 209 | 210 | let stopWatch = System.Diagnostics.Stopwatch.StartNew() 211 | let sorted = GradeUp array 212 | stopWatch.Stop() 213 | printfn "GradeUp: %f" stopWatch.Elapsed.TotalMilliseconds 214 | 215 | let stopWatch = System.Diagnostics.Stopwatch.StartNew() 216 | let sorted = Array.sort array 217 | stopWatch.Stop() 218 | printfn "Array.sort: %f" stopWatch.Elapsed.TotalMilliseconds 219 | 220 | 221 | *) 222 | 223 | //Console.ReadLine() |> ignore 224 | 225 | 0 // return an integer exit code -------------------------------------------------------------------------------- /JWithATwist.Test/System.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist.Test 19 | 20 | open System 21 | open System.Collections 22 | open System.Collections.Generic 23 | open System.Text 24 | open System.IO 25 | open System.Runtime.Serialization.Formatters.Soap 26 | open Xunit 27 | open Xunit.Abstractions 28 | open JWithATwist.Base 29 | open JWithATwist.Define 30 | open JWithATwist.ParserDefinitions 31 | open JWithATwist.ParserInterface 32 | open JWithATwist.Parser 33 | open FParsec 34 | 35 | module System = 36 | 37 | type ``System Tests`` () = 38 | 39 | [] 40 | member x.``Definition on several lines. `` () = 41 | let resultOption = parseAllSpeach @" 42 | { 43 | 1 + 44 | 0 + \ 1 2 3 45 | } " 46 | match resultOption with 47 | | Success(result, _, rest) -> 48 | match result with 49 | |[parseResult] -> 50 | match parseResult with 51 | |{Value=TypeNounUnit f} -> 52 | let r = f () 53 | match r with 54 | |{JValue=JTypeIntegerArray[|2L;4L;7L|]} -> 55 | Assert.True(true) 56 | |_ -> 57 | Assert.True(false) 58 | |_ -> 59 | Assert.True(false) 60 | |_ -> 61 | Assert.True(false) 62 | |_ -> 63 | Assert.True(false) 64 | 65 | [] 66 | member x.``Use JWithATwist from F# `` () = 67 | let resultOption = parseAllSpeach @"{! [ + ] } " 68 | match resultOption with 69 | | Success(result, _, rest) -> 70 | match result with 71 | |[parseResult] -> 72 | match parseResult with 73 | |{Value=TypeVerbDyadic v} -> 74 | let x = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|1L|] ;} 75 | let y = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|1L|] ;} 76 | let expected = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|2L|] ;} 77 | let actual = v x y 78 | Assert.Equal(expected,actual) 79 | |_ -> 80 | Assert.True(false) 81 | |_ -> 82 | Assert.True(false) 83 | |_ -> 84 | Assert.True(false) 85 | 86 | [] 87 | member x.``Use JWithATwist from F# - Define strings `` () = 88 | let resultOption = parseAllSpeach @"{ |> ""a"" } " 89 | match resultOption with 90 | | Success(result, _, rest) -> 91 | match result with 92 | |[parseResult] -> 93 | match parseResult with 94 | |{Value=TypeNounUnit f} -> 95 | let expected = {JType = JTBType.JTypeUnicode; JShape= [||]; JValue = JTypeUnicodeArray [|'a'|] ;} 96 | let actual = f () 97 | Assert.Equal(expected,actual) 98 | |_ -> 99 | Assert.True(false) 100 | |_ -> 101 | Assert.True(false) 102 | |_ -> 103 | Assert.True(false) 104 | 105 | [] 106 | member x.``Save and restore JWithATwist generated FSharp code `` () = 107 | // Serialization of function values 108 | // ("Deserialization will only work from within 109 | // a completely identical binary.") 110 | // https://fsnotebook.net/notebook/fssnip-2R/Serialization_of_functions 111 | let resultOption = parseAllSpeach @"{! [ + ] } " 112 | match resultOption with 113 | | Success(result, _, rest) -> 114 | match result with 115 | |[parseResult] -> 116 | match parseResult with 117 | |{Value=TypeVerbDyadic v} -> 118 | let sf = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); 119 | let Ser v = 120 | use fs = new FileStream("c:/windows/temp/function", FileMode.OpenOrCreate, FileAccess.ReadWrite) 121 | sf.Serialize(fs, v) 122 | let Deser () = 123 | use fs2 = new FileStream("c:/windows/temp/function", FileMode.Open, FileAccess.Read) 124 | sf.Deserialize(fs2) :?> (JVerbDyadic) 125 | Ser v 126 | let vv = Deser () 127 | let x = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|1L|] ;} 128 | let y = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|1L|] ;} 129 | let expected = {JType = JTBType.JTypeInteger; JShape= [||]; JValue = JTypeIntegerArray [|2L|] ;} 130 | let actual = vv x y 131 | Assert.Equal(expected,actual) 132 | |_ -> 133 | Assert.True(false) 134 | |_ -> 135 | Assert.True(false) 136 | |_ -> 137 | Assert.True(false) 138 | 139 | 140 | 141 | 142 | type ``Code snippets`` () = 143 | //System tests and supposed to give some useful code snippets 144 | 145 | 146 | [] 147 | member x.``Matrix multiplication`` () = 148 | let MatrixMultiplication = JVerbDyadicDefine @" 149 | {! {! ( ( -1 <.- |$ ] ) $ 0 ) + / ] } |'/ 2 / [ * '/ 1 2 / ] }" 150 | let x = JNounDefine @"{ |i. 2 3 }" 151 | let y = JNounDefine @"{ |i. 3 2 }" 152 | let actual = MatrixMultiplication x y 153 | let expected = JNounDefine @"{ 2 2 $ 10 13 28 40 }" 154 | Assert.Equal(expected,actual) 155 | let x = JNounDefine @"{ |i. 0 3 }" 156 | let y = JNounDefine @"{ |i. 3 0 }" 157 | let actual = MatrixMultiplication x y 158 | let expected = JNounDefine @"{ 0 0 $ 0 }" 159 | Assert.Equal(expected,actual) 160 | let x = JNounDefine @"{ |i. 2 0 }" 161 | let y = JNounDefine @"{ |i. 0 2 }" 162 | let actual = MatrixMultiplication x y 163 | let expected = JNounDefine @"{ 2 2 $ 0 }" 164 | Assert.Equal(expected,actual) 165 | 166 | [] 167 | member x.``Reverse data along axis of arrays`` () = 168 | let ReverseArrayAxis = JVerbDyadicDefine @" 169 | {! ( |i. ( ( ( |_ |-. [ ) - |_ [ ) * |$ ] ) ) <- |, ] }" 170 | let x = JNounDefine @"{ false true }" 171 | let y = JNounDefine @"{ |i. 3 2 }" 172 | let actual = ReverseArrayAxis x y 173 | let expected = JNounDefine @"{ |i. 3 -2 }" 174 | Assert.Equal(expected,actual) 175 | 176 | [] 177 | member x.``FirstTrueInGroup`` () = 178 | let FirstTrueInGroup = JVerbMonadicDefine @" 179 | {! {! ] *. |-. false , -1 >.- ] } false +. \ ] }" 180 | let y = JNounDefine @"{ false true false true false }" 181 | let actual = FirstTrueInGroup y 182 | let expected = JNounDefine @"{ false true false false false }" 183 | Assert.Equal(expected,actual) 184 | 185 | [] 186 | member x.``GroupLengthFromBooleanGroupDescription`` () = 187 | let GroupLengthFromBooleanGroupDescription = JVerbMonadicDefine @" 188 | {! 189 | {! 190 | ] - ( |# ] ) <.- -1 , -1 >.- ] 191 | } 192 | ( ( |# ] ) <.- 1 >.- ] , true ) /:: |i. |# ] 193 | }" 194 | let y = JNounDefine @"{ true false false true false true false false }" 195 | let actual = GroupLengthFromBooleanGroupDescription y 196 | let expected = JNounDefine @"{ 3 2 3 }" 197 | Assert.Equal(expected,actual) 198 | let y = JNounDefine @"{ 0 <.- true }" 199 | let actual = GroupLengthFromBooleanGroupDescription y 200 | let expected = JNounDefine @"{ |i. 0 }" 201 | Assert.Equal(expected,actual) 202 | let y = JNounDefine @"{ 1 <.- true }" 203 | let actual = GroupLengthFromBooleanGroupDescription y 204 | let expected = JRavel (JNounDefine @"{ 1 }") 205 | Assert.Equal(expected,actual) 206 | 207 | 208 | [] 209 | member x.``GroupLengthFromCategoriesAndCategorization`` () = 210 | let GroupLengthFromCategoriesAndCategorization = JVerbDyadicDefine @" 211 | {! 212 | ( ( |# ] ) = ] i. [ ) 213 | {! 214 | ( |/: [ ) <- ] , ( 0 + / |_ [ = true ) $ 0 215 | } 216 | {! 217 | ] - ( |# ] ) <.- -1 , -1 >.- ] 218 | } 219 | {! 220 | ( ( |# ] ) <.- 1 >.- ] , true ) /:: |i. |# ] 221 | } 222 | ] ~: ( |# ] ) <.- 0 , -1 >.- ] 223 | }" 224 | let x = JNounDefine @"{ 1 2 3 }" 225 | let y = JNounDefine @"{ 1 1 1 2 2 }" 226 | let actual = GroupLengthFromCategoriesAndCategorization x y 227 | let expected = JNounDefine @"{ 3 2 0 }" 228 | Assert.Equal(expected,actual) 229 | let x = JNounDefine @"{ |i. 0 }" 230 | let y = JNounDefine @"{ |i. 0 }" 231 | let actual = GroupLengthFromCategoriesAndCategorization x y 232 | let expected = JNounDefine @"{ |i. 0 }" 233 | Assert.Equal(expected,actual) 234 | let x = JRavel (JNounDefine @"{ 1 }") 235 | let y = JNounDefine @"{ |i. 0 }" 236 | let actual = GroupLengthFromCategoriesAndCategorization x y 237 | let expected = JRavel (JNounDefine @"{ 0 }") 238 | Assert.Equal(expected,actual) 239 | 240 | 241 | 242 | 243 | [] 244 | member x.``cut indices `` () = 245 | //In case the cut testcase fails in this part of cut this testcase makes it easier to find the problem. 246 | let actual = JNounDefine @" 247 | { 248 | true *. / ( ( |< 0 1 ) , ( |< 2 3 4 ) , |< |i. 0 ) = 249 | {! 250 | ( |< |, -1 ) {! |< ( 1 + ( |i. 0 ) $ -1 <.- |> [ ) + |i. ] } \ ] 251 | } 2 3 0 252 | } " 253 | let expected = JNounDefine "{ true }" 254 | Assert.Equal(expected,actual) 255 | 256 | 257 | 258 | [] 259 | member x.``cut `` () = 260 | let Cut = JVerbDyadicDefine @" 261 | {! 262 | ( 263 | ( |< |, -1 ) {! |< ( ( |i. 0 ) $ 1 + -1 <.- |> [ ) + |i. ] } \ [ 264 | ) 265 | {! |< ( |> [ ) <- ] } '/ 0 1 / ] 266 | } " 267 | let x = JNounDefine @"{ 2 3 0 }" 268 | let y = JNounDefine @"{ 1 2 3 4 5 }" 269 | let actual = Cut x y 270 | let expected = JNounDefine @"{ ( |< 1 2 ) , ( |< 3 4 5 ) , |< |i. 0 }" 271 | Assert.Equal(expected,actual) 272 | let x = JNounDefine @"{ |i. 0 }" 273 | let y = JNounDefine @"{ |i. 0 }" 274 | let actual = Cut x y 275 | let expected = JNounDefine @"{ 0 <.- |< |i. 0 }" 276 | Assert.Equal(expected,actual) 277 | let x = JNounDefine @"{ |, 0 }" 278 | let y = JNounDefine @"{ |i. 0 }" 279 | let actual = Cut x y 280 | let expected = JNounDefine @"{ |, |< |i. 0 }" 281 | Assert.Equal(expected,actual) 282 | 283 | [] 284 | member x.``Group mean`` () = 285 | let GroupMean = JVerbMonadicDefine @" 286 | {! 287 | {! 288 | |< 289 | {! ( 0 + / ] ) % |# ] } 290 | |> ] 291 | } 292 | |'/ 0 / ] 293 | }" 294 | let y = JNounDefine @"{ ( |< 4 2 8 ) , ( |< 13 7 9 2 ) , |< 0 1 }" 295 | let actual = GroupMean y 296 | let expected = JNounDefine @"{ |< |'/ 0 / ( 4 + 2 % 3 ) , 7.75 0.5 }" 297 | Assert.Equal(expected,actual) 298 | 299 | [] 300 | member x.``Group mean i F#`` () = 301 | let each y u = 302 | JRankMonadic y (fun yy -> JBox (u (JOpen yy))) ZeroNounConstant 303 | let mean y = 304 | JDivide (JFold ZeroNounConstant y JAdd) (JTally y) 305 | let sets = JNounDefine @"{ ( |< 4 2 8 ) , ( |< 13 7 9 2 ) , |< 0 1 }" 306 | let actual = each sets mean 307 | let expected = JNounDefine @"{ |< |'/ 0 / ( 4 + 2 % 3 ) , 7.75 0.5 }" 308 | Assert.Equal(expected,actual) 309 | 310 | 311 | type ``Use case magic`` () = 312 | //This use case is supposed to show that you can easily use JWithATwist as an extension to F# 313 | //Inputs and result is a simple record type you can use in your F# programs 314 | //The result of a verb definition is an F# function 315 | //If something goes wrong you get a J exception. See the exception list in the beginning of J4Mono.Base 316 | //The tests of the parts of magic is just to make it easier to troubleshoot problems. 317 | //"magic" is a code snippet by Roger Hui. This code is supposed to do the same thing, but within the limits 318 | //of the present JWithATwist implementation. 319 | //magic=: ; @ (<@(] 323 | member x.``magic `` () = 324 | let xNoun = JNounDefine @"{ 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 }" 325 | let yNoun = JNounDefine @"{ 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 }" 326 | let expected = JNounDefine @"{ 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 }" 327 | let magic = JVerbDyadicDefine @" 328 | {! 329 | |> 330 | ( |< |i. 0 ) {! |< ( |> [ ) , |> ] } / 331 | ( 332 | {! 333 | ( |< |, -1 ) 334 | {! 335 | |< 336 | ( 337 | 1 + 338 | ( |i. 0 ) $ 339 | -1 <.- |> [ 340 | ) + 341 | |i. ] 342 | } \ ] 343 | } 344 | {! 345 | ] - 0 , -1 >.- ] 346 | } 347 | {! 348 | ( 1 = ] ) /:: |i. |# ] 349 | } 350 | [ , 1 351 | ) 352 | {! 353 | |< 354 | {! 355 | ( |i. |- |# ] ) <- ] 356 | } 357 | {! 358 | ( |_ 1 = 0 + \ ] ) * ] 359 | } 360 | {! 361 | ( |i. |- |# ] ) <- ] 362 | } 363 | ( |> [ ) <- ] 364 | } '/ 0 1 / ] 365 | } 366 | " 367 | let actual = magic xNoun yNoun 368 | Assert.Equal(expected,actual) 369 | 370 | 371 | 372 | 373 | [] 374 | member x.``magic reverse `` () = 375 | let actual = JNounDefine @" 376 | { 377 | {! ( |i. |- |# ] ) <- ] } 1 2 3 378 | } " 379 | let expected = JNounDefine "{ 3 2 1 }" 380 | Assert.Equal(expected,actual) 381 | 382 | 383 | 384 | 385 | [] 386 | member x.``magic pack up `` () = 387 | let actual = JNounDefine @" 388 | { 389 | |> 390 | ( |< |i. 0 ) {! |< ( |> [ ) , |> ] } / 391 | ( |< 0 0 1 0 ) , |< 1 0 0 392 | } " 393 | let expected = JNounDefine "{ 0 0 1 0 1 0 0 }" 394 | Assert.Equal(expected,actual) 395 | 396 | 397 | [] 398 | member x.``magic first true`` () = 399 | let actual = JNounDefine @" 400 | { 401 | {! 402 | ( |_ 1 = 0 + \ ] ) * ] 403 | } 404 | 0 1 0 1 0 405 | } " 406 | let expected = JNounDefine "{ 0 1 0 0 0 }" 407 | Assert.Equal(expected,actual) 408 | 409 | 410 | 411 | [] 412 | member x.``magic calculate and pack indices `` () = 413 | let actual = JNounDefine @" 414 | { 415 | true *. / ( ( |< 0 1 ) , ( |< 2 3 ) , |< 4 5 ) = 416 | {! 417 | {! 418 | ( |< |, -1 ) {! |< ( 1 + ( |i. 0 ) $ -1 <.- |> [ ) + |i. ] } \ ] 419 | } 420 | {! 421 | ] - 0 , -1 >.- ] 422 | } 423 | {! 424 | ( 1 = ] ) /:: |i. |# ] 425 | } 426 | ] , 1 427 | } 0 0 1 0 1 0 428 | } " 429 | let expected = JNounDefine "{ true }" 430 | Assert.Equal(expected,actual) 431 | 432 | 433 | [] 434 | member x.``magic group length `` () = 435 | let actual = JNounDefine @" 436 | { 437 | true *. / 2 2 2 = 438 | {! 439 | {! 440 | ] - 0 , -1 >.- ] 441 | } 442 | {! 443 | ( 1 = ] ) /:: |i. |# ] 444 | } 445 | ] , 1 446 | } 0 0 1 0 1 0 447 | } " 448 | let expected = JNounDefine "{ true }" 449 | Assert.Equal(expected,actual) 450 | 451 | type ``Use case magic in F#-version`` () = 452 | //This use case is supposed to show that you can easily use JWithATwist as an extension to F# 453 | //You can use the language elements directly from F# and pass the interpreter. 454 | //You can define JWithATwist verbs and use as functions or lambda expressions. 455 | //If you define the verbs in the module, interpretation is only done once. 456 | //magic=: ; @ (<@(] 459 | member x.``magic in F#-version `` () = 460 | let CreateBoxedGroupIndices = JVerbMonadicDefine @" 461 | {! 462 | {! 463 | ( |< |, -1 ) {! |< ( 1 + ( |i. 0 ) $ -1 <.- |> [ ) + |i. ] } \ ] 464 | } 465 | {! 466 | ] - 0 , -1 >.- ] 467 | } 468 | {! 469 | ( 1 = ] ) /:: |i. |# ] 470 | } 471 | ] , 1 472 | }" 473 | let FirstTrueInGroup = JVerbMonadicDefine @" 474 | {! 475 | ( |_ 1 = 0 + \ ] ) * ] 476 | }" 477 | let Raze = JVerbMonadicDefine @" 478 | {! 479 | |> 480 | ( |< |i. 0 ) {! |< ( |> [ ) , |> ] } / ] 481 | }" 482 | let Reverse = JVerbMonadicDefine @" 483 | {! ( |i. |- |# ] ) <- ] }" 484 | let Cut xNoun yNoun = 485 | JRankDyadic (CreateBoxedGroupIndices xNoun) yNoun (JVerbDyadicDefine @"{! |< ( |> [ ) <- ] }" ) (JNounDefine @"{ 0 1 }") 486 | let magic xNoun yNoun = 487 | let ExecuteForEachBox yNoun = 488 | JBox (Reverse(FirstTrueInGroup(Reverse (JOpen yNoun)))) 489 | Raze (JRankMonadic (Cut xNoun yNoun) ExecuteForEachBox (JNounDefine @"{ 0 }")) 490 | let xNoun = JNounDefine @"{ 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 }" 491 | let yNoun = JNounDefine @"{ 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 }" 492 | let expected = JNounDefine @"{ 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 }" 493 | let actual = magic xNoun yNoun 494 | Assert.Equal(expected,actual) -------------------------------------------------------------------------------- /JWithATwist.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /JWithATwist.WiX/Components.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /JWithATwist.WiX/Directories.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /JWithATwist.WiX/JWithATwist.WiX.wixproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 3.10 7 | da0ca381-f715-4201-8f25-0aa7d427eeff 8 | 2.0 9 | JWithATwist-0.13.1 10 | Package 11 | 12 | 13 | 14 | 15 | bin\$(Configuration)\ 16 | obj\$(Configuration)\ 17 | Debug 18 | 19 | 20 | bin\$(Configuration)\ 21 | obj\$(Configuration)\ 22 | -ext WixUIExtension -b C:\Users\erling\Source\Repos\JWithATwist 23 | -arch x64 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | $(WixExtDir)\WixNetFxExtension.dll 33 | WixNetFxExtension 34 | 35 | 36 | 37 | 38 | JWithATwist.Console 39 | {3c623837-231a-47d1-970b-acbfaec4f56a} 40 | True 41 | True 42 | Binaries;Content;Satellites 43 | INSTALLFOLDER 44 | 45 | 46 | JWithATwist.MockInterpreter 47 | {5372d991-f152-4941-aa01-3a04fbd87d76} 48 | True 49 | True 50 | Binaries;Content;Satellites 51 | INSTALLFOLDER 52 | 53 | 54 | JWithATwist 55 | {0f2dada6-c9e9-4b12-8a14-e732166b3458} 56 | True 57 | True 58 | Binaries;Content;Satellites 59 | INSTALLFOLDER 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 75 | -------------------------------------------------------------------------------- /JWithATwist.WiX/Product.wxs: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /JWithATwist.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.8 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JWithATwist", "JWithATwist\JWithATwist.fsproj", "{0F2DADA6-C9E9-4B12-8A14-E732166B3458}" 7 | EndProject 8 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JWithATwist.Test", "JWithATwist.Test\JWithATwist.Test.fsproj", "{D62538F9-589E-4DBD-82A3-44F1C78ADE35}" 9 | EndProject 10 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JWithATwist.PerformanceTest", "JWithATwist.PerformanceTest\JWithATwist.PerformanceTest.fsproj", "{EED8F820-457B-4871-99C6-5493CFB9463D}" 11 | EndProject 12 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JWithATwist.Console", "JWithATwist.Console\JWithATwist.Console.fsproj", "{3C623837-231A-47D1-970B-ACBFAEC4F56A}" 13 | EndProject 14 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JWithATwist.MockInterpreter", "JWithATwist.MockInterpreter\JWithATwist.MockInterpreter.fsproj", "{5372D991-F152-4941-AA01-3A04FBD87D76}" 15 | EndProject 16 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "JWithATwist.WiX", "JWithATwist.WiX\JWithATwist.WiX.wixproj", "{DA0CA381-F715-4201-8F25-0AA7D427EEFF}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | CD_ROM|Any CPU = CD_ROM|Any CPU 21 | CD_ROM|x64 = CD_ROM|x64 22 | CD_ROM|x86 = CD_ROM|x86 23 | Debug|Any CPU = Debug|Any CPU 24 | Debug|x64 = Debug|x64 25 | Debug|x86 = Debug|x86 26 | DVD-5|Any CPU = DVD-5|Any CPU 27 | DVD-5|x64 = DVD-5|x64 28 | DVD-5|x86 = DVD-5|x86 29 | Release|Any CPU = Release|Any CPU 30 | Release|x64 = Release|x64 31 | Release|x86 = Release|x86 32 | SingleImage|Any CPU = SingleImage|Any CPU 33 | SingleImage|x64 = SingleImage|x64 34 | SingleImage|x86 = SingleImage|x86 35 | EndGlobalSection 36 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 37 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 38 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 39 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|x64.ActiveCfg = Release|x64 40 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|x64.Build.0 = Release|x64 41 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|x86.ActiveCfg = Debug|Any CPU 42 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.CD_ROM|x86.Build.0 = Debug|Any CPU 43 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|x64.ActiveCfg = Debug|x64 46 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|x64.Build.0 = Debug|x64 47 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|x86.ActiveCfg = Debug|Any CPU 48 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Debug|x86.Build.0 = Debug|Any CPU 49 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 50 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 51 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|x64.ActiveCfg = Debug|x64 52 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|x64.Build.0 = Debug|x64 53 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|x86.ActiveCfg = Debug|Any CPU 54 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.DVD-5|x86.Build.0 = Debug|Any CPU 55 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|Any CPU.ActiveCfg = Release|Any CPU 56 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|Any CPU.Build.0 = Release|Any CPU 57 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|x64.ActiveCfg = Release|x64 58 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|x64.Build.0 = Release|x64 59 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|x86.ActiveCfg = Release|Any CPU 60 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.Release|x86.Build.0 = Release|Any CPU 61 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 62 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|Any CPU.Build.0 = Release|Any CPU 63 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|x64.ActiveCfg = Release|x64 64 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|x64.Build.0 = Release|x64 65 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|x86.ActiveCfg = Debug|Any CPU 66 | {0F2DADA6-C9E9-4B12-8A14-E732166B3458}.SingleImage|x86.Build.0 = Debug|Any CPU 67 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 68 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 69 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|x64.ActiveCfg = Release|x64 70 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|x64.Build.0 = Release|x64 71 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|x86.ActiveCfg = Debug|Any CPU 72 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.CD_ROM|x86.Build.0 = Debug|Any CPU 73 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 74 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|Any CPU.Build.0 = Debug|Any CPU 75 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|x64.ActiveCfg = Debug|x64 76 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|x64.Build.0 = Debug|x64 77 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|x86.ActiveCfg = Debug|Any CPU 78 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Debug|x86.Build.0 = Debug|Any CPU 79 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 80 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 81 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|x64.ActiveCfg = Debug|x64 82 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|x64.Build.0 = Debug|x64 83 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|x86.ActiveCfg = Debug|Any CPU 84 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.DVD-5|x86.Build.0 = Debug|Any CPU 85 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|Any CPU.ActiveCfg = Release|Any CPU 86 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|Any CPU.Build.0 = Release|Any CPU 87 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|x64.ActiveCfg = Release|x64 88 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|x64.Build.0 = Release|x64 89 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|x86.ActiveCfg = Release|Any CPU 90 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.Release|x86.Build.0 = Release|Any CPU 91 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 92 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|Any CPU.Build.0 = Release|Any CPU 93 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|x64.ActiveCfg = Release|x64 94 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|x64.Build.0 = Release|x64 95 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|x86.ActiveCfg = Debug|Any CPU 96 | {D62538F9-589E-4DBD-82A3-44F1C78ADE35}.SingleImage|x86.Build.0 = Debug|Any CPU 97 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 98 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 99 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|x64.ActiveCfg = Release|x64 100 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|x64.Build.0 = Release|x64 101 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|x86.ActiveCfg = Debug|Any CPU 102 | {EED8F820-457B-4871-99C6-5493CFB9463D}.CD_ROM|x86.Build.0 = Debug|Any CPU 103 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 104 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|Any CPU.Build.0 = Debug|Any CPU 105 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|x64.ActiveCfg = Debug|x64 106 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|x64.Build.0 = Debug|x64 107 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|x86.ActiveCfg = Debug|Any CPU 108 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Debug|x86.Build.0 = Debug|Any CPU 109 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 110 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 111 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|x64.ActiveCfg = Debug|x64 112 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|x64.Build.0 = Debug|x64 113 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|x86.ActiveCfg = Debug|Any CPU 114 | {EED8F820-457B-4871-99C6-5493CFB9463D}.DVD-5|x86.Build.0 = Debug|Any CPU 115 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|Any CPU.ActiveCfg = Release|Any CPU 116 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|Any CPU.Build.0 = Release|Any CPU 117 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|x64.ActiveCfg = Release|x64 118 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|x64.Build.0 = Release|x64 119 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|x86.ActiveCfg = Release|Any CPU 120 | {EED8F820-457B-4871-99C6-5493CFB9463D}.Release|x86.Build.0 = Release|Any CPU 121 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 122 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|Any CPU.Build.0 = Release|Any CPU 123 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|x64.ActiveCfg = Release|x64 124 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|x64.Build.0 = Release|x64 125 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|x86.ActiveCfg = Debug|Any CPU 126 | {EED8F820-457B-4871-99C6-5493CFB9463D}.SingleImage|x86.Build.0 = Debug|Any CPU 127 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 128 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 129 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|x64.ActiveCfg = Release|x64 130 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|x64.Build.0 = Release|x64 131 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|x86.ActiveCfg = Debug|Any CPU 132 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.CD_ROM|x86.Build.0 = Debug|Any CPU 133 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 134 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|Any CPU.Build.0 = Debug|Any CPU 135 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|x64.ActiveCfg = Debug|x64 136 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|x64.Build.0 = Debug|x64 137 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|x86.ActiveCfg = Debug|Any CPU 138 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Debug|x86.Build.0 = Debug|Any CPU 139 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 140 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 141 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|x64.ActiveCfg = Debug|x64 142 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|x64.Build.0 = Debug|x64 143 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|x86.ActiveCfg = Debug|Any CPU 144 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.DVD-5|x86.Build.0 = Debug|Any CPU 145 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|Any CPU.ActiveCfg = Release|Any CPU 146 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|Any CPU.Build.0 = Release|Any CPU 147 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|x64.ActiveCfg = Release|x64 148 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|x64.Build.0 = Release|x64 149 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|x86.ActiveCfg = Release|Any CPU 150 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.Release|x86.Build.0 = Release|Any CPU 151 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 152 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|Any CPU.Build.0 = Release|Any CPU 153 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|x64.ActiveCfg = Release|x64 154 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|x64.Build.0 = Release|x64 155 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|x86.ActiveCfg = Debug|Any CPU 156 | {3C623837-231A-47D1-970B-ACBFAEC4F56A}.SingleImage|x86.Build.0 = Debug|Any CPU 157 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 158 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 159 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|x64.ActiveCfg = Release|x64 160 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|x64.Build.0 = Release|x64 161 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|x86.ActiveCfg = Debug|Any CPU 162 | {5372D991-F152-4941-AA01-3A04FBD87D76}.CD_ROM|x86.Build.0 = Debug|Any CPU 163 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 164 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|Any CPU.Build.0 = Debug|Any CPU 165 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|x64.ActiveCfg = Debug|x64 166 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|x64.Build.0 = Debug|x64 167 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|x86.ActiveCfg = Debug|Any CPU 168 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Debug|x86.Build.0 = Debug|Any CPU 169 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 170 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 171 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|x64.ActiveCfg = Debug|x64 172 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|x64.Build.0 = Debug|x64 173 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|x86.ActiveCfg = Debug|Any CPU 174 | {5372D991-F152-4941-AA01-3A04FBD87D76}.DVD-5|x86.Build.0 = Debug|Any CPU 175 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|Any CPU.ActiveCfg = Release|Any CPU 176 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|Any CPU.Build.0 = Release|Any CPU 177 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|x64.ActiveCfg = Release|x64 178 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|x64.Build.0 = Release|x64 179 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|x86.ActiveCfg = Release|Any CPU 180 | {5372D991-F152-4941-AA01-3A04FBD87D76}.Release|x86.Build.0 = Release|Any CPU 181 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 182 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|Any CPU.Build.0 = Release|Any CPU 183 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|x64.ActiveCfg = Release|x64 184 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|x64.Build.0 = Release|x64 185 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|x86.ActiveCfg = Debug|Any CPU 186 | {5372D991-F152-4941-AA01-3A04FBD87D76}.SingleImage|x86.Build.0 = Debug|Any CPU 187 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|Any CPU.ActiveCfg = Release|x86 188 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|Any CPU.Build.0 = Release|x86 189 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|x64.ActiveCfg = Release|x86 190 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|x64.Build.0 = Release|x86 191 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|x86.ActiveCfg = Release|x86 192 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.CD_ROM|x86.Build.0 = Release|x86 193 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Debug|Any CPU.ActiveCfg = Debug|x86 194 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Debug|x64.ActiveCfg = Debug|x86 195 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Debug|x86.ActiveCfg = Debug|x86 196 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Debug|x86.Build.0 = Debug|x86 197 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|Any CPU.ActiveCfg = Release|x86 198 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|Any CPU.Build.0 = Release|x86 199 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|x64.ActiveCfg = Release|x86 200 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|x64.Build.0 = Release|x86 201 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|x86.ActiveCfg = Debug|x86 202 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.DVD-5|x86.Build.0 = Debug|x86 203 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Release|Any CPU.ActiveCfg = Release|x86 204 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Release|x64.ActiveCfg = Release|x86 205 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Release|x86.ActiveCfg = Release|x86 206 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.Release|x86.Build.0 = Release|x86 207 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|Any CPU.ActiveCfg = Release|x86 208 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|Any CPU.Build.0 = Release|x86 209 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|x64.ActiveCfg = Release|x86 210 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|x64.Build.0 = Release|x86 211 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|x86.ActiveCfg = Release|x86 212 | {DA0CA381-F715-4201-8F25-0AA7D427EEFF}.SingleImage|x86.Build.0 = Release|x86 213 | EndGlobalSection 214 | GlobalSection(SolutionProperties) = preSolution 215 | HideSolutionNode = FALSE 216 | EndGlobalSection 217 | GlobalSection(ExtensibilityGlobals) = postSolution 218 | SolutionGuid = {17AFA4AF-9718-4EB0-B051-465DC7E912FD} 219 | EndGlobalSection 220 | EndGlobal 221 | -------------------------------------------------------------------------------- /JWithATwist/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | namespace JWithATwist.AssemblyInfo 2 | 3 | open System.Reflection 4 | open System.Runtime.CompilerServices 5 | open System.Runtime.InteropServices 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [] 11 | [] 12 | [] 13 | [] 14 | [] 15 | [] 16 | [] 17 | [] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [] 37 | [] 38 | [] 39 | 40 | do 41 | () -------------------------------------------------------------------------------- /JWithATwist/Define.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist 19 | 20 | open JWithATwist.Base 21 | 22 | open JWithATwist.ParserDefinitions 23 | open JWithATwist.ParserInterface 24 | open JWithATwist.Parser 25 | 26 | open System 27 | open System.Text 28 | open System.IO 29 | open System.Diagnostics 30 | open FParsec 31 | open Operators.Checked 32 | 33 | 34 | module Define = 35 | 36 | let JNounDefine (nounDefinition:String) :JNoun = 37 | let resultOption = parseAllSpeach (nounDefinition+" ") 38 | match resultOption with 39 | | Success(result, _, rest) -> 40 | match result with 41 | |[parseResult] -> 42 | match parseResult with 43 | |{Value=TypeNounUnit f} -> 44 | f () 45 | |_ -> 46 | raise JExceptionDomainError 47 | |_ -> 48 | raise JExceptionSystemError 49 | |_ -> 50 | raise JExceptionSyntaxError 51 | 52 | 53 | let JVerbMonadicDefine (verbDefinition:String) :JVerbMonadic = 54 | let resultOption = parseAllSpeach (verbDefinition+" ") 55 | match resultOption with 56 | | Success(result, _, rest) -> 57 | match result with 58 | |[parseResult] -> 59 | match parseResult with 60 | |{Value=TypeVerbMonadic f} -> 61 | f 62 | |_ -> 63 | raise JExceptionDomainError 64 | |_ -> 65 | raise JExceptionSystemError 66 | |_ -> 67 | raise JExceptionSyntaxError 68 | 69 | let JVerbDyadicDefine (verbDefinition:String) :JVerbDyadic = 70 | let resultOption = parseAllSpeach (verbDefinition+" ") 71 | match resultOption with 72 | | Success(result, _, rest) -> 73 | match result with 74 | |[parseResult] -> 75 | match parseResult with 76 | |{Value=TypeVerbDyadic f} -> 77 | f 78 | |_ -> 79 | raise JExceptionDomainError 80 | |_ -> 81 | raise JExceptionSystemError 82 | |_ -> 83 | raise JExceptionSyntaxError -------------------------------------------------------------------------------- /JWithATwist/GPLv3.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Calibri;}{\f2\fnil\fcharset2 Symbol;}} 2 | {\colortbl ;\red0\green0\blue255;} 3 | {\*\generator Riched20 10.0.10586}\viewkind4\uc1 4 | \pard\keepn\sb100\sa100\b\f0\fs28\lang1053 GNU AFFERO GENERAL PUBLIC LICENSE\par 5 | 6 | \pard\sb100\sa100\b0\fs24 Version 3, 19 November 2007\par 7 | Copyright \'a9 2007 Free Software Foundation, Inc. <{{\field{\*\fldinst{HYPERLINK "http://fsf.org/"}}{\fldrslt{http://fsf.org/\ul0\cf0}}}}\f0\fs24 > \line Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\par 8 | 9 | \pard\keepn\sb100\sa100\b\fs28 Preamble\par 10 | 11 | \pard\sb100\sa100\b0\fs24 The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.\par 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\par 13 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\par 14 | Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.\par 15 | A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.\par 16 | The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.\par 17 | An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.\par 18 | The precise terms and conditions for copying, distribution and modification follow.\par 19 | 20 | \pard\keepn\sb100\sa100\b\fs28 TERMS AND CONDITIONS\par 21 | \fs24 0. Definitions.\par 22 | 23 | \pard\sb100\sa100\b0 "This License" refers to version 3 of the GNU Affero General Public License.\par 24 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\par 25 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.\par 26 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.\par 27 | A "covered work" means either the unmodified Program or a work based on the Program.\par 28 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\par 29 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\par 30 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\par 31 | 32 | \pard\keepn\sb100\sa100\b 1. Source Code.\par 33 | 34 | \pard\sb100\sa100\b0 The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.\par 35 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\par 36 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\par 37 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\par 38 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\par 39 | The Corresponding Source for a work in source code form is that same work.\par 40 | 41 | \pard\keepn\sb100\sa100\b 2. Basic Permissions.\par 42 | 43 | \pard\sb100\sa100\b0 All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\par 44 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\par 45 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\par 46 | 47 | \pard\keepn\sb100\sa100\b 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\par 48 | 49 | \pard\sb100\sa100\b0 No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\par 50 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.\par 51 | 52 | \pard\keepn\sb100\sa100\b 4. Conveying Verbatim Copies.\par 53 | 54 | \pard\sb100\sa100\b0 You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\par 55 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\par 56 | 57 | \pard\keepn\sb100\sa100\b 5. Conveying Modified Source Versions.\par 58 | 59 | \pard\sb100\sa100\b0 You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\par 60 | 61 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) The work must carry prominent notices stating that you modified it, and giving a relevant date. \par 62 | {\pntext\f2\'B7\tab}b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". \par 63 | {\pntext\f2\'B7\tab}c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. \par 64 | {\pntext\f2\'B7\tab}d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\par 65 | 66 | \pard\sb100\sa100 A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\par 67 | 68 | \pard\keepn\sb100\sa100\b 6. Conveying Non-Source Forms.\par 69 | 70 | \pard\sb100\sa100\b0 You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\par 71 | 72 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. \par 73 | {\pntext\f2\'B7\tab}b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. \par 74 | {\pntext\f2\'B7\tab}c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. \par 75 | {\pntext\f2\'B7\tab}d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. \par 76 | {\pntext\f2\'B7\tab}e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\par 77 | 78 | \pard\sb100\sa100 A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\par 79 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\par 80 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\par 81 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\par 82 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\par 83 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\par 84 | 85 | \pard\keepn\sb100\sa100\b 7. Additional Terms.\par 86 | 87 | \pard\sb100\sa100\b0 "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\par 88 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\par 89 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\par 90 | 91 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or \par 92 | {\pntext\f2\'B7\tab}b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or \par 93 | {\pntext\f2\'B7\tab}c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or \par 94 | {\pntext\f2\'B7\tab}d) Limiting the use for publicity purposes of names of licensors or authors of the material; or \par 95 | {\pntext\f2\'B7\tab}e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or \par 96 | {\pntext\f2\'B7\tab}f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\par 97 | 98 | \pard\sb100\sa100 All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\par 99 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\par 100 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\par 101 | 102 | \pard\keepn\sb100\sa100\b 8. Termination.\par 103 | 104 | \pard\sb100\sa100\b0 You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\par 105 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\par 106 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\par 107 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\par 108 | 109 | \pard\keepn\sb100\sa100\b 9. Acceptance Not Required for Having Copies.\par 110 | 111 | \pard\sb100\sa100\b0 You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\par 112 | 113 | \pard\keepn\sb100\sa100\b 10. Automatic Licensing of Downstream Recipients.\par 114 | 115 | \pard\sb100\sa100\b0 Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\par 116 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\par 117 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\par 118 | 119 | \pard\keepn\sb100\sa100\b 11. Patents.\par 120 | 121 | \pard\sb100\sa100\b0 A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".\par 122 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\par 123 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\par 124 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\par 125 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\par 126 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\par 127 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\par 128 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\par 129 | 130 | \pard\keepn\sb100\sa100\b 12. No Surrender of Others' Freedom.\par 131 | 132 | \pard\sb100\sa100\b0 If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\par 133 | 134 | \pard\keepn\sb100\sa100\b 13. Remote Network Interaction; Use with the GNU General Public License.\par 135 | 136 | \pard\sb100\sa100\b0 Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.\par 137 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.\par 138 | 139 | \pard\keepn\sb100\sa100\b 14. Revised Versions of this License.\par 140 | 141 | \pard\sb100\sa100\b0 The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\par 142 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.\par 143 | If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\par 144 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\par 145 | 146 | \pard\keepn\sb100\sa100\b 15. Disclaimer of Warranty.\par 147 | 148 | \pard\sb100\sa100\b0 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\par 149 | 150 | \pard\keepn\sb100\sa100\b 16. Limitation of Liability.\par 151 | 152 | \pard\sb100\sa100\b0 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\par 153 | 154 | \pard\keepn\sb100\sa100\b 17. Interpretation of Sections 15 and 16.\par 155 | 156 | \pard\sb100\sa100\b0 If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\par 157 | END OF TERMS AND CONDITIONS\f1\fs22\lang9\par 158 | } 159 | -------------------------------------------------------------------------------- /JWithATwist/JWithATwist.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 2.0 8 | 0f2dada6-c9e9-4b12-8a14-e732166b3458 9 | Library 10 | JWithATwist 11 | JWithATwist 12 | v4.6 13 | 4.4.0.0 14 | true 15 | JWithATwist 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | 3 26 | bin\Debug\JWithATwist.XML 27 | 28 | 29 | pdbonly 30 | true 31 | true 32 | bin\Release\ 33 | TRACE 34 | 3 35 | bin\Release\JWithATwist.XML 36 | 37 | 38 | 11 39 | 40 | 41 | true 42 | full 43 | false 44 | false 45 | bin\Debug\ 46 | DEBUG;TRACE 47 | 3 48 | bin\Debug\JWithATwist.XML 49 | x64 50 | 51 | 52 | pdbonly 53 | true 54 | true 55 | bin\Release\ 56 | TRACE 57 | 3 58 | bin\Release\JWithATwist.XML 59 | x64 60 | 61 | 62 | 63 | 64 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets 65 | 66 | 67 | 68 | 69 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsec.dll 98 | True 99 | 100 | 101 | ..\packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll 102 | True 103 | 104 | 105 | 106 | True 107 | 108 | 109 | 110 | 111 | 112 | 119 | -------------------------------------------------------------------------------- /JWithATwist/JWithATwist.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/JWithATwist.ico -------------------------------------------------------------------------------- /JWithATwist/JWithATwist.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/JWithATwist.xcf -------------------------------------------------------------------------------- /JWithATwist/ParserDefinitions.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist 19 | 20 | open JWithATwist 21 | open JWithATwist.Base 22 | open FParsec 23 | 24 | module ParserDefinitions = 25 | 26 | type Noun = JNoun 27 | type VerbUnit = unit -> unit 28 | //type NounUnit = unit -> Noun 29 | type NounUnit = unit -> JNoun 30 | //type VerbDyadic = Noun -> Noun -> Noun 31 | type VerbDyadic = JVerbDyadic 32 | //type VerbMonadic = Noun -> Noun 33 | type VerbMonadic = JVerbMonadic 34 | //type VerbDyadicUnit = unit -> Noun -> Noun -> Noun 35 | type VerbDyadicUnit = unit -> JVerbDyadic 36 | //type VerbMonadicUnit = unit -> Noun -> Noun 37 | type VerbMonadicUnit = unit -> JVerbMonadic 38 | type AdverbMonadicM = Noun -> VerbMonadic-> Noun 39 | type AdverbMonadicD = Noun -> VerbDyadic-> Noun 40 | type AdverbDyadic = Noun -> Noun -> VerbDyadic-> Noun 41 | type ConjunctionMonadic = Noun -> VerbMonadic -> VerbDyadic -> Noun 42 | type ConjunctionDyadic = Noun -> Noun -> VerbMonadic -> VerbDyadic -> Noun 43 | type ParseResult = 44 | { 45 | Value: ValueDU 46 | } 47 | and ValueDU = 48 | |TypeNounUnit of NounUnit 49 | |TypeVerbUnit of VerbUnit 50 | |TypeVerbMonadicUnit of VerbMonadicUnit 51 | |TypeVerbDyadicUnit of VerbDyadicUnit 52 | |TypeUnitUnit of VerbUnit 53 | |TypeODStart of unit 54 | |TypePStart of unit 55 | |TypeNoun of Noun 56 | |TypeVerbDyadic of VerbDyadic 57 | |TypeVerbMonadic of VerbMonadic 58 | |TypeNounFunctionDyadic of VerbDyadic 59 | |TypeNounFunctionMonadic of VerbMonadic 60 | |TypeAdverbMonadicM of AdverbMonadicM 61 | |TypeAdverbMonadicD of AdverbMonadicD 62 | |TypeAdverbDyadic of AdverbDyadic 63 | |TypeConjunctionMonadic of ConjunctionMonadic 64 | |TypeConjunctionDyadic of ConjunctionDyadic 65 | 66 | 67 | type ParseResultList = ParseResult list 68 | 69 | exception ExceptionRankError 70 | exception ExceptionSyntaxError 71 | exception ExceptionDomainError 72 | exception ExceptionSystemError 73 | exception ExceptionValueError 74 | exception ExceptionLengthError 75 | exception ExceptionNotYetImplemented 76 | 77 | let parseStart:Parser = 78 | let (parseResultList:ParseResultList) = [] 79 | (preturn parseResultList) 80 | 81 | -------------------------------------------------------------------------------- /JWithATwist/ParserInterface.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist 19 | //module Parser 20 | open FParsec 21 | open ParserDefinitions 22 | open Base 23 | open Checked 24 | 25 | module ParserInterface = 26 | 27 | let setNounInteger (x:int64 list) :Noun= 28 | let rValue = List.toArray x 29 | let rShape = 30 | match rValue.Length with 31 | |1 -> 32 | [||] 33 | |_ -> 34 | [|rValue.Length|] 35 | {JType=JTBType.JTypeInteger;JShape=rShape;JValue=JTypeIntegerArray rValue} 36 | 37 | let setNounFloat (x:float list) :Noun= 38 | let rValue = List.toArray x 39 | let rShape = 40 | match rValue.Length with 41 | |1 -> 42 | [||] 43 | |_ -> 44 | [|rValue.Length|] 45 | {JType=JTBType.JTypeFloat;JShape=rShape;JValue=JTypeFloatArray rValue} 46 | 47 | let setNounBoolean (x:bool list) :Noun= 48 | let rValue = List.toArray x 49 | let rShape = 50 | match rValue.Length with 51 | |1 -> 52 | [||] 53 | |_ -> 54 | [|rValue.Length|] 55 | {JType=JTBType.JTypeBoolean;JShape=rShape;JValue=JTypeBooleanArray rValue} 56 | 57 | let setNounUnicode (x:string) :Noun= 58 | let rValue = Array.ofSeq x 59 | let rShape = 60 | match rValue.Length with 61 | |1 -> 62 | [||] 63 | |_ -> 64 | [|rValue.Length|] 65 | {JType=JTBType.JTypeUnicode;JShape=rShape;JValue=JTypeUnicodeArray rValue} 66 | 67 | let setNounBoxed (x:Noun list) :Noun= 68 | let rValue = Array.ofSeq x 69 | let rShape = 70 | match rValue.Length with 71 | |1 -> 72 | [||] 73 | |_ -> 74 | [|rValue.Length|] 75 | {JType=JTBType.JTypeBoxed;JShape=rShape;JValue=JTypeBoxedArray rValue} 76 | 77 | 78 | let parseNounInteger = 79 | ((attempt (many1 (( pint64) .>> ((pchar ' ') .>> spaces)) ))|>>setNounInteger) 80 | 81 | let parseNounFloat = 82 | ( (many1 (( pfloat) .>> ((pchar ' ') .>> spaces)) )|>>setNounFloat) 83 | 84 | let parseNounBoolean = 85 | ( (many1 ( 86 | ( 87 | (( pstring "true")>>. preturn true) 88 | <|> 89 | (( pstring "false")>>. preturn false) 90 | ) .>> ((pchar ' ') .>> spaces)) )|>>setNounBoolean) 91 | 92 | let parseNounUnicode = 93 | let parseStringPart = 94 | ( (pchar '\"') >>. (manyCharsTill anyChar (pchar '\"')) ) 95 | let parseString = 96 | (many1 parseStringPart)|>>(fun x -> String.concat "\"" x)|>>setNounUnicode 97 | (many1 ( parseString .>> ( (pchar ' ') .>> spaces)))|>>setNounBoxed 98 | 99 | 100 | let parseNoun:Parser = 101 | (parseStart 102 | .>>. 103 | ( 104 | parseNounInteger 105 | <|> 106 | parseNounBoolean 107 | <|> 108 | parseNounUnicode 109 | <|> 110 | parseNounFloat 111 | )|>> (fun (x,y) -> y) 112 | ) 113 | 114 | 115 | let setPRNoun (x:Noun) : ParseResult = 116 | let f () = x 117 | {Value= TypeNounUnit f} 118 | 119 | //let setPRAddInteger x = 120 | // {Value = TypeVerbDyadic JAdd} 121 | 122 | //Monadic verbs 123 | //Negate 124 | let setPRNegate x = 125 | {Value = TypeVerbMonadic JNegate} 126 | 127 | let parseNegate:Parser = 128 | ((pstring "|- ") .>> spaces) 129 | 130 | //Magnitude 131 | let setPRMagnitude x = 132 | {Value = TypeVerbMonadic JMagnitude} 133 | 134 | let parseMagnitude:Parser = 135 | ((pstring "|| ") .>> spaces) 136 | 137 | 138 | //Not 139 | let setPRNot x = 140 | {Value = TypeVerbMonadic JNot} 141 | 142 | let parseNot:Parser = 143 | ((pstring "|-. ") .>> spaces) 144 | 145 | //Signum 146 | let setPRSignum x = 147 | {Value = TypeVerbMonadic JSignum} 148 | 149 | let parseSignum:Parser = 150 | ((pstring "|* ") .>> spaces) 151 | 152 | //Floor 153 | let setPRFloor x = 154 | {Value = TypeVerbMonadic JFloor} 155 | 156 | let parseFloor:Parser = 157 | ((pstring "|<. ") .>> spaces) 158 | 159 | //Ceiling 160 | let setPRCeiling x = 161 | {Value = TypeVerbMonadic JCeiling} 162 | 163 | let parseCeiling:Parser = 164 | ((pstring "|>. ") .>> spaces) 165 | 166 | //Monadic Iota 167 | let setPRIotaMonadic x = 168 | {Value = TypeVerbMonadic JIotaMonadic} 169 | 170 | let parseIotaMonadic:Parser = 171 | ((pstring "|i. ") .>> spaces) 172 | 173 | //ShapeOf 174 | let setPRShapeOf x = 175 | {Value = TypeVerbMonadic JShapeOf} 176 | 177 | let parseShapeOf:Parser = 178 | ((pstring "|$ ") .>> spaces) 179 | 180 | //Ravel 181 | let setPRRavel x = 182 | {Value = TypeVerbMonadic JRavel} 183 | 184 | let parseRavel:Parser = 185 | ((pstring "|, ") .>> spaces) 186 | 187 | //Tally 188 | let setPRTally x = 189 | {Value = TypeVerbMonadic JTally} 190 | 191 | let parseTally:Parser = 192 | ((pstring "|# ") .>> spaces) 193 | 194 | //Bti 195 | let setPRBti x = 196 | {Value = TypeVerbMonadic JBti} 197 | 198 | let parseBti:Parser = 199 | ((pstring "|_ ") .>> spaces) 200 | 201 | //Reciprocal 202 | let setPRReciprocal x = 203 | {Value = TypeVerbMonadic JReciprocal} 204 | 205 | let parseReciprocal:Parser = 206 | ((pstring "|% ") .>> spaces) 207 | 208 | //Box 209 | let setPRBox x = 210 | {Value = TypeVerbMonadic JBox} 211 | 212 | let parseBox:Parser = 213 | ((pstring "|< ") .>> spaces) 214 | 215 | //Open 216 | let setPROpen x = 217 | {Value = TypeVerbMonadic JOpen} 218 | 219 | let parseOpen:Parser = 220 | ((pstring "|> ") .>> spaces) 221 | 222 | //Open 223 | let setPRGradeUp x = 224 | {Value = TypeVerbMonadic JGradeUp} 225 | 226 | let parseGradeUp:Parser = 227 | ((pstring "|/: ") .>> spaces) 228 | 229 | //Default format 230 | let setPRDefaultFormat x = 231 | {Value = TypeVerbMonadic JDefaultFormat} 232 | 233 | let parseDefaultFormat:Parser = 234 | ((pstring "|\': ") .>> spaces) 235 | 236 | 237 | //Dyadic verbs 238 | // Add 239 | 240 | let setPRAdd x = 241 | {Value = TypeVerbDyadic JAdd} 242 | 243 | let parseAdd:Parser = 244 | ((pstring "+ ") .>> spaces) 245 | 246 | // Subtract 247 | 248 | let setPRSubtract x = 249 | {Value = TypeVerbDyadic JSubtract} 250 | 251 | let parseSubtract:Parser = 252 | ((pstring "- ") .>> spaces) 253 | 254 | // Times 255 | 256 | let setPRTimes x = 257 | {Value = TypeVerbDyadic JTimes} 258 | 259 | let parseTimes:Parser = 260 | ((pstring "* ") .>> spaces) 261 | 262 | // Divide 263 | 264 | let setPRDivide x = 265 | {Value = TypeVerbDyadic JDivide} 266 | 267 | let parseDivide:Parser = 268 | ((pstring "% ") .>> spaces) 269 | 270 | // Power 271 | 272 | let setPRPower x = 273 | {Value = TypeVerbDyadic JPower} 274 | 275 | let parsePower:Parser = 276 | ((pstring "^ ") .>> spaces) 277 | 278 | // Min 279 | 280 | let setPRMin x = 281 | {Value = TypeVerbDyadic JMin} 282 | 283 | let parseMin:Parser = 284 | ((pstring "<. ") .>> spaces) 285 | 286 | // Max 287 | 288 | let setPRMax x = 289 | {Value = TypeVerbDyadic JMax} 290 | 291 | let parseMax:Parser = 292 | ((pstring ">. ") .>> spaces) 293 | 294 | // And 295 | 296 | let setPRAnd x = 297 | {Value = TypeVerbDyadic JAnd} 298 | 299 | let parseAnd:Parser = 300 | ((pstring "*. ") .>> spaces) 301 | 302 | // Or 303 | 304 | let setPROr x = 305 | {Value = TypeVerbDyadic JOr} 306 | 307 | let parseOr:Parser = 308 | ((pstring "+. ") .>> spaces) 309 | 310 | // Equal 311 | 312 | let setPREqual x = 313 | {Value = TypeVerbDyadic JEqual} 314 | 315 | let parseEqual:Parser = 316 | ((pstring "= ") .>> spaces) 317 | 318 | // Not Equal 319 | 320 | let setPRNotEqual x = 321 | {Value = TypeVerbDyadic JNotEqual} 322 | 323 | let parseNotEqual:Parser = 324 | ((pstring "~: ") .>> spaces) 325 | 326 | // LessThan 327 | 328 | let setPRLessThan x = 329 | {Value = TypeVerbDyadic JLessThan} 330 | 331 | let parseLessThan:Parser = 332 | ((pstring "< ") .>> spaces) 333 | 334 | // LargerThan 335 | 336 | let setPRLargerThan x = 337 | {Value = TypeVerbDyadic JLargerThan} 338 | 339 | let parseLargerThan:Parser = 340 | ((pstring "> ") .>> spaces) 341 | 342 | // LessOrEqual 343 | 344 | let setPRLessOrEqual x = 345 | {Value = TypeVerbDyadic JLessOrEqual} 346 | 347 | let parseLessOrEqual:Parser = 348 | ((pstring "<: ") .>> spaces) 349 | 350 | // LargerOrEqual 351 | 352 | let setPRLargerOrEqual x = 353 | {Value = TypeVerbDyadic JLargerOrEqual} 354 | 355 | let parseLargerOrEqual:Parser = 356 | ((pstring ">: ") .>> spaces) 357 | 358 | //Shape 359 | let setPRShapeDyadic x = 360 | {Value = TypeVerbDyadic JShape} 361 | 362 | let parseShapeDyadic:Parser = 363 | ((pstring "$ ") .>> spaces) 364 | 365 | //Take 366 | let setPRTake x = 367 | {Value = TypeVerbDyadic JTake} 368 | 369 | let parseTake:Parser = 370 | ((pstring "<.- ") .>> spaces) 371 | 372 | //Drop 373 | let setPRDrop x = 374 | {Value = TypeVerbDyadic JDrop} 375 | 376 | let parseDrop:Parser = 377 | ((pstring ">.- ") .>> spaces) 378 | 379 | //Catenate 380 | let setPRCatenate x = 381 | {Value = TypeVerbDyadic JCatenate} 382 | 383 | let parseCatenate:Parser = 384 | ((pstring ", ") .>> spaces) 385 | 386 | //From 387 | let setPRFrom x = 388 | {Value = TypeVerbDyadic JFrom} 389 | 390 | let parseFrom:Parser = 391 | ((pstring "<- ") .>> spaces) 392 | 393 | //Amend 394 | let setPRAmend x = 395 | {Value = TypeVerbDyadic JAmend} 396 | 397 | let parseAmend:Parser = 398 | ((pstring ">- ") .>> spaces) 399 | 400 | //Select 401 | let setPRSelect x = 402 | {Value = TypeVerbDyadic JSelect} 403 | 404 | let parseSelect:Parser = 405 | ((pstring "/:: ") .>> spaces) 406 | 407 | //Replicate 408 | let setPRReplicate x = 409 | {Value = TypeVerbDyadic JReplicate} 410 | 411 | let parseReplicate:Parser = 412 | ((pstring "# ") .>> spaces) 413 | 414 | //Dyadic Iota 415 | let setPRIotaDyadic x = 416 | {Value = TypeVerbDyadic JIotaDyadic} 417 | 418 | let parseIotaDyadic:Parser = 419 | ((pstring "i. ") .>> spaces) 420 | 421 | //Transpose 422 | let setPRTranspose x = 423 | {Value = TypeVerbDyadic JTranspose} 424 | 425 | let parseTranspose:Parser = 426 | ((pstring "\:: ") .>> spaces) 427 | 428 | //Monadic adverbs 429 | //Monadic Rank 430 | let setPRRankMonadic (n:Noun) = 431 | let f (y:Noun) (u:VerbMonadic) : Noun = JRankMonadic y u n 432 | {Value = TypeAdverbMonadicM f} 433 | 434 | let parseRankMonadic:Parser = 435 | ((pstring "|\'/ ") >>. ( parseNounInteger ) .>> (pstring"/ ").>> spaces) 436 | 437 | 438 | 439 | //Dyadic adverbs 440 | //Dyadic Rank 441 | let setPRRankDyadic (n:Noun) = 442 | let f (x:Noun) (y:Noun) (u:VerbDyadic) : Noun = JRankDyadic x y u n 443 | {Value = TypeAdverbDyadic f} 444 | 445 | let parseRankDyadic:Parser = 446 | ((pstring "\'/ ") >>. ( parseNounInteger ) .>> (pstring"/ ").>> spaces) 447 | 448 | //Dyadic Fold 449 | let setPRFold x = 450 | let f (x:Noun) (y:Noun) (u:VerbDyadic) : Noun = JFold x y u 451 | {Value = TypeAdverbDyadic f} 452 | 453 | let parseFold:Parser = 454 | ((pstring "/ ") .>> spaces) 455 | 456 | //Dyadic Scan 457 | let setPRScan x = 458 | let f (x:Noun) (y:Noun) (u:VerbDyadic) : Noun = JScan x y u 459 | {Value = TypeAdverbDyadic f} 460 | 461 | let parseScan:Parser = 462 | ((pstring @"\ ") .>> spaces) 463 | 464 | 465 | 466 | let parseVerbAdverbConjunction = 467 | ( 468 | //Monadic verbs 469 | (parseNegate|>>setPRNegate) 470 | <|> 471 | (parseMagnitude|>>setPRMagnitude) 472 | <|> 473 | (parseNot|>>setPRNot) 474 | <|> 475 | (parseReciprocal|>>setPRReciprocal) 476 | <|> 477 | (parseBox|>>setPRBox) 478 | <|> 479 | (parseOpen|>>setPROpen) 480 | <|> 481 | (parseIotaMonadic|>>setPRIotaMonadic) 482 | <|> 483 | (parseShapeOf|>>setPRShapeOf) 484 | <|> 485 | (parseRavel|>>setPRRavel) 486 | <|> 487 | (parseTally|>>setPRTally) 488 | <|> 489 | (parseSignum|>>setPRSignum) 490 | <|> 491 | (parseBti|>>setPRBti) 492 | <|> 493 | (parseFloor|>>setPRFloor) 494 | <|> 495 | (parseCeiling|>>setPRCeiling) 496 | <|> 497 | (parseGradeUp|>>setPRGradeUp) 498 | <|> 499 | (parseDefaultFormat|>>setPRDefaultFormat) 500 | <|> 501 | //Dyadic verbs 502 | // 503 | (parseAdd|>>setPRAdd) 504 | <|> 505 | (parseSubtract|>>setPRSubtract) 506 | <|> 507 | (parseTimes|>>setPRTimes) 508 | <|> 509 | (parseDivide|>>setPRDivide) 510 | <|> 511 | (parsePower|>>setPRPower) 512 | <|> 513 | (parseMin|>>setPRMin) 514 | <|> 515 | (parseMax|>>setPRMax) 516 | <|> 517 | (parseAnd|>>setPRAnd) 518 | <|> 519 | (parseOr|>>setPROr) 520 | <|> 521 | (parseEqual|>>setPREqual) 522 | <|> 523 | (parseNotEqual|>>setPRNotEqual) 524 | <|> 525 | (parseLessThan|>>setPRLessThan) 526 | <|> 527 | (parseLargerThan|>>setPRLargerThan) 528 | <|> 529 | (parseLessOrEqual|>>setPRLessOrEqual) 530 | <|> 531 | (parseLargerOrEqual|>>setPRLargerOrEqual) 532 | <|> 533 | (parseShapeDyadic|>>setPRShapeDyadic) 534 | <|> 535 | (parseTake|>>setPRTake) 536 | <|> 537 | (parseDrop|>>setPRDrop) 538 | <|> 539 | (parseFrom|>>setPRFrom) 540 | <|> 541 | (parseAmend|>>setPRAmend) 542 | <|> 543 | (parseCatenate|>>setPRCatenate) 544 | <|> 545 | (parseSelect|>>setPRSelect) 546 | <|> 547 | (parseReplicate|>>setPRReplicate) 548 | <|> 549 | (parseIotaDyadic|>>setPRIotaDyadic) 550 | <|> 551 | (parseTranspose|>>setPRTranspose) 552 | <|> 553 | //Monadic adverbs 554 | (parseRankMonadic|>>setPRRankMonadic) 555 | <|> 556 | //Dyadic adverbs 557 | (parseRankDyadic|>>setPRRankDyadic) 558 | <|> 559 | (parseFold|>>setPRFold) 560 | <|> 561 | (parseScan|>>setPRScan) 562 | //Dyadic conjunctions 563 | //Monadic conjunctions 564 | ) 565 | 566 | let ParsePrint (parseResult:ParseResult) = 567 | match parseResult with 568 | |{Value=TypeUnitUnit f} -> 569 | printfn "No result" 570 | |{Value=TypeVerbMonadic f} -> 571 | printfn "Monadic verb" 572 | |{Value=TypeVerbDyadic f} -> 573 | printfn "Dyadic verb" 574 | |{Value=TypeAdverbMonadicM f} -> 575 | printfn "Monadic adverb with monadic left verb" 576 | |{Value=TypeAdverbMonadicD f} -> 577 | printfn "Monadic adverb with dyadic left verb" 578 | |{Value=TypeAdverbDyadic f} -> 579 | printfn "Dyadic adverb" 580 | |{Value=TypeConjunctionMonadic f} -> 581 | printfn "Monadic conjunction" 582 | |{Value=TypeConjunctionDyadic f} -> 583 | printfn "Dyadic conjunction" 584 | |{Value=TypeNounUnit f} -> 585 | //let noun = f () 586 | //JPrint noun 587 | try 588 | let noun = f () 589 | JPrint noun 590 | with 591 | | :? JExceptionRankError -> 592 | printfn "Rank error" 593 | | :? JExceptionDomainError -> 594 | printfn "Domain error" 595 | | :? JExceptionSystemError -> 596 | printfn "System error" 597 | | :? JExceptionValueError -> 598 | printfn "Value error" 599 | | :? JExceptionLengthError -> 600 | printfn "Length error" 601 | | :? JExceptionIndexError -> 602 | printfn "Index error" 603 | | :? JExceptionStackFull -> 604 | printfn "Stack full" 605 | | :? JExceptionMemoryFull -> 606 | printfn "Memory full" 607 | | _ as e -> 608 | printfn "%s" e.Message 609 | |_ -> 610 | raise ExceptionSystemError -------------------------------------------------------------------------------- /JWithATwist/ParserMockDefinitions.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist 19 | 20 | open JWithATwist 21 | 22 | module ParserMockDefinitions = 23 | 24 | type Noun = 25 | { 26 | Value: int 27 | } 28 | type VerbUnit = unit -> unit 29 | type NounUnit = unit -> Noun 30 | type VerbDyadic = Noun -> Noun -> Noun 31 | type VerbMonadic = Noun -> Noun 32 | type VerbDyadicUnit = unit -> Noun -> Noun -> Noun 33 | type VerbMonadicUnit = unit -> Noun -> Noun 34 | type AdverbMonadicM = Noun -> VerbMonadic-> Noun 35 | type AdverbMonadicD = Noun -> VerbDyadic-> Noun 36 | type AdverbDyadic = Noun -> Noun -> VerbDyadic-> Noun 37 | type ConjunctionMonadic = Noun -> VerbMonadic -> VerbDyadic -> Noun 38 | type ConjunctionDyadic = Noun -> Noun -> VerbMonadic -> VerbDyadic -> Noun 39 | type ParseResult = 40 | { 41 | Value: ValueDU 42 | } 43 | and ValueDU = 44 | |TypeNounUnit of NounUnit 45 | |TypeVerbUnit of VerbUnit 46 | |TypeVerbMonadicUnit of VerbMonadicUnit 47 | |TypeVerbDyadicUnit of VerbDyadicUnit 48 | |TypeUnitUnit of VerbUnit 49 | |TypeODStart of unit 50 | |TypePStart of unit 51 | |TypeNoun of Noun 52 | |TypeVerbDyadic of VerbDyadic 53 | |TypeVerbMonadic of VerbMonadic 54 | |TypeNounFunctionDyadic of VerbDyadic 55 | |TypeNounFunctionMonadic of VerbMonadic 56 | |TypeAdverbMonadicM of AdverbMonadicM 57 | |TypeAdverbMonadicD of AdverbMonadicD 58 | |TypeAdverbDyadic of AdverbDyadic 59 | |TypeConjunctionMonadic of ConjunctionMonadic 60 | |TypeConjunctionDyadic of ConjunctionDyadic 61 | 62 | 63 | type ParseResultList = ParseResult list 64 | 65 | exception ExceptionRankError 66 | exception ExceptionSyntaxError 67 | exception ExceptionDomainError 68 | exception ExceptionSystemError 69 | exception ExceptionValueError 70 | exception ExceptionLengthError 71 | exception ExceptionNotYetImplemented 72 | 73 | -------------------------------------------------------------------------------- /JWithATwist/ParserMockInterface.fs: -------------------------------------------------------------------------------- 1 | (* 2 | JWithATwist - A Twisted Version of the Programming Language J 3 | Copyright (C) 2016 Erling Hellenäs 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | *) 18 | namespace JWithATwist 19 | 20 | open ParserMockDefinitions 21 | open FParsec 22 | open System 23 | open Checked 24 | 25 | module ParserMockInterface = 26 | 27 | let parseNoun:Parser = 28 | (pint32 .>> ((pchar ' ') .>> spaces) ) 29 | 30 | let setPRNoun (x:int) : ParseResult= 31 | let (noun :Noun)= {Value = x} 32 | let f () = noun 33 | {Value= TypeNounUnit f} 34 | 35 | let Add (x:Noun) (y:Noun) : Noun = 36 | let r = x.Value + y.Value 37 | {Value= r} 38 | 39 | let Subtract (x:Noun) (y:Noun) : Noun = 40 | let r = x.Value - y.Value 41 | {Value= r} 42 | 43 | let Negate (y:Noun) : Noun = 44 | let r = - y.Value 45 | {Value= r} 46 | 47 | let Insert (y:Noun) (u:VerbDyadic) : Noun = 48 | u y y 49 | 50 | let Table (x:Noun) (y:Noun) (u:VerbDyadic) : Noun = 51 | u x y 52 | 53 | let InsertInsert (y:Noun) (u:VerbMonadic) : Noun = 54 | u y 55 | 56 | let Determinant (y:Noun) (u:VerbMonadic) (v:VerbDyadic): Noun = 57 | u (v y y) 58 | 59 | let DotProduct (x:Noun) (y:Noun) (u:VerbMonadic) (v:VerbDyadic): Noun = 60 | u (v x y) 61 | 62 | let setPRAdd x = 63 | {Value = TypeVerbDyadic Add} 64 | 65 | let setPRSubtract x = 66 | {Value = TypeVerbDyadic Subtract} 67 | 68 | let setPRNegate x = 69 | {Value = TypeVerbMonadic Negate} 70 | 71 | let setPRInsert x = 72 | {Value = TypeAdverbMonadicD Insert} 73 | 74 | let setPRTable x = 75 | {Value = TypeAdverbDyadic Table} 76 | 77 | let setPRInsertInsert x = 78 | {Value = TypeAdverbMonadicM InsertInsert} 79 | 80 | 81 | let setPRDeterminant x = 82 | {Value = TypeConjunctionMonadic Determinant} 83 | 84 | let setPRDotProduct x = 85 | {Value = TypeConjunctionDyadic DotProduct} 86 | 87 | let parseAdd:Parser = 88 | ((pstring "+ ") .>> spaces) 89 | 90 | let parseSubtract:Parser = 91 | ((pstring "- ") .>> spaces) 92 | 93 | let parseNegate:Parser = 94 | ((pstring "|- ") .>> spaces) 95 | 96 | let parseInsert:Parser = 97 | ((pstring "/ ") .>> spaces) 98 | 99 | let parseInsertInsert:Parser = 100 | ((pstring "// ") .>> spaces) 101 | 102 | let parseTable:Parser = 103 | ((pstring "/- ") .>> spaces) 104 | 105 | let parseDeterminant:Parser = 106 | ((pstring "|. ") .>> spaces) 107 | 108 | let parseDotProduct:Parser = 109 | ((pstring ". ") .>> spaces) 110 | 111 | let parseVerbAdverbConjunction = 112 | ( 113 | //Dyadic verbs 114 | (parseAdd|>>setPRAdd) 115 | <|> 116 | (parseSubtract|>>setPRSubtract) 117 | <|> 118 | //Monadic verbs 119 | (parseNegate|>>setPRNegate) 120 | <|> 121 | //Dyadic adverbs 122 | (parseTable|>>setPRTable) 123 | <|> 124 | //Monadic adverbs 125 | (parseInsert|>>setPRInsert) 126 | <|> 127 | (parseInsertInsert|>>setPRInsertInsert) 128 | <|> 129 | //Dyadic conjunctions 130 | (parseDotProduct|>>setPRDotProduct) 131 | <|> 132 | //Monadic conjunctions 133 | (parseDeterminant|>>setPRDeterminant) 134 | 135 | ) 136 | 137 | let ParsePrint (parseResult:ParseResult) = 138 | match parseResult with 139 | |{Value=TypeUnitUnit f} -> 140 | printfn "No result" 141 | |{Value=TypeVerbMonadic f} -> 142 | printfn "Monadic verb" 143 | |{Value=TypeVerbDyadic f} -> 144 | printfn "Dyadic verb" 145 | |{Value=TypeAdverbMonadicM f} -> 146 | printfn "Monadic adverb with monadic left verb" 147 | |{Value=TypeAdverbMonadicD f} -> 148 | printfn "Monadic adverb with dyadic left verb" 149 | |{Value=TypeAdverbDyadic f} -> 150 | printfn "Dyadic adverb" 151 | |{Value=TypeConjunctionMonadic f} -> 152 | printfn "Monadic conjunction" 153 | |{Value=TypeConjunctionDyadic f} -> 154 | printfn "Dyadic conjunction" 155 | |{Value=TypeNounUnit f} -> 156 | try 157 | let noun = f () 158 | printfn "%A" noun.Value 159 | with 160 | | _ as e -> 161 | printfn "%s" e.Message 162 | |_ -> 163 | raise ExceptionSystemError 164 | -------------------------------------------------------------------------------- /JWithATwist/Todo.fs: -------------------------------------------------------------------------------- 1 | module Todo 2 | 3 | 4 | // TODO: Amend when the fill argument is of different rank than the k-cells to fill. 5 | // TODO: Cut 6 | // TODO: Raze 7 | // TODO: Complete user documentation 8 | // TODO: Transpose not working with vector argument 9 | // TODO: Rename Magnitude to Absolute value 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JWithATwist/WixUIBannerBmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/WixUIBannerBmp.bmp -------------------------------------------------------------------------------- /JWithATwist/WixUIBannerBmp.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/WixUIBannerBmp.xcf -------------------------------------------------------------------------------- /JWithATwist/WixUIDialogBmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/WixUIDialogBmp.bmp -------------------------------------------------------------------------------- /JWithATwist/WixUIDialogBmp.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrimne/JWithATwist/72ca46b9d359931783f2fb882733071882fcc1f2/JWithATwist/WixUIDialogBmp.xcf -------------------------------------------------------------------------------- /JWithATwist/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

JWithATwist

8 |

JWithATwist is a programming language under development. It has many similarities with the programming language J. You can look at www.jsoftware.com to find out what J is.

9 |

You can download JWithATwist here.

10 |

You can clone the JWithATwist repository and use JWithATwist from Visual Studio.

11 |

You can find the JWithATwist documentation here.

12 |

You can find information about some design decisions in this blog - erlhelinfotech.wordpress.com.

13 |

The tests are also documentation.

14 | 15 | 16 | --------------------------------------------------------------------------------